On Sun, 01 May 2022 00:48:17 -0400, "Ted Unangst" wrote:

> I don't think we need to concern ourselves with cross awk compatibility here.
>
> Despite the misleading comment, /usr/bin/awk supports toupper.

This must have been to support very old versions of awk (pre-nawk)
since toupper and tolower were added to AT&T awk in October of 1987.
It is also required by POSIX.

OK millert@

 - todd

>
> Index: makesyscalls.sh
> ===================================================================
> RCS file: /home/cvs/src/sys/kern/makesyscalls.sh,v
> retrieving revision 1.15
> diff -u -p -r1.15 makesyscalls.sh
> --- makesyscalls.sh     9 Dec 2021 00:26:10 -0000       1.15
> +++ makesyscalls.sh     1 May 2022 04:45:49 -0000
> @@ -70,28 +70,6 @@ sysent="sysent.switch"
>  
>  trap "rm $sysdcl $sysprotos $sysent" 0
>  
> -# Awk program (must support nawk extensions)
> -# Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
> -awk=${AWK:-awk}
> -
> -# Does this awk have a "toupper" function? (i.e. is it GNU awk)
> -isgawk=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null`
> -
> -# If this awk does not define "toupper" then define our own.
> -if [ "$isgawk" = TRUE ] ; then
> -       # GNU awk provides it.
> -       toupper=
> -else
> -       # Provide our own toupper()
> -       toupper='
> -function toupper(str) {
> -       _toupper_cmd = "echo "str" |tr a-z A-Z"
> -       _toupper_cmd | getline _toupper_str;
> -       close(_toupper_cmd);
> -       return _toupper_str;
> -}'
> -fi
> -
>  # before handing it off to awk, make a few adjustments:
>  #      (1) insert spaces around {, }, (, ), *, and commas.
>  #      (2) get rid of any and all dollar signs (so that rcs id use safe)
> @@ -111,8 +89,7 @@ s/\$//g
>  2,${
>         /^#/!s/\([{}()*,]\)/ \1 /g
>  }
> -' < $2 | $awk "
> -$toupper
> +' < $2 | awk "
>  BEGIN {
>         # to allow nested #if/#else/#endif sets
>         savedepth = 0

Reply via email to