[GRASS-dev] g.mapsets use of sleep()

Hamish hamish_nospam at yahoo.com
Wed Dec 6 01:28:27 EST 2006


Glynn Clements wrote:
> > so  #include <unistd.h>  is no good in windows?
> 
> No; the header exists, but it doesn't declare sleep(). The <stdlib.h>
> header declares _sleep(), although apparently this is deprecated (it
> exists in the MSVCRT DLL, but isn't listed in the documentation index)
> in favour of Sleep().

sleep() is POSIX.1. Bad Microsoft.

> > isn't the system("ls") going to be a problem as well?
> 
> Only if you don't have "ls" ;)
> 
> A lot of the [G_]system and [G_]popen calls in GRASS (I count 105)
> will be similarly problematic. Some will be calling GRASS programs,
> but a lot use Unix commands.

105 really isn't that many.

for the ones that are unix commands, the vast majority are just ls, cp,
mv, rm?

step 1: define portable tcl and C replacements (e.g. glob, unlink())
for the common ones. (eg with Paul's new G_convert_dirseps_to_host())

step 2: fix it for some high profile module and let folks know that's
the reference way to do it. Maybe add to SUBMITTING or a wiki page how
to do that well. Putting it in SUBMITTING makes sure that grass devels
should know about doing it, putting it in the wiki might help external
folks doing a web search.

step 3: we fix them as we find them. e.g. if we guess "ls" is the most
common unix-ism, AFAICT in the C code that is just 5 files for
[G_]system:

imagery/i.ortho.photo/libes/ls_cameras.c
imagery/i.ortho.photo/libes/ls_elev.c
lib/imagery/ls_groups.c

these two are really bad:

lib/fonts/for_grass/try.c:   system ("cd fonts; ls *.hmp | sed 's/.hmp//' | fmt");
lib/fonts/for_grass/fontmap.c:  system ("cd ../fonts; ls *.hmp | sed 's/.hmp//' | fmt");


if steps 1 & 2 above could be solved, I think step 3 could happen very
quickly. At least we could make a start with the libraries...


for popen, lib/gis/error.c and lib/gis/home.c (pwd) look like places to
start.



Hamish




More information about the grass-dev mailing list