hi.

diff to reduce verbosity in flex/lex usage. before:

$ /usr/bin/lex --help
Usage: lex [OPTIONS] [FILE]...
Generates programs that perform pattern-matching on text.

Table Compression:
  -Ca, --align      trade off larger tables for better memory alignment
  -Ce, --ecs        construct equivalence classes
  -Cf               do not compress tables; use -f representation
  -CF               do not compress tables; use -F representation
  -Cm, --meta-ecs   construct meta-equivalence classes
  -Cr, --read       use read() instead of stdio for scanner input
  -f, --full        generate fast, large scanner. Same as -Cfr
  -F, --fast        use alternate table representation. Same as -CFr
  -Cem              default compression (same as --ecs --meta-ecs)

Debugging:
  -d, --debug             enable debug mode in scanner
  -b, --backup            write backing-up information to lex.backup
  -p, --perf-report       write performance report to stderr
  -s, --nodefault         suppress default rule to ECHO unmatched text
  -T, --trace             lex should run in trace mode
  -w, --nowarn            do not generate warnings
  -v, --verbose           write summary of scanner statistics to stdout

Files:
  -o, --outfile=FILE      specify output filename
  -S, --skel=FILE         specify skeleton file
  -t, --stdout            write scanner on stdout instead of lex.yy.c
      --yyclass=NAME      name of C++ class
      --header-file=FILE   create a C header file in addition to the scanner
      --tables-file[=FILE] write tables to FILE

Scanner behavior:
  -7, --7bit              generate 7-bit scanner
  -8, --8bit              generate 8-bit scanner
  -B, --batch             generate batch scanner (opposite of -I)
  -i, --case-insensitive  ignore case in patterns
  -l, --lex-compat        maximal compatibility with original lex
  -X, --posix-compat      maximal compatibility with POSIX lex
  -I, --interactive       generate interactive scanner (opposite of -B)
      --yylineno          track line count in yylineno

Generated code:
  -+,  --c++               generate C++ scanner class
  -Dmacro[=defn]           #define macro defn  (default defn is '1')
  -L,  --noline            suppress #line directives in scanner
  -P,  --prefix=STRING     use STRING as prefix instead of "yy"
  -R,  --reentrant         generate a reentrant C scanner
       --bison-bridge      scanner for bison pure parser.
       --bison-locations   include yylloc support.
       --stdinit           initialize yyin/yyout to stdin/stdout
       --noansi-definitions old-style function definitions
       --noansi-prototypes  empty parameter list in prototypes
       --nounistd          do not include <unistd.h>
       --noFUNCTION        do not generate a particular FUNCTION

Miscellaneous:
  -n                      do-nothing POSIX option
  -?
  -h, --help              produce this help message
  -V, --version           report lex version

after:

$ /usr/obj/usr.bin/lex/lex --help
usage: lex [-78BbFfhIiLlnpsTtVvw+?] [-C[aeFfmr]] [--help] [--version]
        [-ooutput] [-Pprefix] [-Sskeleton] [file ...]

this one is more problematic as the usage is very different. i copied
over the structure from rdist, but did not declare "static void" at the
top as the compiler complained. i left it as "void". also inserted an
exit line at function end.

ok?
jmc

Index: usr.bin/lex/main.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/main.c,v
retrieving revision 1.27
diff -u -p -r1.27 main.c
--- usr.bin/lex/main.c  21 Jan 2017 08:33:07 -0000      1.27
+++ usr.bin/lex/main.c  22 Jun 2021 12:51:48 -0000
@@ -1740,71 +1740,14 @@ basename2(path, strip_ext)
 }
 
 void
-usage()
+usage(void)
 {
-       FILE *f = stdout;
+       extern char *__progname;
 
-       if (!did_outfilename) {
-               snprintf(outfile_path, sizeof(outfile_path), outfile_template,
-                   prefix, C_plus_plus ? "cc" : "c");
-               outfilename = outfile_path;
-       }
-       fprintf(f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
-       fprintf(f,
-           _
-           ("Generates programs that perform pattern-matching on text.\n"
-               "\n" "Table Compression:\n"
-               "  -Ca, --align      trade off larger tables for better memory 
alignment\n"
-               "  -Ce, --ecs        construct equivalence classes\n"
-               "  -Cf               do not compress tables; use -f 
representation\n"
-               "  -CF               do not compress tables; use -F 
representation\n"
-               "  -Cm, --meta-ecs   construct meta-equivalence classes\n"
-               "  -Cr, --read       use read() instead of stdio for scanner 
input\n"
-               "  -f, --full        generate fast, large scanner. Same as 
-Cfr\n"
-               "  -F, --fast        use alternate table representation. Same 
as -CFr\n"
-               "  -Cem              default compression (same as --ecs 
--meta-ecs)\n"
-               "\n" "Debugging:\n"
-               "  -d, --debug             enable debug mode in scanner\n"
-               "  -b, --backup            write backing-up information to %s\n"
-               "  -p, --perf-report       write performance report to stderr\n"
-               "  -s, --nodefault         suppress default rule to ECHO 
unmatched text\n"
-               "  -T, --trace             %s should run in trace mode\n"
-               "  -w, --nowarn            do not generate warnings\n"
-               "  -v, --verbose           write summary of scanner statistics 
to stdout\n"
-               "\n" "Files:\n"
-               "  -o, --outfile=FILE      specify output filename\n"
-               "  -S, --skel=FILE         specify skeleton file\n"
-               "  -t, --stdout            write scanner on stdout instead of 
%s\n"
-               "      --yyclass=NAME      name of C++ class\n"
-               "      --header-file=FILE   create a C header file in addition 
to the scanner\n"
-               "      --tables-file[=FILE] write tables to FILE\n" "\n"
-               "Scanner behavior:\n"
-               "  -7, --7bit              generate 7-bit scanner\n"
-               "  -8, --8bit              generate 8-bit scanner\n"
-               "  -B, --batch             generate batch scanner (opposite of 
-I)\n"
-               "  -i, --case-insensitive  ignore case in patterns\n"
-               "  -l, --lex-compat        maximal compatibility with original 
lex\n"
-               "  -X, --posix-compat      maximal compatibility with POSIX 
lex\n"
-               "  -I, --interactive       generate interactive scanner 
(opposite of -B)\n"
-               "      --yylineno          track line count in yylineno\n"
-               "\n" "Generated code:\n"
-               "  -+,  --c++               generate C++ scanner class\n"
-               "  -Dmacro[=defn]           #define macro defn  (default defn 
is '1')\n"
-               "  -L,  --noline            suppress #line directives in 
scanner\n"
-               "  -P,  --prefix=STRING     use STRING as prefix instead of 
\"yy\"\n"
-               "  -R,  --reentrant         generate a reentrant C scanner\n"
-               "       --bison-bridge      scanner for bison pure parser.\n"
-               "       --bison-locations   include yylloc support.\n"
-               "       --stdinit           initialize yyin/yyout to 
stdin/stdout\n"
-               "       --noansi-definitions old-style function definitions\n"
-               "       --noansi-prototypes  empty parameter list in 
prototypes\n"
-               "       --nounistd          do not include <unistd.h>\n"
-               "       --noFUNCTION        do not generate a particular 
FUNCTION\n"
-               "\n" "Miscellaneous:\n"
-               "  -n                      do-nothing POSIX option\n"
-               "  -?\n"
-               "  -h, --help              produce this help message\n"
-               "  -V, --version           report %s version\n"),
-           backing_name, program_name, outfile_path, program_name);
+       (void) fprintf(stderr,
+               "usage: %s [-78BbFfhIiLlnpsTtVvw+?] [-C[aeFfmr]] [--help]"
+               " [--version]\n"
+               "\t[-ooutput] [-Pprefix] [-Sskeleton] [file ...]\n", 
__progname);
 
+       exit(1);
 }

Reply via email to