瀏覽代碼

use G_getl2, add FIXME comment and debug msg formatting (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40315 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 15 年之前
父節點
當前提交
91e3609efd
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      lib/db/dbmi_base/login.c

+ 5 - 3
lib/db/dbmi_base/login.c

@@ -88,7 +88,7 @@ static int read_file(LOGIN * login)
     login->n = 0;
     login->n = 0;
     file = login_filename();
     file = login_filename();
 
 
-    G_debug(3, "file = %s", file);
+    G_debug(3, "file = <%s>", file);
 
 
     if (stat(file, &info) != 0) {
     if (stat(file, &info) != 0) {
 	G_debug(3, "login file does not exist");
 	G_debug(3, "login file does not exist");
@@ -99,13 +99,15 @@ static int read_file(LOGIN * login)
     if (fd == NULL)
     if (fd == NULL)
 	return -1;
 	return -1;
 
 
-    while (fgets(buf, 2000, fd)) {
+    while (G_getl2(buf, 2000, fd)) {
 	G_chop(buf);
 	G_chop(buf);
 
 
 	usr[0] = pwd[0] = '\0';
 	usr[0] = pwd[0] = '\0';
+	/* FIXME: not safe for spaces in DB path name */
 	ret = sscanf(buf, "%[^ ] %[^ ] %[^ ] %[^ ]", dr, db, usr, pwd);
 	ret = sscanf(buf, "%[^ ] %[^ ] %[^ ] %[^ ]", dr, db, usr, pwd);
 
 
-	G_debug(3, "ret = %d : %s %s %s %s", ret, dr, db, usr, pwd);
+	G_debug(3, "ret = %d : dr=[%s] db=[%s] us=[%s] pw=[%s]",
+		ret, dr, db, usr, pwd);
 
 
 	if (ret < 2) {
 	if (ret < 2) {
 	    G_warning(_("Login file corrupted"));
 	    G_warning(_("Login file corrupted"));