Browse Source

define default answers for page_width and page_length
(merge https://trac.osgeo.org/grass/changeset/64781 from trunk)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64782 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 years ago
parent
commit
176d14e819
3 changed files with 15 additions and 22 deletions
  1. 2 2
      raster/r.report/global.h
  2. 2 2
      raster/r.report/main.c
  3. 11 18
      raster/r.report/parse.c

+ 2 - 2
raster/r.report/global.h

@@ -49,8 +49,8 @@ struct _units_
 extern UNITS unit[MAX_UNITS];
 extern int nunits;
 
-#define DEFAULT_PAGE_LENGTH 0
-#define DEFAULT_PAGE_WIDTH  79
+#define DEFAULT_PAGE_LENGTH "0"
+#define DEFAULT_PAGE_WIDTH  "79"
 
 extern int page_width;
 extern int page_length;

+ 2 - 2
raster/r.report/main.c

@@ -31,8 +31,8 @@ int nstats;
 UNITS unit[MAX_UNITS];
 int nunits;
 
-int page_width = DEFAULT_PAGE_WIDTH;
-int page_length = DEFAULT_PAGE_LENGTH;
+int page_width;
+int page_length;
 int masking = 1;
 int use_formfeed;
 int nlines;

+ 11 - 18
raster/r.report/parse.c

@@ -6,8 +6,6 @@
 
 int parse_command_line(int argc, char *argv[])
 {
-    char pl_desc[256];
-    char pw_desc[256];
     int i;
     char *desc;
     struct
@@ -74,18 +72,16 @@ int parse_command_line(int argc, char *argv[])
     parms.pl->key = "page_length";
     parms.pl->type = TYPE_INTEGER;
     parms.pl->required = NO;
-    sprintf(pl_desc, _("Page length (default: %d lines)"),
-	    DEFAULT_PAGE_LENGTH);
-    parms.pl->description = pl_desc;
+    parms.pl->description = _("Page length");
+    parms.pl->answer = DEFAULT_PAGE_LENGTH;
     parms.pl->guisection = _("Formatting");
 
     parms.pw = G_define_option();
     parms.pw->key = "page_width";
     parms.pw->type = TYPE_INTEGER;
     parms.pw->required = NO;
-    sprintf(pw_desc, _("Page width (default: %d characters)"),
-	    DEFAULT_PAGE_WIDTH);
-    parms.pw->description = pw_desc;
+    parms.pw->description = _("Page width");
+    parms.pw->answer = DEFAULT_PAGE_WIDTH;
     parms.pw->guisection = _("Formatting");
 
 		    parms.nsteps = G_define_option();
@@ -192,19 +188,16 @@ int parse_command_line(int argc, char *argv[])
 	nsteps = 255;
     }
 
-    if (parms.pl->answer) {
-	if (sscanf(parms.pl->answer, "%d", &page_length) != 1 ||
-	    page_length < 0) {
-	    G_fatal_error(_("Illegal page length"));
-	}
+    if (sscanf(parms.pl->answer, "%d", &page_length) != 1 ||
+        page_length < 0) {
+      G_fatal_error(_("Illegal page length"));
     }
 
-    if (parms.pw->answer) {
-	if (sscanf(parms.pw->answer, "%d", &page_width) != 1 ||
-	    page_width < 1) {
-	    G_fatal_error(_("Illegal page width"));
-	}
+    if (sscanf(parms.pw->answer, "%d", &page_width) != 1 ||
+        page_width < 1) {
+      G_fatal_error(_("Illegal page width"));
     }
+
     if (parms.outfile->answer) {
 	if (freopen(parms.outfile->answer, "w", stdout) == NULL) {
 	    perror(parms.outfile->answer);