[GRASS-SVN] r64781 - grass/trunk/raster/r.report

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 2 07:57:55 PST 2015


Author: martinl
Date: 2015-03-02 07:57:55 -0800 (Mon, 02 Mar 2015)
New Revision: 64781

Modified:
   grass/trunk/raster/r.report/global.h
   grass/trunk/raster/r.report/main.c
   grass/trunk/raster/r.report/parse.c
Log:
define default answers for page_width and page_length


Modified: grass/trunk/raster/r.report/global.h
===================================================================
--- grass/trunk/raster/r.report/global.h	2015-03-02 14:16:51 UTC (rev 64780)
+++ grass/trunk/raster/r.report/global.h	2015-03-02 15:57:55 UTC (rev 64781)
@@ -49,8 +49,8 @@
 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;

Modified: grass/trunk/raster/r.report/main.c
===================================================================
--- grass/trunk/raster/r.report/main.c	2015-03-02 14:16:51 UTC (rev 64780)
+++ grass/trunk/raster/r.report/main.c	2015-03-02 15:57:55 UTC (rev 64781)
@@ -31,8 +31,8 @@
 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;

Modified: grass/trunk/raster/r.report/parse.c
===================================================================
--- grass/trunk/raster/r.report/parse.c	2015-03-02 14:16:51 UTC (rev 64780)
+++ grass/trunk/raster/r.report/parse.c	2015-03-02 15:57:55 UTC (rev 64781)
@@ -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 @@
     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 @@
 	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);



More information about the grass-commit mailing list