Sat Oct 31 12:22:43 2020 UTC ()
make(1): remove redundant condition for regmatch_t.rm_eo being -1

If rm_so is -1, rm_eo is guaranteed to be -1 as well.


(rillig)
diff -r1.616 -r1.617 src/usr.bin/make/var.c

cvs diff -r1.616 -r1.617 src/usr.bin/make/var.c (expand / switch to unified diff)

--- src/usr.bin/make/var.c 2020/10/31 11:54:33 1.616
+++ src/usr.bin/make/var.c 2020/10/31 12:22:43 1.617
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.616 2020/10/31 11:54:33 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -119,27 +119,27 @@ @@ -119,27 +119,27 @@
119#include <sys/types.h> 119#include <sys/types.h>
120#include <regex.h> 120#include <regex.h>
121#endif 121#endif
122#include <inttypes.h> 122#include <inttypes.h>
123#include <limits.h> 123#include <limits.h>
124#include <time.h> 124#include <time.h>
125 125
126#include "make.h" 126#include "make.h"
127#include "dir.h" 127#include "dir.h"
128#include "job.h" 128#include "job.h"
129#include "metachar.h" 129#include "metachar.h"
130 130
131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
132MAKE_RCSID("$NetBSD: var.c,v 1.616 2020/10/31 11:54:33 rillig Exp $"); 132MAKE_RCSID("$NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $");
133 133
134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) 134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) 135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) 136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3)
137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) 137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4)
138 138
139ENUM_FLAGS_RTTI_3(VarEvalFlags, 139ENUM_FLAGS_RTTI_3(VarEvalFlags,
140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); 140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
141 141
142/* 142/*
143 * This lets us tell if we have replaced the original environ 143 * This lets us tell if we have replaced the original environ
144 * (which we cannot free). 144 * (which we cannot free).
145 */ 145 */
@@ -1398,27 +1398,27 @@ tryagain: @@ -1398,27 +1398,27 @@ tryagain:
1398 } 1398 }
1399 1399
1400 if (*rp != '\\' || !ch_isdigit(rp[1])) { 1400 if (*rp != '\\' || !ch_isdigit(rp[1])) {
1401 SepBuf_AddBytes(buf, rp, 1); 1401 SepBuf_AddBytes(buf, rp, 1);
1402 continue; 1402 continue;
1403 } 1403 }
1404 1404
1405 { /* \0 to \9 backreference */ 1405 { /* \0 to \9 backreference */
1406 size_t n = (size_t)(rp[1] - '0'); 1406 size_t n = (size_t)(rp[1] - '0');
1407 rp++; 1407 rp++;
1408 1408
1409 if (n >= args->nsub) { 1409 if (n >= args->nsub) {
1410 Error("No subexpression \\%zu", n); 1410 Error("No subexpression \\%zu", n);
1411 } else if (m[n].rm_so == -1 && m[n].rm_eo == -1) { 1411 } else if (m[n].rm_so == -1) {
1412 Error("No match for subexpression \\%zu", n); 1412 Error("No match for subexpression \\%zu", n);
1413 } else { 1413 } else {
1414 SepBuf_AddBytesBetween(buf, wp + m[n].rm_so, 1414 SepBuf_AddBytesBetween(buf, wp + m[n].rm_so,
1415 wp + m[n].rm_eo); 1415 wp + m[n].rm_eo);
1416 } 1416 }
1417 } 1417 }
1418 } 1418 }
1419 1419
1420 wp += m[0].rm_eo; 1420 wp += m[0].rm_eo;
1421 if (args->pflags & VARP_SUB_GLOBAL) { 1421 if (args->pflags & VARP_SUB_GLOBAL) {
1422 flags |= REG_NOTBOL; 1422 flags |= REG_NOTBOL;
1423 if (m[0].rm_so == 0 && m[0].rm_eo == 0) { 1423 if (m[0].rm_so == 0 && m[0].rm_eo == 0) {
1424 SepBuf_AddBytes(buf, wp, 1); 1424 SepBuf_AddBytes(buf, wp, 1);