Import backup from 2005-01-31
This commit is contained in:
1 parent
3381041a8f
commit
4638656aaf
9 files changed
+226
-74
No files matched your search
@@ -44,6 +44,25 @@ int strncmp(char *str1, char *str2, int n)
|
||||
}
|
||||
|
||||
|
||||
/* str_change changes a certain character in a string
|
||||
* to a different character
|
||||
* Returns: how many characters were changed
|
||||
*/
|
||||
int str_change(char *str, char ch1, char ch2)
|
||||
{
|
||||
int count = 0;
|
||||
while (*str)
|
||||
{
|
||||
if (*str == ch1)
|
||||
{
|
||||
*str = ch2;
|
||||
count++;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// counts the occurrences of lookfor in str
|
||||
int str_count(char *str, char lookfor)
|
||||
{
|
||||
@@ -60,6 +79,8 @@ int str_count(char *str, char lookfor)
|
||||
// split the string into substrings by the splitchar, return number of substrings
|
||||
int str_split(char *str, char splitchar)
|
||||
{
|
||||
if (!(*str))
|
||||
return 0;
|
||||
int subs = 1;
|
||||
while (*str)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ void invlpg_(u32_t addr);
|
||||
/* lang.c */
|
||||
int strcmp(char *str1, char *str2);
|
||||
int strncmp(char *str1, char *str2, int n);
|
||||
int str_change(char *str, char ch1, char ch2);
|
||||
int str_count(char *str, char lookfor);
|
||||
int str_split(char *str, char splitchar);
|
||||
char *str_advance(char *str);
|
||||
|
||||
Reference in new issue
Block a user