Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Ensure that command output is always followed b...



details:   https://anonhg.NetBSD.org/src/rev/dbc57449419d
branches:  trunk
changeset: 825321:dbc57449419d
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sun Jul 09 04:54:00 2017 +0000

description:
Ensure that command output is always followed by newline,
even when filemon is not being used.

Tweak MAKE_META_IGNORE_PATTERNS matching to avoid using path name
with :L as it does not handle ':' in path names.

fgetLine: an extra check to avoid shrinking the buffer.

diffstat:

 usr.bin/make/meta.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r f8d4c3feca24 -r dbc57449419d usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Jul 08 22:56:15 2017 +0000
+++ b/usr.bin/make/meta.c       Sun Jul 09 04:54:00 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.67 2016/08/17 15:52:42 sjg Exp $ */
+/*      $NetBSD: meta.c,v 1.68 2017/07/09 04:54:00 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -723,7 +723,7 @@
        pbm = &Mybm;
     }
     if (pbm->mfp != NULL) {
-       fprintf(pbm->mfp, "*** Error code %d%s\n",
+       fprintf(pbm->mfp, "\n*** Error code %d%s\n",
                status,
                (flags & JOB_IGNERR) ?
                "(ignored)" : "");
@@ -778,13 +778,13 @@
 meta_cmd_finish(void *pbmp)
 {
     int error = 0;
-#ifdef USE_FILEMON
     BuildMon *pbm = pbmp;
     int x;
 
     if (!pbm)
        pbm = &Mybm;
 
+#ifdef USE_FILEMON
     if (pbm->filemon_fd >= 0) {
        if (close(pbm->filemon_fd) < 0)
            error = errno;
@@ -792,8 +792,9 @@
        if (error == 0 && x != 0)
            error = x;
        pbm->filemon_fd = pbm->mon_fd = -1;
-    }
+    } else
 #endif
+       fprintf(pbm->mfp, "\n");        /* ensure end with newline */
     return error;
 }
 
@@ -857,6 +858,8 @@
            newsz = ROUNDUP((fs.st_size / 2), BUFSIZ);
            if (newsz <= bufsz)
                newsz = ROUNDUP(fs.st_size, BUFSIZ);
+           if (newsz <= bufsz)
+               return x;               /* truncated */
            if (DEBUG(META)) 
                fprintf(debug_file, "growing buffer %zu -> %zu\n",
                        bufsz, newsz);
@@ -944,10 +947,10 @@
     if (metaIgnorePatterns) {
        char *pm;
 
-       snprintf(fname, sizeof(fname),
-                "${%s:@m@${%s:L:M$m}@}",
-                MAKE_META_IGNORE_PATTERNS, p);
-       pm = Var_Subst(NULL, fname, gn, VARF_WANTRES);
+       Var_Set(".p.", p, gn, 0);
+       pm = Var_Subst(NULL,
+                      "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}",
+                      gn, VARF_WANTRES);
        if (*pm) {
 #ifdef DEBUG_META_MODE
            if (DEBUG(META))



Home | Main Index | Thread Index | Old Index