From 83de09639c6104dc3aecd568e39af6c44a62459f Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Wed, 1 Sep 2004 18:37:14 +0000 Subject: [PATCH] * syntax.c(this_try_alloc_color_pair): Use g_strlcpy instead sequence strncpy(), name[len] = '\0' (edit_read_syntax_rules):Likewise. --- edit/ChangeLog | 6 ++++++ edit/syntax.c | 24 ++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/edit/ChangeLog b/edit/ChangeLog index dac34c958..f5be21a7f 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,3 +1,9 @@ +2004-09-01 Pavel S. Shirshov + + * syntax.c(this_try_alloc_color_pair): Use g_strlcpy instead + sequence strncpy(), name[len] = '\0' + (edit_read_syntax_rules):Likewise. + 2004-08-29 Roland Illig * Code cleanup: Added const qualifier for variables and diff --git a/edit/syntax.c b/edit/syntax.c index 3b1c79c5e..bf9ca0e4b 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -593,16 +593,14 @@ this_try_alloc_color_pair (char *fg, char *bg) if (!*fg) fg = 0; if (fg) { - strncpy (f, fg, sizeof (f) - 1); - f[sizeof (f) - 1] = 0; + g_strlcpy (f, fg, sizeof (f)); p = strchr (f, '/'); if (p) *p = '\0'; fg = f; } if (bg) { - strncpy (b, bg, sizeof (b) - 1); - b[sizeof (b) - 1] = 0; + g_strlcpy (b, bg, sizeof (b)); p = strchr (b, '/'); if (p) *p = '\0'; @@ -705,17 +703,13 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args) check_a; if (!strcmp (*a, "left")) { a++; - strncpy (whole_left, *a, sizeof (whole_left) - 1); - whole_left[sizeof (whole_left) - 1] = 0; + g_strlcpy (whole_left, *a, sizeof (whole_left)); } else if (!strcmp (*a, "right")) { a++; - strncpy (whole_right, *a, sizeof (whole_right) - 1); - whole_right[sizeof (whole_right) - 1] = 0; + g_strlcpy (whole_right, *a, sizeof (whole_right)); } else { - strncpy (whole_left, *a, sizeof (whole_left) - 1); - whole_left[sizeof (whole_left) - 1] = 0; - strncpy (whole_right, *a, sizeof (whole_right) - 1); - whole_right[sizeof (whole_right) - 1] = 0; + g_strlcpy (whole_left, *a, sizeof (whole_left)); + g_strlcpy (whole_right, *a, sizeof (whole_right)); } a++; check_not_a; @@ -777,10 +771,8 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args) bg = *a; if (*a) a++; - strncpy (last_fg, fg ? fg : "", sizeof (last_fg) - 1); - last_fg[sizeof (last_fg) - 1] = 0; - strncpy (last_bg, bg ? bg : "", sizeof (last_bg) - 1); - last_bg[sizeof (last_bg) - 1] = 0; + g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); + g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg)); c->keyword[0]->color = this_try_alloc_color_pair (fg, bg); c->keyword[0]->keyword = g_strdup (" "); check_not_a;