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): document a hard-to-understand pointer ...



details:   https://anonhg.NetBSD.org/src/rev/cfd9d2cb07b6
branches:  trunk
changeset: 974727:cfd9d2cb07b6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 09 09:40:48 2020 +0000

description:
make(1): document a hard-to-understand pointer calculation

diffstat:

 usr.bin/make/var.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 81e855f4e9d4 -r cfd9d2cb07b6 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Aug 09 09:32:04 2020 +0000
+++ b/usr.bin/make/var.c        Sun Aug 09 09:40:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.437 2020/08/09 07:09:57 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.438 2020/08/09 09:40:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.437 2020/08/09 07:09:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.438 2020/08/09 09:40:48 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.437 2020/08/09 07:09:57 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.438 2020/08/09 09:40:48 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3575,7 +3575,9 @@
            *freePtr = extraFree;
        }
     }
-    *lengthPtr = tstr - str + (*tstr ? 1 : 0);
+
+    /* Skip past endc if possible. */
+    *lengthPtr = tstr + (*tstr ? 1 : 0) - str;
 
     if (v->flags & VAR_FROM_ENV) {
        Boolean destroy = nstr != Buf_GetAll(&v->val, NULL);



Home | Main Index | Thread Index | Old Index