mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
string/whitespace handling cleanups (bug #4449, with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5924 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
35
utils.c
35
utils.c
@@ -37,15 +37,36 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
static char base64[64];
|
||||
static char b2a[256];
|
||||
|
||||
char *ast_skip_blanks(char *str)
|
||||
{
|
||||
while (*str && *str < 33)
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
char *ast_trim_blanks(char *str)
|
||||
{
|
||||
if (str) {
|
||||
str += strlen(str) - 1;
|
||||
while (*str && *str < 33)
|
||||
str--;
|
||||
*(++str) = '\0'; /* terminate string */
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
char *ast_skip_nonblanks(char *str)
|
||||
{
|
||||
while (*str && *str > 32)
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
char *ast_strip(char *s)
|
||||
{
|
||||
char *e;
|
||||
|
||||
while (*s && (*s < 33)) s++;
|
||||
e = s + strlen(s) - 1;
|
||||
while ((e > s) && (*e < 33)) e--;
|
||||
*++e = '\0';
|
||||
|
||||
s = ast_skip_blanks(s);
|
||||
if (s)
|
||||
ast_trim_blanks(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user