OSDN Git Service

Delete unused file.
[pf3gnuchains/gcc-fork.git] / gcc / cppcharset.c
index b38eea0..6b69fed 100644 (file)
@@ -92,7 +92,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #endif
 
 /* This structure is used for a resizable string buffer throughout.  */
-struct strbuf
+/* Don't call it strbuf, as that conflicts with unistd.h on systems
+   such as DYNIX/ptx where unistd.h includes stropts.h.  */
+struct _cpp_strbuf
 {
   uchar *text;
   size_t asize;
@@ -278,7 +280,7 @@ one_utf8_to_utf32 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
                   uchar **outbufp, size_t *outbytesleftp)
 {
   uchar *outbuf;
-  cppchar_t s;
+  cppchar_t s = 0;
   int rval;
 
   /* Check for space first, since we know exactly how much we need.  */
@@ -335,7 +337,7 @@ one_utf8_to_utf16 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
                   uchar **outbufp, size_t *outbytesleftp)
 {
   int rval;
-  cppchar_t s;
+  cppchar_t s = 0;
   const uchar *save_inbuf = *inbufp;
   size_t save_inbytesleft = *inbytesleftp;
   uchar *outbuf = *outbufp;
@@ -451,7 +453,7 @@ one_utf16_to_utf8 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
 static inline bool
 conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
                                             uchar **, size_t *),
-                iconv_t cd, const uchar *from, size_t flen, struct strbuf *to)
+                iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to)
 {
   const uchar *inbuf;
   uchar *outbuf;
@@ -492,7 +494,7 @@ conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
 /* These functions convert entire strings between character sets.
    They all have the signature
 
-   bool (*)(iconv_t cd, const uchar *from, size_t flen, struct strbuf *to);
+   bool (*)(iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to);
 
    The input string FROM is converted as specified by the function
    name plus the iconv descriptor CD (which may be fake), and the
@@ -501,28 +503,28 @@ conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
 /* These four use the custom conversion code above.  */
 static bool
 convert_utf8_utf16 (iconv_t cd, const uchar *from, size_t flen,
-                   struct strbuf *to)
+                   struct _cpp_strbuf *to)
 {
   return conversion_loop (one_utf8_to_utf16, cd, from, flen, to);
 }
 
 static bool
 convert_utf8_utf32 (iconv_t cd, const uchar *from, size_t flen,
-                   struct strbuf *to)
+                   struct _cpp_strbuf *to)
 {
   return conversion_loop (one_utf8_to_utf32, cd, from, flen, to);
 }
 
 static bool
 convert_utf16_utf8 (iconv_t cd, const uchar *from, size_t flen,
-                   struct strbuf *to)
+                   struct _cpp_strbuf *to)
 {
   return conversion_loop (one_utf16_to_utf8, cd, from, flen, to);
 }
 
 static bool
 convert_utf32_utf8 (iconv_t cd, const uchar *from, size_t flen,
-                   struct strbuf *to)
+                   struct _cpp_strbuf *to)
 {
   return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);
 }
@@ -530,7 +532,7 @@ convert_utf32_utf8 (iconv_t cd, const uchar *from, size_t flen,
 /* Identity conversion, used when we have no alternative.  */
 static bool
 convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
-                      const uchar *from, size_t flen, struct strbuf *to)
+                      const uchar *from, size_t flen, struct _cpp_strbuf *to)
 {
   if (to->len + flen > to->asize)
     {
@@ -547,7 +549,7 @@ convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
 #if HAVE_ICONV
 static bool
 convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
-                    struct strbuf *to)
+                    struct _cpp_strbuf *to)
 {
   ICONV_CONST char *inbuf;
   char *outbuf;
@@ -647,18 +649,18 @@ init_iconv_desc (cpp_reader *pfile, const char *to, const char *from)
       if (ret.cd == (iconv_t) -1)
        {
          if (errno == EINVAL)
-           cpp_error (pfile, DL_ERROR, /* XXX should be DL_SORRY */
+           cpp_error (pfile, CPP_DL_ERROR, /* XXX should be DL_SORRY */
                       "conversion from %s to %s not supported by iconv",
                       from, to);
          else
-           cpp_errno (pfile, DL_ERROR, "iconv_open");
+           cpp_errno (pfile, CPP_DL_ERROR, "iconv_open");
 
          ret.func = convert_no_conversion;
        }
     }
   else
     {
-      cpp_error (pfile, DL_ERROR, /* XXX should be DL_SORRY */
+      cpp_error (pfile, CPP_DL_ERROR, /* XXX should be DL_SORRY */
                 "no iconv implementation, cannot convert from %s to %s",
                 from, to);
       ret.func = convert_no_conversion;
@@ -802,10 +804,10 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
   const uchar *base = str - 2;
 
   if (!CPP_OPTION (pfile, cplusplus) && !CPP_OPTION (pfile, c99))
-    cpp_error (pfile, DL_WARNING,
+    cpp_error (pfile, CPP_DL_WARNING,
               "universal character names are only valid in C++ and C99");
   else if (CPP_WTRADITIONAL (pfile) && identifier_pos == 0)
-    cpp_error (pfile, DL_WARNING,
+    cpp_error (pfile, CPP_DL_WARNING,
               "the meaning of '\\%c' is different in traditional C",
               (int) str[-1]);
 
@@ -831,7 +833,8 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
   if (length)
     {
       /* We'll error when we try it out as the start of an identifier.  */
-      cpp_error (pfile, DL_ERROR, "incomplete universal character name %.*s",
+      cpp_error (pfile, CPP_DL_ERROR,
+                "incomplete universal character name %.*s",
                 (int) (str - base), base);
       result = 1;
     }
@@ -842,7 +845,8 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
           || (result & 0x80000000)
           || (result >= 0xD800 && result <= 0xDFFF))
     {
-      cpp_error (pfile, DL_ERROR, "%.*s is not a valid universal character",
+      cpp_error (pfile, CPP_DL_ERROR,
+                "%.*s is not a valid universal character",
                 (int) (str - base), base);
       result = 1;
     }
@@ -851,11 +855,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
       int validity = ucn_valid_in_identifier (pfile, result);
 
       if (validity == 0)
-       cpp_error (pfile, DL_ERROR,
+       cpp_error (pfile, CPP_DL_ERROR,
                   "universal character %.*s is not valid in an identifier",
                   (int) (str - base), base);
       else if (validity == 2 && identifier_pos == 1)
-       cpp_error (pfile, DL_ERROR,
+       cpp_error (pfile, CPP_DL_ERROR,
    "universal character %.*s is not valid at the start of an identifier",
                   (int) (str - base), base);
     }
@@ -873,7 +877,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
 
 static const uchar *
 convert_ucn (cpp_reader *pfile, const uchar *from, const uchar *limit,
-            struct strbuf *tbuf, bool wide)
+            struct _cpp_strbuf *tbuf, bool wide)
 {
   cppchar_t ucn;
   uchar buf[6];
@@ -890,17 +894,19 @@ convert_ucn (cpp_reader *pfile, const uchar *from, const uchar *limit,
   if (rval)
     {
       errno = rval;
-      cpp_errno (pfile, DL_ERROR, "converting UCN to source character set");
+      cpp_errno (pfile, CPP_DL_ERROR,
+                "converting UCN to source character set");
     }
   else if (!APPLY_CONVERSION (cvt, buf, 6 - bytesleft, tbuf))
-    cpp_errno (pfile, DL_ERROR, "converting UCN to execution character set");
+    cpp_errno (pfile, CPP_DL_ERROR,
+              "converting UCN to execution character set");
 
   return from;
 }
 
 static void
 emit_numeric_escape (cpp_reader *pfile, cppchar_t n,
-                    struct strbuf *tbuf, bool wide)
+                    struct _cpp_strbuf *tbuf, bool wide)
 {
   if (wide)
     {
@@ -948,7 +954,7 @@ emit_numeric_escape (cpp_reader *pfile, cppchar_t n,
    number.  You can, e.g. generate surrogate pairs this way.  */
 static const uchar *
 convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
-            struct strbuf *tbuf, bool wide)
+            struct _cpp_strbuf *tbuf, bool wide)
 {
   cppchar_t c, n = 0, overflow = 0;
   int digits_found = 0;
@@ -957,7 +963,7 @@ convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
   size_t mask = width_to_mask (width);
 
   if (CPP_WTRADITIONAL (pfile))
-    cpp_error (pfile, DL_WARNING,
+    cpp_error (pfile, CPP_DL_WARNING,
               "the meaning of '\\x' is different in traditional C");
 
   from++;  /* skip 'x' */
@@ -974,14 +980,14 @@ convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
 
   if (!digits_found)
     {
-      cpp_error (pfile, DL_ERROR,
+      cpp_error (pfile, CPP_DL_ERROR,
                 "\\x used with no following hex digits");
       return from;
     }
 
   if (overflow | (n != (n & mask)))
     {
-      cpp_error (pfile, DL_PEDWARN,
+      cpp_error (pfile, CPP_DL_PEDWARN,
                 "hex escape sequence out of range");
       n &= mask;
     }
@@ -999,7 +1005,7 @@ convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
    number.  */
 static const uchar *
 convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
-            struct strbuf *tbuf, bool wide)
+            struct _cpp_strbuf *tbuf, bool wide)
 {
   size_t count = 0;
   cppchar_t c, n = 0;
@@ -1020,7 +1026,7 @@ convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
 
   if (n != (n & mask))
     {
-      cpp_error (pfile, DL_PEDWARN,
+      cpp_error (pfile, CPP_DL_PEDWARN,
                 "octal escape sequence out of range");
       n &= mask;
     }
@@ -1036,7 +1042,7 @@ convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
    pointer.  Handles all relevant diagnostics.  */
 static const uchar *
 convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
-               struct strbuf *tbuf, bool wide)
+               struct _cpp_strbuf *tbuf, bool wide)
 {
   /* Values of \a \b \e \f \n \r \t \v respectively.  */
 #if HOST_CHARSET == HOST_CHARSET_ASCII
@@ -1088,14 +1094,14 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
 
     case 'a':
       if (CPP_WTRADITIONAL (pfile))
-       cpp_error (pfile, DL_WARNING,
+       cpp_error (pfile, CPP_DL_WARNING,
                   "the meaning of '\\a' is different in traditional C");
       c = charconsts[0];
       break;
 
     case 'e': case 'E':
       if (CPP_PEDANTIC (pfile))
-       cpp_error (pfile, DL_PEDWARN,
+       cpp_error (pfile, CPP_DL_PEDWARN,
                   "non-ISO-standard escape sequence, '\\%c'", (int) c);
       c = charconsts[2];
       break;
@@ -1103,16 +1109,16 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
     default:
     unknown:
       if (ISGRAPH (c))
-       cpp_error (pfile, DL_PEDWARN,
+       cpp_error (pfile, CPP_DL_PEDWARN,
                   "unknown escape sequence '\\%c'", (int) c);
       else
-       cpp_error (pfile, DL_PEDWARN,
+       cpp_error (pfile, CPP_DL_PEDWARN,
                   "unknown escape sequence: '\\%03o'", (int) c);
     }
 
   /* Now convert what we have to the execution character set.  */
   if (!APPLY_CONVERSION (cvt, &c, 1, tbuf))
-    cpp_errno (pfile, DL_ERROR,
+    cpp_errno (pfile, CPP_DL_ERROR,
               "converting escape sequence to execution character set");
 
   return from + 1;
@@ -1128,7 +1134,7 @@ bool
 cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
                      cpp_string *to, bool wide)
 {
-  struct strbuf tbuf;
+  struct _cpp_strbuf tbuf;
   const uchar *p, *base, *limit;
   size_t i;
   struct cset_converter cvt
@@ -1172,7 +1178,7 @@ cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
   return true;
 
  fail:
-  cpp_errno (pfile, DL_ERROR, "converting to execution character set");
+  cpp_errno (pfile, CPP_DL_ERROR, "converting to execution character set");
   free (tbuf.text);
   return false;
 }
@@ -1234,10 +1240,11 @@ narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
   if (i > max_chars)
     {
       i = max_chars;
-      cpp_error (pfile, DL_WARNING, "character constant too long for its type");
+      cpp_error (pfile, CPP_DL_WARNING,
+                "character constant too long for its type");
     }
   else if (i > 1 && CPP_OPTION (pfile, warn_multichar))
-    cpp_error (pfile, DL_WARNING, "multi-character character constant");
+    cpp_error (pfile, CPP_DL_WARNING, "multi-character character constant");
 
   /* Multichar constants are of type int and therefore signed.  */
   if (i > 1)
@@ -1296,7 +1303,8 @@ wide_str_to_charconst (cpp_reader *pfile, cpp_string str,
      character exactly fills a wchar_t, so a multi-character wide
      character constant is guaranteed to overflow.  */
   if (off > 0)
-    cpp_error (pfile, DL_WARNING, "character constant too long for its type");
+    cpp_error (pfile, CPP_DL_WARNING,
+              "character constant too long for its type");
 
   /* Truncate the constant to its natural width, and simultaneously
      sign- or zero-extend to the full width of cppchar_t.  */
@@ -1328,7 +1336,7 @@ cpp_interpret_charconst (cpp_reader *pfile, const cpp_token *token,
   /* an empty constant will appear as L'' or '' */
   if (token->val.str.len == (size_t) (2 + wide))
     {
-      cpp_error (pfile, DL_ERROR, "empty character constant");
+      cpp_error (pfile, CPP_DL_ERROR, "empty character constant");
       return 0;
     }
   else if (!cpp_interpret_string (pfile, &token->val.str, 1, &str, wide))