[GRASS-dev] r.colors: rules file list unsorted

Daniel Calvelo dca.gis at gmail.com
Sun Jan 28 20:48:59 EST 2007


On 1/28/07, Glynn Clements <glynn at gclements.plus.com> wrote:
>
> Paul Kelly wrote:
> >
> > What about a library function that does the same thing as system("ls") or
> > system("ls -C"). I can think of several places where it would be useful.
> > It could accept the directory as an argument, also the stream to output
> > too (e.g. stdout or stderr)
>
> A library function should probably return the entries as an array of
> strings (char **) rather than write them to a stream. The caller can
> deal with writing them, if that's desired.

That's how it's done in the patched r.colors. If it must be turned
into a library function, where would it go? What would its name be?
I'm willing to do it (and also change any system("ls")'s remaining).

> > and perhaps a flag to do a column-wise listing
> > (a la "ls -C"). I think this would be the hardest part to do; not sure how
> > ls does it - unless there is something easy we could do with format
> > conversion strings?
>
> Read all of the names, find the longest name to determine the column
> widths, divide the width of the terminal[1] by the column width to
> determine the number of columns, write out all of the strings padded
> to a fixed width.

The parser uses column break with a hardcoded value. We certainly
could use a global function for determining column width.

[snip]

Daniel.

-- 
-- Daniel Calvelo Aros




More information about the grass-dev mailing list