From 471cc93f6cdaee5b86e21fe7bdd11009f0559f3c Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 26 Nov 2010 23:36:50 +0000 Subject: [PATCH] fix some bad code in legalAtom, allowing /a/b not to be quoted (obs from Paulo Moura). --- C/write.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/C/write.c b/C/write.c index 504c2bdf2..740359f0e 100755 --- a/C/write.c +++ b/C/write.c @@ -292,29 +292,30 @@ wrputref(CODEADDR ref, int Quote_illegal, wrf writewch) /* writes a data base static int legalAtom(unsigned char *s) /* Is this a legal atom ? */ - { wchar_t ch = *s; if (ch == '\0') - return(FALSE); + return FALSE; if (Yap_chtype[ch] != LC) { - if (ch == '[') - return (*++s == ']' && !(*++s)); - else if (ch == '{') - return (*++s == '}' && !(*++s)); + if (ch == '[') { + return (s[1] == ']' && !s[2]); + } else if (ch == '{') { + return (s[1] == '}' && !s[2]); // else if (ch == '/') // return (*++s != '*'); - else if (Yap_chtype[ch] == SL) - return (!*++s); - else if ((ch == ',' || ch == '.') && !s[1]) + } else if (Yap_chtype[ch] == SL) { + return (!s[1]); + } else if ((ch == ',' || ch == '.') && !s[1]) { return FALSE; - else + } else { while (ch) { - if (Yap_chtype[ch] != SY) + if (Yap_chtype[ch] != SY) { return FALSE; + } ch = *++s; } + } return TRUE; } else while ((ch = *++s) != 0)