Oops, this patch broke things. For example, the following is invalid:

> Index: chartypes/unicode.c
> ===================================================================
> RCS file: /home/perlcvs/parrot/chartypes/unicode.c,v
> retrieving revision 1.5
> diff -c -r1.5 unicode.c
> *** chartypes/unicode.c       4 Jan 2002 16:17:46 -0000       1.5
> --- chartypes/unicode.c       14 Jan 2002 16:40:54 -0000
> ***************
> *** 24,30 ****
>   
>   static BOOLVAL
>   unicode_is_digit(INTVAL c) {
> !     return isdigit(c) ? 1 : 0; /* FIXME - Other code points are also digits */
>   }
>   
>   static INTVAL
> --- 24,30 ----
>   
>   static BOOLVAL
>   unicode_is_digit(INTVAL c) {
> !     return (BOOLVAL)(isdigit(c)); /* FIXME - Other code points are also digits */
>   }
>   
>   static INTVAL

BOOLVAL turns out to be an unsigned char. isdigit() returns an int. So
you really do need the '? 0 : 1'. (On my machine, isdigit(48) return
2048, which is zero when cast to BOOLVAL.)

>      BOOLVAL get_bool () {
> !       return (BOOLVAL)SELF->data;
>      }
>   
>      void* get_value () {
> --- 72,78 ----
>      }
>   
>      BOOLVAL get_bool () {
> !       return (BOOLVAL)(SELF->data != NULL);
>      }

This works, after the change, on my machine at least. But what type
does != officially return? Is it allowed to return eg SELF->data?

Perhaps we should make BOOLVAL be an int or unsigned int? Still have
to worry about pointers, but at least we can return things directly
from libc's boolean functions.

This patch makes the tests pass again:

Index: chartypes/unicode.c
===================================================================
RCS file: /home/perlcvs/parrot/chartypes/unicode.c,v
retrieving revision 1.6
diff -a -u -r1.6 unicode.c
--- chartypes/unicode.c 14 Jan 2002 20:04:19 -0000      1.6
+++ chartypes/unicode.c 14 Jan 2002 21:33:43 -0000
@@ -24,7 +24,7 @@
 
 static BOOLVAL
 unicode_is_digit(INTVAL c) {
-    return (BOOLVAL)(isdigit(c)); /* FIXME - Other code points are also digits */
+    return (BOOLVAL)(isdigit(c) ? 1 : 0); /* FIXME - Other code points are also 
+digits */
 }
 
 static INTVAL
Index: chartypes/usascii.c
===================================================================
RCS file: /home/perlcvs/parrot/chartypes/usascii.c,v
retrieving revision 1.4
diff -a -u -r1.4 usascii.c
--- chartypes/usascii.c 14 Jan 2002 20:04:19 -0000      1.4
+++ chartypes/usascii.c 14 Jan 2002 21:33:43 -0000
@@ -47,7 +47,7 @@
 
 static BOOLVAL
 usascii_is_digit(INTVAL c) {
-    return (BOOLVAL)(isdigit(c));
+    return (BOOLVAL)(isdigit(c) ? 1 : 0);
 }
 
 static INTVAL

Reply via email to