diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-12-17 23:55:02 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-12-17 23:55:02 +0000 |
commit | 355799ce0bbb078237dfc1ae9874bbc5342acbc4 (patch) | |
tree | 7ca980c01c0d4d1d55a3b7b15418c95c5618afae /utils/utils.c | |
parent | 4346b2b62b940182575e6612e46234355afa083c (diff) | |
download | netsurf-355799ce0bbb078237dfc1ae9874bbc5342acbc4.tar.gz netsurf-355799ce0bbb078237dfc1ae9874bbc5342acbc4.tar.bz2 |
Merge branches/MarkieB/gtkmain to trunk.
svn path=/trunk/netsurf/; revision=9729
Diffstat (limited to 'utils/utils.c')
-rw-r--r-- | utils/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c index ae58222b9..c8cfcb410 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -62,6 +62,29 @@ int whitespace(const char * str) } /** + * returns a string without its underscores + * \param replacespace true to insert a space where there was an underscore + */ + +char *remove_underscores(const char *s, bool replacespace) +{ + size_t i, ii, len; + char *ret; + len = strlen(s); + ret = malloc(len + 1); + if (ret == NULL) + return NULL; + for (i = 0, ii = 0; i < len; i++) { + if (s[i] != '_') + ret[ii++] = s[i]; + else if (replacespace) + ret[ii++] = ' '; + } + ret[ii] = '\0'; + return ret; +} + +/** * Replace consecutive whitespace with a single space. * * \param s source string |