Apply #70: Add StrLower() function.
This commit is contained in:
parent
eb3732a2cd
commit
179e16ed24
2 changed files with 35 additions and 0 deletions
26
src/Str.c
26
src/Str.c
|
@ -277,6 +277,32 @@ StrInt(long i)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
StrLower(char *str)
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
ret = Malloc(len + 1);
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
ret[i] = tolower(str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret[len] = '\0';
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
StrEquals(const char *str1, const char *str2)
|
StrEquals(const char *str1, const char *str2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,15 @@ extern char * StrRandom(size_t);
|
||||||
*/
|
*/
|
||||||
extern char * StrInt(long);
|
extern char * StrInt(long);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a string into a lowercase version of it using
|
||||||
|
* .Xr tolower 3 ,
|
||||||
|
* returning the lowercase version on the heap, or NULL if there was
|
||||||
|
* a memory allocation error. The returned string should be freed by
|
||||||
|
* the caller after it is no longer needed.
|
||||||
|
*/
|
||||||
|
extern char * StrLower(char *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two strings and determine whether or not they are equal.
|
* Compare two strings and determine whether or not they are equal.
|
||||||
* This is the most common use case of strcmp() in Cytoplasm, but
|
* This is the most common use case of strcmp() in Cytoplasm, but
|
||||||
|
|
Loading…
Reference in a new issue