[GRASS-dev] g.mlist: doesn't show a single raster?
Ivan Shmakov
ivan at theory.asu.ru
Wed Feb 20 23:18:37 EST 2008
>>>>> Ivan Shmakov <ivan at theory.asu.ru> writes:
[...]
> Also (though it presumably is a different issue):
[...]
> NB: the `max_len >= screen_width' case isn't handled properly!
[...]
I stand corrected, it's completely the same issue, as long as
`g.mlist' is implemented on top of `g.list'.
Please consider the following patch.
lib/gis/ls.c (G_ls_format): Handle the case when the screen width is
less or equal to the maximum length of the name to be output; don't pad
the names with spaces when printing in 1-column.
(nntp://news.gmane.org/gmane.comp.gis.grass.devel/25019)
diff --git a/lib/gis/ls.c b/lib/gis/ls.c
index 44e02bd..c0cf4a5 100644
--- a/lib/gis/ls.c
+++ b/lib/gis/ls.c
@@ -155,10 +155,13 @@ void G_ls_format(const char **list, int num_items, int perline, FILE *stream)
/* Auto-fit the number of items that will
* fit per line (+1 because of space after item) */
perline = screen_width / (max_len + 1);
+ if (perline < 1) perline = 1;
}
/* Field width to accomodate longest filename */
- field_width = screen_width / perline;
+ /* NB: don't pad the names with spaces when printing one name per
+ * line */
+ field_width = (perline > 1) ? (screen_width / perline) : 0;
/* Longest column height (i.e. num_items <= perline * column_height) */
column_height = (num_items / perline) + ((num_items % perline) > 0);
More information about the grass-dev
mailing list