diff options
Diffstat (limited to 'src/stringutils.c')
-rw-r--r-- | src/stringutils.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/stringutils.c b/src/stringutils.c index 11a31ab..9cba1c2 100644 --- a/src/stringutils.c +++ b/src/stringutils.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> +#include <ctype.h> #include <stdarg.h> #include <errno.h> #ifdef HAVE_STAT @@ -33,6 +34,31 @@ #include "gpgrt-int.h" +char * +_gpgrt_trim_spaces (char *str) +{ + char *string, *p, *mark; + + string = str; + /* Find first non space character. */ + for (p=string; *p && isspace (*(unsigned char*)p) ; p++) + ; + /* Move characters. */ + for ((mark = NULL); (*string = *p); string++, p++) + if (isspace (*(unsigned char*)p)) + { + if (!mark) + mark = string; + } + else + mark = NULL; + if (mark) + *mark = '\0' ; /* Remove trailing spaces. */ + + return str ; +} + + /* Helper for _gpgrt_fnameconcat. The additional flag WANT_ABS tells * whether an absolute file name is requested. */ char * |