On Mon, Jul 07, 2003 at 11:41:21PM +1200, H Bowman wrote:
> > > s.in.ascii sites=mylidar input=lidar.flt fs=
> > Either set fs= to something or leave it out.
> >
> > This is probably a bug, as 's.in.ascii fs=' should take you to the
> > help page, and it doesn't.
>
> Attached a bugfix - could you have a look if you agree with it
> (strings are not my friends...)?I don't know enough C trivia to tell you why a zero-length string is
!=NULL either, but your patch seems to look & work fine.
OK, I have submitted it to CVS now (should I update the rel branch
as well?).
I think the problem is more general with "xxxxxx->type = TYPE_STRING;"
where the parser doesn't fail when the string length is zero.
e.g., try 's.in.ascii site='
Mhhh, maybe we need a fix in the parser.c file?
The attached patch (added to yours) cleans that for this specific case,
but the problem remains maybe in other modules.Hamish
--- main.c.OLD Mon Jul 7 22:37:52 2003
+++ main.c Mon Jul 7 23:08:46 2003
@@ -128,9 +128,11 @@
if (dims<2)
G_fatal_error ("number of dimensions must be greater than 1");- fs = parm.fs->answer;
- if (fs != NULL)
- {
+ if ( strlen(parm.fs->answer) < 1 )
+ G_fatal_error ("field separator cannot be empty");
+ else
+ {
+ fs = parm.fs->answer;
if(strcmp (fs, "space") == 0)
fs = NULL;
else if(strcmp (fs, "tab") == 0)
@@ -139,11 +141,8 @@out_fd = G_fopen_sites_new (output);
if (out_fd == NULL)
- {
- fprintf (stderr, " %s - can't create sites file [%s]",
- me, output);
- exit(1);
- }
+ G_fatal_error ("can't create sites file [%s].", output);
+G_site_put_head (out_fd, &shead);
/* G_free(shead.name);
Markus