瀏覽代碼

added G_INFO_FORMAT_PLAIN

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34164 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 16 年之前
父節點
當前提交
53e9fd3e22
共有 3 個文件被更改,包括 21 次插入7 次删除
  1. 1 0
      include/gis.h
  2. 3 0
      lib/gis/error.c
  3. 17 7
      lib/gis/percent.c

+ 1 - 0
include/gis.h

@@ -203,6 +203,7 @@ static const char *GRASS_copyright __attribute__ ((unused))
 #define G_INFO_FORMAT_STANDARD 0	/* GRASS_MESSAGE_FORMAT=standard or not defined */
 #define G_INFO_FORMAT_STANDARD 0	/* GRASS_MESSAGE_FORMAT=standard or not defined */
 #define G_INFO_FORMAT_GUI      1	/* GRASS_MESSAGE_FORMAT=gui */
 #define G_INFO_FORMAT_GUI      1	/* GRASS_MESSAGE_FORMAT=gui */
 #define G_INFO_FORMAT_SILENT   2	/* GRASS_MESSAGE_FORMAT=silent */
 #define G_INFO_FORMAT_SILENT   2	/* GRASS_MESSAGE_FORMAT=silent */
+#define G_INFO_FORMAT_PLAIN    3	/* GRASS_MESSAGE_FORMAT=plain */
 
 
 /* Icon types */
 /* Icon types */
 #define G_ICON_CROSS  0
 #define G_ICON_CROSS  0

+ 3 - 0
lib/gis/error.c

@@ -332,6 +332,7 @@ static int write_error(const char *msg, int fatal,
 	logfile = getenv("GIS_ERROR_LOG");
 	logfile = getenv("GIS_ERROR_LOG");
 	if (!logfile) {
 	if (!logfile) {
 	    char buf[GPATH_MAX];
 	    char buf[GPATH_MAX];
+
 	    sprintf(buf, "%s/GIS_ERROR_LOG", G__home());
 	    sprintf(buf, "%s/GIS_ERROR_LOG", G__home());
 	    logfile = G_store(buf);
 	    logfile = G_store(buf);
 	}
 	}
@@ -495,6 +496,8 @@ int G_info_format(void)
 	    grass_info_format = G_INFO_FORMAT_GUI;
 	    grass_info_format = G_INFO_FORMAT_GUI;
 	else if (fstr && G_strcasecmp(fstr, "silent") == 0)
 	else if (fstr && G_strcasecmp(fstr, "silent") == 0)
 	    grass_info_format = G_INFO_FORMAT_SILENT;
 	    grass_info_format = G_INFO_FORMAT_SILENT;
+	else if (fstr && G_strcasecmp(fstr, "plain") == 0)
+	    grass_info_format = G_INFO_FORMAT_BATCH;
 	else
 	else
 	    grass_info_format = G_INFO_FORMAT_STANDARD;
 	    grass_info_format = G_INFO_FORMAT_STANDARD;
     }
     }

+ 17 - 7
lib/gis/percent.c

@@ -111,15 +111,25 @@ int G_percent2(long n, long d, int s, FILE * out)
 		fprintf(out, "%4d%%\b\b\b\b\b", x);
 		fprintf(out, "%4d%%\b\b\b\b\b", x);
 	    }
 	    }
 	}
 	}
-	else {			/* GUI */
-	    if (out != NULL) {
-		if (first) {
-		    fprintf(out, "\n");
+	else {
+	    if (format == G_INFO_FORMAT_BATCH) {
+		if (out != NULL) {
+		    if (x == 100)
+			fprintf(out, "%d\n", x);
+		    else
+			fprintf(out, "%d..", x);
+		}
+	    }
+	    else {		/* GUI */
+		if (out != NULL) {
+		    if (first) {
+			fprintf(out, "\n");
+		    }
+		    fprintf(out, "GRASS_INFO_PERCENT: %d\n", x);
+		    fflush(out);
 		}
 		}
-		fprintf(out, "GRASS_INFO_PERCENT: %d\n", x);
-		fflush(out);
+		first = 0;
 	    }
 	    }
-	    first = 0;
 	}
 	}
     }
     }