From 55eb58fde19e69d37627e002cdca52bc6b58e03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 22 Feb 1999 22:35:28 +0100 Subject: [PATCH] Added idea for a heuristic for 8bit => wide string conversion in cpp(). Rev: src/cpp.c:1.37 --- src/cpp.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cpp.c b/src/cpp.c index 1d44e40bfb..5718c210d7 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -5,10 +5,9 @@ \*/ /* - * $Id: cpp.c,v 1.36 1999/02/22 15:22:24 grubba Exp $ + * $Id: cpp.c,v 1.37 1999/02/22 21:35:28 grubba Exp $ */ #include "global.h" -/* #include "dynamic_buffer.h" */ #include "language.h" #include "lex.h" #include "stralloc.h" @@ -2100,6 +2099,28 @@ void f_cpp(INT32 args) }else{ this.current_file=make_shared_string("-"); } + + if ((!sp[-args].u.string->size_shift) && (sp[-args].u.string->len > 1)) { + /* Try to determine if we need to recode the string */ + + /* At least a prefix of two bytes need to be 7bit in a valid + * Pike program. + */ + /* Heuristic: + * + * Index 0 | Index 1 | Interpretation + * --------+---------+------------------------------------------ + * 0 | 0 | 32bit wide string. + * 0 | >0 | 16bit Unicode string. + * >0 | 0 | 16bit Unicode string reverse byte order. + * 0xff | 0xfe | 16bit Unicode string. + * 0xfe | 0xff | 16bit Unicode string reverse byte order. + * 0x7b | 0x83 | EBCDIC-US ("#c"). + * 0x7b | 0x40 | EBCDIC-US ("# "). + * --------+---------+------------------------------------------ + * Other | Other | 8bit standard string. + */ + } init_string_builder(&this.buf, 0); this.current_line=1; -- GitLab