* cfgloop.c (flow_loop_entry_edges_find): Fix typo.
[official-gcc.git] / gcc / f / ansify.c
blobec9910779e78b0bde4579b1285f88720ee5093e2
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 #include "hconfig.h"
23 #include "system.h"
25 #define die_unless(c) \
26 do if (!(c)) \
27 { \
28 fprintf (stderr, "%s:%lu: %s\n", argv[1], lineno, #c); \
29 die (); \
30 } \
31 while(0)
33 static void ATTRIBUTE_NORETURN
34 die (void)
36 exit (1);
39 int
40 main(int argc, char **argv)
42 int c;
43 static unsigned long lineno = 1;
45 die_unless (argc == 2);
47 printf ("\
48 /* This file is automatically generated from `%s',\n\
49 which you should modify instead. */\n\
50 #line 1 \"%s\"\n\
52 argv[1], argv[1]);
54 while ((c = getchar ()) != EOF)
56 switch (c)
58 default:
59 putchar (c);
60 break;
62 case '\n':
63 ++lineno;
64 putchar (c);
65 break;
67 case '"':
68 putchar (c);
69 for (;;)
71 c = getchar ();
72 die_unless (c != EOF);
73 switch (c)
75 case '"':
76 putchar (c);
77 goto next_char;
79 case '\n':
80 putchar ('\\');
81 putchar ('n');
82 putchar ('\\');
83 putchar ('\n');
84 ++lineno;
85 break;
87 case '\\':
88 putchar (c);
89 c = getchar ();
90 die_unless (c != EOF);
91 putchar (c);
92 if (c == '\n')
93 ++lineno;
94 break;
96 default:
97 putchar (c);
98 break;
101 break;
103 case '\'':
104 putchar (c);
105 for (;;)
107 c = getchar ();
108 die_unless (c != EOF);
109 switch (c)
111 case '\'':
112 putchar (c);
113 goto next_char;
115 case '\n':
116 putchar ('\\');
117 putchar ('n');
118 putchar ('\\');
119 putchar ('\n');
120 ++lineno;
121 break;
123 case '\\':
124 putchar (c);
125 c = getchar ();
126 die_unless (c != EOF);
127 putchar (c);
128 if (c == '\n')
129 ++lineno;
130 break;
132 default:
133 putchar (c);
134 break;
137 break;
139 case '/':
140 putchar (c);
141 c = getchar ();
142 putchar (c);
143 if (c != '*')
144 break;
145 for (;;)
147 c = getchar ();
148 die_unless (c != EOF);
150 switch (c)
152 case '\n':
153 ++lineno;
154 putchar (c);
155 break;
157 case '*':
158 c = getchar ();
159 die_unless (c != EOF);
160 if (c == '/')
162 putchar ('*');
163 putchar ('/');
164 goto next_char;
166 if (c == '\n')
168 ++lineno;
169 putchar (c);
171 break;
173 default:
174 /* Don't bother outputting content of comments. */
175 break;
178 break;
181 next_char:
185 die_unless (c == EOF);
187 return 0;