[GRASS-SVN] r30423 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 2 13:20:50 EST 2008
Author: 1gray
Date: 2008-03-02 13:20:50 -0500 (Sun, 02 Mar 2008)
New Revision: 30423
Modified:
grass/trunk/lib/gis/ls.c
Log:
lib/gis/ls.c (G_ls_format): Eliminated extra whitespace.
lib/gis/ls.c: Updated copyright years.
Modified: grass/trunk/lib/gis/ls.c
===================================================================
--- grass/trunk/lib/gis/ls.c 2008-03-02 18:14:11 UTC (rev 30422)
+++ grass/trunk/lib/gis/ls.c 2008-03-02 18:20:50 UTC (rev 30423)
@@ -5,7 +5,7 @@
\author Paul Kelly
- (C) 2007 by the GRASS Development Team
+ (C) 2007, 2008 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
@@ -124,7 +124,7 @@
void G_ls_format(const char **list, int num_items, int perline, FILE *stream)
{
- int i, j;
+ int i;
int field_width, column_height;
int screen_width = 80; /* Default width of 80 columns */
@@ -163,20 +163,25 @@
/* Longest column height (i.e. num_items <= perline * column_height) */
column_height = (num_items / perline) + ((num_items % perline) > 0);
- for (i=0; i < column_height; i++)
- {
- for (j=0; j < perline; j++)
- {
- int cur = j * column_height + i;
-
- if (cur >= num_items)
- continue; /* No more items to print in this row */
-
- /* Print filenames in left-justified fixed-width fields */
- fprintf(stream, "%-*s", field_width, list[cur]);
- }
- fprintf(stream, "\n");
- }
+ {
+ const int max
+ = num_items + column_height - (num_items % column_height);
+ const char **next;
+
+ for (i = 1, next = list; i <= num_items; i++) {
+ const char **cur = next;
+
+ next += column_height;
+ if (next >= list + num_items) {
+ /* the next item has to be on the other line */
+ next -= (max - 1
+ - (next < list + max ? column_height : 0));
+ fprintf (stream, "%s\n", *cur);
+ } else {
+ fprintf (stream, "%-*s", field_width, *cur);
+ }
+ }
+ }
return;
}
More information about the grass-commit
mailing list