From bc29722caef4b5866c6d60fb99eb79ff0758ea66 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 3 Jul 2002 22:40:42 +0000 Subject: 2002-07-03 Tom Yu * Makefile.in: Fix rebuild rules et_?.perl -> et_?.pl. Also, strip the "#!" line. * error_table.h: Fix mac conditional, due to _et_list declaration moving from et_c.awk * et_c.perl, et_h.perl: Remove. * et_c.pl, et_h.pl: Generate. [porting some 1-2-2-branch changes] * com_err.h: Windows should include as opposed to * et_c.perl, et_h.perl: Renamed to et_c.pl and et_h.pl because the extension is used as a newline separator heuristic in MacPerl parser * et_c.perl, et_h.perl: Removed #! from the first line to avoid confusing MacPerl * com_err.h, error_message.c, et.pbexp, et_c.awk, et_h.awk: conditionalized com_err so it doesn't need to export et_list on Mac OS X [pullups from 1-2-2-branch] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14599 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/et/ChangeLog | 36 ++++++ src/util/et/Makefile.in | 8 +- src/util/et/com_err.h | 13 +- src/util/et/error_message.c | 16 ++- src/util/et/error_table.h | 2 +- src/util/et/et.pbexp | 10 ++ src/util/et/et_c.awk | 6 +- src/util/et/et_c.perl | 281 ------------------------------------------ src/util/et/et_c.pl | 292 ++++++++++++++++++++++++++++++++++++++++++++ src/util/et/et_h.awk | 6 +- src/util/et/et_h.perl | 223 --------------------------------- src/util/et/et_h.pl | 232 +++++++++++++++++++++++++++++++++++ 12 files changed, 609 insertions(+), 516 deletions(-) create mode 100644 src/util/et/et.pbexp delete mode 100644 src/util/et/et_c.perl create mode 100644 src/util/et/et_c.pl delete mode 100644 src/util/et/et_h.perl create mode 100644 src/util/et/et_h.pl diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog index 7e27e5689..4b767f953 100644 --- a/src/util/et/ChangeLog +++ b/src/util/et/ChangeLog @@ -1,3 +1,39 @@ +2002-07-03 Tom Yu + + * Makefile.in: Fix rebuild rules et_?.perl -> et_?.pl. Also, + strip the "#!" line. + + * error_table.h: Fix mac conditional, due to _et_list declaration + moving from et_c.awk + + * et_c.perl, et_h.perl: Remove. + + * et_c.pl, et_h.pl: Generate. + +2002-07-03 Danilo Almeida + + * com_err.h: Windows should include as opposed + to + [pullup from 1-2-2-branch] + +2002-07-03 Miro Jurisic + + * et_c.perl, et_h.perl: + Renamed to et_c.pl and et_h.pl because the extension is used + as a newline separator heuristic in MacPerl parser + + * et_c.perl, et_h.perl: + Removed #! from the first line to avoid confusing MacPerl + + [pullups from 1-2-2-branch] + +2002-07-03 Alexandra Ellwood + + * com_err.h, error_message.c, et.pbexp, et_c.awk, et_h.awk: + conditionalized com_err so it doesn't need to export et_list + on Mac OS X + [pullup from 1-2-2-branch] + 2001-10-05 Ken Raeburn * com_err.h (KRB5_EXPORTVAR): Don't define. diff --git a/src/util/et/Makefile.in b/src/util/et/Makefile.in index c7e3651c9..9ddecfb31 100644 --- a/src/util/et/Makefile.in +++ b/src/util/et/Makefile.in @@ -164,11 +164,11 @@ compile_et: $(srcdir)/compile_et.sh $(srcdir)/config_script rebuild: rebuild-c rebuild-h rebuild-c: - a2p < $(srcdir)/et_c.awk > $(srcdir)/et_c.tmp - mv -f $(srcdir)/et_c.tmp $(srcdir)/et_c.perl + a2p < $(srcdir)/et_c.awk | awk 'NR != 1 || $$0 !~ /^\043!/{print;}' > $(srcdir)/et_c.tmp + mv -f $(srcdir)/et_c.tmp $(srcdir)/et_c.pl rebuild-h: - a2p < $(srcdir)/et_h.awk > $(srcdir)/et_h.tmp - mv -f $(srcdir)/et_h.tmp $(srcdir)/et_h.perl + a2p < $(srcdir)/et_h.awk | awk 'NR != 1 || $$0 !~ /^\043!/{print;}' > $(srcdir)/et_h.tmp + mv -f $(srcdir)/et_h.tmp $(srcdir)/et_h.pl clean-unix:: $(RM) compile_et diff --git a/src/util/et/com_err.h b/src/util/et/com_err.h index c56fad2b1..8738a5a7f 100644 --- a/src/util/et/com_err.h +++ b/src/util/et/com_err.h @@ -13,7 +13,14 @@ #ifndef __COM_ERR_H #if defined(_WIN32) || defined(macintosh) +#ifdef _WIN32 #include +#else +#include +#endif +#if defined(macintosh) && defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__) +#pragma import on +#endif #endif #ifndef KRB5_CALLCONV @@ -53,7 +60,7 @@ extern errcode_t KRB5_CALLCONV remove_error_table (const struct error_table *) /*@modifies internalState@*/; -#if !defined(_WIN32) && !defined(macintosh) +#if !defined(_WIN32) && !defined(macintosh) && !defined(__MACH__) /* * The display routine should be application specific. A global hook, * may cause inappropriate display procedures to be called between @@ -68,5 +75,9 @@ extern et_old_error_hook_func reset_com_err_hook (void); } #endif +#if defined(macintosh) && defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__) +#pragma import reset +#endif + #define __COM_ERR_H #endif /* ! defined(__COM_ERR_H) */ diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index 827b52aa7..450148f06 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -27,8 +27,9 @@ #include "com_err.h" #include "error_table.h" -#ifdef macintosh -#include +#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) + #include + #include #endif #if defined(_WIN32) @@ -48,7 +49,7 @@ extern const int sys_nerr; static char buffer[ET_EBUFSIZ]; -#if (defined(_WIN32) || defined(macintosh)) +#if (defined(_WIN32) || defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))) /*@null@*/ static struct et_list * _et_list = (struct et_list *) NULL; #else /* Old interface compatibility */ @@ -199,12 +200,19 @@ error_message(long code) oops: -#if defined(macintosh) +#if TARGET_OS_MAC { /* This may be a Mac OS Toolbox error or an MIT Support Library Error. Ask ErrorLib */ if (GetErrorLongString(code, buffer, ET_EBUFSIZ - 1) == noErr) { return buffer; } + +#if TARGET_API_MAC_OSX + /* ComErr and ErrorLib don't know about this error, ask the system */ + /* Of course there's no way to tell if it knew what error it got */ + return (strerror (code)); +#endif + } #endif diff --git a/src/util/et/error_table.h b/src/util/et/error_table.h index d30457d3f..505521dfe 100644 --- a/src/util/et/error_table.h +++ b/src/util/et/error_table.h @@ -19,7 +19,7 @@ struct et_list { /*@dependent@*//*@null@*/ struct et_list *next; /*@dependent@*//*@null@*/ const struct error_table *table; }; -#if !defined(_WIN32) && !defined(macintosh) +#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__)) /*@null@*//*@dependent@*/ extern struct et_list * _et_list; #endif diff --git a/src/util/et/et.pbexp b/src/util/et/et.pbexp new file mode 100644 index 000000000..31097615a --- /dev/null +++ b/src/util/et/et.pbexp @@ -0,0 +1,10 @@ +# +# comerr library Macintosh export file +# +# $Header$ + +_com_err +_com_err_va +_error_message +_add_error_table +_remove_error_table diff --git a/src/util/et/et_c.awk b/src/util/et/et_c.awk index 023c831c3..10662b6e5 100644 --- a/src/util/et/et_c.awk +++ b/src/util/et/et_c.awk @@ -113,7 +113,9 @@ c2n["_"]=63 print "# include \"win-mac.h\"" > outfile print "#endif" > outfile print "" > outfile + print "#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))" > outfile print "extern void initialize_" table_name "_error_table (void);" > outfile + print "#endif" > outfile print "" > outfile print "/* Lclint doesn't handle null annotations on arrays" > outfile print " properly, so we need this typedef in each" > outfile @@ -185,7 +187,9 @@ END { print " 0" > outfile print "};" > outfile print "" > outfile + print "#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))" > outfile print "#include " > outfile + print "#endif" > outfile print "" > outfile if (tab_base_high == 0) { print "const struct error_table et_" table_name "_error_table = { text, " \ @@ -197,7 +201,7 @@ END { tab_base_low, table_item_count) > outfile } print "" > outfile - print "#if !defined(_WIN32) && !defined(macintosh)" > outfile + print "#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))" > outfile print "void initialize_" table_name "_error_table (void)" > outfile print " /*@modifies internalState@*/" > outfile print "{" > outfile diff --git a/src/util/et/et_c.perl b/src/util/et/et_c.perl deleted file mode 100644 index ad85ec759..000000000 --- a/src/util/et/et_c.perl +++ /dev/null @@ -1,281 +0,0 @@ -#!/usr/athena/bin/perl -eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - # this emulates #! processing on NIH machines. - # (remove #! line above if indigestible) - -eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; - # process any FOO=bar switches - -$[ = 1; # set array base to 1 -$FS = ' '; # set field separator -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator - -$char_shift = 64; -## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; -$c2n{'A'} = 1; -$c2n{'B'} = 2; -$c2n{'C'} = 3; -$c2n{'D'} = 4; -$c2n{'E'} = 5; -$c2n{'F'} = 6; -$c2n{'G'} = 7; -$c2n{'H'} = 8; -$c2n{'I'} = 9; -$c2n{'J'} = 10; -$c2n{'K'} = 11; -$c2n{'L'} = 12; -$c2n{'M'} = 13; -$c2n{'N'} = 14; -$c2n{'O'} = 15; -$c2n{'P'} = 16; -$c2n{'Q'} = 17; -$c2n{'R'} = 18; -$c2n{'S'} = 19; -$c2n{'T'} = 20; -$c2n{'U'} = 21; -$c2n{'V'} = 22; -$c2n{'W'} = 23; -$c2n{'X'} = 24; -$c2n{'Y'} = 25; -$c2n{'Z'} = 26; -$c2n{'a'} = 27; -$c2n{'b'} = 28; -$c2n{'c'} = 29; -$c2n{'d'} = 30; -$c2n{'e'} = 31; -$c2n{'f'} = 32; -$c2n{'g'} = 33; -$c2n{'h'} = 34; -$c2n{'i'} = 35; -$c2n{'j'} = 36; -$c2n{'k'} = 37; -$c2n{'l'} = 38; -$c2n{'m'} = 39; -$c2n{'n'} = 40; -$c2n{'o'} = 41; -$c2n{'p'} = 42; -$c2n{'q'} = 43; -$c2n{'r'} = 44; -$c2n{'s'} = 45; -$c2n{'t'} = 46; -$c2n{'u'} = 47; -$c2n{'v'} = 48; -$c2n{'w'} = 49; -$c2n{'x'} = 50; -$c2n{'y'} = 51; -$c2n{'z'} = 52; -$c2n{'0'} = 53; -$c2n{'1'} = 54; -$c2n{'2'} = 55; -$c2n{'3'} = 56; -$c2n{'4'} = 57; -$c2n{'5'} = 58; -$c2n{'6'} = 59; -$c2n{'7'} = 60; -$c2n{'8'} = 61; -$c2n{'9'} = 62; -$c2n{'_'} = 63; - -line: while (<>) { - chomp; # strip record separator - @Fld = split($FS, $_, 9999); - if (/^#/) { - next line; - } - if (/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/) { - $table_number = 0; - $table_name = $Fld[2]; - $mod_base = 1000000; - for ($i = 1; $i <= length($table_name); $i++) { - $table_number = ($table_number * $char_shift) + - - $c2n{substr($table_name, $i, 1)}; - } - - # We start playing *_high, *low games here because the some - # awk programs do not have the necessary precision (sigh) - $tab_base_low = $table_number % $mod_base; - $tab_base_high = int($table_number / $mod_base); - $tab_base_sign = 1; - - # figure out: table_number_base=table_number*256 - $tab_base_low = $tab_base_low * 256; - $tab_base_high = ($tab_base_high * 256) + int($tab_base_low / - - $mod_base); - $tab_base_low = $tab_base_low % $mod_base; - - if ($table_number > 128 * 256 * 256) { - # figure out: table_number_base -= 256*256*256*256 - # sub_high, sub_low is 256*256*256*256 - $sub_low = 256 * 256 * 256 % $mod_base; - $sub_high = int(256 * 256 * 256 / $mod_base); - - $sub_low = $sub_low * 256; - $sub_high = ($sub_high * 256) + int($sub_low / $mod_base); - $sub_low = $sub_low % $mod_base; - - $tab_base_low = $sub_low - $tab_base_low; - $tab_base_high = $sub_high - $tab_base_high; - $tab_base_sign = -1; - if ($tab_base_low < 0) { - $tab_base_low = $tab_base_low + $mod_base; - $tab_base_high--; - } - } - &Pick('>', $outfile) && - (print $fh '/*'); - &Pick('>', $outfile) && - (print $fh ' * ' . $outfile . ':'); - &Pick('>', $outfile) && - (print $fh - - ' * This file is automatically generated; please do not edit it.'); - &Pick('>', $outfile) && - (print $fh ' */'); - - &Pick('>', $outfile) && - (print $fh '#if defined(_WIN32)'); - &Pick('>', $outfile) && - (print $fh "# include \"win-mac.h\""); - &Pick('>', $outfile) && - (print $fh '#endif'); - &Pick('>', $outfile) && - (print $fh ''); - &Pick('>', $outfile) && - (print $fh 'extern void initialize_' . $table_name . - - '_error_table (void);'); - &Pick('>', $outfile) && - (print $fh ''); - &Pick('>', $outfile) && - (print $fh "/* Lclint doesn't handle null annotations on arrays"); - &Pick('>', $outfile) && - (print $fh ' properly, so we need this typedef in each'); - &Pick('>', $outfile) && - (print $fh ' generated .c file. */'); - &Pick('>', $outfile) && - (print $fh '/*@-redef@*/'); - &Pick('>', $outfile) && - (print $fh 'typedef /*@null@*/ const char *ncptr;'); - &Pick('>', $outfile) && - (print $fh '/*@=redef@*/'); - &Pick('>', $outfile) && - (print $fh ''); - &Pick('>', $outfile) && - (print $fh 'static ncptr const text[] = {'); - $table_item_count = 0; - } - - if (($continuation == 1) && ($_ =~ /\\[ \t]*$/)) { - $text = substr($_, 1, length($_) - 1); - # printf "\t\t\"%s\"\n", text > outfile - $cont_buf = $cont_buf . $text; - } - - if (($continuation == 1) && ($_ =~ /"[ \t]*$/)) { - # printf "\t\t\"%s,\n", $0 > outfile - &Pick('>', $outfile) && - (printf $fh "\t%s,\n", $cont_buf . $_); - $continuation = 0; - } - - if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/) { - $table_item_count++; - $skipone = 1; - next line; - } - - if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/) { - $text = ''; - for ($i = 3; $i <= $#Fld; $i++) { - $text = $text . $FS . $Fld[$i]; - } - $text = substr($text, 2, length($text) - 1); - &Pick('>', $outfile) && - (printf $fh "\t%s,\n", $text); - $table_item_count++; - } - - if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*\\[ \t]*$/) { - $text = ''; - for ($i = 3; $i <= $#Fld; $i++) { - $text = $text . $FS . $Fld[$i]; - } - $text = substr($text, 2, length($text) - 2); - # printf "\t%s\"\n", text > outfile - $cont_buf = $text; - $continuation++; - } - - if (/^[ \t]*".*\\[ \t]*$/) { - if ($skipone) { - $text = substr($_, 1, length($_) - 1); - # printf "\t%s\"\n", text > outfile - $cont_buf = $text; - $continuation++; - } - $skipone = 0; - } - - if ($skipone) { - &Pick('>', $outfile) && - (printf $fh "\t%s,\n", $_); - } - $skipone = 0; -} - -&Pick('>', $outfile) && - (print $fh ' 0'); -&Pick('>', $outfile) && - (print $fh '};'); -&Pick('>', $outfile) && - (print $fh ''); -&Pick('>', $outfile) && - (print $fh '#include '); -&Pick('>', $outfile) && - (print $fh ''); -if ($tab_base_high == 0) { - &Pick('>', $outfile) && - (print $fh 'const struct error_table et_' . $table_name . - - '_error_table = { text, ' . sprintf('%dL, %d };', - - $tab_base_sign * $tab_base_low, $table_item_count)); -} -else { - &Pick('>', $outfile) && - (print $fh 'const struct error_table et_' . $table_name . - - '_error_table = { text, ' . sprintf('%d%06dL, %d };', - - $tab_base_sign * $tab_base_high, $tab_base_low, $table_item_count)); -} -&Pick('>', $outfile) && - (print $fh ''); -&Pick('>', $outfile) && - (print $fh - - '#if !defined(_WIN32) && !defined(macintosh)'); -&Pick('>', $outfile) && - (print $fh 'void initialize_' . $table_name . '_error_table (void)'); -&Pick('>', $outfile) && - (print $fh ' /*@modifies internalState@*/'); -&Pick('>', $outfile) && - (print $fh '{'); -&Pick('>', $outfile) && - (print $fh ' (void) add_error_table (&et_' . $table_name . - - '_error_table);'); -&Pick('>', $outfile) && - (print $fh '}'); -&Pick('>', $outfile) && - (print $fh '#endif'); - -sub Pick { - local($mode,$name,$pipe) = @_; - $fh = $name; - open($name,$mode.$name.$pipe) unless $opened{$name}++; -} diff --git a/src/util/et/et_c.pl b/src/util/et/et_c.pl new file mode 100644 index 000000000..fff4a56ff --- /dev/null +++ b/src/util/et/et_c.pl @@ -0,0 +1,292 @@ +eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + # this emulates #! processing on NIH machines. + # (remove #! line above if indigestible) + +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; + # process any FOO=bar switches + +$[ = 1; # set array base to 1 +$FS = ' '; # set field separator +$, = ' '; # set output field separator +$\ = "\n"; # set output record separator + +$char_shift = 64; +## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; +$c2n{'A'} = 1; +$c2n{'B'} = 2; +$c2n{'C'} = 3; +$c2n{'D'} = 4; +$c2n{'E'} = 5; +$c2n{'F'} = 6; +$c2n{'G'} = 7; +$c2n{'H'} = 8; +$c2n{'I'} = 9; +$c2n{'J'} = 10; +$c2n{'K'} = 11; +$c2n{'L'} = 12; +$c2n{'M'} = 13; +$c2n{'N'} = 14; +$c2n{'O'} = 15; +$c2n{'P'} = 16; +$c2n{'Q'} = 17; +$c2n{'R'} = 18; +$c2n{'S'} = 19; +$c2n{'T'} = 20; +$c2n{'U'} = 21; +$c2n{'V'} = 22; +$c2n{'W'} = 23; +$c2n{'X'} = 24; +$c2n{'Y'} = 25; +$c2n{'Z'} = 26; +$c2n{'a'} = 27; +$c2n{'b'} = 28; +$c2n{'c'} = 29; +$c2n{'d'} = 30; +$c2n{'e'} = 31; +$c2n{'f'} = 32; +$c2n{'g'} = 33; +$c2n{'h'} = 34; +$c2n{'i'} = 35; +$c2n{'j'} = 36; +$c2n{'k'} = 37; +$c2n{'l'} = 38; +$c2n{'m'} = 39; +$c2n{'n'} = 40; +$c2n{'o'} = 41; +$c2n{'p'} = 42; +$c2n{'q'} = 43; +$c2n{'r'} = 44; +$c2n{'s'} = 45; +$c2n{'t'} = 46; +$c2n{'u'} = 47; +$c2n{'v'} = 48; +$c2n{'w'} = 49; +$c2n{'x'} = 50; +$c2n{'y'} = 51; +$c2n{'z'} = 52; +$c2n{'0'} = 53; +$c2n{'1'} = 54; +$c2n{'2'} = 55; +$c2n{'3'} = 56; +$c2n{'4'} = 57; +$c2n{'5'} = 58; +$c2n{'6'} = 59; +$c2n{'7'} = 60; +$c2n{'8'} = 61; +$c2n{'9'} = 62; +$c2n{'_'} = 63; + +line: while (<>) { + chomp; # strip record separator + @Fld = split($FS, $_, 9999); + if (/^#/) { + next line; + } + if (/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/) { + $table_number = 0; + $table_name = $Fld[2]; + $mod_base = 1000000; + for ($i = 1; $i <= length($table_name); $i++) { + $table_number = ($table_number * $char_shift) + + + $c2n{substr($table_name, $i, 1)}; + } + + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + $tab_base_low = $table_number % $mod_base; + $tab_base_high = int($table_number / $mod_base); + $tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + $tab_base_low = $tab_base_low * 256; + $tab_base_high = ($tab_base_high * 256) + int($tab_base_low / + + $mod_base); + $tab_base_low = $tab_base_low % $mod_base; + + if ($table_number > 128 * 256 * 256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + $sub_low = 256 * 256 * 256 % $mod_base; + $sub_high = int(256 * 256 * 256 / $mod_base); + + $sub_low = $sub_low * 256; + $sub_high = ($sub_high * 256) + int($sub_low / $mod_base); + $sub_low = $sub_low % $mod_base; + + $tab_base_low = $sub_low - $tab_base_low; + $tab_base_high = $sub_high - $tab_base_high; + $tab_base_sign = -1; + if ($tab_base_low < 0) { + $tab_base_low = $tab_base_low + $mod_base; + $tab_base_high--; + } + } + &Pick('>', $outfile) && + (print $fh '/*'); + &Pick('>', $outfile) && + (print $fh ' * ' . $outfile . ':'); + &Pick('>', $outfile) && + (print $fh + + ' * This file is automatically generated; please do not edit it.'); + &Pick('>', $outfile) && + (print $fh ' */'); + + &Pick('>', $outfile) && + (print $fh '#if defined(_WIN32)'); + &Pick('>', $outfile) && + (print $fh "# include \"win-mac.h\""); + &Pick('>', $outfile) && + (print $fh '#endif'); + &Pick('>', $outfile) && + (print $fh ''); + &Pick('>', $outfile) && + (print $fh + + '#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))'); + &Pick('>', $outfile) && + (print $fh 'extern void initialize_' . $table_name . + + '_error_table (void);'); + &Pick('>', $outfile) && + (print $fh '#endif'); + &Pick('>', $outfile) && + (print $fh ''); + &Pick('>', $outfile) && + (print $fh "/* Lclint doesn't handle null annotations on arrays"); + &Pick('>', $outfile) && + (print $fh ' properly, so we need this typedef in each'); + &Pick('>', $outfile) && + (print $fh ' generated .c file. */'); + &Pick('>', $outfile) && + (print $fh '/*@-redef@*/'); + &Pick('>', $outfile) && + (print $fh 'typedef /*@null@*/ const char *ncptr;'); + &Pick('>', $outfile) && + (print $fh '/*@=redef@*/'); + &Pick('>', $outfile) && + (print $fh ''); + &Pick('>', $outfile) && + (print $fh 'static ncptr const text[] = {'); + $table_item_count = 0; + } + + if (($continuation == 1) && ($_ =~ /\\[ \t]*$/)) { + $text = substr($_, 1, length($_) - 1); + # printf "\t\t\"%s\"\n", text > outfile + $cont_buf = $cont_buf . $text; + } + + if (($continuation == 1) && ($_ =~ /"[ \t]*$/)) { + # printf "\t\t\"%s,\n", $0 > outfile + &Pick('>', $outfile) && + (printf $fh "\t%s,\n", $cont_buf . $_); + $continuation = 0; + } + + if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/) { + $table_item_count++; + $skipone = 1; + next line; + } + + if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/) { + $text = ''; + for ($i = 3; $i <= $#Fld; $i++) { + $text = $text . $FS . $Fld[$i]; + } + $text = substr($text, 2, length($text) - 1); + &Pick('>', $outfile) && + (printf $fh "\t%s,\n", $text); + $table_item_count++; + } + + if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*\\[ \t]*$/) { + $text = ''; + for ($i = 3; $i <= $#Fld; $i++) { + $text = $text . $FS . $Fld[$i]; + } + $text = substr($text, 2, length($text) - 2); + # printf "\t%s\"\n", text > outfile + $cont_buf = $text; + $continuation++; + } + + if (/^[ \t]*".*\\[ \t]*$/) { + if ($skipone) { + $text = substr($_, 1, length($_) - 1); + # printf "\t%s\"\n", text > outfile + $cont_buf = $text; + $continuation++; + } + $skipone = 0; + } + + if ($skipone) { + &Pick('>', $outfile) && + (printf $fh "\t%s,\n", $_); + } + $skipone = 0; +} + +&Pick('>', $outfile) && + (print $fh ' 0'); +&Pick('>', $outfile) && + (print $fh '};'); +&Pick('>', $outfile) && + (print $fh ''); +&Pick('>', $outfile) && + (print $fh + + '#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))'); +&Pick('>', $outfile) && + (print $fh '#include '); +&Pick('>', $outfile) && + (print $fh '#endif'); +&Pick('>', $outfile) && + (print $fh ''); +if ($tab_base_high == 0) { + &Pick('>', $outfile) && + (print $fh 'const struct error_table et_' . $table_name . + + '_error_table = { text, ' . sprintf('%dL, %d };', + + $tab_base_sign * $tab_base_low, $table_item_count)); +} +else { + &Pick('>', $outfile) && + (print $fh 'const struct error_table et_' . $table_name . + + '_error_table = { text, ' . sprintf('%d%06dL, %d };', + + $tab_base_sign * $tab_base_high, $tab_base_low, $table_item_count)); +} +&Pick('>', $outfile) && + (print $fh ''); +&Pick('>', $outfile) && + (print $fh + + '#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))'); +&Pick('>', $outfile) && + (print $fh 'void initialize_' . $table_name . '_error_table (void)'); +&Pick('>', $outfile) && + (print $fh ' /*@modifies internalState@*/'); +&Pick('>', $outfile) && + (print $fh '{'); +&Pick('>', $outfile) && + (print $fh ' (void) add_error_table (&et_' . $table_name . + + '_error_table);'); +&Pick('>', $outfile) && + (print $fh '}'); +&Pick('>', $outfile) && + (print $fh '#endif'); + +sub Pick { + local($mode,$name,$pipe) = @_; + $fh = $name; + open($name,$mode.$name.$pipe) unless $opened{$name}++; +} diff --git a/src/util/et/et_h.awk b/src/util/et/et_h.awk index 2cea1532d..1bbe5e972 100644 --- a/src/util/et/et_h.awk +++ b/src/util/et/et_h.awk @@ -111,7 +111,11 @@ c2n["_"]=63 print " * This file is automatically generated; please do not edit it." > outfile print " */" > outfile print "" > outfile + print "#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))" > outfile + print "#include " > outfile + print "#else" > outfile print "#include " > outfile + print "#endif" > outfile print "" > outfile } @@ -148,7 +152,7 @@ END { print "" > outfile print "extern struct error_table et_" table_name "_error_table;" > outfile print "" > outfile - print "#if !defined(_WIN32) && !defined(macintosh)" > outfile + print "#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))" > outfile print "/* for compatibility with older versions... */" > outfile print "extern void initialize_" table_name "_error_table () /*@modifies internalState@*/;" > outfile print "#define init_" table_name "_err_tbl initialize_" table_name "_error_table" > outfile diff --git a/src/util/et/et_h.perl b/src/util/et/et_h.perl deleted file mode 100644 index 5789617a4..000000000 --- a/src/util/et/et_h.perl +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/athena/bin/perl -eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - # this emulates #! processing on NIH machines. - # (remove #! line above if indigestible) - -eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; - # process any FOO=bar switches - -$[ = 1; # set array base to 1 -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator - -$char_shift = 64; -## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; -$c2n{'A'} = 1; -$c2n{'B'} = 2; -$c2n{'C'} = 3; -$c2n{'D'} = 4; -$c2n{'E'} = 5; -$c2n{'F'} = 6; -$c2n{'G'} = 7; -$c2n{'H'} = 8; -$c2n{'I'} = 9; -$c2n{'J'} = 10; -$c2n{'K'} = 11; -$c2n{'L'} = 12; -$c2n{'M'} = 13; -$c2n{'N'} = 14; -$c2n{'O'} = 15; -$c2n{'P'} = 16; -$c2n{'Q'} = 17; -$c2n{'R'} = 18; -$c2n{'S'} = 19; -$c2n{'T'} = 20; -$c2n{'U'} = 21; -$c2n{'V'} = 22; -$c2n{'W'} = 23; -$c2n{'X'} = 24; -$c2n{'Y'} = 25; -$c2n{'Z'} = 26; -$c2n{'a'} = 27; -$c2n{'b'} = 28; -$c2n{'c'} = 29; -$c2n{'d'} = 30; -$c2n{'e'} = 31; -$c2n{'f'} = 32; -$c2n{'g'} = 33; -$c2n{'h'} = 34; -$c2n{'i'} = 35; -$c2n{'j'} = 36; -$c2n{'k'} = 37; -$c2n{'l'} = 38; -$c2n{'m'} = 39; -$c2n{'n'} = 40; -$c2n{'o'} = 41; -$c2n{'p'} = 42; -$c2n{'q'} = 43; -$c2n{'r'} = 44; -$c2n{'s'} = 45; -$c2n{'t'} = 46; -$c2n{'u'} = 47; -$c2n{'v'} = 48; -$c2n{'w'} = 49; -$c2n{'x'} = 50; -$c2n{'y'} = 51; -$c2n{'z'} = 52; -$c2n{'0'} = 53; -$c2n{'1'} = 54; -$c2n{'2'} = 55; -$c2n{'3'} = 56; -$c2n{'4'} = 57; -$c2n{'5'} = 58; -$c2n{'6'} = 59; -$c2n{'7'} = 60; -$c2n{'8'} = 61; -$c2n{'9'} = 62; -$c2n{'_'} = 63; - -line: while (<>) { - ($Fld1,$Fld2) = split(' ', $_, 9999); - if (/^#/) { - next line; - } - if (/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/) { - $table_number = 0; - $table_name = $Fld2; - $mod_base = 1000000; - for ($i = 1; $i <= length($table_name); $i++) { - $table_number = ($table_number * $char_shift) + - - $c2n{substr($table_name, $i, 1)}; - } - # We start playing *_high, *low games here because the some - # awk programs do not have the necessary precision (sigh) - $tab_base_low = $table_number % $mod_base; - $tab_base_high = int($table_number / $mod_base); - $tab_base_sign = 1; - - # figure out: table_number_base=table_number*256 - $tab_base_low = $tab_base_low * 256; - $tab_base_high = ($tab_base_high * 256) + int($tab_base_low / - - $mod_base); - $tab_base_low = $tab_base_low % $mod_base; - - if ($table_number > 128 * 256 * 256) { - # figure out: table_number_base -= 256*256*256*256 - # sub_high, sub_low is 256*256*256*256 - $sub_low = 256 * 256 * 256 % $mod_base; - $sub_high = int(256 * 256 * 256 / $mod_base); - - $sub_low = $sub_low * 256; - $sub_high = ($sub_high * 256) + int($sub_low / $mod_base); - $sub_low = $sub_low % $mod_base; - - $tab_base_low = $sub_low - $tab_base_low; - $tab_base_high = $sub_high - $tab_base_high; - $tab_base_sign = -1; - if ($tab_base_low < 0) { - $tab_base_low = $tab_base_low + $mod_base; - $tab_base_high--; - } - } - $curr_low = $tab_base_low; - $curr_high = $tab_base_high; - $curr_sign = $tab_base_sign; - &Pick('>', $outfile) && - (print $fh '/*'); - &Pick('>', $outfile) && - (print $fh ' * ' . $outfile . ':'); - &Pick('>', $outfile) && - (print $fh - - ' * This file is automatically generated; please do not edit it.'); - &Pick('>', $outfile) && - (print $fh ' */'); - &Pick('>', $outfile) && - (print $fh ''); - &Pick('>', $outfile) && - (print $fh '#include '); - &Pick('>', $outfile) && - (print $fh ''); - } - - if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/) { - $tag = substr($Fld2, 1, length($Fld2) - 1); - if ($curr_high == 0) { - &Pick('>', $outfile) && - (printf $fh "#define %-40s (%dL)\n", $tag, - - $curr_sign * $curr_low); - } - else { - &Pick('>', $outfile) && - (printf $fh "#define %-40s (%d%06dL)\n", $tag, - - $curr_high * $curr_sign, $curr_low); - } - $curr_low += $curr_sign; - if ($curr_low >= $mod_base) { #??? - $curr_low -= $mod_base; - $curr_high++; - } - if ($curr_low < 0) { - $cur_low += $mod_base; - $cur_high--; - } - } -} - -if ($tab_base_high == 0) { - &Pick('>', $outfile) && - (print $fh '#define ERROR_TABLE_BASE_' . $table_name . ' (' . - - sprintf('%d', $tab_base_sign * $tab_base_low) . 'L)'); -} -else { - &Pick('>', $outfile) && - (print $fh '#define ERROR_TABLE_BASE_' . $table_name . ' (' . - - sprintf('%d%06d', $tab_base_sign * $tab_base_high, - - $tab_base_low) . 'L)'); -} -&Pick('>', $outfile) && - (print $fh ''); -&Pick('>', $outfile) && - (print $fh 'extern struct error_table et_' . $table_name . - - '_error_table;'); -&Pick('>', $outfile) && - (print $fh ''); -&Pick('>', $outfile) && - (print $fh - - '#if !defined(_WIN32) && !defined(macintosh)'); -&Pick('>', $outfile) && - (print $fh '/* for compatibility with older versions... */'); -&Pick('>', $outfile) && - (print $fh 'extern void initialize_' . $table_name . - - '_error_table () /*@modifies internalState@*/;'); -&Pick('>', $outfile) && - (print $fh '#define init_' . $table_name . '_err_tbl initialize_' . - - $table_name . '_error_table'); -&Pick('>', $outfile) && - (print $fh '#define ' . $table_name . '_err_base ERROR_TABLE_BASE_' . - - $table_name); -&Pick('>', $outfile) && - (print $fh '#else'); -&Pick('>', $outfile) && - (print $fh '#define initialize_' . $table_name . '_error_table()'); -&Pick('>', $outfile) && - (print $fh '#endif'); - -sub Pick { - local($mode,$name,$pipe) = @_; - $fh = $name; - open($name,$mode.$name.$pipe) unless $opened{$name}++; -} diff --git a/src/util/et/et_h.pl b/src/util/et/et_h.pl new file mode 100644 index 000000000..5debb4869 --- /dev/null +++ b/src/util/et/et_h.pl @@ -0,0 +1,232 @@ +eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + # this emulates #! processing on NIH machines. + # (remove #! line above if indigestible) + +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; + # process any FOO=bar switches + +$[ = 1; # set array base to 1 +$, = ' '; # set output field separator +$\ = "\n"; # set output record separator + +$char_shift = 64; +## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; +$c2n{'A'} = 1; +$c2n{'B'} = 2; +$c2n{'C'} = 3; +$c2n{'D'} = 4; +$c2n{'E'} = 5; +$c2n{'F'} = 6; +$c2n{'G'} = 7; +$c2n{'H'} = 8; +$c2n{'I'} = 9; +$c2n{'J'} = 10; +$c2n{'K'} = 11; +$c2n{'L'} = 12; +$c2n{'M'} = 13; +$c2n{'N'} = 14; +$c2n{'O'} = 15; +$c2n{'P'} = 16; +$c2n{'Q'} = 17; +$c2n{'R'} = 18; +$c2n{'S'} = 19; +$c2n{'T'} = 20; +$c2n{'U'} = 21; +$c2n{'V'} = 22; +$c2n{'W'} = 23; +$c2n{'X'} = 24; +$c2n{'Y'} = 25; +$c2n{'Z'} = 26; +$c2n{'a'} = 27; +$c2n{'b'} = 28; +$c2n{'c'} = 29; +$c2n{'d'} = 30; +$c2n{'e'} = 31; +$c2n{'f'} = 32; +$c2n{'g'} = 33; +$c2n{'h'} = 34; +$c2n{'i'} = 35; +$c2n{'j'} = 36; +$c2n{'k'} = 37; +$c2n{'l'} = 38; +$c2n{'m'} = 39; +$c2n{'n'} = 40; +$c2n{'o'} = 41; +$c2n{'p'} = 42; +$c2n{'q'} = 43; +$c2n{'r'} = 44; +$c2n{'s'} = 45; +$c2n{'t'} = 46; +$c2n{'u'} = 47; +$c2n{'v'} = 48; +$c2n{'w'} = 49; +$c2n{'x'} = 50; +$c2n{'y'} = 51; +$c2n{'z'} = 52; +$c2n{'0'} = 53; +$c2n{'1'} = 54; +$c2n{'2'} = 55; +$c2n{'3'} = 56; +$c2n{'4'} = 57; +$c2n{'5'} = 58; +$c2n{'6'} = 59; +$c2n{'7'} = 60; +$c2n{'8'} = 61; +$c2n{'9'} = 62; +$c2n{'_'} = 63; + +line: while (<>) { + ($Fld1,$Fld2) = split(' ', $_, 9999); + if (/^#/) { + next line; + } + if (/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/) { + $table_number = 0; + $table_name = $Fld2; + $mod_base = 1000000; + for ($i = 1; $i <= length($table_name); $i++) { + $table_number = ($table_number * $char_shift) + + + $c2n{substr($table_name, $i, 1)}; + } + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + $tab_base_low = $table_number % $mod_base; + $tab_base_high = int($table_number / $mod_base); + $tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + $tab_base_low = $tab_base_low * 256; + $tab_base_high = ($tab_base_high * 256) + int($tab_base_low / + + $mod_base); + $tab_base_low = $tab_base_low % $mod_base; + + if ($table_number > 128 * 256 * 256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + $sub_low = 256 * 256 * 256 % $mod_base; + $sub_high = int(256 * 256 * 256 / $mod_base); + + $sub_low = $sub_low * 256; + $sub_high = ($sub_high * 256) + int($sub_low / $mod_base); + $sub_low = $sub_low % $mod_base; + + $tab_base_low = $sub_low - $tab_base_low; + $tab_base_high = $sub_high - $tab_base_high; + $tab_base_sign = -1; + if ($tab_base_low < 0) { + $tab_base_low = $tab_base_low + $mod_base; + $tab_base_high--; + } + } + $curr_low = $tab_base_low; + $curr_high = $tab_base_high; + $curr_sign = $tab_base_sign; + &Pick('>', $outfile) && + (print $fh '/*'); + &Pick('>', $outfile) && + (print $fh ' * ' . $outfile . ':'); + &Pick('>', $outfile) && + (print $fh + + ' * This file is automatically generated; please do not edit it.'); + &Pick('>', $outfile) && + (print $fh ' */'); + &Pick('>', $outfile) && + (print $fh ''); + &Pick('>', $outfile) && + (print $fh + + '#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))'); + &Pick('>', $outfile) && + (print $fh '#include '); + &Pick('>', $outfile) && + (print $fh '#else'); + &Pick('>', $outfile) && + (print $fh '#include '); + &Pick('>', $outfile) && + (print $fh '#endif'); + &Pick('>', $outfile) && + (print $fh ''); + } + + if (/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/) { + $tag = substr($Fld2, 1, length($Fld2) - 1); + if ($curr_high == 0) { + &Pick('>', $outfile) && + (printf $fh "#define %-40s (%dL)\n", $tag, + + $curr_sign * $curr_low); + } + else { + &Pick('>', $outfile) && + (printf $fh "#define %-40s (%d%06dL)\n", $tag, + + $curr_high * $curr_sign, $curr_low); + } + $curr_low += $curr_sign; + if ($curr_low >= $mod_base) { #??? + $curr_low -= $mod_base; + $curr_high++; + } + if ($curr_low < 0) { + $cur_low += $mod_base; + $cur_high--; + } + } +} + +if ($tab_base_high == 0) { + &Pick('>', $outfile) && + (print $fh '#define ERROR_TABLE_BASE_' . $table_name . ' (' . + + sprintf('%d', $tab_base_sign * $tab_base_low) . 'L)'); +} +else { + &Pick('>', $outfile) && + (print $fh '#define ERROR_TABLE_BASE_' . $table_name . ' (' . + + sprintf('%d%06d', $tab_base_sign * $tab_base_high, + + $tab_base_low) . 'L)'); +} +&Pick('>', $outfile) && + (print $fh ''); +&Pick('>', $outfile) && + (print $fh 'extern struct error_table et_' . $table_name . + + '_error_table;'); +&Pick('>', $outfile) && + (print $fh ''); +&Pick('>', $outfile) && + (print $fh + + '#if !defined(_WIN32) && !defined(macintosh) && !(defined(__MACH__) && defined(__APPLE__))'); +&Pick('>', $outfile) && + (print $fh '/* for compatibility with older versions... */'); +&Pick('>', $outfile) && + (print $fh 'extern void initialize_' . $table_name . + + '_error_table () /*@modifies internalState@*/;'); +&Pick('>', $outfile) && + (print $fh '#define init_' . $table_name . '_err_tbl initialize_' . + + $table_name . '_error_table'); +&Pick('>', $outfile) && + (print $fh '#define ' . $table_name . '_err_base ERROR_TABLE_BASE_' . + + $table_name); +&Pick('>', $outfile) && + (print $fh '#else'); +&Pick('>', $outfile) && + (print $fh '#define initialize_' . $table_name . '_error_table()'); +&Pick('>', $outfile) && + (print $fh '#endif'); + +sub Pick { + local($mode,$name,$pipe) = @_; + $fh = $name; + open($name,$mode.$name.$pipe) unless $opened{$name}++; +} -- cgit