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: document that the input buffer is not nul...



details:   https://anonhg.NetBSD.org/src/rev/89bd348d74be
branches:  trunk
changeset: 1027158:89bd348d74be
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Dec 07 23:56:06 2021 +0000

description:
make: document that the input buffer is not null-terminated

diffstat:

 usr.bin/make/parse.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 750327c98400 -r 89bd348d74be usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Dec 07 23:20:09 2021 +0000
+++ b/usr.bin/make/parse.c      Tue Dec 07 23:56:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.570 2021/12/07 23:20:09 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.571 2021/12/07 23:56:06 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.570 2021/12/07 23:20:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.571 2021/12/07 23:56:06 rillig Exp $");
 
 /* types and constants */
 
@@ -124,10 +124,14 @@
        unsigned int cond_depth; /* 'if' nesting when file opened */
        bool depending; /* state of doing_depend on EOF */
 
-       /* The buffer from which the file's content is read. */
+       /*
+        * The buffer from which the file's content is read.  The buffer
+        * always ends with '\n', the buffer is not null-terminated, that is,
+        * buf_end[0] is already out of bounds.
+        */
        char *buf_freeIt;
        char *buf_ptr;          /* next char to be read */
-       char *buf_end;
+       char *buf_end;          /* buf_end[-1] == '\n' */
 
        /* Function to read more data, with a single opaque argument. */
        ReadMoreProc readMore;
@@ -2634,7 +2638,8 @@
 
 /*
  * Parse until the end of a line, taking into account lines that end with
- * backslash-newline.
+ * backslash-newline.  The resulting line goes from out_line to out_line_end;
+ * the line is not null-terminated.
  */
 static ParseRawLineResult
 ParseRawLine(IFile *curFile, char **out_line, char **out_line_end,



Home | Main Index | Thread Index | Old Index