From 506da0b1bfac5e1e398d78a803d0640021454498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Fri, 27 Nov 2009 16:09:48 +0000 Subject: [PATCH] make write always protect operators when they are not used as operators so as to follow standard (#150). --- C/stdpreds.c | 10 +++++++++- C/write.c | 6 ++---- H/Yatom.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/C/stdpreds.c b/C/stdpreds.c index c1de66269..c61e09e60 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -2869,11 +2869,19 @@ init_current_predicate_for_atom(void) static OpEntry * NextOp(OpEntry *pp) { - while (!EndOfPAEntr(pp) && pp->KindOfPE != OpProperty) + while (!EndOfPAEntr(pp) && pp->KindOfPE != OpProperty && + (pp->OpModule != PROLOG_MODULE || pp->OpModule != CurrentModule)) pp = RepOpProp(pp->NextOfPE); return (pp); } +int +Yap_IsOp(Atom at) +{ + OpEntry *op = NextOp(RepOpProp((Prop)(RepAtom(at)->PropsOfAE))); + return (!EndOfPAEntr(op)); +} + static Int unify_op(OpEntry *op) { diff --git a/C/write.c b/C/write.c index 9d7a35127..64030aa26 100644 --- a/C/write.c +++ b/C/write.c @@ -216,14 +216,12 @@ legalAtom(unsigned char *s) /* Is this a legal atom ? */ static int LeftOpToProtect(Atom at, int p) { - int op, rp; - return Yap_IsPrefixOp(at, &op, &rp); + return Yap_IsOp(at); } static int RightOpToProtect(Atom at, int p) { - int op, lp; - return Yap_IsPosfixOp(at, &op, &lp); + return Yap_IsOp(at); } static wtype diff --git a/H/Yatom.h b/H/Yatom.h index 69b45b06b..1595b86a6 100644 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -491,6 +491,7 @@ typedef enum OpEntry *STD_PROTO(Yap_GetOpProp,(Atom, op_type)); int STD_PROTO(Yap_IsPrefixOp,(Atom,int *,int *)); +int STD_PROTO(Yap_IsOp,(Atom)); int STD_PROTO(Yap_IsInfixOp,(Atom,int *,int *,int *)); int STD_PROTO(Yap_IsPosfixOp,(Atom,int *,int *));