diff --git a/C/scanner.c b/C/scanner.c index 09d43f37b..89a2ae8ec 100644 --- a/C/scanner.c +++ b/C/scanner.c @@ -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)); diff --git a/C/write.c b/C/write.c index 92f0a831a..7b1ef8581 100644 --- a/C/write.c +++ b/C/write.c @@ -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); } } diff --git a/changes-5.1.html b/changes-5.1.html index b7095a660..ee1a0a692 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -19,6 +19,8 @@