Mon, Jun 19 2006
09:36:10
|
|
Request created by hbowman
|
|
Subject: r.out.tiff: check for .tif.tif
Hi,
r.out.tiff automatically appends a ".tif" to the end of the output filename.
It should check to see if the string ends in upper/lower case .tif or .tiff
before doing this. A lot of folks assume filename extensions will be added
when needed, so I think we should continue to append.
probably r.out.png and friends as well.
anyone have a simple C replacement for `basename $file .tif`?
thanks,
Hamish
|
|
Mon, Jun 19 2006
12:49:59
|
|
Mail sent by paul-grass@stjohnspoint.co.uk
|
|
Return-Path |
<paul-grass@stjohnspoint.co.uk>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Mon, 19 Jun 2006 11:49:42 +0100 (BST)
|
From |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
X-X-Sender |
paulk@agrippa.ukshells.co.uk
|
To |
Request Tracker <grass-bugs@intevation.de>
|
Cc |
grass-dev@grass.itc.it
|
Subject |
Re: [GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
In-Reply-To |
<20060619073610.E7E3C1005B8@lists.intevation.de>
|
Message-ID |
<Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk>
|
References |
<20060619073610.E7E3C1005B8@lists.intevation.de>
|
MIME-Version |
1.0
|
Content-Type |
TEXT/PLAIN; charset=US-ASCII; format=flowed
|
X-SA-Do-Not-Run |
Yes
|
X-SA-Exim-Connect-IP |
217.10.143.90
|
X-SA-Exim-Mail-From |
paul-grass@stjohnspoint.co.uk
|
X-SA-Exim-Scanned |
No (on mail.ukshells.net); SAEximRunCond expanded to false
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
On Mon, 19 Jun 2006, Request Tracker wrote:
> anyone have a simple C replacement for `basename $file .tif`?
Sounds like it would be useful as a library function. I wrote the
following which seems to work, but could do with more testing:
/**
* \brief Checks if a filename matches a certain file extension
* (case insensitive) and if so, truncates the string to the
* base file name (cf. basename Unix command)
*
* Truncates filename to the base part (before the last .)
* if it matches the extension, otherwise leaves it unchanged.
*
* \param filename String containing filename
*
* \param ext String containing extension to look for (case
* insensitive and as long as needs to be, e.g. tif will
* match .tif and .tiff, sh will match .shp and .shx, htm will
* match .htm and .html)
*
* \return Pointer to filename
**/
char * G_basename(char *filename, char *desired_ext)
{
/* Find the last . in the filename */
char *dot = strrchr(filename, '.');
/* Check there is a dot and its not the last character
* in the string, i.e. there is an extension */
if(dot && ((dot - filename) < strlen(filename)) )
{
char *ext = dot + 1;
/* if the extension matches (case insensitive)
* then truncate the filename to the basename */
if( strncasecmp(ext, desired_ext, strlen(desired_ext)) == 0 )
*dot = '\0';
}
return filename;
}
|
|
Mon, Jun 19 2006
17:48:05
|
|
Mail sent by pkelly
|
|
OK I committed something similar to CVS and updated r.out.tiff so it uses the
new G_basename() function. Seems to work well with my limited testing... |
|
Tue, Jun 20 2006
02:18:38
|
|
Mail sent by hamish_nospam@yahoo.com
|
|
Return-Path |
<hamish_nospam@yahoo.com>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Tue, 20 Jun 2006 12:18:31 +1200
|
From |
Hamish <hamish_nospam@yahoo.com>
|
To |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
Cc |
grass-bugs@intevation.de, grass-dev@grass.itc.it
|
Subject |
Re: [GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
Message-Id |
<20060620121831.54cb161d.hamish_nospam@yahoo.com>
|
In-Reply-To |
<Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk>
|
References |
<20060619073610.E7E3C1005B8@lists.intevation.de> <Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk>
|
X-Mailer |
Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
|
X-Face |
M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB 8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
|
Mime-Version |
1.0
|
Content-Type |
text/plain; charset=US-ASCII
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.0 tagged_above=-999.0 required=3.0 tests=BAYES_00, FORGED_YAHOO_RCVD
|
X-Spam-Level |
|
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.
Is it better to use G_tolcase() or G_str_to_lower() first? [I just
noticed those were duplicates. We should consolidate. G_str_to_lower()
is only 2 months old so the obvious choice for removal, but it does
have a better name.]
lib/gis/mapcase.c
lib/gis/strings.c
oh, I see in lib/gis/strings.c we have a G_strcasecmp().
We still should merge G_tolcase() and G_str_to_lower() though.
I see lib/gis/mapcase.c defines tolower() and toupper(). As those are
both standard ANSI C fns, they are redundant and should be removed?
Hamish
|
|
Tue, Jun 20 2006
03:03:21
|
|
Mail sent by rez@touchofmadness.com
|
|
Return-Path |
<rez@touchofmadness.com>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Subject |
Re: [GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
From |
Brad Douglas <rez@touchofmadness.com>
|
Reply-To |
rez@touchofmadness.com
|
To |
Hamish <hamish_nospam@yahoo.com>
|
Cc |
Paul Kelly <paul-grass@stjohnspoint.co.uk>, grass-bugs@intevation.de, grass-dev@grass.itc.it
|
In-Reply-To |
<20060620121831.54cb161d.hamish_nospam@yahoo.com>
|
References |
<20060619073610.E7E3C1005B8@lists.intevation.de> <Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk> <20060620121831.54cb161d.hamish_nospam@yahoo.com>
|
Content-Type |
text/plain
|
Date |
Mon, 19 Jun 2006 18:02:59 -0700
|
Message-Id |
<1150765379.2467.536.camel@devel>
|
Mime-Version |
1.0
|
X-Mailer |
Evolution 2.6.2 (2.6.2-1.fc5.5)
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
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().
> Is it better to use G_tolcase() or G_str_to_lower() first? [I just
> noticed those were duplicates. We should consolidate. G_str_to_lower()
> is only 2 months old so the obvious choice for removal, but it does
> have a better name.]
>
> lib/gis/mapcase.c
> lib/gis/strings.c
>
> oh, I see in lib/gis/strings.c we have a G_strcasecmp().
:-)
> We still should merge G_tolcase() and G_str_to_lower() though.
>
> I see lib/gis/mapcase.c defines tolower() and toupper(). As those are
> both standard ANSI C fns, they are redundant and should be removed?
Yeah, it appears that G_to[u|l]case() are redundant. swig uses
G_tolcase(), but I don't see why it couldn't be replaced with
G_str_to_lower().
--
Brad Douglas <rez touchofmadness com> KB8UYR
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785
|
|
Tue, Jun 20 2006
04:28:54
|
|
Mail sent by hamish_nospam@yahoo.com
|
|
Return-Path |
<hamish_nospam@yahoo.com>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Tue, 20 Jun 2006 14:28:50 +1200
|
From |
Hamish <hamish_nospam@yahoo.com>
|
To |
Paul Kelly via RT <grass-bugs@intevation.de>
|
Subject |
Re: [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
Message-Id |
<20060620142850.6ffce5ba.hamish_nospam@yahoo.com>
|
In-Reply-To |
<20060619154805.741241005B8@lists.intevation.de>
|
References |
<20060619154805.741241005B8@lists.intevation.de>
|
X-Mailer |
Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
|
X-Face |
M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB 8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
|
Mime-Version |
1.0
|
Content-Type |
text/plain; charset=US-ASCII
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.0 tagged_above=-999.0 required=3.0 tests=BAYES_00, FORGED_YAHOO_RCVD
|
X-Spam-Level |
|
> OK I committed something similar to CVS and updated r.out.tiff so it
> uses the new G_basename() function. Seems to work well with my limited
> testing...
cheers.
Hamish
|
|
Tue, Jun 20 2006
10:24:11
|
|
Mail sent by paul-grass@stjohnspoint.co.uk
|
|
Return-Path |
<paul-grass@stjohnspoint.co.uk>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Message-ID |
<4497B11E.3080604@stjohnspoint.co.uk>
|
Date |
Tue, 20 Jun 2006 09:26:06 +0100
|
From |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
User-Agent |
Mozilla Thunderbird 1.0.6 (Windows/20050716)
|
X-Accept-Language |
en-us, en
|
MIME-Version |
1.0
|
To |
rez@touchofmadness.com
|
Cc |
Hamish <hamish_nospam@yahoo.com>, grass-bugs@intevation.de, grass-dev@grass.itc.it
|
Subject |
Re: [GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
References |
<20060619073610.E7E3C1005B8@lists.intevation.de> <Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk> <20060620121831.54cb161d.hamish_nospam@yahoo.com> <1150765379.2467.536.camel@devel>
|
In-Reply-To |
<1150765379.2467.536.camel@devel>
|
Content-Type |
text/plain; charset=ISO-8859-1; format=flowed
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
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.
|
|
Tue, Jun 20 2006
12:59:00
|
|
Mail sent by paul-grass@stjohnspoint.co.uk
|
|
Return-Path |
<paul-grass@stjohnspoint.co.uk>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Tue, 20 Jun 2006 11:58:42 +0100 (BST)
|
From |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
X-X-Sender |
paulk@agrippa.ukshells.co.uk
|
To |
Brad Douglas <rez@touchofmadness.com>
|
Cc |
Hamish <hamish_nospam@yahoo.com>, grass-dev@grass.itc.it, grass-bugs@intevation.de
|
Subject |
Re: [GRASS-dev] [bug #4628] (grass) r.out.tiff: check for .tif.tif
|
In-Reply-To |
<1150798710.2467.568.camel@devel>
|
Message-ID |
<Pine.LNX.4.62.0606201155370.28482@agrippa.ukshells.co.uk>
|
References |
<20060619073610.E7E3C1005B8@lists.intevation.de> <Pine.LNX.4.62.0606191145500.28482@agrippa.ukshells.co.uk> <20060620121831.54cb161d.hamish_nospam@yahoo.com> <1150765379.2467.536.camel@devel> <4497B11E.3080604@stjohnspoint.co.uk> <1150798710.2467.568.camel@devel>
|
MIME-Version |
1.0
|
Content-Type |
TEXT/PLAIN; charset=US-ASCII; format=flowed
|
X-SA-Do-Not-Run |
Yes
|
X-SA-Exim-Connect-IP |
217.10.143.90
|
X-SA-Exim-Mail-From |
paul-grass@stjohnspoint.co.uk
|
X-SA-Exim-Scanned |
No (on mail.ukshells.net); SAEximRunCond expanded to false
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
On Tue, 20 Jun 2006, Brad Douglas wrote:
>> 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.
>
> I can add G_strncasecmp() if it's absolutely necessary (and nobody
> objects).
Well, I have put in a portable version (into basename.c) now and it works
so OK for now I think. But if we come across somewhere else that it's
needed then would be worthwhile.
Paul
|
|
Wed, Jul 5 2006
14:21:07
|
|
Mail sent by mneteler
|
|
|
Wed, Jul 5 2006
14:21:09
|
|
Status changed to resolved by mneteler
|
|