Sun Nov 1 12:34:46 2020 UTC ()
make(1): clean up comments in ApplyModifier_Words


(rillig)
diff -r1.632 -r1.633 src/usr.bin/make/var.c

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

--- src/usr.bin/make/var.c 2020/10/31 23:23:22 1.632
+++ src/usr.bin/make/var.c 2020/11/01 12:34:45 1.633
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.632 2020/10/31 23:23:22 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.633 2020/11/01 12:34:45 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.
@@ -120,27 +120,27 @@ @@ -120,27 +120,27 @@
120#include <regex.h> 120#include <regex.h>
121#endif 121#endif
122#include <errno.h> 122#include <errno.h>
123#include <inttypes.h> 123#include <inttypes.h>
124#include <limits.h> 124#include <limits.h>
125#include <time.h> 125#include <time.h>
126 126
127#include "make.h" 127#include "make.h"
128#include "dir.h" 128#include "dir.h"
129#include "job.h" 129#include "job.h"
130#include "metachar.h" 130#include "metachar.h"
131 131
132/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 132/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
133MAKE_RCSID("$NetBSD: var.c,v 1.632 2020/10/31 23:23:22 rillig Exp $"); 133MAKE_RCSID("$NetBSD: var.c,v 1.633 2020/11/01 12:34:45 rillig Exp $");
134 134
135#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) 135#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
136#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) 136#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
137#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) 137#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3)
138#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) 138#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4)
139 139
140ENUM_FLAGS_RTTI_3(VarEvalFlags, 140ENUM_FLAGS_RTTI_3(VarEvalFlags,
141 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); 141 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
142 142
143/* 143/*
144 * This lets us tell if we have replaced the original environ 144 * This lets us tell if we have replaced the original environ
145 * (which we cannot free). 145 * (which we cannot free).
146 */ 146 */
@@ -2104,27 +2104,28 @@ ApplyModifier_Defined(const char **pp, A @@ -2104,27 +2104,28 @@ ApplyModifier_Defined(const char **pp, A
2104 return AMR_OK; 2104 return AMR_OK;
2105} 2105}
2106 2106
2107/* :L */ 2107/* :L */
2108static ApplyModifierResult 2108static ApplyModifierResult
2109ApplyModifier_Literal(const char **pp, ApplyModifiersState *st) 2109ApplyModifier_Literal(const char **pp, ApplyModifiersState *st)
2110{ 2110{
2111 ApplyModifiersState_Define(st); 2111 ApplyModifiersState_Define(st);
2112 st->newVal = bmake_strdup(st->v->name); 2112 st->newVal = bmake_strdup(st->v->name);
2113 (*pp)++; 2113 (*pp)++;
2114 return AMR_OK; 2114 return AMR_OK;
2115} 2115}
2116 2116
2117static Boolean TryParseTime(const char **pp, time_t *out_time) 2117static Boolean
 2118TryParseTime(const char **pp, time_t *out_time)
2118{ 2119{
2119 char *end; 2120 char *end;
2120 unsigned long n; 2121 unsigned long n;
2121 2122
2122 if (!ch_isdigit(**pp)) 2123 if (!ch_isdigit(**pp))
2123 return FALSE; 2124 return FALSE;
2124 2125
2125 errno = 0; 2126 errno = 0;
2126 n = strtoul(*pp, &end, 10); 2127 n = strtoul(*pp, &end, 10);
2127 if (n == ULONG_MAX && errno == ERANGE) 2128 if (n == ULONG_MAX && errno == ERANGE)
2128 return FALSE; 2129 return FALSE;
2129 2130
2130 *pp = end; 2131 *pp = end;
@@ -2710,41 +2711,41 @@ ApplyModifier_Words(const char **pp, App @@ -2710,41 +2711,41 @@ ApplyModifier_Words(const char **pp, App
2710 2711
2711 if (ep[0] == '\0') { /* Found only one integer in :[N] */ 2712 if (ep[0] == '\0') { /* Found only one integer in :[N] */
2712 last = first; 2713 last = first;
2713 } else if (ep[0] == '.' && ep[1] == '.' && ep[2] != '\0') { 2714 } else if (ep[0] == '.' && ep[1] == '.' && ep[2] != '\0') {
2714 /* Expecting another integer after ".." */ 2715 /* Expecting another integer after ".." */
2715 ep += 2; 2716 ep += 2;
2716 last = (int)strtol(ep, &ep, 0); 2717 last = (int)strtol(ep, &ep, 0);
2717 if (ep[0] != '\0') /* Found junk after ".." */ 2718 if (ep[0] != '\0') /* Found junk after ".." */
2718 goto bad_modifier; 2719 goto bad_modifier;
2719 } else 2720 } else
2720 goto bad_modifier; /* Found junk instead of ".." */ 2721 goto bad_modifier; /* Found junk instead of ".." */
2721 2722
2722 /* 2723 /*
2723 * Now seldata is properly filled in, but we still have to check for 0 as 2724 * Now first and last are properly filled in, but we still have to check
2724 * a special case. 2725 * for 0 as a special case.
2725 */ 2726 */
2726 if (first == 0 && last == 0) { 2727 if (first == 0 && last == 0) {
2727 /* ":[0]" or perhaps ":[0..0]" */ 2728 /* ":[0]" or perhaps ":[0..0]" */
2728 st->oneBigWord = TRUE; 2729 st->oneBigWord = TRUE;
2729 st->newVal = st->val; 2730 st->newVal = st->val;
2730 goto ok; 2731 goto ok;
2731 } 2732 }
2732 2733
2733 /* ":[0..N]" or ":[N..0]" */ 2734 /* ":[0..N]" or ":[N..0]" */
2734 if (first == 0 || last == 0) 2735 if (first == 0 || last == 0)
2735 goto bad_modifier; 2736 goto bad_modifier;
2736 2737
2737 /* Normal case: select the words described by seldata. */ 2738 /* Normal case: select the words described by first and last. */
2738 st->newVal = VarSelectWords(st->sep, st->oneBigWord, st->val, first, last); 2739 st->newVal = VarSelectWords(st->sep, st->oneBigWord, st->val, first, last);
2739 2740
2740ok: 2741ok:
2741 free(estr); 2742 free(estr);
2742 return AMR_OK; 2743 return AMR_OK;
2743 2744
2744bad_modifier: 2745bad_modifier:
2745 free(estr); 2746 free(estr);
2746 return AMR_BAD; 2747 return AMR_BAD;
2747} 2748}
2748 2749
2749static int 2750static int
2750str_cmp_asc(const void *a, const void *b) 2751str_cmp_asc(const void *a, const void *b)