]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
nl, pinky: replace uses of strcat
authorJim Meyering <meyering@redhat.com>
Mon, 10 Aug 2009 06:11:33 +0000 (08:11 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 10 Aug 2009 07:17:07 +0000 (09:17 +0200)
* src/nl.c (main): Avoid strcat, on principle.  Use stpcpy instead.
* src/pinky.c (print_long_entry): Likewise.

src/nl.c
src/pinky.c

index 56d5a3998c7f82e281bd7bf8ec5e5a1e1f8b28ab..2deb314a45d4aae57687aec7ce3ecb88cf317a01 100644 (file)
--- a/src/nl.c
+++ b/src/nl.c
@@ -577,15 +577,15 @@ main (int argc, char **argv)
 
   header_del_len = len * 3;
   header_del = xmalloc (header_del_len + 1);
-  strcat (strcat (strcpy (header_del, section_del), section_del), section_del);
+  stpcpy (stpcpy (stpcpy (header_del, section_del), section_del), section_del);
 
   body_del_len = len * 2;
   body_del = xmalloc (body_del_len + 1);
-  strcat (strcpy (body_del, section_del), section_del);
+  stpcpy (stpcpy (body_del, section_del), section_del);
 
   footer_del_len = len;
   footer_del = xmalloc (footer_del_len + 1);
-  strcpy (footer_del, section_del);
+  stpcpy (footer_del, section_del);
 
   /* Initialize the input buffer.  */
   initbuffer (&line_buf);
index 25052367e4de3f64a6e232bc997568a703975fe2..8ddd218fae5dfb28b8febcf5f4153809c48169e3 100644 (file)
@@ -363,10 +363,8 @@ print_long_entry (const char name[])
       char buf[1024];
       const char *const baseproject = "/.project";
       char *const project =
-      xmalloc (strlen (pw->pw_dir) + strlen (baseproject) + 1);
-
-      strcpy (project, pw->pw_dir);
-      strcat (project, baseproject);
+        xmalloc (strlen (pw->pw_dir) + strlen (baseproject) + 1);
+      stpcpy (stpcpy (project, pw->pw_dir), baseproject);
 
       stream = fopen (project, "r");
       if (stream)
@@ -389,10 +387,8 @@ print_long_entry (const char name[])
       char buf[1024];
       const char *const baseplan = "/.plan";
       char *const plan =
-      xmalloc (strlen (pw->pw_dir) + strlen (baseplan) + 1);
-
-      strcpy (plan, pw->pw_dir);
-      strcat (plan, baseplan);
+        xmalloc (strlen (pw->pw_dir) + strlen (baseplan) + 1);
+      stpcpy (stpcpy (plan, pw->pw_dir), baseplan);
 
       stream = fopen (plan, "r");
       if (stream)