From dd31499bf969baa68e66fca81b9f95447b6f3f2a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 20 Apr 2016 23:38:08 +0100 Subject: move remove underscores utility to alongside the single gtk call site --- gtk/toolbar.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gtk') diff --git a/gtk/toolbar.c b/gtk/toolbar.c index f5aa7fd3f..801259812 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -90,6 +90,34 @@ struct nsgtk_theme { /* apng throbber element */ }; +/** + * returns a string without its underscores + * + * \param s The string to change. + * \param replacespace true to insert a space where there was an underscore + * \return The altered string + */ +static 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; +} + + /** * get default image for buttons / menu items from gtk stock items. * -- cgit v1.2.3