+2006-12-08 Borut Razem <borut.razem AT siol.net>
+
+ * support/cpp2/sdcc.h: removed x*alloc() macros
+ * support/cpp2/libiberty.h: uncommented out x*alloc() declarations
+ * support/cpp2/Makefile.bcc, support/cpp2/Makefile.in,
+ support/cpp2/sdcpp.sdc: x*alloc files added to the project
+ * support/cpp2/system.h: moved #include "sdcc.h"
+ * support/cpp2/libiberty/xexit.c, support/cpp2/libiberty/xmalloc.c,
+ support/cpp2/libiberty/xstrdup.c, support/cpp2/libiberty/xstrerror.c:
+ added
+ * support/cpp2/sdcppinit.c: added -isysroot, -fsigned-char,
+ -funsigned-char options
+ * support/cpp2/sdcppmain.c: fixed bug 1611411
+
2006-12-07 Borut Razem <borut.razem AT siol.net>
* support/cpp2/cpplib.c: reverted sdcpp special handling of _Pragma()
hashtable.obj mkdeps.obj prefix.obj version.obj mbchar.obj \
line-map.obj cpptrad.obj \
safe-ctype.obj obstack.obj splay-tree.obj lbasename.obj \
- hex.obj concat.obj
+ hex.obj concat.obj \
+ xmalloc.obj xstrdup.obj xexit.obj xstrerror.obj
TARGET = $(PRJDIR)/bin/sdcpp.exe
lbasename.obj: libiberty\lbasename.c
hex.obj: libiberty\hex.c
concat.obj: libiberty\concat.c
+xmalloc.obj: libiberty\xmalloc.c
+xstrdup.obj: libiberty\xstrdup.c
+xexit.obj: libiberty\xexit.c
+xstrerror.obj: libiberty\xstrerror.c
-$(RANLIB) libcpp.a
MY_LIBIBERTY_BITS = safe-ctype.o obstack.o splay-tree.o \
- lbasename.o hex.o concat.o
+ lbasename.o hex.o concat.o \
+ xmalloc.o xstrdup.o xstrerror.o xexit.o
$(TARGET): sdcppmain.o sdcppinit.o $(MY_LIBIBERTY_BITS) libcpp.a $(LIBDEPS)
mkdir -p $(dir $@)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
concat.o: $(LIBIBERTY_DIR)/concat.c $(CONFIG_H) $(LIBCPP_DEPS)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+xmalloc.o: $(LIBIBERTY_DIR)/xmalloc.c $(CONFIG_H) $(LIBCPP_DEPS)
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+xstrdup.o: $(LIBIBERTY_DIR)/xstrdup.c $(CONFIG_H) $(LIBCPP_DEPS)
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+xexit.o: $(LIBIBERTY_DIR)/xexit.c $(CONFIG_H) $(LIBCPP_DEPS)
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+xstrerror.o: $(LIBIBERTY_DIR)/xstrerror.c $(CONFIG_H) $(LIBCPP_DEPS)
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) cppdefault.h Makefile
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(PREPROCESSOR_DEFINES) \
extern void xexit (int status) ATTRIBUTE_NORETURN;
-#if 0 /* SDCC specific */
/* Set the program name used by xmalloc. */
extern void xmalloc_set_program_name (const char *);
/* Copy an existing memory buffer to a new memory buffer without fail. */
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
-#endif
/* Physical memory routines. Return values are in BYTES. */
extern double physmem_total (void);
--- /dev/null
+/* xexit.c -- Run any exit handlers, then exit.
+ Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If not, write
+to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/*
+
+@deftypefn Replacement void xexit (int @var{code})
+
+Terminates the program. If any functions have been registered with
+the @code{xatexit} replacement function, they will be called first.
+Termination is handled via the system's normal @code{exit} call.
+
+@end deftypefn
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include "libiberty.h"
+
+
+/* This variable is set by xatexit if it is called. This way, xmalloc
+ doesn't drag xatexit into the link. */
+void (*_xexit_cleanup) (void);
+
+void
+xexit (int code)
+{
+ if (_xexit_cleanup != NULL)
+ (*_xexit_cleanup) ();
+ exit (code);
+}
--- /dev/null
+/* memory allocation routines with error checking.
+ Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/*
+
+@deftypefn Replacement void* xmalloc (size_t)
+
+Allocate memory without fail. If @code{malloc} fails, this will print
+a message to @code{stderr} (using the name set by
+@code{xmalloc_set_program_name},
+if any) and then call @code{xexit}. Note that it is therefore safe for
+a program to contain @code{#define malloc xmalloc} in its source.
+
+@end deftypefn
+
+@deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
+Reallocate memory without fail. This routine functions like @code{realloc},
+but will behave the same as @code{xmalloc} if memory cannot be found.
+
+@end deftypefn
+
+@deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
+
+Allocate memory without fail, and set it to zero. This routine functions
+like @code{calloc}, but will behave the same as @code{xmalloc} if memory
+cannot be found.
+
+@end deftypefn
+
+@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
+
+You can use this to set the name of the program used by
+@code{xmalloc_failed} when printing a failure message.
+
+@end deftypefn
+
+@deftypefn Replacement void xmalloc_failed (size_t)
+
+This function is not meant to be called by client code, and is listed
+here for completeness only. If any of the allocation routines fail, this
+function will be called to print an error message and terminate execution.
+
+@end deftypefn
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#include <stdio.h>
+
+#include <stddef.h>
+
+#if VMS
+#include <stdlib.h>
+#include <unixlib.h>
+#else
+/* For systems with larger pointers than ints, these must be declared. */
+# if HAVE_STDLIB_H && HAVE_UNISTD_H && HAVE_DECL_MALLOC \
+ && HAVE_DECL_REALLOC && HAVE_DECL_CALLOC && HAVE_DECL_SBRK
+# include <stdlib.h>
+# include <unistd.h>
+# else
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+void *malloc (size_t);
+void *realloc (void *, size_t);
+void *calloc (size_t, size_t);
+void *sbrk (ptrdiff_t);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+# endif /* HAVE_STDLIB_H ... */
+#endif /* VMS */
+
+/* The program name if set. */
+static const char *name = "";
+
+#ifdef HAVE_SBRK
+/* The initial sbrk, set when the program name is set. Not used for win32
+ ports other than cygwin32. */
+static char *first_break = NULL;
+#endif /* HAVE_SBRK */
+
+void
+xmalloc_set_program_name (const char *s)
+{
+ name = s;
+#ifdef HAVE_SBRK
+ /* Win32 ports other than cygwin32 don't have brk() */
+ if (first_break == NULL)
+ first_break = (char *) sbrk (0);
+#endif /* HAVE_SBRK */
+}
+
+void
+xmalloc_failed (size_t size)
+{
+#ifdef HAVE_SBRK
+ extern char **environ;
+ size_t allocated;
+
+ if (first_break != NULL)
+ allocated = (char *) sbrk (0) - first_break;
+ else
+ allocated = (char *) sbrk (0) - (char *) &environ;
+ fprintf (stderr,
+ "\n%s%sout of memory allocating %lu bytes after a total of %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size, (unsigned long) allocated);
+#else /* HAVE_SBRK */
+ fprintf (stderr,
+ "\n%s%sout of memory allocating %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) size);
+#endif /* HAVE_SBRK */
+ xexit (1);
+}
+
+PTR
+xmalloc (size_t size)
+{
+ PTR newmem;
+
+ if (size == 0)
+ size = 1;
+ newmem = malloc (size);
+ if (!newmem)
+ xmalloc_failed (size);
+
+ return (newmem);
+}
+
+PTR
+xcalloc (size_t nelem, size_t elsize)
+{
+ PTR newmem;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ newmem = calloc (nelem, elsize);
+ if (!newmem)
+ xmalloc_failed (nelem * elsize);
+
+ return (newmem);
+}
+
+PTR
+xrealloc (PTR oldmem, size_t size)
+{
+ PTR newmem;
+
+ if (size == 0)
+ size = 1;
+ if (!oldmem)
+ newmem = malloc (size);
+ else
+ newmem = realloc (oldmem, size);
+ if (!newmem)
+ xmalloc_failed (size);
+
+ return (newmem);
+}
--- /dev/null
+/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
+ This trivial function is in the public domain.
+ Ian Lance Taylor, Cygnus Support, December 1995. */
+
+/*
+
+@deftypefn Replacement char* xstrdup (const char *@var{s})
+
+Duplicates a character string without fail, using @code{xmalloc} to
+obtain memory.
+
+@end deftypefn
+
+*/
+
+#include <sys/types.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+# ifdef HAVE_STRINGS_H
+# include <strings.h>
+# endif
+#endif
+#include "ansidecl.h"
+#include "libiberty.h"
+
+char *
+xstrdup (const char *s)
+{
+ register size_t len = strlen (s) + 1;
+ register char *ret = XNEWVEC (char, len);
+ return (char *) memcpy (ret, s, len);
+}
--- /dev/null
+/* xstrerror.c -- jacket routine for more robust strerror() usage.
+ Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
+ This code is in the public domain. */
+
+/*
+
+@deftypefn Replacement char* xstrerror (int @var{errnum})
+
+Behaves exactly like the standard @code{strerror} function, but
+will never return a @code{NULL} pointer.
+
+@end deftypefn
+
+*/
+
+#include <stdio.h>
+
+#include "config.h"
+#include "libiberty.h"
+
+#ifdef VMS
+# include <errno.h>
+# if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+extern char *strerror (int,...);
+# define DONT_DECLARE_STRERROR
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+# endif
+#endif /* VMS */
+
+
+#ifndef DONT_DECLARE_STRERROR
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+extern char *strerror (int);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+#endif
+
+/* If strerror returns NULL, we'll format the number into a static buffer. */
+
+#define ERRSTR_FMT "undocumented error #%d"
+static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
+
+/* Like strerror, but result is never a null pointer. */
+
+char *
+xstrerror (int errnum)
+{
+ char *errstr;
+#ifdef VMS
+ char *(*vmslib_strerror) (int,...);
+
+ /* Override any possibly-conflicting declaration from system header. */
+ vmslib_strerror = (char *(*) (int,...)) strerror;
+ /* Second argument matters iff first is EVMSERR, but it's simpler to
+ pass it unconditionally. `vaxc$errno' is declared in <errno.h>
+ and maintained by the run-time library in parallel to `errno'.
+ We assume that `errnum' corresponds to the last value assigned to
+ errno by the run-time library, hence vaxc$errno will be relevant. */
+ errstr = (*vmslib_strerror) (errnum, vaxc$errno);
+#else
+ errstr = strerror (errnum);
+#endif
+
+ /* If `errnum' is out of range, result might be NULL. We'll fix that. */
+ if (!errstr)
+ {
+ sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
+ errstr = xstrerror_buf;
+ }
+ return errstr;
+}
-/* Various stuff needed to hack the build for SDCC. */
-#define xmalloc malloc
-#define xstrdup strdup
-#define xrealloc realloc
-#define xcalloc calloc
-
-#define xstrerror strerror
-#define xmalloc_set_program_name(n) /* nada */
-
/*
* From defaults.h
*/
\r
SOURCE=.\version.c\r
# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\libiberty\xexit.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\libiberty\xmalloc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\libiberty\xstrdup.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\libiberty\xstrerror.c\r
+# End Source File\r
# End Group\r
# Begin Group "Header Files"\r
\r
/* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
CPP_OPTION (pfile, operator_names) = 1;
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
+ CPP_OPTION (pfile, sysroot) = cpp_SYSROOT;
/* SDCC _asm specific */
CPP_OPTION (pfile, preproc_asm) = 1;
|| (CPP_OPTION (pfile, cplusplus)
&& !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
{
- /* Does this dir start with the prefix? */
+ /* Should we be translating sysrooted dirs too? Assume
+ that iprefix and sysroot are mutually exclusive, for
+ now. */
+ if (p->add_sysroot && CPP_OPTION (pfile, sysroot)
+ && *(CPP_OPTION (pfile, sysroot)))
+ continue;
+
+ /* Does this dir start with the prefix? */
if (!strncmp (p->fname, default_prefix, default_len))
{
/* Yes; change prefix and add to search list. */
int flen = strlen (p->fname);
int this_len = specd_len + flen - default_len;
- char *str = (char *) xmalloc (this_len + 1);
+
+ char *str = (char *) xmalloc (this_len + 1);
memcpy (str, specd_prefix, specd_len);
memcpy (str + specd_len,
p->fname + default_len,
}
}
- /* Search ordinary names for GNU include directories. */
for (p = cpp_include_defaults; p->fname; p++)
{
/* Some standard dirs are only for C++. */
|| (CPP_OPTION (pfile, cplusplus)
&& !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
{
- char *str = update_path (p->fname, p->component);
+ char *str;
+
+ /* Should this dir start with the sysroot? */
+ if (p->add_sysroot && CPP_OPTION (pfile, sysroot)
+ && *(CPP_OPTION (pfile, sysroot)))
+ str = concat (CPP_OPTION (pfile, sysroot), p->fname, NULL);
+
+ else
+ str = update_path (p->fname, p->component);
+
append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
}
}
free_chain (CPP_OPTION (pfile, pending)->directive_head);
}
-/* Use mkdeps.c to output dependency information. */
-static void
-output_deps (cpp_reader *pfile)
-{
- /* Stream on which to print the dependency information. */
- FILE *deps_stream = 0;
- const char *const deps_mode =
- CPP_OPTION (pfile, deps.append) ? "a" : "w";
-
- if (CPP_OPTION (pfile, deps.file)[0] == '\0')
- deps_stream = stdout;
- else
- {
- deps_stream = fopen (CPP_OPTION (pfile, deps.file), deps_mode);
- if (deps_stream == 0)
- {
- cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps.file));
- return;
- }
- }
-
- deps_write (pfile->deps, deps_stream, 72);
-
- if (CPP_OPTION (pfile, deps.phony_targets))
- deps_phony_targets (pfile->deps, deps_stream);
-
- /* Don't close stdout. */
- if (deps_stream != stdout)
- {
- if (ferror (deps_stream) || fclose (deps_stream) != 0)
- cpp_error (pfile, DL_ERROR, "I/O error on output");
- }
-}
-
-/* This is called at the end of preprocessing. It pops the
- last buffer and writes dependency output. It should also
- clear macro definitions, such that you could call cpp_start_read
- with a new filename to restart processing. */
-void
-sdcpp_finish (cpp_reader *pfile)
-{
- /* Warn about unused macros before popping the final buffer. */
- if (CPP_OPTION (pfile, warn_unused_macros))
- cpp_forall_identifiers (pfile, _cpp_warn_if_unused_macro, NULL);
-
- /* cpplex.c leaves the final buffer on the stack. This it so that
- it returns an unending stream of CPP_EOFs to the client. If we
- popped the buffer, we'd dereference a NULL buffer pointer and
- segfault. It's nice to allow the client to do worry-free excess
- cpp_get_token calls. */
- while (pfile->buffer)
- _cpp_pop_buffer (pfile);
-
- /* Don't write the deps file if preprocessing has failed. */
- if (CPP_OPTION (pfile, deps.style) && pfile->errors == 0)
- output_deps (pfile);
-
- /* Report on headers that could use multiple include guards. */
- if (CPP_OPTION (pfile, print_include_names))
- _cpp_report_missing_guards (pfile);
-}
-
/* Push the next buffer on the stack given by -include, if any. */
void
_cpp_maybe_push_include_file (pfile)
DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
DEF_OPT("fshow-column", 0, OPT_fshow_column) \
+ DEF_OPT("fsigned-char", 0, OPT_fsigned_char) \
DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
DEF_OPT("funsigned-char", 0, OPT_funsigned_char) \
DEF_OPT("h", 0, OPT_h) \
DEF_OPT("imacros", no_fil, OPT_imacros) \
DEF_OPT("include", no_fil, OPT_include) \
DEF_OPT("iprefix", no_pth, OPT_iprefix) \
+ DEF_OPT("isysroot", no_dir, OPT_isysroot) \
DEF_OPT("isystem", no_dir, OPT_isystem) \
DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
CPP_OPTION (pfile, tabstop) = tabstop;
}
break;
+ case OPT_fsigned_char:
+ CPP_OPTION (pfile, unsigned_char) = 0;
+ break;
+ case OPT_funsigned_char:
+ CPP_OPTION (pfile, unsigned_char) = 1;
+ break;
case OPT_w:
CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
CPP_OPTION (pfile, include_prefix) = arg;
CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
break;
- case OPT_lang_c:
+ case OPT_isysroot:
+ CPP_OPTION (pfile, sysroot) = arg;
+ break;
+ case OPT_lang_c:
cpp_set_lang (pfile, CLK_GNUC89);
break;
case OPT_lang_cplusplus:
-iwithprefix <dir> Add <dir> to the end of the system include path\n\
-iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
-isystem <dir> Add <dir> to the start of the system include path\n\
+ -isysroot <dir> Set <dir> to be the system root directory\n\
"), stdout);
fputs (_("\
-idirafter <dir> Add <dir> to the end of the system include path\n\
fputs (_("\
-fpreprocessed Treat the input file as already preprocessed\n\
-ftabstop=<number> Distance between tab stops for column reporting\n\
+ -fsigned-char Make \"char\" signed by default\n\
+ -funsigned-char Make \"char\" unsigned by default\n\
-P Do not generate #line directives\n\
-$ Do not allow '$' in identifiers\n\
-remap Remap file names when including files\n\
/* True if we have seen a "fatal" error. */
#define CPP_FATAL_ERRORS(PFILE) (cpp_errors (PFILE) >= CPP_FATAL_LIMIT)
+extern void sdcpp_finish (cpp_reader *pfile);
+
+
const char *progname; /* Needs to be global. */
cpp_preprocess_file (pfile, pfile->opts.in_fname, outf);
}
+/* Print a fatal I/O error message. Argument are like printf.
+ Also include a system error message based on `errno'. */
+void
+fatal_io_error VPARAMS ((const char *msgid, ...))
+{
+ va_list ap;
+
+ va_start (ap, msgid);
+ fprintf (stderr, "%s: %s: ", progname, xstrerror (errno));
+ vfprintf(stderr, msgid, ap);
+ va_end (ap);
+ exit (FATAL_EXIT_CODE);
+}
+
+/* Common finish hook for the C, ObjC and C++ front ends. */
+void
+common_finish (cpp_reader *pfile)
+{
+ FILE *deps_stream = NULL;
+
+ if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
+ {
+ const char *const deps_mode =
+ CPP_OPTION (pfile, deps.append) ? "a" : "w";
+
+ /* If -M or -MM was seen without -MF, default output to the
+ output stream. */
+ if (CPP_OPTION (pfile, deps.file)[0] == '\0')
+ deps_stream = stdout;
+ else
+ {
+ deps_stream = fopen (CPP_OPTION (pfile, deps.file), deps_mode);
+ if (deps_stream == 0)
+ {
+ cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps.file));
+ return;
+ }
+ }
+ }
+
+ /* For performance, avoid tearing down cpplib's internal structures
+ with cpp_destroy (). */
+ cpp_finish (pfile, deps_stream);
+
+ if (deps_stream && deps_stream != stdout
+ && (ferror (deps_stream) || fclose (deps_stream)))
+ fatal_io_error ("closing dependency file %s", CPP_OPTION (pfile, deps.file));
+}
+
int
main (int argc, char **argv)
{
do_preprocessing (pfile, argc, argv);
+ common_finish(pfile);
+
cpp_destroy (pfile);
return SUCCESS_EXIT_CODE;
/* Get libiberty declarations. */
#include "libiberty.h"
-#include "sdcc.h"
#include "symcat.h"
/* Provide a default for the HOST_BIT_BUCKET.
#endif /* GCC >= 3.0 */
+/* SDCC specific */
+#include "sdcc.h"
+
#endif /* ! GCC_SYSTEM_H */