# HG changeset patch # User Rob Landley # Date 1371928986 18000 # Node ID 39ac9e0ad6ada7909e2de17bb6f96622eb425a02 # Parent 9e00446064fa47b326383f555f0d5169523c52c3 Generate FLAG_longopt macros for --longopts with no corresponding short option. diff -r 9e00446064fa -r 39ac9e0ad6ad scripts/make.sh --- a/scripts/make.sh Tue Jun 18 18:13:06 2013 -0500 +++ b/scripts/make.sh Sat Jun 22 14:23:06 2013 -0500 @@ -43,9 +43,9 @@ echo "Generate headers from toys/*/*.c..." -# Create a list of all the applets toybox can provide. Note that the first -# entry is out of order on purpose (the toybox multiplexer applet must be the -# first element of the array). The rest must be sorted in alphabetical order +# Create a list of all the commands toybox can provide. Note that the first +# entry is out of order on purpose (the toybox multiplexer command must be the +# first element of the array). The rest must be sorted in alphabetical order # for fast binary search. echo "generated/newtoys.h" @@ -59,10 +59,12 @@ function getflags() { - sed -n -e "s/.*TOY($1"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \ + FLX="$1" + shift + sed -n -e "s/.*TOY($FLX"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \ -e 't keep;d;:keep' -e 's/^[<>=][0-9]//' -e 's/[?&^]//' \ -e 't keep' -e 's/[><=][0-9][0-9]*//g' -e 's/+.//g' \ - -e 's/([^)]*)//g' -e 's/\[[^]]*\]//g' -e 's/[-?^:&#|@*]//g' -e 'p' + -e 's/\[[^]]*\]//g' -e 's/[-?^:&#|@*]//g' "$@" -e 'p' } # Extract global structure definitions and flag definitions from toys/*/*.c @@ -85,17 +87,30 @@ -e 's/^GLOBALS(/struct '"$NAME"'_data {/' \ -e 's/^)/};/' -e 'p' $i - FLAGS="$(echo "$NEWTOYS" | getflags "$NAME")" - ZFLAGS="$(echo "$ALLTOYS" | getflags "$NAME" | sed 's/[-'"$FLAGS"']//g')" + LONGFLAGS="$(echo "$NEWTOYS" | getflags "$NAME" -e 's/\(\(([^)]*)\)*\).*/\1/' -e 's/(//g' -e 's/)/ /g')" + FLAGS="$(echo "$NEWTOYS" | getflags "$NAME" -e 's/([^)]*)//g')" + ZFLAGS="$(echo "$ALLTOYS" | getflags "$NAME" -e 's/([^)]*)//g' -e 's/[-'"$FLAGS"']//g')" + LONGFLAGLEN="$(echo "$LONGFLAGS" | wc -w)" echo "#ifdef FOR_${NAME}" X=0 + # Provide values for --longopts with no corresponding short flags + for i in $LONGFLAGS + do + X=$(($X+1)) + echo -e "#define FLAG_$i\t(1<<$(($LONGFLAGLEN+${#FLAGS}-$X)))" + done + + # Provide values for active flags + X=0 while [ $X -lt ${#FLAGS} ] do echo -ne "#define FLAG_${FLAGS:$X:1}\t" X=$(($X+1)) echo "(1<<$((${#FLAGS}-$X)))" done + + # Provide zeroes for inactive flags X=0 while [ $X -lt ${#ZFLAGS} ] do