[GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif

Paul Kelly paul-grass at stjohnspoint.co.uk
Tue Jun 20 04:26:06 EDT 2006


Brad Douglas wrote:
> On Tue, 2006-06-20 at 12:18 +1200, Hamish wrote:
> 
>>H:
>>
>>>>anyone have a simple C replacement for `basename $file .tif`?
>>
>>P:
>>
>>>Sounds like it would be useful as a library function. I wrote the 
>>>following which seems to work, but could do with more testing:
>>
>>..
>>
>>>char * G_basename(char *filename, char *desired_ext)
>>
>>..
>>
>>>         if( strncasecmp(ext, desired_ext, strlen(desired_ext)) == 0 )
>>
>>Is strncasecmp() portable? man page says "only" BSD 4.4 compliant.
> 
> 
> Yes, it's BSD and not to our definition of portable.  Please use
> G_strcasecmp().

Hmmm but it needs to be strncasecmp so "tif" will also match "tiff" etc. 
I guess I could implement it as a for loop matching character by 
character. Will change that.




More information about the grass-dev mailing list