Correct typos.
[official-gcc.git] / gcc / opt-read.awk
blobc488ed5cde53f65785ac68631bb391916351071f
1 # Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011
2 # Free Software Foundation, Inc.
3 # Contributed by Kelley Cook, June 2004.
4 # Original code from Neil Booth, May 2003.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the
8 # Free Software Foundation; either version 3, or (at your option) any
9 # later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
20 # Read in the option records generated from opt-gather.awk.
22 BEGIN {
23 n_opts = 0
24 n_langs = 0
25 n_target_save = 0
26 n_extra_vars = 0
27 n_extra_target_vars = 0
28 n_extra_masks = 0
29 n_extra_c_includes = 0
30 n_extra_h_includes = 0
31 n_enums = 0
32 have_save = 0;
33 quote = "\042"
34 comma = ","
35 FS=SUBSEP
36 # Default the name of header created from opth-gen.awk to options.h
37 if (header_name == "") header_name="options.h"
40 # Collect the text and flags of each option into an array
42 if ($1 == "Language") {
43 langs[n_langs] = $2
44 n_langs++;
46 else if ($1 == "TargetSave") {
47 # Make sure the declarations are put in source order
48 target_save_decl[n_target_save] = $2
49 n_target_save++
51 else if ($1 == "Variable") {
52 extra_vars[n_extra_vars] = $2
53 n_extra_vars++
55 else if ($1 == "TargetVariable") {
56 # Combination of TargetSave and Variable
57 extra_vars[n_extra_vars] = $2
58 n_extra_vars++
60 var = $2
61 sub(" *=.*", "", var)
62 orig_var = var
63 name = var
64 type = var
65 sub("^.*[ *]", "", name)
66 sub(" *" name "$", "", type)
67 target_save_decl[n_target_save] = type " x_" name
68 n_target_save++
70 extra_target_vars[n_extra_target_vars] = name
71 n_extra_target_vars++
73 else if ($1 == "HeaderInclude") {
74 extra_h_includes[n_extra_h_includes++] = $2;
76 else if ($1 == "SourceInclude") {
77 extra_c_includes[n_extra_c_includes++] = $2;
79 else if ($1 == "Enum") {
80 props = $2
81 name = opt_args("Name", props)
82 type = opt_args("Type", props)
83 unknown_error = opt_args("UnknownError", props)
84 enum_names[n_enums] = name
85 enum_type[name] = type
86 enum_index[name] = n_enums
87 enum_unknown_error[name] = unknown_error
88 enum_help[name] = $3
89 n_enums++
91 else if ($1 == "EnumValue") {
92 props = $2
93 enum_name = opt_args("Enum", props)
94 string = opt_args("String", props)
95 value = opt_args("Value", props)
96 val_flags = "0"
97 val_flags = val_flags \
98 test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \
99 test_flag("DriverOnly", props, "| CL_ENUM_DRIVER_ONLY")
100 enum_data[enum_name] = enum_data[enum_name] \
101 " { " quote string quote ", " value ", " val_flags \
102 " },\n"
104 else {
105 name = opt_args("Mask", $1)
106 if (name == "") {
107 opts[n_opts] = $1
108 flags[n_opts] = $2
109 help[n_opts] = $3
110 for (i = 4; i <= NF; i++)
111 help[n_opts] = help[n_opts] " " $i
112 n_opts++;
114 else {
115 extra_masks[n_extra_masks++] = name