add workaround for dlopen() bug on OpenBSD (relative paths that
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 83438e9..90500a4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -545,9 +545,21 @@ S_study_chunk(pTHX_ regnode **scanp, I32 *deltap, regnode *last, scan_data_t *da
                    }
                }
                else if (flags & SCF_DO_STCLASS_AND) {
-                   cl_and(data->start_class, &accum);
-                   if (min1)
+                   if (min1) {
+                       cl_and(data->start_class, &accum);
                        flags &= ~SCF_DO_STCLASS;
+                   }
+                   else {
+                       /* Switch to OR mode: cache the old value of 
+                        * data->start_class */
+                       StructCopy(data->start_class, &and_with,
+                                  struct regnode_charclass_class);
+                       flags &= ~SCF_DO_STCLASS_AND;
+                       StructCopy(&accum, data->start_class,
+                                  struct regnode_charclass_class);
+                       flags |= SCF_DO_STCLASS_OR;
+                       data->start_class->flags |= ANYOF_EOS;
+                   }
                }
            }
            else if (code == BRANCHJ)   /* single branch is optimized. */
@@ -2558,11 +2570,19 @@ tryagain:
                        p++;
                        break;
                    case 'e':
-                       ender = '\033';
+#ifdef ASCIIish
+                         ender = '\033';
+#else
+                         ender = '\047';
+#endif
                        p++;
                        break;
                    case 'a':
-                       ender = '\007';
+#ifdef ASCIIish
+                         ender = '\007';
+#else
+                         ender = '\057';
+#endif
                        p++;
                        break;
                    case 'x':
@@ -2898,8 +2918,13 @@ S_regclass(pTHX)
            case 't':   value = '\t';                   break;
            case 'f':   value = '\f';                   break;
            case 'b':   value = '\b';                   break;
+#ifdef ASCIIish
            case 'e':   value = '\033';                 break;
            case 'a':   value = '\007';                 break;
+#else
+           case 'e':   value = '\047';                 break;
+           case 'a':   value = '\057';                 break;
+#endif
            case 'x':
                value = (UV)scan_hex(PL_regcomp_parse, 2, &numlen);
                PL_regcomp_parse += numlen;
@@ -2918,7 +2943,7 @@ S_regclass(pTHX)
                    Perl_warner(aTHX_ WARN_UNSAFE, 
                                "/%.127s/: Unrecognized escape \\%c in character class passed through",
                                PL_regprecomp,
-                               value);
+                               (int)value);
                break;
            }
        }
@@ -3360,8 +3385,13 @@ S_regclassutf8(pTHX)
            case 't':           value = '\t';           break;
            case 'f':           value = '\f';           break;
            case 'b':           value = '\b';           break;
+#ifdef ASCIIish
            case 'e':           value = '\033';         break;
            case 'a':           value = '\007';         break;
+#else
+           case 'e':           value = '\047';         break;
+           case 'a':           value = '\057';         break;
+#endif
            case 'x':
                if (*PL_regcomp_parse == '{') {
                    e = strchr(PL_regcomp_parse++, '}');
@@ -3391,7 +3421,7 @@ S_regclassutf8(pTHX)
                    Perl_warner(aTHX_ WARN_UNSAFE, 
                                "/%.127s/: Unrecognized escape \\%c in character class passed through",
                                PL_regprecomp,
-                               value);
+                               (int)value);
                break;
            }
        }