+2006-12-27 Borut Razem <borut.razem AT siol.net>
+
+ * support/cpp2/cppmain.c, support/cpp2/mbchar.[ch]: removed
+ * support/cpp2/libiberty/Makefile.in, support/cpp2/libiberty/sdcpp.dsp:
+ mbchar removed
+ * support/cpp2/libiberty/getpwd.c, support/cpp2/sdcpp.h:
+ fixed for borland C
+ * support/cpp2/libiberty/Makefile.bcc: updated
+
2006-12-26 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCpeeph.c: made labelHashEntry global,
CFLAGS = $(CFLAGS) -I. -I./libiberty -DHAVE_CONFIG_H
-OBJECTS = sdcppmain.obj sdcppinit.obj \
- cppmain.obj cpplib.obj cpplex.obj cppmacro.obj cppexp.obj \
+OBJECTS = sdcpp.obj cppinit.obj \
+ cpplib.obj cpplex.obj cppmacro.obj cppexp.obj \
cppfiles.obj cpphash.obj cpperror.obj cppdefault.obj \
- hashtable.obj mkdeps.obj prefix.obj version.obj mbchar.obj \
+ hashtable.obj mkdeps.obj prefix.obj version.obj \
line-map.obj cpptrad.obj \
+ sdcpp-opts.obj cppcharset.obj hashtab.obj c-incpath.obj c-ppoutput.obj opts.obj options.obj diagnostic.obj pretty-print.obj \
safe-ctype.obj obstack.obj splay-tree.obj lbasename.obj \
hex.obj concat.obj \
- xmalloc.obj xstrdup.obj xexit.obj xstrerror.obj
+ xmalloc.obj xstrdup.obj xexit.obj xmemdup.obj xstrerror.obj getpwd.obj vasprintf.obj
TARGET = $(PRJDIR)/bin/sdcpp.exe
xmalloc.obj: libiberty\xmalloc.c
xstrdup.obj: libiberty\xstrdup.c
xexit.obj: libiberty\xexit.c
+xmemdup.obj: libiberty\xmemdup.c
xstrerror.obj: libiberty\xstrerror.c
+getpwd.obj: libiberty\getpwd.c
+vasprintf.obj: libiberty\vasprintf.c
\ No newline at end of file
cppcharset.o: cppcharset.c $(CONFIG_H) $(SYSTEM_H)
-mbchar.o: mbchar.c mbchar.h $(CONFIG_H) $(SYSTEM_H)
-
prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) Makefile prefix.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DPREFIX=\"$(prefix)\" \
LIBCPP_OBJS = c-ppoutput.o cppinit.o cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \
cpphash.o cpperror.o cppdefault.o \
- hashtable.o mkdeps.o prefix.o version.o mbchar.o \
+ hashtable.o mkdeps.o prefix.o version.o \
line-map.o cpptrad.o cppcharset.o hashtab.o \
opts.o options.o diagnostic.o pretty-print.o c-incpath.o
mkdeps.h prefix.h output.h version.h
cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
cppexp.o: cppexp.c $(CONFIG_H) $(LIBCPP_DEPS)
-cpplex.o: cpplex.c $(CONFIG_H) $(LIBCPP_DEPS) mbchar.h
+cpplex.o: cpplex.c $(CONFIG_H) $(LIBCPP_DEPS)
cppmacro.o: cppmacro.c $(CONFIG_H) $(LIBCPP_DEPS)
cpplib.o: cpplib.c $(CONFIG_H) $(LIBCPP_DEPS)
cpphash.o: cpphash.c $(CONFIG_H) $(LIBCPP_DEPS)
+++ /dev/null
-/* Preprocess only, using cpplib.
- Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
- Written by Per Bothner, 1994-95.
-
-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 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.
-
- In other words, you are welcome to use, share and improve this program.
- You are forbidden to forbid anyone else to use, share and improve
- what you give them. Help stamp out software-hoarding! */
-
-#include "config.h"
-#include "system.h"
-#include "cpplib.h"
-#include "cpphash.h"
-
-static void setup_callbacks PARAMS ((cpp_reader *));
-
-/* General output routines. */
-static void scan_translation_unit PARAMS ((cpp_reader *));
-static void scan_translation_unit_trad PARAMS ((cpp_reader *));
-static void account_for_newlines PARAMS ((cpp_reader *, const uchar *,
- size_t));
-static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *));
-
-static void print_line PARAMS ((cpp_reader *, const struct line_map *,
- unsigned int, const char *));
-static void maybe_print_line PARAMS ((cpp_reader *, const struct line_map *,
- unsigned int));
-
-/* Callback routines for the parser. Most of these are active only
- in specific modes. */
-static void cb_line_change PARAMS ((cpp_reader *, const cpp_token *, int));
-static void cb_define PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
-static void cb_undef PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
-static void cb_include PARAMS ((cpp_reader *, unsigned int,
- const unsigned char *, const cpp_token *));
-static void cb_ident PARAMS ((cpp_reader *, unsigned int,
- const cpp_string *));
-static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
-static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
-
-/* Preprocess and output. */
-void
-cpp_preprocess_file (pfile, in_fname, out_stream)
- cpp_reader *pfile;
- const char *in_fname;
- FILE *out_stream;
-{
- /* Initialize the printer structure. Setting print.line to -1 here
- is a trick to guarantee that the first token of the file will
- cause a linemarker to be output by maybe_print_line. */
- pfile->print.line = (unsigned int) -1;
- pfile->print.printed = 0;
- pfile->print.prev = 0;
- pfile->print.map = 0;
- pfile->print.outf = out_stream;
-
- setup_callbacks (pfile);
-
- if (cpp_read_main_file (pfile, in_fname, NULL))
- {
- cpp_options *options = &pfile->opts;
- cpp_finish_options (pfile);
-
- /* A successful cpp_read_main_file guarantees that we can call
- cpp_scan_nooutput or cpp_get_token next. */
- if (options->no_output)
- {
- /* Scan -included buffers, then the main file. */
- while (pfile->buffer->prev)
- cpp_scan_nooutput (pfile);
- cpp_scan_nooutput (pfile);
- }
- else if (options->traditional)
- scan_translation_unit_trad (pfile);
- else
- scan_translation_unit (pfile);
-
- /* -dM command line option. Should this be in cpp_finish? */
- if (options->dump_macros == dump_only)
- cpp_forall_identifiers (pfile, dump_macro, NULL);
- }
-
- /* Flush any pending output. */
- if (pfile->print.printed)
- putc ('\n', pfile->print.outf);
-}
-
-/* Set up the callbacks as appropriate. */
-static void
-setup_callbacks (pfile)
- cpp_reader *pfile;
-{
- cpp_options *options = &pfile->opts;
- cpp_callbacks *cb = cpp_get_callbacks (pfile);
-
- if (! options->no_output)
- {
- cb->line_change = cb_line_change;
- /* Don't emit #pragma or #ident directives if we are processing
- assembly language; the assembler may choke on them. */
- if (options->lang != CLK_ASM)
- {
- cb->ident = cb_ident;
- cb->def_pragma = cb_def_pragma;
- }
- if (! options->no_line_commands)
- cb->file_change = cb_file_change;
- }
-
- if (options->dump_includes)
- cb->include = cb_include;
-
- if (options->dump_macros == dump_names
- || options->dump_macros == dump_definitions)
- {
- cb->define = cb_define;
- cb->undef = cb_undef;
- }
-}
-
-/* Writes out the preprocessed file, handling spacing and paste
- avoidance issues. */
-static void
-scan_translation_unit (pfile)
- cpp_reader *pfile;
-{
- bool avoid_paste = false;
-
- pfile->print.source = NULL;
- for (;;)
- {
- const cpp_token *token = cpp_get_token (pfile);
-
- if (token->type == CPP_PADDING)
- {
- avoid_paste = true;
- if (pfile->print.source == NULL
- || (!(pfile->print.source->flags & PREV_WHITE)
- && token->val.source == NULL))
- pfile->print.source = token->val.source;
- continue;
- }
-
- if (token->type == CPP_EOF)
- break;
-
- /* Subtle logic to output a space if and only if necessary. */
- if (avoid_paste)
- {
- if (pfile->print.source == NULL)
- pfile->print.source = token;
- if (pfile->print.source->flags & PREV_WHITE
- || (pfile->print.prev
- && cpp_avoid_paste (pfile, pfile->print.prev, token))
- || (pfile->print.prev == NULL && token->type == CPP_HASH))
- putc (' ', pfile->print.outf);
- }
- else if (token->flags & PREV_WHITE)
- putc (' ', pfile->print.outf);
-
- avoid_paste = false;
- pfile->print.source = NULL;
- pfile->print.prev = token;
- cpp_output_token (token, pfile->print.outf);
-
- if (token->type == CPP_COMMENT
- /* SDCC _asm specific */
- || token->type == CPP_ASM)
- account_for_newlines (pfile, token->val.str.text, token->val.str.len);
- }
-}
-
-/* Adjust pfile->print.line for newlines embedded in output. */
-static void
-account_for_newlines (pfile, str, len)
- cpp_reader *pfile;
- const uchar *str;
- size_t len;
-{
- while (len--)
- if (*str++ == '\n')
- pfile->print.line++;
-}
-
-/* Writes out a traditionally preprocessed file. */
-static void
-scan_translation_unit_trad (pfile)
- cpp_reader *pfile;
-{
- while (_cpp_read_logical_line_trad (pfile))
- {
- size_t len = pfile->out.cur - pfile->out.base;
- maybe_print_line (pfile, pfile->print.map, pfile->out.first_line);
- fwrite (pfile->out.base, 1, len, pfile->print.outf);
- pfile->print.printed = 1;
- if (!CPP_OPTION (pfile, discard_comments))
- account_for_newlines (pfile, pfile->out.base, len);
- }
-}
-
-/* If the token read on logical line LINE needs to be output on a
- different line to the current one, output the required newlines or
- a line marker, and return 1. Otherwise return 0. */
-static void
-maybe_print_line (pfile, map, line)
- cpp_reader *pfile;
- const struct line_map *map;
- unsigned int line;
-{
- /* End the previous line of text. */
- if (pfile->print.printed)
- {
- putc ('\n', pfile->print.outf);
- pfile->print.line++;
- pfile->print.printed = 0;
- }
-
- if (line >= pfile->print.line && line < pfile->print.line + 8)
- {
- while (line > pfile->print.line)
- {
- putc ('\n', pfile->print.outf);
- pfile->print.line++;
- }
- }
- else
- print_line (pfile, map, line, "");
-}
-
-/* Output a line marker for logical line LINE. Special flags are "1"
- or "2" indicating entering or leaving a file. */
-static void
-print_line (pfile, map, line, special_flags)
- cpp_reader *pfile;
- const struct line_map *map;
- unsigned int line;
- const char *special_flags;
-{
- /* End any previous line of text. */
- if (pfile->print.printed)
- putc ('\n', pfile->print.outf);
- pfile->print.printed = 0;
-
- pfile->print.line = line;
- if (! CPP_OPTION (pfile, no_line_commands))
- {
- size_t to_file_len = strlen (map->to_file);
- unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1);
- unsigned char *p;
-
- /* cpp_quote_string does not nul-terminate, so we have to do it
- ourselves. */
- p = cpp_quote_string (to_file_quoted,
- (unsigned char *)map->to_file, to_file_len);
- *p = '\0';
- fprintf (pfile->print.outf, "# %u \"%s\"%s",
- SOURCE_LINE (map, pfile->print.line),
- to_file_quoted, special_flags);
-
- if (map->sysp == 2)
- fputs (" 3 4", pfile->print.outf);
- else if (map->sysp == 1)
- fputs (" 3", pfile->print.outf);
-
- putc ('\n', pfile->print.outf);
- }
-}
-
-/* Called when a line of output is started. TOKEN is the first token
- of the line, and at end of file will be CPP_EOF. */
-static void
-cb_line_change (pfile, token, parsing_args)
- cpp_reader *pfile;
- const cpp_token *token;
- int parsing_args;
-{
- if (token->type == CPP_EOF || parsing_args)
- return;
-
- maybe_print_line (pfile, pfile->print.map, token->line);
- pfile->print.prev = 0;
- pfile->print.source = 0;
-
- /* Supply enough spaces to put this token in its original column,
- one space per column greater than 2, since scan_translation_unit
- will provide a space if PREV_WHITE. Don't bother trying to
- reconstruct tabs; we can't get it right in general, and nothing
- ought to care. Some things do care; the fault lies with them. */
- if (!CPP_OPTION (pfile, traditional))
- {
- pfile->print.printed = 1;
- if (token->col > 2)
- {
- unsigned int spaces = token->col - 2;
-
- while (spaces--)
- putc (' ', pfile->print.outf);
- }
- }
-}
-
-static void
-cb_ident (pfile, line, str)
- cpp_reader *pfile;
- unsigned int line;
- const cpp_string * str;
-{
- maybe_print_line (pfile, pfile->print.map, line);
- fprintf (pfile->print.outf, "#ident \"%s\"\n", str->text);
- pfile->print.line++;
-}
-
-static void
-cb_define (pfile, line, node)
- cpp_reader *pfile;
- unsigned int line;
- cpp_hashnode *node;
-{
- maybe_print_line (pfile, pfile->print.map, line);
- fputs ("#define ", pfile->print.outf);
-
- /* -dD command line option. */
- if (CPP_OPTION (pfile, dump_macros) == dump_definitions)
- fputs ((const char *) cpp_macro_definition (pfile, node),
- pfile->print.outf);
- else
- fputs ((const char *) NODE_NAME (node), pfile->print.outf);
-
- putc ('\n', pfile->print.outf);
- pfile->print.line++;
-}
-
-static void
-cb_undef (pfile, line, node)
- cpp_reader *pfile;
- unsigned int line;
- cpp_hashnode *node;
-{
- maybe_print_line (pfile, pfile->print.map, line);
- fprintf (pfile->print.outf, "#undef %s\n", NODE_NAME (node));
- pfile->print.line++;
-}
-
-static void
-cb_include (pfile, line, dir, header)
- cpp_reader *pfile;
- unsigned int line;
- const unsigned char *dir;
- const cpp_token *header;
-{
- maybe_print_line (pfile, pfile->print.map, line);
- fprintf (pfile->print.outf, "#%s %s\n", dir,
- cpp_token_as_text (pfile, header));
- pfile->print.line++;
-}
-
-/* The file name, line number or system header flags have changed, as
- described in MAP. From this point on, the old pfile->print.map might be
- pointing to freed memory, and so must not be dereferenced. */
-
-static void
-cb_file_change (pfile, map)
- cpp_reader *pfile;
- const struct line_map *map;
-{
- const char *flags = "";
-
- /* First time? */
- if (pfile->print.map == NULL)
- {
- /* Avoid printing foo.i when the main file is foo.c. */
- if (!CPP_OPTION (pfile, preprocessed))
- print_line (pfile, map, map->from_line, flags);
- }
- else
- {
- /* Bring current file to correct line when entering a new file. */
- if (map->reason == LC_ENTER)
- maybe_print_line (pfile, map - 1, map->from_line - 1);
-
- if (map->reason == LC_ENTER)
- flags = " 1";
- else if (map->reason == LC_LEAVE)
- flags = " 2";
- print_line (pfile, map, map->from_line, flags);
- }
-
- pfile->print.map = map;
-}
-
-/* Copy a #pragma directive to the preprocessed output. */
-static void
-cb_def_pragma (pfile, line)
- cpp_reader *pfile;
- unsigned int line;
-{
- maybe_print_line (pfile, pfile->print.map, line);
- fputs ("#pragma ", pfile->print.outf);
- cpp_output_line (pfile, pfile->print.outf);
- pfile->print.line++;
-}
-
-/* Dump out the hash table. */
-static int
-dump_macro (pfile, node, v)
- cpp_reader *pfile;
- cpp_hashnode *node;
- void *v ATTRIBUTE_UNUSED;
-{
- if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
- {
- fputs ("#define ", pfile->print.outf);
- fputs ((const char *) cpp_macro_definition (pfile, node),
- pfile->print.outf);
- putc ('\n', pfile->print.outf);
- pfile->print.line++;
- }
-
- return 1;
-}
#else /* VMS || _WIN32 && !__CYGWIN__ */
#if defined(_WIN32)
+#if defined(__BORLANDC__)
+#include <dir.h>
+#else
#include <direct.h>
#define getcwd _getcwd
#endif
+#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 255
+++ /dev/null
-/* Multibyte Character Functions.
- Copyright (C) 1998 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC 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.
-
-GCC 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 GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
-
-/* Note regarding cross compilation:
-
- In general, translation of multibyte characters to wide characters can
- only work in a native compiler since the translation function (mbtowc)
- needs to know about both the source and target character encoding. However,
- this particular implementation for JIS, SJIS and EUCJP source characters
- will work for any compiler with a newlib target. Other targets may also
- work provided that their wchar_t implementation is 2 bytes and the encoding
- leaves the source character values unchanged (except for removing the
- state shifting markers). */
-
-#include "config.h"
-#ifdef MULTIBYTE_CHARS
-#include "system.h"
-#include "mbchar.h"
-#include <locale.h>
-
-typedef enum {ESCAPE, DOLLAR, BRACKET, AT, B, J, NUL, JIS_CHAR, OTHER,
- JIS_C_NUM} JIS_CHAR_TYPE;
-
-typedef enum {ASCII, A_ESC, A_ESC_DL, JIS, JIS_1, JIS_2, J_ESC, J_ESC_BR,
- J2_ESC, J2_ESC_BR, INV, JIS_S_NUM} JIS_STATE;
-
-typedef enum {COPYA, COPYJ, COPYJ2, MAKE_A, MAKE_J, NOOP,
- EMPTY, ERROR} JIS_ACTION;
-
-/* State/action tables for processing JIS encoding:
-
- Where possible, switches to JIS are grouped with proceding JIS characters
- and switches to ASCII are grouped with preceding JIS characters.
- Thus, maximum returned length is:
- 2 (switch to JIS) + 2 (JIS characters) + 2 (switch back to ASCII) = 6. */
-
-static const JIS_STATE JIS_state_table[JIS_S_NUM][JIS_C_NUM] = {
-/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTH*/
-/*ASCII*/ { A_ESC, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII,ASCII,ASCII},
-/*A_ESC*/ { ASCII, A_ESC_DL,ASCII, ASCII, ASCII, ASCII, ASCII,ASCII,ASCII},
-/*A_ESC_DL*/{ ASCII, ASCII, ASCII, JIS, JIS, ASCII, ASCII,ASCII,ASCII},
-/*JIS*/ { J_ESC, JIS_1, JIS_1, JIS_1, JIS_1, JIS_1, INV, JIS_1,INV },
-/*JIS_1*/ { INV, JIS_2, JIS_2, JIS_2, JIS_2, JIS_2, INV, JIS_2,INV },
-/*JIS_2*/ { J2_ESC,JIS, JIS, JIS, JIS, JIS, INV, JIS, JIS },
-/*J_ESC*/ { INV, INV, J_ESC_BR, INV, INV, INV, INV, INV, INV },
-/*J_ESC_BR*/{ INV, INV, INV, INV, ASCII, ASCII, INV, INV, INV },
-/*J2_ESC*/ { INV, INV, J2_ESC_BR,INV, INV, INV, INV, INV, INV },
-/*J2_ESC_BR*/{INV, INV, INV, INV, ASCII, ASCII, INV, INV, INV },
-};
-
-static const JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = {
-/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTH */
-/*ASCII */ {NOOP, COPYA, COPYA, COPYA, COPYA, COPYA, EMPTY, COPYA, COPYA},
-/*A_ESC */ {COPYA, NOOP, COPYA, COPYA, COPYA, COPYA, COPYA, COPYA, COPYA},
-/*A_ESC_DL */{COPYA, COPYA, COPYA, MAKE_J, MAKE_J, COPYA, COPYA, COPYA, COPYA},
-/*JIS */ {NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, ERROR, NOOP, ERROR},
-/*JIS_1 */ {ERROR, NOOP, NOOP, NOOP, NOOP, NOOP, ERROR, NOOP, ERROR},
-/*JIS_2 */ {NOOP, COPYJ2,COPYJ2,COPYJ2, COPYJ2, COPYJ2,ERROR, COPYJ2,COPYJ2},
-/*J_ESC */ {ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR},
-/*J_ESC_BR */{ERROR, ERROR, ERROR, ERROR, NOOP, NOOP, ERROR, ERROR, ERROR},
-/*J2_ESC */ {ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR},
-/*J2_ESC_BR*/{ERROR, ERROR, ERROR, ERROR, COPYJ, COPYJ, ERROR, ERROR, ERROR},
-};
-
-
-const char *literal_codeset = NULL;
-
-/* Store into *PWC (if PWC is not null) the wide character
- corresponding to the multibyte character at the start of the
- buffer S of size N. Return the number of bytes in the multibyte
- character. Return -1 if the bytes do not form a valid character,
- or 0 if S is null or points to a null byte.
-
- This function behaves like the Standard C function mbtowc, except
- it treats locale names of the form "C-..." specially. */
-
-int
-local_mbtowc (pwc, s, n)
- wchar_t *pwc;
- const char *s;
- size_t n;
-{
- static JIS_STATE save_state = ASCII;
- JIS_STATE curr_state = save_state;
- const unsigned char *t = (const unsigned char *) s;
-
- if (s != NULL && n == 0)
- return -1;
-
- if (literal_codeset == NULL || strlen (literal_codeset) <= 1)
- /* This must be the "C" locale or unknown locale -- fall thru */
- ;
- else if (! strcmp (literal_codeset, "C-SJIS"))
- {
- int char1;
- if (s == NULL)
- /* Not state-dependent. */
- return 0;
-
- char1 = *t;
- if (ISSJIS1 (char1))
- {
- int char2 = t[1];
-
- if (n <= 1)
- return -1;
-
- if (ISSJIS2 (char2))
- {
- if (pwc != NULL)
- *pwc = (((wchar_t) *t) << 8) + (wchar_t) (*(t + 1));
- return 2;
- }
-
- return -1;
- }
-
- if (pwc != NULL)
- *pwc = (wchar_t) *t;
-
- if (*t == '\0')
- return 0;
-
- return 1;
- }
- else if (! strcmp (literal_codeset, "C-EUCJP"))
- {
- int char1;
-
- if (s == NULL)
- /* Not state-dependent. */
- return 0;
-
- char1 = *t;
- if (ISEUCJP (char1))
- {
- int char2 = t[1];
-
- if (n <= 1)
- return -1;
-
- if (ISEUCJP (char2))
- {
- if (pwc != NULL)
- *pwc = (((wchar_t) *t) << 8) + (wchar_t) (*(t + 1));
- return 2;
- }
-
- return -1;
- }
-
- if (pwc != NULL)
- *pwc = (wchar_t) *t;
-
- if (*t == '\0')
- return 0;
-
- return 1;
- }
- else if (! strcmp (literal_codeset, "C-JIS"))
- {
- JIS_ACTION action;
- JIS_CHAR_TYPE ch;
- const unsigned char *ptr;
- size_t i, curr_ch;
-
- if (s == NULL)
- {
- save_state = ASCII;
- /* State-dependent. */
- return 1;
- }
-
- ptr = t;
-
- for (i = 0; i < n; i++)
- {
- curr_ch = t[i];
- switch (curr_ch)
- {
- case JIS_ESC_CHAR:
- ch = ESCAPE;
- break;
- case '$':
- ch = DOLLAR;
- break;
- case '@':
- ch = AT;
- break;
- case '(':
- ch = BRACKET;
- break;
- case 'B':
- ch = B;
- break;
- case 'J':
- ch = J;
- break;
- case '\0':
- ch = NUL;
- break;
- default:
- if (ISJIS (curr_ch))
- ch = JIS_CHAR;
- else
- ch = OTHER;
- }
-
- action = JIS_action_table[curr_state][ch];
- curr_state = JIS_state_table[curr_state][ch];
-
- switch (action)
- {
- case NOOP:
- break;
-
- case EMPTY:
- if (pwc != NULL)
- *pwc = (wchar_t) 0;
-
- save_state = curr_state;
- return i;
-
- case COPYA:
- if (pwc != NULL)
- *pwc = (wchar_t) *ptr;
- save_state = curr_state;
- return i + 1;
-
- case COPYJ:
- if (pwc != NULL)
- *pwc = (((wchar_t) *ptr) << 8) + (wchar_t) (*(ptr + 1));
-
- save_state = curr_state;
- return i + 1;
-
- case COPYJ2:
- if (pwc != NULL)
- *pwc = (((wchar_t) *ptr) << 8) + (wchar_t) (*(ptr + 1));
-
- save_state = curr_state;
- return ptr - t + 2;
-
- case MAKE_A:
- case MAKE_J:
- ptr = (const unsigned char *) (t + i + 1);
- break;
-
- case ERROR:
- default:
- return -1;
- }
- }
-
- /* More than n bytes needed. */
- return -1;
- }
-
-#ifdef CROSS_COMPILE
- if (s == NULL)
- /* Not state-dependent. */
- return 0;
-
- if (pwc != NULL)
- *pwc = *s;
- return 1;
-#else
-
- /* This must be the "C" locale or unknown locale. */
- return mbtowc (pwc, s, n);
-#endif
-}
-
-/* Return the number of bytes in the multibyte character at the start
- of the buffer S of size N. Return -1 if the bytes do not form a
- valid character, or 0 if S is null or points to a null byte.
-
- This function behaves like the Standard C function mblen, except
- it treats locale names of the form "C-..." specially. */
-
-int
-local_mblen (s, n)
- const char *s;
- size_t n;
-{
- return local_mbtowc (NULL, s, n);
-}
-
-/* Return the maximum mumber of bytes in a multibyte character.
-
- This function returns the same value as the Standard C macro MB_CUR_MAX,
- except it treats locale names of the form "C-..." specially. */
-
-int
-local_mb_cur_max ()
-{
- if (literal_codeset == NULL || strlen (literal_codeset) <= 1)
- ;
- else if (! strcmp (literal_codeset, "C-SJIS"))
- return 2;
- else if (! strcmp (literal_codeset, "C-EUCJP"))
- return 2;
- else if (! strcmp (literal_codeset, "C-JIS"))
- return 8; /* 3 + 2 + 3 */
-
-#ifdef CROSS_COMPILE
- return 1;
-#else
- if (MB_CUR_MAX > 0)
- return MB_CUR_MAX;
-
- return 1; /* default */
-#endif
-}
-#else /* MULTIBYTE_CHARS */
-extern int dummy; /* silence 'ANSI C forbids an empty source file' warning */
-#endif /* MULTIBYTE_CHARS */
+++ /dev/null
-/* Various declarations for functions found in mbchar.c
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC 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.
-
-GCC 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 GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
-
-#ifndef GCC_MBCHAR_H
-#define GCC_MBCHAR_H
-
-#ifdef MULTIBYTE_CHARS
-
-/* Escape character used for JIS encoding */
-#define JIS_ESC_CHAR 0x1b
-
-#define ISSJIS1(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xef))
-#define ISSJIS2(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc))
-#define ISEUCJP(c) ((c) >= 0xa1 && (c) <= 0xfe)
-#define ISJIS(c) ((c) >= 0x21 && (c) <= 0x7e)
-
-extern int local_mbtowc PARAMS ((wchar_t *, const char *, size_t));
-extern int local_mblen PARAMS ((const char *, size_t));
-extern int local_mb_cur_max PARAMS ((void));
-
-/* The locale being used for multibyte characters in string/char literals. */
-extern const char *literal_codeset;
-#endif /* MULTIBYTE_CHARS */
-#endif /* ! GCC_MBCHAR_H */
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\mbchar.c\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\mkdeps.c\r
# End Source File\r
# Begin Source File\r
#ifdef _WIN32
#include <string.h>
-#define strcasecmp _stricmp
+#define strcasecmp stricmp
#endif
#define BYTES_BIG_ENDIAN 0
-#if defined _MSC_VER || defined __MINGW32__
+#if defined _MSC_VER || defined __MINGW32__ || defined __BORLANDC__
/*
* The following define causes the following warning:
* warning: `I' flag used with `%x' printf format
/* Nonzero means pass #include lines through to the output. */
-char flag_dump_includes;
+extern char flag_dump_includes;
/* In c-ppoutput.c */
extern void init_pp_output (FILE *);