Parcourir la source

conditionalize output to not confuse the user with useless messages

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32682 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler il y a 16 ans
Parent
commit
5ab2d009b7
2 fichiers modifiés avec 32 ajouts et 18 suppressions
  1. 20 11
      vector/v.distance/main.c
  2. 12 7
      vector/v.to.db/report.c

+ 20 - 11
vector/v.distance/main.c

@@ -1095,9 +1095,12 @@ int main(int argc, char *argv[])
 	db_commit_transaction(driver);
 	db_commit_transaction(driver);
 
 
     /* print stats */
     /* print stats */
-    G_message(_("%d categories with more than 1 feature in vector map <%s>"),
-	      update_dupl, from_opt->answer);
-    G_message(_("%d categories - no nearest feature found"), update_notfound);
+    if (update_dupl > 0)
+	G_message(_("%d categories with more than 1 feature in vector map <%s>"),
+		  update_dupl, from_opt->answer);
+    if (update_notfound > 0)
+	G_message(_("%d categories - no nearest feature found"),
+		  update_notfound);
 
 
     if (!print_flag->answer) {
     if (!print_flag->answer) {
 	db_close_database_shutdown_driver(driver);
 	db_close_database_shutdown_driver(driver);
@@ -1107,17 +1110,23 @@ int main(int argc, char *argv[])
 	if (all && table_opt->answer) {
 	if (all && table_opt->answer) {
 	    G_message(_("%d distances calculated"), count);
 	    G_message(_("%d distances calculated"), count);
 	    G_message(_("%d records inserted"), update_ok);
 	    G_message(_("%d records inserted"), update_ok);
-	    G_message(_("%d insert errors"), update_err);
+	    if (update_err > 0)
+		G_message(_("%d insert errors"), update_err);
 	}
 	}
 	else if (!all) {
 	else if (!all) {
-	    G_message(_("%d categories read from the map"), nfcats);
-	    G_message(_("%d categories exist in the table"), ncatexist);
-	    G_message(_("%d categories read from the map exist in the table"),
-		      update_exist);
-	    G_message(_("%d categories read from the map don't exist in the table"),
-		      update_notexist);
+	    if (nfcats > 0)
+		G_message(_("%d categories read from the map"), nfcats);
+	    if (ncatexist > 0)
+		G_message(_("%d categories exist in the table"), ncatexist);
+	    if (update_exist > 0)
+		G_message(_("%d categories read from the map exist in the table"),
+			  update_exist);
+	    if (update_notexist > 0)
+		G_message(_("%d categories read from the map don't exist in the table"),
+			  update_notexist);
 	    G_message(_("%d records updated"), update_ok);
 	    G_message(_("%d records updated"), update_ok);
-	    G_message(_("%d update errors"), update_err);
+	    if (update_err > 0)
+		G_message(_("%d update errors"), update_err);
 
 
 	    G_free(catexist);
 	    G_free(catexist);
 	}
 	}

+ 12 - 7
vector/v.to.db/report.c

@@ -171,14 +171,19 @@ int report(void)
 
 
 int print_stat(void)
 int print_stat(void)
 {
 {
-    G_message(_("%d categories read from map"), vstat.rcat);
-    G_message(_("%d records selected from table"), vstat.select);
-    G_message(_("%d categories read from map exist in selection from table"),
-	      vstat.exist);
-    G_message(_("%d categories read from map don't exist in selection from table"),
-	      vstat.notexist);
+    if (vstat.rcat > 0)
+	G_message(_("%d categories read from map"), vstat.rcat);
+    if (vstat.select > 0)
+	G_message(_("%d records selected from table"), vstat.select);
+    if (vstat.exist > 0)
+	G_message(_("%d categories read from map exist in selection from table"),
+		  vstat.exist);
+    if (vstat.notexist > 0)
+	G_message(_("%d categories read from map don't exist in selection from table"),
+		  vstat.notexist);
     G_message(_("%d records updated/inserted"), vstat.update);
     G_message(_("%d records updated/inserted"), vstat.update);
-    G_message(_("%d update/insert errors"), vstat.error);
+    if (vstat.error > 0)
+	G_message(_("%d update/insert errors"), vstat.error);
     if (vstat.dupl > 0)
     if (vstat.dupl > 0)
 	G_message(_("%d categories with more points (coordinates not loaded)"),
 	G_message(_("%d categories with more points (coordinates not loaded)"),
 		  vstat.dupl);
 		  vstat.dupl);