avoid messing with stream 1

This commit is contained in:
Vitor Santos Costa 2016-06-17 17:06:19 +01:00
parent 735ccca095
commit 710ca208d2

View File

@ -1,20 +1,20 @@
/************************************************************************* /*************************************************************************
* * * *
* 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: write.c * * File: write.c *
* Last rev: * * Last rev: *
* mods: * * mods: *
* comments: Writing a Prolog Term * * comments: Writing a Prolog Term *
* * * *
*************************************************************************/ *************************************************************************/
#ifdef SCCS #ifdef SCCS
static char SccsId[] = "%W% %G%"; static char SccsId[] = "%W% %G%";
#endif #endif
@ -325,7 +325,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */
int found_dot = FALSE; int found_dot = FALSE;
char *pt = s; char *pt = s;
int ch; int ch;
/* always use C locale for writing numbers */ /* always use C locale for writing numbers */
#if O_LOCALE #if O_LOCALE
const unsigned char *decimalpoint = const unsigned char *decimalpoint =
(unsigned char *)localeconv()->decimal_point; (unsigned char *)localeconv()->decimal_point;
@ -605,7 +605,7 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
return; return;
} }
s = (unsigned char *)RepAtom(atom)->StrOfAE; s = (unsigned char *)RepAtom(atom)->StrOfAE;
/* #define CRYPT_FOR_STEVE 1*/ /* #define CRYPT_FOR_STEVE 1*/
#ifdef CRYPT_FOR_STEVE #ifdef CRYPT_FOR_STEVE
if (Yap_GetValue(AtomCryptAtoms) != TermNil && if (Yap_GetValue(AtomCryptAtoms) != TermNil &&
Yap_GetAProp(atom, OpProperty) == NIL) { Yap_GetAProp(atom, OpProperty) == NIL) {
@ -1274,7 +1274,6 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
char *Yap_TermToString(Term t, size_t *lengthp, encoding_t enc, int flags) { char *Yap_TermToString(Term t, size_t *lengthp, encoding_t enc, int flags) {
CACHE_REGS CACHE_REGS
int sno = Yap_open_buf_write_stream(enc, flags); int sno = Yap_open_buf_write_stream(enc, flags);
int old_output_stream = LOCAL_c_output_stream;
const char *sf; const char *sf;
if (sno < 0) if (sno < 0)
@ -1285,9 +1284,9 @@ char *Yap_TermToString(Term t, size_t *lengthp, encoding_t enc, int flags) {
else else
GLOBAL_Stream[sno].encoding = LOCAL_encoding; GLOBAL_Stream[sno].encoding = LOCAL_encoding;
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority); Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
sf = Yap_MemExportStreamPtr(sno); sf = Yap_MemExportStreamPtr(sno);
Yap_CloseStream(sno); Yap_CloseStream(sno);
LOCAL_c_output_stream = old_output_stream;
if (Yap_HasException()) if (Yap_HasException())
return NULL; return NULL;
return (char *)sf; return (char *)sf;