From e90a1ce0248400796f432752789c9cadea14064c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Tue, 15 Feb 2011 18:40:18 +0000 Subject: [PATCH] avoid repeated fetch --- packages/PLStream/pl-write.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/PLStream/pl-write.c b/packages/PLStream/pl-write.c index 62410423e..61b641dde 100644 --- a/packages/PLStream/pl-write.c +++ b/packages/PLStream/pl-write.c @@ -1087,20 +1087,22 @@ writeTerm2(term_t t, int prec, write_options *options, bool arg) _PL_get_arg(1, t, arg); #if __YAP_PROLOG__ - if ( PL_get_integer(arg, &n) && n == -1 ) - { char buf[16]; - - buf[0] = '_'; - buf[1] = EOS; - - return PutToken(buf, out); - } + /* YAP supports $VAR(-1) as a quick hack to write singleton variables */ +#define MIN_DOLLAR_VAR -1 +#else +#define MIN_DOLLAR_VAR 0 #endif - if ( PL_get_integer(arg, &n) && n >= 0 ) + if ( PL_get_integer(arg, &n) && n >= MIN_DOLLAR_VAR ) { int i = n % 26; int j = n / 26; char buf[16]; +#if __YAP_PROLOG__ + if ( n == -1 ) { + buf[0] = '_'; + buf[1] = EOS; + } else +#endif if ( j == 0 ) { buf[0] = i+'A'; buf[1] = EOS;