/* fix-header.c - Make C header file suitable for C++.
- Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
-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 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 3, 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.
+ 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
/* This program massages a system include file (such as stdio.h),
into a form that is compatible with GNU C and GNU C++.
#include "obstack.h"
#include "scan.h"
#include "cpplib.h"
-#include "c-incpath.h"
-
-static void v_fatal (const char *, va_list)
- ATTRIBUTE_PRINTF (1,0) ATTRIBUTE_NORETURN;
-static void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+#include "incpath.h"
+#include "errors.h"
#ifdef TARGET_EXTRA_INCLUDES
-static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
+void
+TARGET_EXTRA_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
+ const char *iprefix ATTRIBUTE_UNUSED,
+ int stdinc ATTRIBUTE_UNUSED)
+{
+}
+#endif
-struct target_c_incpath_s target_c_incpath = { hook_void_int };
+#ifdef TARGET_EXTRA_PRE_INCLUDES
+void
+TARGET_EXTRA_PRE_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
+ const char *iprefix ATTRIBUTE_UNUSED,
+ int stdinc ATTRIBUTE_UNUSED)
+{
+}
#endif
struct line_maps line_table;
&& strncmp (fn->fname, name, name_length) == 0)
return fn;
i = (i+1) % HASH_SIZE;
- if (i == i0)
- abort ();
+ gcc_assert (i != i0);
}
}
char *inc_filename;
int inc_filename_length;
-const char *progname = "fix-header";
FILE *outf;
sstring line;
/* We only have a partial function declaration,
so remember that we have to add a complete prototype. */
partial_count++;
- partial = obstack_alloc (&scan_file_obstack, sizeof (struct partial_proto));
+ partial
+ = (struct partial_proto *)
+ obstack_alloc (&scan_file_obstack,
+ sizeof (struct partial_proto));
partial->line_seen = line;
partial->fn = fn;
fn->partial = partial;
if (argv[i][2] != '\0')
{
strings_processed = 1;
- add_path (xstrdup (argv[i] + 2), BRACKET, false);
+ add_path (xstrdup (argv[i] + 2), BRACKET, false, false);
}
else if (i + 1 != argc)
{
strings_processed = 2;
- add_path (xstrdup (argv[i + 1]), BRACKET, false);
+ add_path (xstrdup (argv[i + 1]), BRACKET, false, false);
}
}
else if (argv[i][1] == 'D')
exit (FATAL_EXIT_CODE);
register_include_chains (scan_in, NULL /* sysroot */, NULL /* iprefix */,
- true /* stdinc */, false /* cxx_stdinc */,
- false /* verbose */);
+ NULL /* imultilib */, true /* stdinc */,
+ false /* cxx_stdinc */, false /* verbose */);
/* We are scanning a system header, so mark it as such. */
cpp_make_system_header (scan_in, 1, 0);
long int inf_size;
struct symbol_list *cur_symbols;
+ progname = "fix-header";
if (argv[0] && argv[0][0])
{
char *p;
exit (FATAL_EXIT_CODE);
}
inf_size = sbuf.st_size;
- inf_buffer = xmalloc (inf_size + 2);
+ inf_buffer = XNEWVEC (char, inf_size + 2);
inf_ptr = inf_buffer;
to_read = inf_size;
return 0;
}
-\f
-
-static void
-v_fatal (const char *str, va_list ap)
-{
- fprintf (stderr, "%s: %s: ", progname, inc_filename);
- vfprintf (stderr, str, ap);
- fprintf (stderr, "\n");
-
- exit (FATAL_EXIT_CODE);
-}
-
-static void
-fatal (const char *str, ...)
-{
- va_list ap;
-
- va_start (ap, str);
- v_fatal (str, ap);
- va_end (ap);
-}