diff options
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/rpmfileutil.c | 23 | ||||
-rw-r--r-- | rpmio/rpmfileutil.h | 7 |
2 files changed, 30 insertions, 0 deletions
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index 40e4e5afb..b07c93a9c 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -840,3 +840,26 @@ exit: return rc; } +char * rpmEscapeSpaces(const char * s) +{ + const char * se; + char * t; + char * te; + size_t nb = 0; + + for (se = s; *se; se++) { + if (isspace(*se)) + nb++; + nb++; + } + nb++; + + t = te = xmalloc(nb); + for (se = s; *se; se++) { + if (isspace(*se)) + *te++ = '\\'; + *te++ = *se; + } + *te = '\0'; + return t; +} diff --git a/rpmio/rpmfileutil.h b/rpmio/rpmfileutil.h index 336ccd266..bd45d183f 100644 --- a/rpmio/rpmfileutil.h +++ b/rpmio/rpmfileutil.h @@ -103,4 +103,11 @@ char * rpmGetPath (const char * path, ...); */ int rpmGlob(const char * patterns, int * argcPtr, char *** argvPtr); +/** + * Escape isspace(3) characters in string. + * @param s string + * @return escaped string + */ +char * rpmEscapeSpaces(const char * s); + #endif /* _RPMFILEUTIL_H */ |