OSDN Git Service

* Makefile.in (html): Add html generation support.
[pf3gnuchains/gcc-fork.git] / gcc / opt-functions.awk
1 #  Copyright (C) 2003,2004 Free Software Foundation, Inc.
2 #  Contributed by Kelley Cook, June 2004.
3 #  Original code from Neil Booth, May 2003.
4 #
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 # Some common subroutines for use by opt[ch]-gen.awk.
20
21 function switch_flags (flags)
22 {
23         flags = " " flags " "
24         result = "0"
25         for (j = 0; j < n_langs; j++) {
26                 regex = " " langs[j] " "
27                 gsub ( "\\+", "\\+", regex )
28                 if (flags ~ regex)
29                         result = result " | " macros[j]
30         }
31         if (flags ~ " Common ") result = result " | CL_COMMON"
32         if (flags ~ " Joined ") result = result " | CL_JOINED"
33         if (flags ~ " JoinedOrMissing ") \
34             result = result " | CL_JOINED | CL_MISSING_OK"
35         if (flags ~ " Separate ") result = result " | CL_SEPARATE"
36         if (flags ~ " RejectNegative ") result = result " | CL_REJECT_NEGATIVE"
37         if (flags ~ " UInteger ") result = result " | CL_UINTEGER"
38         if (flags ~ " Undocumented ") result = result " | CL_UNDOCUMENTED"
39         if (flags ~ " Report ") result = result " | CL_REPORT"
40         sub( "^0 \\| ", "", result )
41         return result
42 }
43
44 function var_args(flags)
45 {
46         if (flags !~ "Var\\(")
47             return ""
48         sub(".*Var\\(", "", flags)
49         sub("\\).*", "", flags)
50
51         return flags
52 }
53 function var_name(flags)
54 {
55         s = var_args(flags)
56         if (s == "")
57                 return "";
58         sub( ",.*", "", s)
59         return s
60 }
61 function var_set(flags)
62 {
63         s = var_args(flags)
64         if (s !~ ",")
65                 return "0, 0"
66         sub( "[^,]*,", "", s)
67         return "1, " s
68 }
69 function var_ref(flags)
70 {
71         name = var_name(flags)
72         if (name == "")
73                 return "0"
74         else
75                 return "&" name
76 }