mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-25 05:29:46 +00:00
* src/function.c (parse_textint): Handle ints without 0 properly.
* tests/scripts/functions/intcmp: Add tests for values without 0.
This commit is contained in:
parent
e72c5e021f
commit
2b25eac587
2 changed files with 10 additions and 7 deletions
|
@ -1294,7 +1294,7 @@ parse_textint (const char *number, const char *msg,
|
|||
const char *after_sign, *after_number;
|
||||
const char *p = next_token (number);
|
||||
int negative = *p == '-';
|
||||
int nonzero = 0;
|
||||
int nonzero;
|
||||
|
||||
if (*p == '\0')
|
||||
OS (fatal, *expanding_var, _("%s: empty value"), msg);
|
||||
|
@ -1307,9 +1307,9 @@ parse_textint (const char *number, const char *msg,
|
|||
*numstart = p;
|
||||
|
||||
while (ISDIGIT (*p))
|
||||
if (*p++ == '0')
|
||||
nonzero = 1;
|
||||
++p;
|
||||
after_number = p;
|
||||
nonzero = *numstart != after_number;
|
||||
*sign = negative ? -nonzero : nonzero;
|
||||
|
||||
/* Check for extra non-whitespace stuff after the value. */
|
||||
|
|
|
@ -9,15 +9,18 @@ n = -10
|
|||
# Zero
|
||||
z = 0
|
||||
# Positive
|
||||
p = 1000000000
|
||||
p = 888
|
||||
min = -9223372036854775808
|
||||
max = 9223372036854775807
|
||||
huge = 8857889956778499040639527525992734031025567913257255490371761260681427
|
||||
.RECIPEPREFIX = >
|
||||
all:
|
||||
> @echo 0_1 $(intcmp $n,$n)
|
||||
> @echo 0_2 $(intcmp $n,$z)
|
||||
> @echo 0_3 $(intcmp $z,$n)
|
||||
> @echo 0_2 $(intcmp $z,$z)
|
||||
> @echo 0_3 $(intcmp -$z,$z)
|
||||
> @echo 0_4 $(intcmp $p,$p)
|
||||
> @echo 0_5 $(intcmp $n,$z)
|
||||
> @echo 0_6 $(intcmp $z,$n)
|
||||
> @echo 1_1 $(intcmp $n,$n,$(shell echo lt))
|
||||
> @echo 1_2 $(intcmp $n,$z,$(shell echo lt))
|
||||
> @echo 1_3 $(intcmp $z,$n,$(shell echo lt))
|
||||
|
@ -36,7 +39,7 @@ all:
|
|||
> @echo 5_1 $(intcmp $(huge),-$(huge),lt,eq,gt)
|
||||
> @echo 5_2 $(intcmp -$(huge),-$(huge),lt,eq,gt)
|
||||
> @echo 5_3 $(intcmp +$(huge),$(huge),lt,eq,gt)
|
||||
', '', "0_1 -10\n0_2\n0_3\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n4_0 lt\n4_1 gt\n4_2 eq\n4_3 eq\n5_0 lt\n5_1 gt\n5_2 eq\n5_3 eq\n");
|
||||
', '', "0_1 -10\n0_2 0\n0_3 0\n0_4 888\n0_5\n0_6\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n4_0 lt\n4_1 gt\n4_2 eq\n4_3 eq\n5_0 lt\n5_1 gt\n5_2 eq\n5_3 eq\n");
|
||||
|
||||
# Test error conditions
|
||||
|
||||
|
|
Loading…
Reference in a new issue