This is Vladimir's update to last_char_is(). Since 'char *' is
the least common denominator, I modified it to use that (not const), which will minimize the need for casting elsewhere.
This commit is contained in:
parent
de0ca0cd9e
commit
186bf1defc
@ -25,9 +25,12 @@
|
|||||||
* underrun the buffer if the string length is 0. Also avoids a possible
|
* underrun the buffer if the string length is 0. Also avoids a possible
|
||||||
* space-hogging inline of strlen() per usage.
|
* space-hogging inline of strlen() per usage.
|
||||||
*/
|
*/
|
||||||
int last_char_is(const char *s, const int c)
|
char * last_char_is(char *s, int c)
|
||||||
{
|
{
|
||||||
int l = strlen(s);
|
char *sret = s+strlen(s)-1;
|
||||||
if (l==0) return 0;
|
if (sret>=s && *sret == c) {
|
||||||
return (s[l-1] == c);
|
return sret;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user