fix encoding issues

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1944 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2007-10-02 12:32:46 +00:00
parent fd049830a3
commit a5406ccc02
3 changed files with 19 additions and 14 deletions

View File

@ -984,7 +984,7 @@ Yap_tokenizer(int inp_stream)
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
break;
}
if (ch > MAX_ISO_LATIN1){
if (!wcharp && ch > MAX_ISO_LATIN1){
/* does not fit in ISO-LATIN */
wcharp = ch_to_wide(TokImage, charp);
}
@ -1019,7 +1019,7 @@ Yap_tokenizer(int inp_stream)
if (scan_next) {
ch = QuotedNxtch(inp_stream);
}
} else if (chtype[ch] == EF) {
} else if (chtype[ch] == EF && ch <= MAX_ISO_LATIN1) {
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
break;
@ -1042,10 +1042,11 @@ Yap_tokenizer(int inp_stream)
return l;
}
}
if (wcharp)
*wcharp++ = '\0';
else
if (wcharp) {
*wcharp = '\0';
} else {
*charp = '\0';
}
if (quote == '"') {
if (wcharp) {
mp = AllocScannerMemory(sizeof(wchar_t)*(len+1));

View File

@ -55,10 +55,10 @@ STATIC_PROTO(void wrputn, (Int, wrf));
STATIC_PROTO(void wrputs, (char *, wrf));
STATIC_PROTO(void wrputf, (Float, wrf));
STATIC_PROTO(void wrputref, (CODEADDR, int, wrf));
STATIC_PROTO(int legalAtom, (char *));
STATIC_PROTO(int legalAtom, (unsigned char *));
STATIC_PROTO(int LeftOpToProtect, (Atom, int));
STATIC_PROTO(int RightOpToProtect, (Atom, int));
STATIC_PROTO(wtype AtomIsSymbols, (char *));
STATIC_PROTO(wtype AtomIsSymbols, (unsigned char *));
STATIC_PROTO(void putAtom, (Atom, int, wrf));
STATIC_PROTO(void writeTerm, (Term, int, int, int, struct write_globs *));
@ -97,8 +97,9 @@ wrputn(Int n, wrf writewch) /* writes an integer */
static void
wrputs(char *s, wrf writewch) /* writes a string */
{
while (*s)
while (*s) {
wrputc(*s++, writewch);
}
}
static void
@ -162,10 +163,11 @@ wrputref(CODEADDR ref, int Quote_illegal, wrf writewch) /* writes a data base
}
static int
legalAtom(char *s) /* Is this a legal atom ? */
legalAtom(unsigned char *s) /* Is this a legal atom ? */
{
register int ch = *s;
wchar_t ch = *s;
if (ch == '\0')
return(FALSE);
if (Yap_chtype[ch] != LC) {
@ -205,7 +207,7 @@ static int RightOpToProtect(Atom at, int p)
}
static wtype
AtomIsSymbols(char *s) /* Is this atom just formed by symbols ? */
AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
{
int ch;
if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0')
@ -221,7 +223,7 @@ static void
putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
{
char *s = RepAtom(atom)->StrOfAE;
unsigned char *s = (unsigned char *)RepAtom(atom)->StrOfAE;
wtype atom_or_symbol = AtomIsSymbols(s);
/* #define CRYPT_FOR_STEVE 1*/
@ -258,7 +260,7 @@ putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
if (!legalAtom(s) && Quote_illegal) {
wrputc('\'', writewch);
while (*s) {
int ch = *s++;
wchar_t ch = *s++;
wrputc(ch, writewch);
if (ch == '\\' && yap_flags[CHARACTER_ESCAPE_FLAG] != CPROLOG_CHARACTER_ESCAPES)
wrputc('\\', writewch); /* be careful about backslashes */
@ -267,7 +269,7 @@ putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
}
wrputc('\'', writewch);
} else {
wrputs(s, writewch);
wrputs((char *)s, writewch);
}
}

View File

@ -19,6 +19,8 @@
<ul>
<li> FIXED: have has table of preds with repeated functors (obs from
Bernd Gutmann).</li>
<li> FIXED: major bugs in encoding support (obs from
Paulo Moura).</li>
<li> FIXED: overflow while gc was storing pointers in trail (obs from Angelika Kimmig).</li>
<li> FIXED: implement directive encoding/1 (obs from Paulo Moura).</li>
<li> UPGRADED: to current JPL.</li>