The isalpha() in newlib triggers a gcc warning if used with a char as
input. One way to work around this is to simply pass an int, which is
how POSIX defines isalpha anyway.
---
 src/compiler/unique.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/compiler/unique.c b/src/compiler/unique.c
index a34ce53..7804dcd 100644
--- a/src/compiler/unique.c
+++ b/src/compiler/unique.c
@@ -84,12 +84,24 @@ static int cmp_n(const void *a, const void *b)
 }
 
 
+/*
+ * "isid" is not only a minor convenient enhancement, but it also shields us
+ * from implementations of isalpha() that trigger compiler warnings if "c" is
+ * a character.
+ */
+
+static int isid(int c)
+{
+       return isalpha(c) || c == '_';
+}
+
+
 const char *unique(const char *s)
 {
        const char **res;
        const char **walk;
 
-       if(!isalnum(*s) && *s != '_')
+       if(!isid(*s))
                return s;
        res = bsearch(s, well_known, sizeof(well_known)/sizeof(*well_known),
            sizeof(s), cmp);
@@ -112,7 +124,7 @@ const char *unique_n(const char *s, int n)
        const char **res;
        const char **walk;
 
-       if(!isalnum(*s) && *s != '_')
+       if(!isid(*s))
                return s;
        res = bsearch(&key, well_known, sizeof(well_known)/sizeof(*well_known),
            sizeof(s), cmp_n);
-- 
1.7.1

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode

Reply via email to