Changeset 30423


Ignore:
Timestamp:
Mar 2, 2008, 10:20:50 AM (16 years ago)
Author:
1gray
Message:

lib/gis/ls.c (G_ls_format): Eliminated extra whitespace.
lib/gis/ls.c: Updated copyright years.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/lib/gis/ls.c

    r30281 r30423  
    66   \author Paul Kelly
    77   
    8    (C) 2007 by the GRASS Development Team
     8   (C) 2007, 2008 by the GRASS Development Team
    99
    1010   This program is free software under the GNU General Public
     
    125125void G_ls_format(const char **list, int num_items, int perline, FILE *stream)
    126126{
    127     int i, j;
     127    int i;
    128128
    129129    int field_width, column_height;
     
    164164    column_height = (num_items / perline) + ((num_items % perline) > 0);
    165165
    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    }
    180185   
    181186    return;
Note: See TracChangeset for help on using the changeset viewer.