aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2019-10-30 14:11:05 +0200
committerIgor Pashev <pashev.igor@gmail.com>2019-10-30 14:11:27 +0200
commit87ef72e1260fee0882a0dcdb8d329b268f09ca0c (patch)
treea0ec820c6ce959530c7cf88bd72b3013e69a883f
parentf36154c03aab2c81c6132a1a411fa0aa30ea4e2a (diff)
downloadbrainfuck-87ef72e1260fee0882a0dcdb8d329b268f09ca0c.tar.gz
Use memcpy instead of strncpy
Fix warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation]
-rw-r--r--brainfuck.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/brainfuck.c b/brainfuck.c
index 69dae83..fb15282 100644
--- a/brainfuck.c
+++ b/brainfuck.c
@@ -418,17 +418,17 @@ optimize_code ()
}
/*
- * FIXME valid while we use finite integers
+ * FIXME valid while we use finite integers
*/
substr = new_code;
while (NULL != (substr = strstr (substr, "[-]")))
{
- strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */
+ memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */
}
substr = new_code;
while (NULL != (substr = strstr (substr, "[+]")))
{
- strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */
+ memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */
}
free (code);