Daily bump.
[official-gcc.git] / gcc / f / ansify.c
blob6c6d01f911fa77f4ee2ec4c23a5cd380ecc68539
1 /* ansify.c
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 /* From f/proj.h, which uses #error -- not all C compilers
23 support that, and we want *this* program to be compilable
24 by pretty much any C compiler. */
25 #include "hconfig.j"
26 #include "system.j"
27 #include "assert.j"
28 #if HAVE_STDDEF_H
29 #include <stddef.h>
30 #endif
32 typedef enum
34 #if !defined(false) || !defined(true)
35 false = 0, true = 1,
36 #endif
37 #if !defined(FALSE) || !defined(TRUE)
38 FALSE = 0, TRUE = 1,
39 #endif
40 Doggone_Trailing_Comma_Dont_Work = 1
41 } bool;
43 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
45 #define die_unless(c) \
46 do if (!(c)) \
47 { \
48 fprintf (stderr, "%s:%lu: " #c "\n", argv[1], lineno); \
49 die (); \
50 } \
51 while(0)
53 static void
54 die (void)
56 exit (1);
59 int
60 main(int argc, char **argv)
62 int c;
63 static unsigned long lineno = 1;
65 die_unless (argc == 2);
67 printf ("\
68 /* This file is automatically generated from `%s',\n\
69 which you should modify instead. */\n\
70 # 1 \"%s\"\n\
72 argv[1], argv[1]);
74 while ((c = getchar ()) != EOF)
76 switch (c)
78 default:
79 putchar (c);
80 break;
82 case '\n':
83 ++lineno;
84 putchar (c);
85 break;
87 case '"':
88 putchar (c);
89 for (;;)
91 c = getchar ();
92 die_unless (c != EOF);
93 switch (c)
95 case '"':
96 putchar (c);
97 goto next_char;
99 case '\n':
100 putchar ('\\');
101 putchar ('n');
102 putchar ('\\');
103 putchar ('\n');
104 ++lineno;
105 break;
107 case '\\':
108 putchar (c);
109 c = getchar ();
110 die_unless (c != EOF);
111 putchar (c);
112 if (c == '\n')
113 ++lineno;
114 break;
116 default:
117 putchar (c);
118 break;
121 break;
123 case '\'':
124 putchar (c);
125 for (;;)
127 c = getchar ();
128 die_unless (c != EOF);
129 switch (c)
131 case '\'':
132 putchar (c);
133 goto next_char;
135 case '\n':
136 putchar ('\\');
137 putchar ('n');
138 putchar ('\\');
139 putchar ('\n');
140 ++lineno;
141 break;
143 case '\\':
144 putchar (c);
145 c = getchar ();
146 die_unless (c != EOF);
147 putchar (c);
148 if (c == '\n')
149 ++lineno;
150 break;
152 default:
153 putchar (c);
154 break;
157 break;
159 case '/':
160 putchar (c);
161 c = getchar ();
162 putchar (c);
163 if (c != '*')
164 break;
165 for (;;)
167 c = getchar ();
168 die_unless (c != EOF);
170 switch (c)
172 case '\n':
173 ++lineno;
174 putchar (c);
175 break;
177 case '*':
178 c = getchar ();
179 die_unless (c != EOF);
180 if (c == '/')
182 putchar ('*');
183 putchar ('/');
184 goto next_char;
186 if (c == '\n')
188 ++lineno;
189 putchar (c);
191 break;
193 default:
194 /* Don't bother outputting content of comments. */
195 break;
198 break;
201 next_char:
205 die_unless (c == EOF);
207 return 0;