diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/stringhelp.c | 30 | ||||
-rw-r--r-- | common/stringhelp.h | 1 | ||||
-rw-r--r-- | common/utf8conv.c | 2 |
3 files changed, 32 insertions, 1 deletions
diff --git a/common/stringhelp.c b/common/stringhelp.c index 68fe99796..7d5b5f806 100644 --- a/common/stringhelp.c +++ b/common/stringhelp.c @@ -213,6 +213,36 @@ trim_spaces( char *str ) return str ; } + +/* Same as trim_spaces but only condider, space, tab, cr and lf as space. */ +char * +ascii_trim_spaces (char *str) +{ + char *string, *p, *mark; + + string = str; + + /* Find first non-ascii space character. */ + for (p=string; *p && ascii_isspace (*p); p++) + ; + /* Move characters. */ + for (mark=NULL; (*string = *p); string++, p++ ) + { + if (ascii_isspace (*p)) + { + if (!mark) + mark = string; + } + else + mark = NULL ; + } + if (mark) + *mark = '\0' ; /* Remove trailing spaces. */ + + return str ; +} + + /**************** * remove trailing white spaces */ diff --git a/common/stringhelp.h b/common/stringhelp.h index 7df6c7656..42bb19aaf 100644 --- a/common/stringhelp.h +++ b/common/stringhelp.h @@ -42,6 +42,7 @@ char *has_leading_keyword (const char *string, const char *keyword); const char *memistr (const void *buf, size_t buflen, const char *sub); char *mem2str( char *, const void *, size_t); char *trim_spaces( char *string ); +char *ascii_trim_spaces (char *string); char *trim_trailing_spaces( char *string ); unsigned int trim_trailing_chars( unsigned char *line, unsigned len, const char *trimchars); diff --git a/common/utf8conv.c b/common/utf8conv.c index d2c282002..01604e176 100644 --- a/common/utf8conv.c +++ b/common/utf8conv.c @@ -803,7 +803,7 @@ wchar_to_native (const wchar_t *string) } -/* Return a malloced wide char string from an UTF-8 encoded input +/* Return a malloced wide char string from native encoded input * string STRING. Caller must free this value. Returns NULL and sets * ERRNO on failure. Calling this function with STRING set to NULL is * not defined. */ |