summaryrefslogtreecommitdiff
path: root/src/glyphs.c
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-07-19 09:00:41 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-07-19 09:23:42 +0200
commit6932023f4d4fff964a06a9d017716749abafe27b (patch)
tree96b738664346e25d3ae790fb7b79eb62a280f02c /src/glyphs.c
parentfff17fe8fefcfa8a1ab0caf374b83cd167f11734 (diff)
downloadbison-6932023f4d4fff964a06a9d017716749abafe27b.tar.gz
style: avoid strncpy
syntax-check seems to dislike strncpy. The GNU Coreutils replaced their uses of strncpy with stpncpy. strlcpy is not an option. http://sources.redhat.com/ml/libc-alpha/2002-01/msg00159.html http://sources.redhat.com/ml/libc-alpha/2002-01/msg00011.html http://lists.gnu.org/archive/html/bug-gnulib/2004-09/msg00181.html * src/glyphs.c: Use stpncpy.
Diffstat (limited to 'src/glyphs.c')
-rw-r--r--src/glyphs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/glyphs.c b/src/glyphs.c
index 0c0e9fc2..b69659d8 100644
--- a/src/glyphs.c
+++ b/src/glyphs.c
@@ -63,8 +63,8 @@ static long
on_success (const char *buf, size_t buflen, void *callback_arg)
{
callback_arg_t *arg = (callback_arg_t *) callback_arg;
- assert (buflen < sizeof arg->buf);
- strncpy (arg->buf, buf, buflen);
+ assert (buflen + 1 < sizeof arg->buf);
+ *stpncpy (arg->buf, buf, buflen) = '\0';
return 1;
}
@@ -73,7 +73,7 @@ on_failure (unsigned code MAYBE_UNUSED, const char *msg MAYBE_UNUSED,
void *callback_arg)
{
callback_arg_t *arg = (callback_arg_t *) callback_arg;
- assert (strlen (arg->fallback) < sizeof arg->buf);
+ assert (strlen (arg->fallback) + 1 < sizeof arg->buf);
strcpy (arg->buf, arg->fallback);
return 0;
}