This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] RFA: -finput-charset support


Here's the final patch to add input character set support into gcc. It
fixes a few regressions (PR 11439) so I'd like to put it into 3.4 as
well (since the first patch was also in there and this is finishing up
that work and fixing it as well).

Bootstrapped and regression tested on x86-linux with a few different
environments/command lines.

-eric

-- 
Eric Christopher <echristo@redhat.com>

gcc/ChangeLog
2004-01-29  Eric Christopher  <echristo@redhat.com>
	    Zack Weinberg  <zack@codesourcery.com>

	c-opts.c (c_common_handle_option): Add -finput-charset.
	c.opt: Ditto.
	cppcharset.c (one_iso88591_to_utf8): Remove.
	(convert_iso88591_utf8): Ditto.
	(conversion_tab): Remove 8859-1 converter.
	(_cpp_input_to_utf8): Remove.
	(_cpp_init_iconv_buffer): Ditto.
	(_cpp_close_iconv_buffer): Ditto.
	(_cpp_convert_input): New function.
	(_cpp_default_encoding): Ditto.
	cpphash.h: Add/remove prototypes for above.
	cppfiles.c (read_file_guts): Use _cpp_convert_input.
	cppinit.c (cpp_create_reader): Use _cpp_default_encoding
	for narrow execution and input character sets.
	cpplib.c (cpp_push_buffer): Delete uses of removed functions.
	doc/cppopts.texi: Document -finput-charset.

gcc/testsuite/ChangeLog
2004-01-29 Eric Christopher  <echristo@redhat.com>
	   Zack Weinberg  <zack@codesourcery.com>

	gcc.c-torture/execute/wchar_t-1.c: Add -finput-charset.
	
libstdc++/testsuite/ChangeLog

2004-01-29  Eric Christopher  <echristo@redhat.com>
	    Zack Weinberg  <zack@codesourcery.com>

	22_locale/collate/compare/wchar_t/2.cc: Remove xfail. Use
	-finput-charset.
	22_locale/collate/compare/wchar_t/wrapped_env.cc: Ditto.
	22_locale/collate/compare/wchar_t/wrapped_locale.cc: Ditto.
	22_locale/collate/hash/wchar_t/2.cc: Ditto.
	22_locale/collate/hash/wchar_t/wrapped_env.cc: Ditto.
	22_locale/collate/hash/wchar_t/wrapped_locale.cc: Ditto.
	22_locale/collate/transform/wchar_t/2.cc: Ditto.
	22_locale/collate/transform/wchar_t/wrapped_env.cc: Ditto.
	22_locale/collate/transform/wchar_t/wrapped_locale.cc: Ditto.
	
? fastjar/fastjar.info
? fastjar/grepjar.1
? fastjar/jar.1
? gcc/ada/gnat-style.info
? gcc/ada/gnat_rm.info
? gcc/ada/gnat_rm.info-1
? gcc/ada/gnat_ug_unx.info
? gcc/ada/gnat_ug_unx.info-1
? gcc/ada/gnat_ug_vms.info
? gcc/ada/gnat_ug_vms.info-1
? gcc/ada/gnat_ug_vxw.info
? gcc/ada/gnat_ug_vxw.info-1
? gcc/ada/gnat_ug_wnt.info
? gcc/ada/gnat_ug_wnt.info-1
? gcc/doc/cpp.1
? gcc/doc/cpp.info
? gcc/doc/cpp.info-1
? gcc/doc/cppinternals.info
? gcc/doc/fsf-funding.7
? gcc/doc/gcc.1
? gcc/doc/gcc.info
? gcc/doc/gcc.info-1
? gcc/doc/gccinstall.info
? gcc/doc/gccinstall.info-1
? gcc/doc/gccint.info
? gcc/doc/gccint.info-1
? gcc/doc/gcov.1
? gcc/doc/gfdl.7
? gcc/doc/gpl.7
? gcc/f/g77.1
? gcc/f/g77.info
? gcc/f/g77.info-1
Index: gcc/c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.98
diff -c -r1.98 c-opts.c
*** gcc/c-opts.c	21 Jan 2004 20:39:51 -0000	1.98
--- gcc/c-opts.c	29 Jan 2004 23:01:56 -0000
***************
*** 904,909 ****
--- 904,913 ----
        cpp_opts->wide_charset = arg;
        break;
  
+     case OPT_finput_charset_:
+       cpp_opts->input_charset = arg;
+       break;
+ 
      case OPT_ftemplate_depth_:
        max_tinst_depth = value;
        break;
Index: gcc/c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.17
diff -c -r1.17 c.opt
*** gcc/c.opt	25 Sep 2003 01:25:50 -0000	1.17
--- gcc/c.opt	29 Jan 2004 23:01:56 -0000
***************
*** 482,487 ****
--- 482,492 ----
  C ObjC C++ ObjC++ Joined RejectNegative
  -fexec-charset=<cset>	Convert all strings and character constants to character set <cset>
  
+ finput-charset=
+ C ObjC C++ ObjC++ Joined RejectNegative
+ -finput-charset=<cset>      Specify the default character set for source files.
+ 
+ 
  fexternal-templates
  C++ ObjC++
  
Index: gcc/cppcharset.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppcharset.c,v
retrieving revision 1.19
diff -c -r1.19 cppcharset.c
*** gcc/cppcharset.c	21 Jan 2004 20:39:52 -0000	1.19
--- gcc/cppcharset.c	29 Jan 2004 23:01:56 -0000
***************
*** 446,476 ****
    return 0;
  }
  
- /* The first 256 code points of ISO 8859.1 have the same numeric
-    values as the first 256 code points of Unicode, therefore the
-    incoming ISO 8859.1 character can be passed directly to
-    one_cppchar_to_utf8 (which expects a Unicode value).  */
- 
- static int
- one_iso88591_to_utf8 (iconv_t bigend ATTRIBUTE_UNUSED, const uchar **inbufp,
- 		      size_t *inbytesleftp, uchar **outbufp, size_t *outbytesleftp)
- {
-   const uchar *inbuf = *inbufp;
-   int rval;
- 
-   if (*inbytesleftp > 1)
-     return EINVAL;
- 
-   rval = one_cppchar_to_utf8 ((cppchar_t)*inbuf, outbufp, outbytesleftp);
-   if (rval)
-     return rval;
- 
-   *inbufp += 1;
-   *inbytesleftp -= 1;
- 
-   return 0;
- }
- 
  /* Helper routine for the next few functions.  The 'const' on
     one_conversion means that we promise not to modify what function is
     pointed to, which lets the inliner see through it.  */
--- 446,451 ----
***************
*** 554,567 ****
    return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);
  }
  
- static bool
- convert_iso88591_utf8 (iconv_t cd, const uchar *from, size_t flen,
-                        struct _cpp_strbuf *to)
- {
-   return conversion_loop (one_iso88591_to_utf8, cd, from, flen, to);
- }
- 
- 
  /* Identity conversion, used when we have no alternative.  */
  static bool
  convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
--- 529,534 ----
***************
*** 639,645 ****
    { "UTF-32BE/UTF-8", convert_utf32_utf8, (iconv_t)1 },
    { "UTF-16LE/UTF-8", convert_utf16_utf8, (iconv_t)0 },
    { "UTF-16BE/UTF-8", convert_utf16_utf8, (iconv_t)1 },
-   { "ISO-8859-1/UTF-8", convert_iso88591_utf8, (iconv_t)0 },
  };
  
  /* Subroutine of cpp_init_iconv: initialize and return a
--- 606,611 ----
***************
*** 1388,1431 ****
  }
  
  uchar *
! _cpp_input_to_utf8 (cpp_reader *pfile, const uchar *input, cppchar_t length)
  {
!   struct _cpp_strbuf tbuf;
!   struct cset_converter cvt = pfile->buffer->input_cset_desc;
  
!   tbuf.asize = MAX (OUTBUF_BLOCK_SIZE, length);
!   tbuf.text = xmalloc (tbuf.asize);
!   tbuf.len = 0;
  
!   if (!APPLY_CONVERSION (cvt, input, length, &tbuf))
!    {
!       cpp_error (pfile, CPP_DL_ERROR, "converting input to source character set.");
!       return NULL;
!    }
  
!   if (length)
!     tbuf.text[tbuf.len] = '\n';
!   else
!     tbuf.text[0] = '\n';
  
!   return tbuf.text;
! }
  
!   /* Check the input file format. At present assuming the input file
!      is in iso-8859-1 format. Convert this input character set to
!      source character set format (UTF-8). */
  
! void
! _cpp_init_iconv_buffer (cpp_reader *pfile, const char *from)
! {
!   pfile->buffer->input_cset_desc = init_iconv_desc (pfile, SOURCE_CHARSET,
! 						    from);
  }
  
! void
! _cpp_close_iconv_buffer (cpp_reader *pfile)
  {
!   if (HAVE_ICONV
!       && pfile->buffer->input_cset_desc.func == convert_using_iconv)
!     iconv_close (pfile->buffer->input_cset_desc.cd);
  }
--- 1354,1411 ----
  }
  
  uchar *
! _cpp_convert_input (cpp_reader *pfile, const char *input_charset,
! 		    uchar *input, size_t size, size_t len, off_t *st_size)
  {
!   struct cset_converter input_cset;
!   struct _cpp_strbuf to;
  
!   input_cset = init_iconv_desc (pfile, SOURCE_CHARSET, input_charset);
!   if (input_cset.func == convert_no_conversion)
!     {
!       to.text = input;
!       to.asize = size;
!       to.len = len;
!     }
!   else
!     {
!       to.asize = MAX (65536, len);
!       to.text = xmalloc (to.asize);
!       to.len = 0;
  
!       if (!APPLY_CONVERSION (input_cset, input, len, &to))
! 	cpp_error (pfile, CPP_DL_ERROR,
! 		   "failure to convert %s to %s",
! 		   CPP_OPTION (pfile, input_charset), SOURCE_CHARSET);
  
!       free (input);
!     }
  
!   /* Clean up the mess.  */
!   if (input_cset.func == convert_using_iconv)
!     iconv_close (input_cset.cd);
  
!   /* Resize buffer if we allocated substantially too much, or if we
!      haven't enough space for the \n-terminator.  */
!   if (to.len + 4096 < to.asize || to.len >= to.asize)
!     to.text = xrealloc (to.text, to.len + 1);
  
!   to.text[to.len] = '\n';
!   *st_size = to.len;
!   return to.text;
  }
  
! const char *
! _cpp_default_encoding (void)
  {
!   const char *current_encoding = NULL;
! 
! #if defined (HAVE_LOCALE_H) && defined (HAVE_LANGINFO_CODESET)
!   setlocale (LC_CTYPE, "");
!   current_encoding = nl_langinfo (CODESET);
! #endif
!   if (current_encoding == NULL || *current_encoding == '\0')
!     current_encoding = SOURCE_CHARSET;
! 
!   return current_encoding;
  }
Index: gcc/cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.200
diff -c -r1.200 cppfiles.c
*** gcc/cppfiles.c	20 Jan 2004 07:35:21 -0000	1.200
--- gcc/cppfiles.c	29 Jan 2004 23:01:57 -0000
***************
*** 312,318 ****
  
  /* Try to open the path FILE->name appended to FILE->dir.  This is
     where remap and PCH intercept the file lookup process.  Return true
!    if the file was found, whether or not the open was successful.  
     Set *INVALID_PCH to true if a PCH file is found but wasn't valid.  */
  
  static bool
--- 312,318 ----
  
  /* Try to open the path FILE->name appended to FILE->dir.  This is
     where remap and PCH intercept the file lookup process.  Return true
!    if the file was found, whether or not the open was successful.
     Set *INVALID_PCH to true if a PCH file is found but wasn't valid.  */
  
  static bool
***************
*** 398,407 ****
  	  open_file_failed (pfile, file);
  	  if (invalid_pch)
  	    {
! 	      cpp_error (pfile, CPP_DL_ERROR, 
  	       "one or more PCH files were found, but they were invalid");
  	      if (!cpp_get_options (pfile)->warn_invalid_pch)
! 		cpp_error (pfile, CPP_DL_ERROR, 
  			   "use -Winvalid-pch for more information");
  	    }
  	  break;
--- 398,407 ----
  	  open_file_failed (pfile, file);
  	  if (invalid_pch)
  	    {
! 	      cpp_error (pfile, CPP_DL_ERROR,
  	       "one or more PCH files were found, but they were invalid");
  	      if (!cpp_get_options (pfile)->warn_invalid_pch)
! 		cpp_error (pfile, CPP_DL_ERROR,
  			   "use -Winvalid-pch for more information");
  	    }
  	  break;
***************
*** 457,463 ****
    ssize_t size, total, count;
    uchar *buf;
    bool regular;
!   
    if (S_ISBLK (file->st.st_mode))
      {
        cpp_error (pfile, CPP_DL_ERROR, "%s is a block device", file->path);
--- 457,463 ----
    ssize_t size, total, count;
    uchar *buf;
    bool regular;
! 
    if (S_ISBLK (file->st.st_mode))
      {
        cpp_error (pfile, CPP_DL_ERROR, "%s is a block device", file->path);
***************
*** 514,528 ****
      cpp_error (pfile, CPP_DL_WARNING,
  	       "%s is shorter than expected", file->path);
  
!   /* Shrink buffer if we allocated substantially too much.  */
!   if (total + 4096 < size)
!     buf = xrealloc (buf, total + 1);
! 
!   /* The lexer requires that the buffer be \n-terminated.  */
!   buf[total] = '\n';
! 
!   file->buffer = buf;
!   file->st.st_size = total;
    file->buffer_valid = true;
  
    return true;
--- 514,521 ----
      cpp_error (pfile, CPP_DL_WARNING,
  	       "%s is shorter than expected", file->path);
  
!   file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset),
! 				     buf, size, total, &file->st.st_size);
    file->buffer_valid = true;
  
    return true;
***************
*** 566,572 ****
    if (file->once_only)
      return false;
  
!   /* We must mark the file once-only if #import now, before header 
       guard checks.  Otherwise, undefining the header guard might
       cause the file to be re-stacked.  */
    if (import)
--- 559,565 ----
    if (file->once_only)
      return false;
  
!   /* We must mark the file once-only if #import now, before header
       guard checks.  Otherwise, undefining the header guard might
       cause the file to be re-stacked.  */
    if (import)
***************
*** 1283,1289 ****
       This is used as an optimisation, it means we don't have to search
       the structure if we're processing a regular #include.  */
    bool have_once_only;
!   
    struct pchf_entry {
      /* The size of this file.  This is used to save running a MD5 checksum
         if the sizes don't match.  */
--- 1276,1282 ----
       This is used as an optimisation, it means we don't have to search
       the structure if we're processing a regular #include.  */
    bool have_once_only;
! 
    struct pchf_entry {
      /* The size of this file.  This is used to save running a MD5 checksum
         if the sizes don't match.  */
***************
*** 1298,1304 ****
  static struct pchf_data *pchf;
  
  /* Data for pchf_addr.  */
! struct pchf_adder_info 
  {
    cpp_reader *pfile;
    struct pchf_data *d;
--- 1291,1297 ----
  static struct pchf_data *pchf;
  
  /* Data for pchf_addr.  */
! struct pchf_adder_info
  {
    cpp_reader *pfile;
    struct pchf_data *d;
***************
*** 1322,1332 ****
  	 the PCH file shouldn't be written...  */
        if (f->dont_read || f->err_no)
  	return 1;
!       
        d->entries[count].once_only = f->once_only;
        d->have_once_only |= f->once_only;
        if (f->buffer_valid)
! 	  md5_buffer ((const char *)f->buffer, 
  		      f->st.st_size, d->entries[count].sum);
        else
  	{
--- 1315,1325 ----
  	 the PCH file shouldn't be written...  */
        if (f->dont_read || f->err_no)
  	return 1;
! 
        d->entries[count].once_only = f->once_only;
        d->have_once_only |= f->once_only;
        if (f->buffer_valid)
! 	  md5_buffer ((const char *)f->buffer,
  		      f->st.st_size, d->entries[count].sum);
        else
  	{
***************
*** 1365,1386 ****
    struct pchf_data *result;
    size_t result_size;
    struct pchf_adder_info pai;
!   
    count = htab_elements (pfile->file_hash);
!   result_size = (sizeof (struct pchf_data) 
  		 + sizeof (struct pchf_entry) * (count - 1));
    result = xcalloc (result_size, 1);
!   
    result->count = 0;
    result->have_once_only = false;
!   
    pai.pfile = pfile;
    pai.d = result;
    htab_traverse (pfile->file_hash, pchf_adder, &pai);
  
    result_size = (sizeof (struct pchf_data)
                   + sizeof (struct pchf_entry) * (result->count - 1));
!   
    qsort (result->entries, result->count, sizeof (struct pchf_entry),
  	 pchf_save_compare);
  
--- 1358,1379 ----
    struct pchf_data *result;
    size_t result_size;
    struct pchf_adder_info pai;
! 
    count = htab_elements (pfile->file_hash);
!   result_size = (sizeof (struct pchf_data)
  		 + sizeof (struct pchf_entry) * (count - 1));
    result = xcalloc (result_size, 1);
! 
    result->count = 0;
    result->have_once_only = false;
! 
    pai.pfile = pfile;
    pai.d = result;
    htab_traverse (pfile->file_hash, pchf_adder, &pai);
  
    result_size = (sizeof (struct pchf_data)
                   + sizeof (struct pchf_entry) * (result->count - 1));
! 
    qsort (result->entries, result->count, sizeof (struct pchf_entry),
  	 pchf_save_compare);
  
***************
*** 1393,1403 ****
  _cpp_read_file_entries (cpp_reader *pfile ATTRIBUTE_UNUSED, FILE *f)
  {
    struct pchf_data d;
!   
    if (fread (&d, sizeof (struct pchf_data) - sizeof (struct pchf_entry), 1, f)
         != 1)
      return false;
!   
    pchf = xmalloc (sizeof (struct pchf_data)
  		  + sizeof (struct pchf_entry) * (d.count - 1));
    memcpy (pchf, &d, sizeof (struct pchf_data) - sizeof (struct pchf_entry));
--- 1386,1396 ----
  _cpp_read_file_entries (cpp_reader *pfile ATTRIBUTE_UNUSED, FILE *f)
  {
    struct pchf_data d;
! 
    if (fread (&d, sizeof (struct pchf_data) - sizeof (struct pchf_entry), 1, f)
         != 1)
      return false;
! 
    pchf = xmalloc (sizeof (struct pchf_data)
  		  + sizeof (struct pchf_entry) * (d.count - 1));
    memcpy (pchf, &d, sizeof (struct pchf_data) - sizeof (struct pchf_entry));
***************
*** 1422,1428 ****
  
    /* Do we need to worry about entries that don't have ONCE_ONLY set?  */
    bool check_included;
!   
    /* The file that we're searching for.  */
    _cpp_file *f;
  };
--- 1415,1421 ----
  
    /* Do we need to worry about entries that don't have ONCE_ONLY set?  */
    bool check_included;
! 
    /* The file that we're searching for.  */
    _cpp_file *f;
  };
***************
*** 1435,1449 ****
    const struct pchf_entry *e = (const struct pchf_entry *)e_p;
    struct pchf_compare_data *d = (struct pchf_compare_data *)d_p;
    int result;
!   
    result = memcmp (&d->size, &e->size, sizeof (off_t));
    if (result != 0)
      return result;
!   
    if (! d->sum_computed)
      {
        _cpp_file *const f = d->f;
!       
        md5_buffer ((const char *)f->buffer, f->st.st_size, d->sum);
        d->sum_computed = true;
      }
--- 1428,1442 ----
    const struct pchf_entry *e = (const struct pchf_entry *)e_p;
    struct pchf_compare_data *d = (struct pchf_compare_data *)d_p;
    int result;
! 
    result = memcmp (&d->size, &e->size, sizeof (off_t));
    if (result != 0)
      return result;
! 
    if (! d->sum_computed)
      {
        _cpp_file *const f = d->f;
! 
        md5_buffer ((const char *)f->buffer, f->st.st_size, d->sum);
        d->sum_computed = true;
      }
***************
*** 1458,1464 ****
      return 1;
  }
  
! /* Check that F is not in a list read from a PCH file (if any).  
     Assumes that f->buffer_valid is true.  Return TRUE if the file
     should not be read.  */
  
--- 1451,1457 ----
      return 1;
  }
  
! /* Check that F is not in a list read from a PCH file (if any).
     Assumes that f->buffer_valid is true.  Return TRUE if the file
     should not be read.  */
  
***************
*** 1468,1474 ****
  			    bool check_included)
  {
    struct pchf_compare_data d;
!   
    if (pchf == NULL
        || (! check_included && ! pchf->have_once_only))
      return false;
--- 1461,1467 ----
  			    bool check_included)
  {
    struct pchf_compare_data d;
! 
    if (pchf == NULL
        || (! check_included && ! pchf->have_once_only))
      return false;
Index: gcc/cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.207
diff -c -r1.207 cpphash.h
*** gcc/cpphash.h	21 Jan 2004 20:39:52 -0000	1.207
--- gcc/cpphash.h	29 Jan 2004 23:01:57 -0000
***************
*** 563,571 ****
  extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
  				 unsigned int, unsigned int);
  extern void _cpp_pop_buffer (cpp_reader *);
- extern uchar *_cpp_input_to_utf8 (cpp_reader *, const unsigned char *, cppchar_t);
- extern void _cpp_init_iconv_buffer (cpp_reader *, const char *);
- extern void _cpp_close_iconv_buffer (cpp_reader *);
  
  /* In cpptrad.c.  */
  extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *);
--- 563,568 ----
***************
*** 582,589 ****
  extern cppchar_t _cpp_valid_ucn (cpp_reader *, const uchar **,
  				 const uchar *, int);
  extern void _cpp_destroy_iconv (cpp_reader *);
! extern bool _cpp_interpret_string_notranslate (cpp_reader *, const cpp_string *,
  					       cpp_string *);
  
  /* Utility routines and macros.  */
  #define DSC(str) (const uchar *)str, sizeof str - 1
--- 579,590 ----
  extern cppchar_t _cpp_valid_ucn (cpp_reader *, const uchar **,
  				 const uchar *, int);
  extern void _cpp_destroy_iconv (cpp_reader *);
! extern bool _cpp_interpret_string_notranslate (cpp_reader *,
! 					       const cpp_string *,
  					       cpp_string *);
+ extern uchar *_cpp_convert_input (cpp_reader *, const char *, uchar *,
+ 				  size_t, size_t, off_t *);
+ extern const char *_cpp_default_encoding (void);
  
  /* Utility routines and macros.  */
  #define DSC(str) (const uchar *)str, sizeof str - 1
Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.300
diff -c -r1.300 cppinit.c
*** gcc/cppinit.c	21 Jan 2004 20:39:52 -0000	1.300
--- gcc/cppinit.c	29 Jan 2004 23:01:57 -0000
***************
*** 159,169 ****
    CPP_OPTION (pfile, bytes_big_endian) = 1;  /* does not matter */
  
    /* Default to no charset conversion.  */
!   CPP_OPTION (pfile, narrow_charset) = 0;
    CPP_OPTION (pfile, wide_charset) = 0;
  
!   /* Default the input character set to iso-8859-1 for now. */
!   CPP_OPTION (pfile, input_charset) = "ISO-8859-1";
  
    /* A fake empty "directory" used as the starting point for files
       looked up without a search path.  Name cannot be '/' because we
--- 159,169 ----
    CPP_OPTION (pfile, bytes_big_endian) = 1;  /* does not matter */
  
    /* Default to no charset conversion.  */
!   CPP_OPTION (pfile, narrow_charset) = _cpp_default_encoding ();
    CPP_OPTION (pfile, wide_charset) = 0;
  
!   /* Default the input character set to UTF-8.  */
!   CPP_OPTION (pfile, input_charset) = _cpp_default_encoding ();
  
    /* A fake empty "directory" used as the starting point for files
       looked up without a search path.  Name cannot be '/' because we
***************
*** 579,585 ****
        debugdir[token->val.str.len - 4] = '\0';
  
        pfile->cb.dir_change (pfile, debugdir);
!     }      
  
    /* We want to process the fake line changes as regular changes, to
       get them output.  */
--- 579,585 ----
        debugdir[token->val.str.len - 4] = '\0';
  
        pfile->cb.dir_change (pfile, debugdir);
!     }
  
    /* We want to process the fake line changes as regular changes, to
       get them output.  */
***************
*** 591,597 ****
  /* This is called at the end of preprocessing.  It pops the last
     buffer and writes dependency output, and returns the number of
     errors.
!  
     Maybe it should also reset state, such that you could call
     cpp_start_read with a new filename to restart processing.  */
  int
--- 591,597 ----
  /* This is called at the end of preprocessing.  It pops the last
     buffer and writes dependency output, and returns the number of
     errors.
! 
     Maybe it should also reset state, such that you could call
     cpp_start_read with a new filename to restart processing.  */
  int
Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.358
diff -c -r1.358 cpplib.c
*** gcc/cpplib.c	21 Jan 2004 20:39:53 -0000	1.358
--- gcc/cpplib.c	29 Jan 2004 23:01:58 -0000
***************
*** 1925,1931 ****
  		 int from_stage3)
  {
    cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
-   const char *input = CPP_OPTION (pfile, input_charset);
  
    /* Clears, amongst other things, if_stack and mi_cmacro.  */
    memset (new, 0, sizeof (cpp_buffer));
--- 1925,1930 ----
***************
*** 1937,1943 ****
    new->need_line = true;
  
    pfile->buffer = new;
-   _cpp_init_iconv_buffer (pfile, input);
  
    return new;
  }
--- 1936,1941 ----
***************
*** 1959,1966 ****
  
    /* In case of a missing #endif.  */
    pfile->state.skipping = 0;
- 
-   _cpp_close_iconv_buffer (pfile);
  
    /* _cpp_do_file_change expects pfile->buffer to be the new one.  */
    pfile->buffer = buffer->prev;
--- 1957,1962 ----
Index: gcc/doc/cppopts.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cppopts.texi,v
retrieving revision 1.29
diff -c -r1.29 cppopts.texi
*** gcc/doc/cppopts.texi	18 Jan 2004 01:20:46 -0000	1.29
--- gcc/doc/cppopts.texi	29 Jan 2004 23:01:59 -0000
***************
*** 511,516 ****
--- 511,526 ----
  by the system's @code{iconv} library routine; however, you will have
  problems with encodings that do not fit exactly in @code{wchar_t}.
  
+ @item -finput-charset=@var{charset}
+ @opindex finput-charset
+ Set the input character set, used for translation from the character
+ set of the input file to the source character set used by GCC. If the
+ locale does not specify, or GCC cannot get this information from the
+ locale, the default is UTF-8. This can be overriden by either the locale
+ or this command line option. Currently the command line option takes
+ precedence if there's a conflict. @var{charset} can be any encoding
+ supported by the system's @code{iconv} library routine.
+ 
  @item -fworking-directory
  @opindex fworking-directory
  @opindex fno-working-directory
Index: gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c,v
retrieving revision 1.3
diff -c -r1.3 wchar_t-1.c
*** gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c	10 Dec 2003 09:34:10 -0000	1.3
--- gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c	29 Jan 2004 23:02:04 -0000
***************
*** 1,3 ****
--- 1,4 ----
+ /* { dg-options "-finput-charset=utf-8" } */
  typedef __WCHAR_TYPE__ wchar_t;
  wchar_t x[] = L"Ã";
  wchar_t y = L'Ã';
Index: libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/2.cc,v
retrieving revision 1.5
diff -c -r1.5 2.cc
*** libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/2.cc	23 Sep 2003 20:02:18 -0000	1.5
--- libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/2.cc	29 Jan 2004 23:02:08 -0000
***************
*** 18,26 ****
  // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  // USA.
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  // 22.2.4.1.1 collate members
  
--- 18,25 ----
  // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  // USA.
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  // 22.2.4.1.1 collate members
  
Index: libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_env.cc
*** libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc	24 Jul 2003 21:07:35 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_env.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  
Index: libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_locale.cc
*** libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc	24 Jul 2003 21:07:35 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/wrapped_locale.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  
Index: libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/2.cc,v
retrieving revision 1.5
diff -c -r1.5 2.cc
*** libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/2.cc	23 Sep 2003 20:02:18 -0000	1.5
--- libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/2.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <locale>
  #include <testsuite_hooks.h>
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <locale>
  #include <testsuite_hooks.h>
Index: libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_env.cc
*** libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc	24 Jul 2003 21:07:36 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_env.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  
Index: libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_locale.cc
*** libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc	24 Jul 2003 21:07:36 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/hash/wchar_t/wrapped_locale.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  
Index: libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/2.cc,v
retrieving revision 1.5
diff -c -r1.5 2.cc
*** libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/2.cc	23 Sep 2003 20:02:19 -0000	1.5
--- libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/2.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <locale>
  #include <testsuite_hooks.h>
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <locale>
  #include <testsuite_hooks.h>
Index: libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_env.cc
*** libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc	24 Jul 2003 21:07:37 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_env.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  
Index: libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc,v
retrieving revision 1.3
diff -c -r1.3 wrapped_locale.cc
*** libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc	24 Jul 2003 21:07:37 -0000	1.3
--- libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/wrapped_locale.cc	29 Jan 2004 23:02:08 -0000
***************
*** 20,28 ****
  
  // 22.2.4.1.1 collate members
  
! // Doesn't work due to use of literal ISO8859.1 characters.  PR 11439
! // { dg-do compile { xfail *-*-* } } should be run
! // { dg-excess-errors "" }
  
  #include <testsuite_hooks.h>
  
--- 20,27 ----
  
  // 22.2.4.1.1 collate members
  
! // { dg-do run }
! // { dg-options "-finput-charset=iso-8859-1" }
  
  #include <testsuite_hooks.h>
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]