aboutsummaryrefslogtreecommitdiff
path: root/deps/sysobj_early/src/nice_name.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/sysobj_early/src/nice_name.c')
-rw-r--r--deps/sysobj_early/src/nice_name.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/deps/sysobj_early/src/nice_name.c b/deps/sysobj_early/src/nice_name.c
index e5e15a46..fdb4557c 100644
--- a/deps/sysobj_early/src/nice_name.c
+++ b/deps/sysobj_early/src/nice_name.c
@@ -34,11 +34,15 @@ gboolean str_shorten(gchar *str, const gchar *find, const gchar *replace) {
long unsigned lr = strlen(replace);
gchar *p = strstr(str, find);
if (p) {
- if (lr > lf) lr = lf;
- gchar *buff = g_strnfill(lf, ' ');
- strncpy(buff, replace, lr);
- strncpy(p, buff, lf);
- g_free(buff);
+ if(lr==lf){
+ strncpy(p, replace, lf);
+ } else {
+ if (lr > lf) lr = lf;
+ gchar *buff = g_strnfill(lf, ' ');
+ if(lr) strncpy(buff, replace, lr);
+ strncpy(p, buff, lf);
+ g_free(buff);
+ }
return TRUE;
}
return FALSE;
@@ -50,11 +54,15 @@ gboolean str_shorten_anycase(gchar *str, const gchar *find, const gchar *replace
long unsigned lr = strlen(replace);
gchar *p = strcasestr(str, find);
if (p) {
- if (lr > lf) lr = lf;
- gchar *buff = g_strnfill(lf, ' ');
- strncpy(buff, replace, lr);
- strncpy(p, buff, lf);
- g_free(buff);
+ if(lr==lf){
+ strncpy(p, replace, lf);
+ } else {
+ if (lr > lf) lr = lf;
+ gchar *buff = g_strnfill(lf, ' ');
+ if(lr) strncpy(buff, replace, lr);
+ strncpy(p, buff, lf);
+ g_free(buff);
+ }
return TRUE;
}
return FALSE;