move remove underscores utility to alongside the single gtk call site

This commit is contained in:
Vincent Sanders 2016-04-20 23:38:08 +01:00
parent 7ba291037b
commit dd31499bf9
3 changed files with 28 additions and 31 deletions

View File

@ -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.
*

View File

@ -42,28 +42,6 @@
#include "utils/dirent.h"
#include "utils/utils.h"
/* exported interface documented in utils/utils.h */
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;
}
/* exported interface documented in utils/utils.h */
char *squash_whitespace(const char *s)
{

View File

@ -127,15 +127,6 @@ struct dirent;
*/
char * squash_whitespace(const char * s);
/**
* 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
*/
char *remove_underscores(const char *s, bool replacespace);
/**
* Converts NUL terminated UTF-8 encoded string s containing zero or more
* spaces (char 32) or TABs (char 9) to non-breaking spaces