git: ac196a584575 - main - m4: Allow empty base argument in eval()

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sat, 24 May 2025 16:57:51 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=ac196a5845757a4d92cdfc4927170576dce5de9d

commit ac196a5845757a4d92cdfc4927170576dce5de9d
Author:     Eric Blake <eblake@redhat.com>
AuthorDate: 2025-05-23 14:37:20 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-05-24 16:57:24 +0000

    m4: Allow empty base argument in eval()
    
    POSIX specifies "The second argument, if specified, shall set the radix
    for the result; if the argument is blank or unspecified, the default
    is 10."  Previously we reported an invalid
    
    PR:             287015
    Reviewed by:    emaste
---
 usr.bin/m4/eval.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index 82218eb9ba1c..3170d52bfe2a 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -181,7 +181,7 @@ expand_builtin(const char *argv[], int argc, int td)
 		int maxdigits = 0;
 		const char *errstr;
 
-		if (argc > 3) {
+		if (argc > 3 && *argv[3] != '\0') {
 			base = strtonum(argv[3], 2, 36, &errstr);
 			if (errstr) {
 				m4errx(1, "expr: base is %s: %s.",