fix writing streams by write.c
This commit is contained in:
parent
5d65c49292
commit
665d426e13
48
C/write.c
48
C/write.c
@ -336,6 +336,23 @@ wrputref(CODEADDR ref, int Quote_illegal, struct write_globs *wglb)
|
||||
lastw = alphanum;
|
||||
}
|
||||
|
||||
/* writes a blob (default) */
|
||||
static void
|
||||
wrputblob(CODEADDR ref, int Quote_illegal, struct write_globs *wglb)
|
||||
{
|
||||
char s[256];
|
||||
wrf stream = wglb->stream;
|
||||
|
||||
putAtom(AtomSWIStream, Quote_illegal, wglb);
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
sprintf(s, "(%p)", ref);
|
||||
#else
|
||||
sprintf(s, "(0x%p)", ref);
|
||||
#endif
|
||||
wrputs(s, stream);
|
||||
lastw = alphanum;
|
||||
}
|
||||
|
||||
static int
|
||||
legalAtom(unsigned char *s) /* Is this a legal atom ? */
|
||||
{
|
||||
@ -455,25 +472,16 @@ write_quoted(int ch, int quote, wrf stream)
|
||||
static void
|
||||
putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
|
||||
{
|
||||
unsigned char *s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||
wtype atom_or_symbol = AtomIsSymbols(s);
|
||||
unsigned char *s;
|
||||
wtype atom_or_symbol;
|
||||
wrf stream = wglb->stream;
|
||||
|
||||
/* #define CRYPT_FOR_STEVE 1*/
|
||||
#ifdef CRYPT_FOR_STEVE
|
||||
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
|
||||
char s[16];
|
||||
sprintf(s,"x%x", (CELL)s);
|
||||
wrputs(s, stream);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (IsBlob(atom)) {
|
||||
wrputref((CODEADDR)RepAtom(atom),1,stream);
|
||||
wrputblob((CODEADDR)RepAtom(atom),wglb->Quote_illegal,wglb);
|
||||
return;
|
||||
}
|
||||
if (IsWideAtom(atom)) {
|
||||
wchar_t *ws = (wchar_t *)s;
|
||||
wchar_t *ws = RepAtom(atom)->WStrOfAE;
|
||||
|
||||
if (Quote_illegal) {
|
||||
wrputc('\'', stream);
|
||||
@ -487,6 +495,17 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
|
||||
}
|
||||
return;
|
||||
}
|
||||
s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||
/* #define CRYPT_FOR_STEVE 1*/
|
||||
#ifdef CRYPT_FOR_STEVE
|
||||
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
|
||||
char s[16];
|
||||
sprintf(s,"x%x", (CELL)s);
|
||||
wrputs(s, stream);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
atom_or_symbol = AtomIsSymbols(s);
|
||||
if (lastw == atom_or_symbol && atom_or_symbol != separator /* solo */)
|
||||
wrputc(' ', stream);
|
||||
lastw = atom_or_symbol;
|
||||
@ -669,7 +688,6 @@ restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
||||
if (rwt->u.s.ptr) {
|
||||
CELL *ptr;
|
||||
if (wglb->Keep_terms) {
|
||||
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u.s.ptr PASS_REGS);
|
||||
t = Yap_GetPtrFromSlot(rwt->u.s.old PASS_REGS);
|
||||
Yap_RecoverSlots(2 PASS_REGS);
|
||||
} else {
|
||||
@ -853,7 +871,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
write_var(RepAppl(t)+1, wglb, &nrwt);
|
||||
return;
|
||||
case (CELL)FunctorDBRef:
|
||||
wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb->stream);
|
||||
wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb);
|
||||
return;
|
||||
case (CELL)FunctorLongInt:
|
||||
wrputn(LongIntOfTerm(t),wglb);
|
||||
|
@ -272,6 +272,7 @@
|
||||
AtomStaticClause = Yap_FullLookupAtom("$static_clause");
|
||||
AtomStaticProcedure = Yap_LookupAtom("static_procedure");
|
||||
AtomStream = Yap_FullLookupAtom("$stream");
|
||||
AtomSWIStream = Yap_FullLookupAtom("<stream>");
|
||||
AtomVStream = Yap_LookupAtom("stream");
|
||||
AtomStreams = Yap_LookupAtom("streams");
|
||||
AtomStreamOrAlias = Yap_LookupAtom("stream_or_alias");
|
||||
|
@ -272,6 +272,7 @@
|
||||
AtomStaticClause = AtomAdjust(AtomStaticClause);
|
||||
AtomStaticProcedure = AtomAdjust(AtomStaticProcedure);
|
||||
AtomStream = AtomAdjust(AtomStream);
|
||||
AtomSWIStream = AtomAdjust(AtomSWIStream);
|
||||
AtomVStream = AtomAdjust(AtomVStream);
|
||||
AtomStreams = AtomAdjust(AtomStreams);
|
||||
AtomStreamOrAlias = AtomAdjust(AtomStreamOrAlias);
|
||||
|
@ -542,6 +542,8 @@
|
||||
#define AtomStaticProcedure Yap_heap_regs->AtomStaticProcedure_
|
||||
Atom AtomStream_;
|
||||
#define AtomStream Yap_heap_regs->AtomStream_
|
||||
Atom AtomSWIStream_;
|
||||
#define AtomSWIStream Yap_heap_regs->AtomSWIStream_
|
||||
Atom AtomVStream_;
|
||||
#define AtomVStream Yap_heap_regs->AtomVStream_
|
||||
Atom AtomStreams_;
|
||||
|
@ -277,6 +277,7 @@ A StartupSavedState F "$startup_saved_state"
|
||||
A StaticClause F "$static_clause"
|
||||
A StaticProcedure N "static_procedure"
|
||||
A Stream F "$stream"
|
||||
A SWIStream F "<stream>"
|
||||
A VStream N "stream"
|
||||
A Streams N "streams"
|
||||
A StreamOrAlias N "stream_or_alias"
|
||||
|
Reference in New Issue
Block a user