From b601e6f54b847a38b83b01e88d3149dff3ccbf15 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Thu, 8 Nov 2018 16:54:28 +0000 Subject: [PATCH] elm entry - warn - write a specirfic string truncate func to avoid warnings so gcc likes to warn even if the truncation is intended. there are verious ways around this, but in this case it's really just writing your own ... which is pretty simple. there is just too much warning noise for efl. --- src/lib/elementary/elm_entry.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index 1bc579817c..4a33ff230e 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -3032,6 +3032,17 @@ _text_append_idler(void *data) } } +static void +my_string_copy_truncate(char *dest, const char *src, size_t len) +{ + char *p; + for (p = dest; len > 0; p++, src++, len--) + { + *p = *src; + if (*src == 0) break; + } +} + static void _chars_add_till_limit(Evas_Object *obj, char **text, @@ -3095,8 +3106,8 @@ _chars_add_till_limit(Evas_Object *obj, return; } can_add = 0; - strncpy(new_text, new_text + idx, - current_len - ((new_text + idx) - *text)); + my_string_copy_truncate(new_text, new_text + idx, + current_len - ((new_text + idx) - *text)); current_len -= idx; (*text)[current_len] = 0; }