Commit 6b88314c by Zack Weinberg

cppcharset.c (one_utf8_to_cppchar, [...]): New functions.

	* cppcharset.c (one_utf8_to_cppchar, one_cppchar_to_utf8,
	one_utf8_to_utf32, one_utf32_to_utf8, one_utf8_to_utf16,
	one_utf16_to_utf8, conversion_loop, convert_utf8_utf16,
	convert_utf8_utf32, convert_utf16_utf8,	convert_utf32_utf8,
	convert_no_conversion, convert_using_iconv): New functions.
	(APPLY_CONVERSION): New macro.
	(struct conversion, conversion_tab): New data structure.
	(init_iconv_desc): Check conversion_tab for a custom conversion
	primitive before trying to use iconv.
	(convert_cset): Deleted.
	(cpp_init_iconv): Use UTF- terminology, not UCS-.
	(_cpp_destroy_iconv): Update to match.
	(_cpp_valid_ucn): We don't need iconv to implement UCNs.
	(convert_ucn): Use one_cppchar_to_utf8 and APPLY_CONVERSION.
	(convert_escape, cpp_interpret_string): Use APPLY_CONVERSION.
	(_cpp_interpret_string_notranslate): New function, moved here
	from cpplib.c.

	* cpphash.h (convert_f, struct cset_converter): New types.
	(struct cpp_reader): narrow_cset_desc and wide_cset_desc
	are now struct cset_converter, not bare iconv_t.
	Update prototypes.
	* cpplib.c (interpret_string_notranslate): Moved to cppcharset.c;
	all callers changed.

From-SVN: r69204
parent 38f4680f
2003-07-10 Zack Weinberg <zack@codesourcery.com>
* cppcharset.c (one_utf8_to_cppchar, one_cppchar_to_utf8,
one_utf8_to_utf32, one_utf32_to_utf8, one_utf8_to_utf16,
one_utf16_to_utf8, conversion_loop, convert_utf8_utf16,
convert_utf8_utf32, convert_utf16_utf8, convert_utf32_utf8,
convert_no_conversion, convert_using_iconv): New functions.
(APPLY_CONVERSION): New macro.
(struct conversion, conversion_tab): New data structure.
(init_iconv_desc): Check conversion_tab for a custom conversion
primitive before trying to use iconv.
(convert_cset): Deleted.
(cpp_init_iconv): Use UTF- terminology, not UCS-.
(_cpp_destroy_iconv): Update to match.
(_cpp_valid_ucn): We don't need iconv to implement UCNs.
(convert_ucn): Use one_cppchar_to_utf8 and APPLY_CONVERSION.
(convert_escape, cpp_interpret_string): Use APPLY_CONVERSION.
(_cpp_interpret_string_notranslate): New function, moved here
from cpplib.c.
* cpphash.h (convert_f, struct cset_converter): New types.
(struct cpp_reader): narrow_cset_desc and wide_cset_desc
are now struct cset_converter, not bare iconv_t.
Update prototypes.
* cpplib.c (interpret_string_notranslate): Moved to cppcharset.c;
all callers changed.
2003-07-10 Kelley Cook <kelleycook@wideopenwest.com>
* Makefile.in (options.h): Depend on Makefile. Add move-if-change
......
......@@ -35,6 +35,15 @@ typedef int iconv_t; /* dummy */
struct directive; /* Deliberately incomplete. */
struct pending_option;
struct op;
struct strbuf;
typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
struct strbuf *);
struct cset_converter
{
convert_f func;
iconv_t cd;
};
#ifndef HAVE_UCHAR
typedef unsigned char uchar;
......@@ -369,14 +378,13 @@ struct cpp_reader
unsigned char *macro_buffer;
unsigned int macro_buffer_len;
/* Iconv descriptor for converting from the source character set
to the execution character set. (iconv_t)-1 for no conversion. */
iconv_t narrow_cset_desc;
/* Descriptor for converting from the source character set to the
execution character set. */
struct cset_converter narrow_cset_desc;
/* Iconv descriptor for converting from the execution character set
to the wide execution character set. (iconv_t)-1 for no conversion
other than zero-extending each character to the width of wchar_t. */
iconv_t wide_cset_desc;
/* Descriptor for converting from the source character set to the
wide execution character set. */
struct cset_converter wide_cset_desc;
/* Tree of other included files. See cppfiles.c. */
struct splay_tree_s *all_include_files;
......@@ -555,8 +563,11 @@ extern uchar *_cpp_copy_replacement_text (const cpp_macro *, uchar *);
extern size_t _cpp_replacement_text_len (const cpp_macro *);
/* In cppcharset.c. */
cppchar_t _cpp_valid_ucn (cpp_reader *, const uchar **, const uchar *, int);
void _cpp_destroy_iconv (cpp_reader *);
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
......
......@@ -733,21 +733,6 @@ strtoul_for_line (const uchar *str, unsigned int len, long unsigned int *nump)
return 0;
}
/* Subroutine of do_line and do_linemarker. Convert escape sequences
in a string, but do not perform character set conversion. */
static bool
interpret_string_notranslate (cpp_reader *pfile, const cpp_string *in,
cpp_string *out)
{
iconv_t save_narrow_cset_desc = pfile->narrow_cset_desc;
bool retval;
pfile->narrow_cset_desc = (iconv_t) -1;
retval = cpp_interpret_string (pfile, in, 1, out, false);
pfile->narrow_cset_desc = save_narrow_cset_desc;
return retval;
}
/* Interpret #line command.
Note that the filename string (if any) is a true string constant
(escapes are interpreted), unlike in #line. */
......@@ -780,7 +765,7 @@ do_line (cpp_reader *pfile)
if (token->type == CPP_STRING)
{
cpp_string s = { 0, 0 };
if (interpret_string_notranslate (pfile, &token->val.str, &s))
if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
new_file = (const char *)s.text;
check_eol (pfile);
}
......@@ -829,7 +814,7 @@ do_linemarker (cpp_reader *pfile)
if (token->type == CPP_STRING)
{
cpp_string s = { 0, 0 };
if (interpret_string_notranslate (pfile, &token->val.str, &s))
if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
new_file = (const char *)s.text;
new_sysp = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment