[GRASS-dev] Re: [GRASS-user] g.list type=rast gives floating point exception

Glynn Clements glynn at gclements.plus.com
Thu Oct 19 11:09:58 EDT 2006


Maciej Sieczka wrote:

> > where maxlen is the length of the longest map name in the list. If the
> > denominator is greater than 80, num_cols will be zero. num_cols is
> > used as the RHS of the % (modulus) operator, hence the division by
> > zero. I'll add a test for that case.
> 
> Glynn,
> 
> In current CVS the floating point exception with long names is gone,
> but if any of the elements listed by g.list is longer than my terminal
> width, all the elements are separated with a redundant empty line.
> 
> To notice that create eg. a vector of a name this long:
> 
> bricz_pkt_shorties_break_onlycat_prune_poly_prune_addcat_tmp_12724_0_v_breach5_9_2
> 
> and do 'g.list vect'. You'll see what I mean. Could those sparse empty
> lines be avoided?

I've committed the attached patch, which avoids padding the last
column. This prevents the blank lines which occur when padding beyond
the width of the terminal.

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
Index: lib/gis/list.c
===================================================================
RCS file: /grassrepository/grass6/lib/gis/list.c,v
retrieving revision 2.17
diff -u -r2.17 list.c
--- lib/gis/list.c	18 Oct 2006 16:44:49 -0000	2.17
+++ lib/gis/list.c	19 Oct 2006 15:05:43 -0000
@@ -251,7 +251,12 @@
             fprintf(out,"%-18s %-.60s\n",list[i],title);
         }
         else
-            fprintf(out,"%-*s", maxlen+1, list[i]);
+	{
+	    if ((i+1) % num_cols)
+                fprintf(out,"%-*s", maxlen+1, list[i]);
+	    else
+                fprintf(out,"%s", list[i]);
+	}
 
         if (!lister && !((i+1) % num_cols))
             fprintf(out, "\n");


More information about the grass-dev mailing list