fix no output

This commit is contained in:
Vitor Santos Costa 2016-08-15 14:50:58 -05:00
parent 2595555982
commit fccf3d9f6f

View File

@ -1,19 +1,19 @@
/************************************************************************* /*************************************************************************
* * * *
* YAP Prolog * * YAP Prolog *
* * * *
* Yap Prolog was developed at NCCUP - Universidade do Porto * * Yap Prolog was developed at NCCUP - Universidade do Porto *
* * * *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* * * *
************************************************************************** **************************************************************************
* * * *
* File: charcodes.c * * File: charcodes.c *
* Last rev: 5/2/88 * * Last rev: 5/2/88 *
* mods: * * mods: *
* comments: Character codes and character conversion * * comments: Character codes and character conversion *
* * * *
*************************************************************************/ *************************************************************************/
#ifdef SCCS #ifdef SCCS
static char SccsId[] = "%W% %G%"; static char SccsId[] = "%W% %G%";
#endif #endif
@ -401,6 +401,7 @@ static int format_print_str(Int sno, Int size, Int has_size, Term args,
while (*pt && (!has_size || size > 0)) { while (*pt && (!has_size || size > 0)) {
utf8proc_int32_t ch; utf8proc_int32_t ch;
pt += get_utf8(pt, -1, &ch); pt += get_utf8(pt, -1, &ch);
f_putc(sno, ch);
} }
} else { } else {
while (!has_size || size > 0) { while (!has_size || size > 0) {
@ -508,6 +509,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
format_info finfo; format_info finfo;
Term fmod = CurrentModule; Term fmod = CurrentModule;
bool alloc_fstr = false; bool alloc_fstr = false;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (GLOBAL_Stream[sno0].status & InMemory_Stream_f) { if (GLOBAL_Stream[sno0].status & InMemory_Stream_f) {
old_handler = GLOBAL_Stream[sno].u.mem_string.error_handler; old_handler = GLOBAL_Stream[sno].u.mem_string.error_handler;
@ -533,7 +535,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
args = oargs; args = oargs;
tail = otail; tail = otail;
targ = 0; targ = 0;
if (IsVarTerm(tail)) { if (IsVarTerm(tail)) {
Yap_Error(INSTANTIATION_ERROR, tail, "format/2"); Yap_Error(INSTANTIATION_ERROR, tail, "format/2");
return (FALSE); return (FALSE);
} else if ((fptr = Yap_TextToUTF8Buffer(tail))) { } else if ((fptr = Yap_TextToUTF8Buffer(tail))) {
@ -596,10 +598,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
finfo.lstart = 0; finfo.lstart = 0;
if (true || !(GLOBAL_Stream[sno].status & InMemory_Stream_f)) if (true || !(GLOBAL_Stream[sno].status & InMemory_Stream_f))
sno = Yap_OpenBufWriteStream(PASS_REGS1); sno = Yap_OpenBufWriteStream(PASS_REGS1);
if (sno < 0) if (sno < 0) {
return false;
f_putc = GLOBAL_Stream[sno0].stream_wputc;
if (sno == -1) {
if (!alloc_fstr) if (!alloc_fstr)
fstr = NULL; fstr = NULL;
if (mytargs == targs) { if (mytargs == targs) {
@ -608,6 +607,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
format_clean_up(sno, sno0, &finfo, fstr, targs); format_clean_up(sno, sno0, &finfo, fstr, targs);
return false; return false;
} }
f_putc = GLOBAL_Stream[sno0].stream_wputc;
while ((fptr += get_utf8(fptr, -1, &ch)) && ch) { while ((fptr += get_utf8(fptr, -1, &ch)) && ch) {
Term t = TermNil; Term t = TermNil;
int has_repeats = false; int has_repeats = false;