Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): remove redundant assignment from Cmd_Exec



details:   https://anonhg.NetBSD.org/src/rev/4efd6508c033
branches:  trunk
changeset: 937118:4efd6508c033
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 09 09:07:54 2020 +0000

description:
make(1): remove redundant assignment from Cmd_Exec

A Buffer is always null-terminated.

diffstat:

 usr.bin/make/main.c |  19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)

diffs (51 lines):

diff -r 2465d9833aa5 -r 4efd6508c033 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Aug 09 09:01:29 2020 +0000
+++ b/usr.bin/make/main.c       Sun Aug 09 09:07:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1698,20 +1698,13 @@
        else if (WEXITSTATUS(status) != 0)
            *errfmt = "\"%s\" returned non-zero status";
 
-       /* Null-terminate the result and convert newlines to spaces. */
-       res[res_len] = '\0';
+       /* Convert newlines to spaces.  A final newline is just stripped */
        cp = &res[res_len];
-
-       if (res_len > 0 && *--cp == '\n') {
-           /*
-            * A final newline is just stripped
-            */
+       if (res_len > 0 && *--cp == '\n')
            *cp-- = '\0';
-       }
        while (cp >= res) {
-           if (*cp == '\n') {
+           if (*cp == '\n')
                *cp = ' ';
-           }
            cp--;
        }
        break;



Home | Main Index | Thread Index | Old Index