develooper Front page | perl.perl5.porters | Postings from November 1999

[PATCH: 5.005_62] implement /[:ascii:]/ on ebcdic machines

From:
Peter Prymmer
Date:
November 25, 1999 21:06
Subject:
[PATCH: 5.005_62] implement /[:ascii:]/ on ebcdic machines
Message ID:
199911260506.VAA17230@brio.forte.com

The following patch fixes the new /[:ascii:]/ regular expression
on non ASCII machines.  Do note that isASCII is #defined to be isascii()
on EBCDIC machines.  On OS/390 isascii() is bi-modal.  Under the
effect of #define _XOPEN_SOURCE isascii() returns true for chars
in the range 0 <= c <= 127, but under the effect of #define _ALL_SOURCE
isascii() returns true for those EBCDIC chars that correspond to the
ASCII character set.  In os390.sh we set ccflags to contain -D_ALL_SOURCE,
but that flag is not set in vmesa.sh or posix-bc.sh so those folks might
beware of this change and the tests done in t/op/regexp*.t.

Peter Prymmer


diff -ru perl5.005_62.orig/regcomp.c perl5.005_62/regcomp.c
--- perl5.005_62.orig/regcomp.c	Fri Oct 15 00:07:44 1999
+++ perl5.005_62/regcomp.c	Thu Nov 25 20:15:25 1999
@@ -2484,16 +2484,28 @@
 		    if (LOC)
 			ANYOF_CLASS_SET(opnd, ANYOF_ASCII);
 		    else {
-			for (value = 0; value < 128; value++)
-			    ANYOF_BITMAP_SET(opnd, value);
+#			ifdef ASCIIish
+			    for (value = 0; value < 128; value++)
+			        ANYOF_BITMAP_SET(opnd, value);
+#			else  /* EBCDIC */
+			    for (value = 0; value < 256; value++)
+			        if (isASCII(value))
+			            ANYOF_BITMAP_SET(opnd, value);
+#			endif /* EBCDIC */
 		    }
 		    break;
 		case ANYOF_NASCII:
 		    if (LOC)
 			ANYOF_CLASS_SET(opnd, ANYOF_NASCII);
 		    else {
-			for (value = 128; value < 256; value++)
-			    ANYOF_BITMAP_SET(opnd, value);
+#			ifdef ASCIIish
+			    for (value = 128; value < 256; value++)
+			        ANYOF_BITMAP_SET(opnd, value);
+#			else  /* EBCDIC */
+			    for (value = 0; value < 256; value++)
+			        if (!isASCII(value))
+			            ANYOF_BITMAP_SET(opnd, value);
+#			endif /* EBCDIC */
 		    }
 		    break;
 		case ANYOF_CNTRL:
End of Patch.





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About