diff --git a/src/util.c b/src/util.c
index 35658b0..4c446b4 100644
a
|
b
|
name_trunc (const char *txt, int trunc_len) |
236 | 236 | int txt_len; |
237 | 237 | char *p; |
238 | 238 | |
| 239 | if (!txt) |
| 240 | return NULL; |
| 241 | if (!*txt) |
| 242 | >return txt; |
| 243 | |
239 | 244 | if ((size_t) trunc_len > sizeof (x) - 1) { |
240 | 245 | trunc_len = sizeof (x) - 1; |
241 | 246 | } |
242 | | txt_len = strlen (txt); |
| 247 | txt_len = (int) strlen (txt); |
243 | 248 | if (txt_len <= trunc_len) { |
244 | 249 | strcpy (x, txt); |
245 | 250 | } else { |
246 | 251 | int y = (trunc_len / 2) + (trunc_len % 2); |
247 | | strncpy (x, txt, y); |
248 | | strncpy (x + y, txt + txt_len - (trunc_len / 2), trunc_len / 2); |
| 252 | strncpy (x, txt, (size_t) y); |
| 253 | strncpy (x + y, txt + (size_t) (txt_len - (trunc_len / 2)), (size_t) trunc_len / 2); |
249 | 254 | x[y] = '~'; |
250 | 255 | } |
251 | 256 | x[trunc_len] = 0; |