Changeset 30423
- Timestamp:
- Mar 2, 2008, 10:20:50 AM (16 years ago)
- File:
-
- 1 edited
-
grass/trunk/lib/gis/ls.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/lib/gis/ls.c
r30281 r30423 6 6 \author Paul Kelly 7 7 8 (C) 2007 by the GRASS Development Team8 (C) 2007, 2008 by the GRASS Development Team 9 9 10 10 This program is free software under the GNU General Public … … 125 125 void G_ls_format(const char **list, int num_items, int perline, FILE *stream) 126 126 { 127 int i , j;127 int i; 128 128 129 129 int field_width, column_height; … … 164 164 column_height = (num_items / perline) + ((num_items % perline) > 0); 165 165 166 for (i=0; i < column_height; i++) 167 { 168 for (j=0; j < perline; j++) 169 { 170 int cur = j * column_height + i; 171 172 if (cur >= num_items) 173 continue; /* No more items to print in this row */ 174 175 /* Print filenames in left-justified fixed-width fields */ 176 fprintf(stream, "%-*s", field_width, list[cur]); 177 } 178 fprintf(stream, "\n"); 179 } 166 { 167 const int max 168 = num_items + column_height - (num_items % column_height); 169 const char **next; 170 171 for (i = 1, next = list; i <= num_items; i++) { 172 const char **cur = next; 173 174 next += column_height; 175 if (next >= list + num_items) { 176 /* the next item has to be on the other line */ 177 next -= (max - 1 178 - (next < list + max ? column_height : 0)); 179 fprintf (stream, "%s\n", *cur); 180 } else { 181 fprintf (stream, "%-*s", field_width, *cur); 182 } 183 } 184 } 180 185 181 186 return;
Note:
See TracChangeset
for help on using the changeset viewer.
