From 35fcacb16d045067f65adeed4be62e23d04c6e15 Mon Sep 17 00:00:00 2001 From: Phineas Su Date: Wed, 15 Jul 2026 17:47:38 +0000 Subject: [PATCH] fix(gen_expand): add numeric validation for input argument n Executing ./gen_expand without arguments or with non-numeric parameters resulted in unhandled script errors and could produce malformed header files. This change validates that $n is a positive integer before proceeding, and fixes capitalization in comments. Signed-off-by: Phineas Su --- gen_expand | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gen_expand b/gen_expand index 254a81d..ddfa978 100755 --- a/gen_expand +++ b/gen_expand @@ -15,10 +15,11 @@ use warnings; use strict; -defined(my $n = shift) - or die "usage: $0 n\n"; +my $n = shift; +(defined($n) && $n =~ /^\d+$/ && $n >= 1) + or die "usage: $0 \n"; -# special cases i can't be bothered to handle otherwise +# special cases I can't be bothered to handle otherwise print "#define x1(x) x\n"; print "#define x2(x) x x\n"; print "#define x3(x) x2(x) x\n";