summaryrefslogtreecommitdiff
path: root/pcretest.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-09-08 15:58:38 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-09-08 15:58:38 +0000
commit5a848b2083b8e68478a3fcf76955936e6fb28b1a (patch)
tree22de44511121078b49413bdaf33bffaa5adb6490 /pcretest.c
parent5bc26cb3e177038f3d023c5cb6897035e24b357e (diff)
downloadpcre-5a848b2083b8e68478a3fcf76955936e6fb28b1a.tar.gz
Fix -C option in pcretest for EBCDIC environments.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1030 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r--pcretest.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/pcretest.c b/pcretest.c
index 8bd32fd..604514e 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -1097,6 +1097,39 @@ return sys_errlist[n];
#endif /* HAVE_STRERROR */
+
+/*************************************************
+* Print newline configuration *
+*************************************************/
+
+/*
+Argument: the return code from PCRE_CONFIG_NEWLINE
+Returns: nothing
+*/
+
+static void
+print_newline_config(int rc)
+{
+const char *s = NULL;
+printf(" Newline sequence is ");
+switch(rc)
+ {
+ case CHAR_CR: s = "CR"; break;
+ case CHAR_LF: s = "LF"; break;
+ case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break;
+ case -1: s = "ANY"; break;
+ case -2: s = "ANYCRLF"; break;
+
+ default:
+ printf("a non-standard value: 0x%04x\n", rc);
+ return;
+ }
+
+printf("%s\n", s);
+}
+
+
+
/*************************************************
* JIT memory callback *
*************************************************/
@@ -2428,12 +2461,7 @@ while (argc > 1 && argv[op][0] == '-')
if (strcmp(argv[op + 1], "newline") == 0)
{
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
- /* Note that these values are always the ASCII values, even
- in EBCDIC environments. CR is 13 and NL is 10. */
- printf("%s\n", (rc == 13)? "CR" :
- (rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" :
- (rc == -2)? "ANYCRLF" :
- (rc == -1)? "ANY" : "???");
+ print_newline_config(rc);
goto EXIT;
}
printf("Unknown -C option: %s\n", argv[op + 1]);
@@ -2442,6 +2470,10 @@ while (argc > 1 && argv[op][0] == '-')
printf("PCRE version %s\n", version);
printf("Compiled with\n");
+
+#ifdef EBCDIC
+ printf(" EBCDIC code support: LF is 0x%02x\n", CHAR_LF);
+#endif
/* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both
are set, either both UTFs are supported or both are not supported. */
@@ -2475,12 +2507,7 @@ are set, either both UTFs are supported or both are not supported. */
else
printf(" No just-in-time compiler support\n");
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
- /* Note that these values are always the ASCII values, even
- in EBCDIC environments. CR is 13 and NL is 10. */
- printf(" Newline sequence is %s\n", (rc == 13)? "CR" :
- (rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" :
- (rc == -2)? "ANYCRLF" :
- (rc == -1)? "ANY" : "???");
+ print_newline_config(rc);
(void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc);
printf(" \\R matches %s\n", rc? "CR, LF, or CRLF only" :
"all Unicode newlines");