-# Copyright (C) 2003,2004 Free Software Foundation, Inc.\r
-# Contributed by Kelley Cook, June 2004.\r
-# Original code from Neil Booth, May 2003.\r
-#\r
-# This program is free software; you can redistribute it and/or modify it\r
-# under the terms of the GNU General Public License as published by the\r
-# Free Software Foundation; either version 2, or (at your option) any\r
-# later version.\r
-# \r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-# \r
-# You should have received a copy of the GNU General Public License\r
-# along with this program; if not, write to the Free Software\r
-# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
-\r
-# This Awk script reads in the option records generated from \r
-# opt-gather.awk, combines the flags of duplicat options and generates a\r
-# C file.\r
-#\r
-# This program uses functions from opt-functions.awk\r
-#\r
-# Usage: awk -f opt-functions.awk -f optc-gen.awk \\r
-# [-v header_name=header.h] < inputfile > options.c\r
-\r
-BEGIN {\r
- n_opts = 0\r
- n_langs = 0\r
- quote = "\042"\r
- comma = ","\r
- FS=SUBSEP\r
- # Default the name of header created from opth-gen.awk to options.h\r
- if (header_name == "") header_name="options.h"\r
-}\r
-\r
-# Collect the text and flags of each option into an array\r
- {\r
- if ($1 == "Language") {\r
- langs[n_langs] = $2\r
- n_langs++;\r
- }\r
- else {\r
- name = opt_args("Mask", $1)\r
- if (name == "") {\r
- opts[n_opts] = $1\r
- flags[n_opts] = $2\r
- help[n_opts] = $3\r
- n_opts++;\r
- }\r
- }\r
- }\r
-\r
-# Dump that array of options into a C file.\r
-END {\r
-print "/* This file is auto-generated by opts.sh. */"\r
-print ""\r
-n_headers = split(header_name, headers, " ")\r
-for (i = 1; i <= n_headers; i++)\r
- print "#include " quote headers[i] quote\r
-print "#include " quote "opts.h" quote\r
-print "#include " quote "intl.h" quote\r
-print ""\r
-\r
-for (i = 0; i < n_opts; i++) {\r
- name = var_name(flags[i]);\r
- if (name == "")\r
- continue;\r
-\r
- if (flag_set_p("VarExists", flags[i]))\r
- continue;\r
-\r
- init = opt_args("Init", flags[i])\r
- if (init != "")\r
- init = " = " init;\r
- else if (name in var_seen)\r
- continue;\r
-\r
- print "/* Set by -" opts[i] "."\r
- print " " help[i] " */"\r
- print var_type(flags[i]) name init ";"\r
- print ""\r
-\r
- var_seen[name] = 1;\r
-}\r
-\r
-print ""\r
-print "/* Local state variables. */"\r
-for (i = 0; i < n_opts; i++) {\r
- name = static_var(opts[i], flags[i]);\r
- if (name != "")\r
- print "static " var_type(flags[i]) name ";"\r
-}\r
-print ""\r
-\r
-print "const char * const lang_names[] =\n{"\r
-for (i = 0; i < n_langs; i++) {\r
- macros[i] = "CL_" langs[i]\r
- gsub( "[^A-Za-z0-9_]", "X", macros[i] )\r
- s = substr(" ", length (macros[i]))\r
- print " " quote langs[i] quote ","\r
- }\r
-\r
-print " 0\n};\n"\r
-print "const unsigned int cl_options_count = N_OPTS;\n"\r
-\r
-print "const struct cl_option cl_options[] =\n{"\r
-\r
-for (i = 0; i < n_opts; i++)\r
- back_chain[i] = "N_OPTS";\r
-\r
-for (i = 0; i < n_opts; i++) {\r
- # Combine the flags of identical switches. Switches\r
- # appear many times if they are handled by many front\r
- # ends, for example.\r
- while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {\r
- flags[i + 1] = flags[i] " " flags[i + 1];\r
- i++;\r
- }\r
-\r
- len = length (opts[i]);\r
- enum = "OPT_" opts[i]\r
- if (opts[i] == "finline-limit=")\r
- enum = enum "eq"\r
- gsub ("[^A-Za-z0-9]", "_", enum)\r
-\r
- # If this switch takes joined arguments, back-chain all\r
- # subsequent switches to it for which it is a prefix. If\r
- # a later switch S is a longer prefix of a switch T, T\r
- # will be back-chained to S in a later iteration of this\r
- # for() loop, which is what we want.\r
- if (flag_set_p("Joined.*", flags[i])) {\r
- for (j = i + 1; j < n_opts; j++) {\r
- if (substr (opts[j], 1, len) != opts[i])\r
- break;\r
- back_chain[j] = enum;\r
- }\r
- }\r
-\r
- s = substr(" ", length (opts[i]))\r
- if (i + 1 == n_opts)\r
- comma = ""\r
-\r
- if (help[i] == "")\r
- hlp = "0"\r
- else\r
- hlp = quote help[i] quote;\r
-\r
- printf(" { %c-%s%c,\n %s,\n %s, %u,\n",\r
- quote, opts[i], quote, hlp, back_chain[i], len)\r
- condition = opt_args("Condition", flags[i])\r
- cl_flags = switch_flags(flags[i])\r
- if (condition != "")\r
- printf("#if %s\n" \\r
- " %s,\n" \\r
- "#else\n" \\r
- " CL_DISABLED,\n" \\r
- "#endif\n",\r
- condition, cl_flags, cl_flags)\r
- else\r
- printf(" %s,\n", cl_flags)\r
- printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]),\r
- var_set(flags[i]), comma)\r
-}\r
-\r
-print "};"\r
-}\r
+# Copyright (C) 2003,2004 Free Software Foundation, Inc.
+# Contributed by Kelley Cook, June 2004.
+# Original code from Neil Booth, May 2003.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# This Awk script reads in the option records generated from
+# opt-gather.awk, combines the flags of duplicat options and generates a
+# C file.
+#
+# This program uses functions from opt-functions.awk
+#
+# Usage: awk -f opt-functions.awk -f optc-gen.awk \
+# [-v header_name=header.h] < inputfile > options.c
+
+BEGIN {
+ n_opts = 0
+ n_langs = 0
+ quote = "\042"
+ comma = ","
+ FS=SUBSEP
+ # Default the name of header created from opth-gen.awk to options.h
+ if (header_name == "") header_name="options.h"
+}
+
+# Collect the text and flags of each option into an array
+ {
+ if ($1 == "Language") {
+ langs[n_langs] = $2
+ n_langs++;
+ }
+ else {
+ name = opt_args("Mask", $1)
+ if (name == "") {
+ opts[n_opts] = $1
+ flags[n_opts] = $2
+ help[n_opts] = $3
+ n_opts++;
+ }
+ }
+ }
+
+# Dump that array of options into a C file.
+END {
+print "/* This file is auto-generated by opts.sh. */"
+print ""
+n_headers = split(header_name, headers, " ")
+for (i = 1; i <= n_headers; i++)
+ print "#include " quote headers[i] quote
+print "#include " quote "opts.h" quote
+print "#include " quote "intl.h" quote
+print ""
+
+for (i = 0; i < n_opts; i++) {
+ name = var_name(flags[i]);
+ if (name == "")
+ continue;
+
+ if (flag_set_p("VarExists", flags[i]))
+ continue;
+
+ init = opt_args("Init", flags[i])
+ if (init != "")
+ init = " = " init;
+ else if (name in var_seen)
+ continue;
+
+ print "/* Set by -" opts[i] "."
+ print " " help[i] " */"
+ print var_type(flags[i]) name init ";"
+ print ""
+
+ var_seen[name] = 1;
+}
+
+print ""
+print "/* Local state variables. */"
+for (i = 0; i < n_opts; i++) {
+ name = static_var(opts[i], flags[i]);
+ if (name != "")
+ print "static " var_type(flags[i]) name ";"
+}
+print ""
+
+print "const char * const lang_names[] =\n{"
+for (i = 0; i < n_langs; i++) {
+ macros[i] = "CL_" langs[i]
+ gsub( "[^A-Za-z0-9_]", "X", macros[i] )
+ s = substr(" ", length (macros[i]))
+ print " " quote langs[i] quote ","
+ }
+
+print " 0\n};\n"
+print "const unsigned int cl_options_count = N_OPTS;\n"
+
+print "const struct cl_option cl_options[] =\n{"
+
+for (i = 0; i < n_opts; i++)
+ back_chain[i] = "N_OPTS";
+
+for (i = 0; i < n_opts; i++) {
+ # Combine the flags of identical switches. Switches
+ # appear many times if they are handled by many front
+ # ends, for example.
+ while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
+ flags[i + 1] = flags[i] " " flags[i + 1];
+ i++;
+ }
+
+ len = length (opts[i]);
+ enum = "OPT_" opts[i]
+ if (opts[i] == "finline-limit=")
+ enum = enum "eq"
+ gsub ("[^A-Za-z0-9]", "_", enum)
+
+ # If this switch takes joined arguments, back-chain all
+ # subsequent switches to it for which it is a prefix. If
+ # a later switch S is a longer prefix of a switch T, T
+ # will be back-chained to S in a later iteration of this
+ # for() loop, which is what we want.
+ if (flag_set_p("Joined.*", flags[i])) {
+ for (j = i + 1; j < n_opts; j++) {
+ if (substr (opts[j], 1, len) != opts[i])
+ break;
+ back_chain[j] = enum;
+ }
+ }
+
+ s = substr(" ", length (opts[i]))
+ if (i + 1 == n_opts)
+ comma = ""
+
+ if (help[i] == "")
+ hlp = "0"
+ else
+ hlp = quote help[i] quote;
+
+ printf(" { %c-%s%c,\n %s,\n %s, %u,\n",
+ quote, opts[i], quote, hlp, back_chain[i], len)
+ condition = opt_args("Condition", flags[i])
+ cl_flags = switch_flags(flags[i])
+ if (condition != "")
+ printf("#if %s\n" \
+ " %s,\n" \
+ "#else\n" \
+ " CL_DISABLED,\n" \
+ "#endif\n",
+ condition, cl_flags, cl_flags)
+ else
+ printf(" %s,\n", cl_flags)
+ printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]),
+ var_set(flags[i]), comma)
+}
+
+print "};"
+}