diff --git a/C/text.c b/C/text.c index 7d0efccc2..2be9a9333 100644 --- a/C/text.c +++ b/C/text.c @@ -144,6 +144,13 @@ SkipListCodes(Term *l, Term **tailp, Int *atoms, int *wide) do_derefa(v,l,derefa_unk,derefa_nonvar); s = l; + + if (*l == TermNil) { + *tailp = l; + *atoms = 0; + *wide = FALSE; + return 0; + } if ( IsPairTerm(*l) ) { intptr_t power = 1, lam = 0; do @@ -468,7 +475,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal USES_REGS) LOCAL_Error_TYPE = gen_type_error( inp->type ); LOCAL_Error_Term = t; } - } else if (IsPairTerm(t)) { + } else if (IsPairTerm(t) || t == TermNil) { if (inp->type & (YAP_STRING_CODES|YAP_STRING_ATOMS)) { inp->type &= (YAP_STRING_CODES|YAP_STRING_ATOMS); return read_Text( buf, inp, enc, minimal PASS_REGS);