fixes for upcast and lowercase

This commit is contained in:
Vítor Santos Costa 2015-10-22 11:51:07 +01:00
parent aaa9aa2b7b
commit f1c9952c77

View File

@ -58,24 +58,6 @@ static Int skip(USES_REGS1);
static Int flush_output(USES_REGS1); static Int flush_output(USES_REGS1);
static Int flush_all_streams(USES_REGS1); static Int flush_all_streams(USES_REGS1);
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
/**
* MkCharTerm: convert a character into a single atom.
*
* @param c the character code
*
* @return the term.
*/
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
wchar_t cs[2];
if (c < 0)
return MkAtomTerm(AtomEof);
cs[0] = c;
cs[1] = '\0';
return MkAtomTerm(Yap_LookupMaybeWideAtom(cs));
}
/** /**
* CharOfAtom: convert an atom into a single character. * CharOfAtom: convert an atom into a single character.
* *
@ -186,11 +168,11 @@ static int yap_fflush(int sno) {
static Int get(USES_REGS1) { /* '$get'(Stream,-N) */ static Int get(USES_REGS1) { /* '$get'(Stream,-N) */
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get/2"); int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get/2");
int ch; int ch;
//Int status; // Int status;
if (sno < 0) if (sno < 0)
return FALSE; return FALSE;
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) <= 32 && ch >= 0) while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) <= 32 && ch >= 0)
; ;
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
@ -204,7 +186,7 @@ static Int get_char(USES_REGS1) { /* '$get'(Stream,-N) */
if (sno < 0) if (sno < 0)
return FALSE; return FALSE;
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
ch = GLOBAL_Stream[sno].stream_wgetc(sno); ch = GLOBAL_Stream[sno].stream_wgetc(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
return (Yap_unify_constant(ARG2, MkCharTerm(ch))); return (Yap_unify_constant(ARG2, MkCharTerm(ch)));
@ -212,12 +194,12 @@ static Int get_char(USES_REGS1) { /* '$get'(Stream,-N) */
static Int get_code(USES_REGS1) { /* get0(Stream,-N) */ static Int get_code(USES_REGS1) { /* get0(Stream,-N) */
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get0/2"); int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get0/2");
//Int status; // Int status;
Int out; Int out;
if (sno < 0) if (sno < 0)
return (FALSE); return (FALSE);
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
out = GLOBAL_Stream[sno].stream_wgetc(sno); out = GLOBAL_Stream[sno].stream_wgetc(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
return (Yap_unify_constant(ARG2, MkIntegerTerm(out))); return (Yap_unify_constant(ARG2, MkIntegerTerm(out)));
@ -226,10 +208,10 @@ static Int get_code(USES_REGS1) { /* get0(Stream,-N) */
static Int get_1(USES_REGS1) { /* get_code1(Stream,-N) */ static Int get_1(USES_REGS1) { /* get_code1(Stream,-N) */
int sno = LOCAL_c_input_stream; int sno = LOCAL_c_input_stream;
int ch; int ch;
//Int status; // Int status;
LOCK(GLOBAL_Stream[sno].streamlock); LOCK(GLOBAL_Stream[sno].streamlock);
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) <= 32 && ch >= 0) while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) <= 32 && ch >= 0)
; ;
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
@ -238,10 +220,10 @@ static Int get_1(USES_REGS1) { /* get_code1(Stream,-N) */
static Int getcode_1(USES_REGS1) { /* get0(Stream,-N) */ static Int getcode_1(USES_REGS1) { /* get0(Stream,-N) */
int sno = LOCAL_c_input_stream; int sno = LOCAL_c_input_stream;
//Int status; // Int status;
Int out; Int out;
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
LOCK(GLOBAL_Stream[sno].streamlock); LOCK(GLOBAL_Stream[sno].streamlock);
out = GLOBAL_Stream[sno].stream_wgetc(sno); out = GLOBAL_Stream[sno].stream_wgetc(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
@ -250,11 +232,11 @@ static Int getcode_1(USES_REGS1) { /* get0(Stream,-N) */
static Int getchar_1(USES_REGS1) { /* get0(Stream,-N) */ static Int getchar_1(USES_REGS1) { /* get0(Stream,-N) */
int sno = LOCAL_c_input_stream; int sno = LOCAL_c_input_stream;
//Int status; // Int status;
Int out; Int out;
LOCK(GLOBAL_Stream[sno].streamlock); LOCK(GLOBAL_Stream[sno].streamlock);
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
out = GLOBAL_Stream[sno].stream_wgetc(sno); out = GLOBAL_Stream[sno].stream_wgetc(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
return (Yap_unify_constant(ARG1, MkCharTerm(out))); return (Yap_unify_constant(ARG1, MkCharTerm(out)));
@ -262,7 +244,7 @@ static Int getchar_1(USES_REGS1) { /* get0(Stream,-N) */
static Int get0_line_codes(USES_REGS1) { /* '$get0'(Stream,-N) */ static Int get0_line_codes(USES_REGS1) { /* '$get0'(Stream,-N) */
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get0/2"); int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "get0/2");
//Int status; // Int status;
Term out; Term out;
Int ch = '\0'; Int ch = '\0';
int rewind; int rewind;
@ -270,7 +252,7 @@ static Int get0_line_codes(USES_REGS1) { /* '$get0'(Stream,-N) */
if (sno < 0) if (sno < 0)
return (FALSE); return (FALSE);
rewind = FALSE; rewind = FALSE;
//status = GLOBAL_Stream[sno].status; // status = GLOBAL_Stream[sno].status;
out = read_line(sno); out = read_line(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
if (rewind) if (rewind)