diff options
author | Mark-Jason Dominus <mjd@plover.com> | 2000-07-04 06:00:12 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-07-11 13:54:09 +0000 |
commit | f805f8cce32dfd1ced3ebf12975766f50f88ec0c (patch) | |
tree | f31ef25240984d596bca4c5f46bbaec2994acbfd /toke.c | |
parent | 46c1698f90ff4d1ca2d1f36008d72123e3f7907f (diff) | |
download | perl-f805f8cce32dfd1ced3ebf12975766f50f88ec0c.tar.gz |
Be less forgiving about ambiguous and illegal tr ranges.
Subject: Re: [ID 20000703.001] tr/// operator understands multiple hyphens in a bizarre way
Date: Tue, 04 Jul 2000 10:00:12 -0400
Message-ID: <20000704140012.17772.qmail@plover.com>
Subject: Re: [ID 20000703.001] tr/// operator understands multiple hyphens in a bizarre way
From: Mark-Jason Dominus <mjd@plover.com>
Date: Wed, 05 Jul 2000 09:37:36 -0400
Message-ID: <20000705133736.27293.qmail@plover.com>
p4raw-id: //depot/cfgperl@6339
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -1208,6 +1208,7 @@ S_scan_const(pTHX_ char *start) register char *s = start; /* start of the constant */ register char *d = SvPVX(sv); /* destination for copies */ bool dorange = FALSE; /* are we in a translit range? */ + bool didrange = FALSE; /* did we just finish a range? */ bool has_utf = FALSE; /* embedded \x{} */ I32 len; /* ? */ UV uv; @@ -1241,6 +1242,13 @@ S_scan_const(pTHX_ char *start) min = (U8)*d; /* first char in range */ max = (U8)d[1]; /* last char in range */ + + if (min > max) { + Perl_croak(aTHX_ + "Invalid [] range \"%c-%c\" in transliteration operator", + min, max); + } + #ifndef ASCIIish if ((isLOWER(min) && isLOWER(max)) || (isUPPER(min) && isUPPER(max))) { @@ -1261,11 +1269,15 @@ S_scan_const(pTHX_ char *start) /* mark the range as done, and continue */ dorange = FALSE; + didrange = TRUE; continue; - } + } /* range begins (ignore - as first or last char) */ else if (*s == '-' && s+1 < send && s != start) { + if (didrange) { + croak("Ambiguous range in transliteration operator"); + } if (utf) { *d++ = (char)0xff; /* use illegal utf8 byte--see pmtrans */ s++; @@ -1273,7 +1285,9 @@ S_scan_const(pTHX_ char *start) } dorange = TRUE; s++; - } + } else { + didrange = FALSE; + } } /* if we get here, we're not doing a transliteration */ |