Skip to content

Commit c68c3ab

Browse files
committed
toke.c: remove PERL_CR_FILTER
When enabled (e.g. with `./Configure -A ccflags=-DPERL_CR_FILTER`), this would define an implicit source filter that turns \r\n pairs into \n whenever the parser reads a line of Perl source code. As far as I can tell, perl already does the equivalent of this (without a source filter) on all platforms and has done so since 5.005. (Also, the code could read out-of-bounds if the last character of the line read was a \r.)
1 parent 8d585c6 commit c68c3ab

File tree

4 files changed

+5
-67
lines changed

4 files changed

+5
-67
lines changed

embed.fnc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5970,12 +5970,6 @@ Sf |void |printbuf |NN const char * const fmt \
59705970
S |int |tokereport |I32 rv \
59715971
|NN const YYSTYPE *lvalp
59725972
# endif
5973-
# if defined(PERL_CR_FILTER)
5974-
S |I32 |cr_textfilter |int idx \
5975-
|NULLOK SV *sv \
5976-
|int maxlen
5977-
S |void |strip_return |NN SV *sv
5978-
# endif
59795973
# if !defined(PERL_NO_UTF16_FILTER)
59805974
S |U8 * |add_utf16_textfilter \
59815975
|NN U8 * const s \

embed.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,10 +1730,6 @@
17301730
# define printbuf(a,b) S_printbuf(aTHX_ a,b)
17311731
# define tokereport(a,b) S_tokereport(aTHX_ a,b)
17321732
# endif
1733-
# if defined(PERL_CR_FILTER)
1734-
# define cr_textfilter(a,b,c) S_cr_textfilter(aTHX_ a,b,c)
1735-
# define strip_return(a) S_strip_return(aTHX_ a)
1736-
# endif
17371733
# if !defined(PERL_NO_UTF16_FILTER)
17381734
# define add_utf16_textfilter(a,b) S_add_utf16_textfilter(aTHX_ a,b)
17391735
# define utf16_textfilter(a,b,c) S_utf16_textfilter(aTHX_ a,b,c)

proto.h

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toke.c

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -800,47 +800,6 @@ S_scan_terminated(pTHX_ char *s, I32 ival) {
800800

801801
#include "feature.h"
802802

803-
/*
804-
* experimental text filters for win32 carriage-returns, utf16-to-utf8 and
805-
* utf16-to-utf8-reversed.
806-
*/
807-
808-
#ifdef PERL_CR_FILTER
809-
static void
810-
strip_return(SV *sv)
811-
{
812-
const char *s = SvPVX_const(sv);
813-
const char * const e = s + SvCUR(sv);
814-
815-
PERL_ARGS_ASSERT_STRIP_RETURN;
816-
817-
/* outer loop optimized to do nothing if there are no CR-LFs */
818-
while (s < e) {
819-
if (*s++ == '\r' && *s == '\n') {
820-
/* hit a CR-LF, need to copy the rest */
821-
char *d = s - 1;
822-
*d++ = *s++;
823-
while (s < e) {
824-
if (*s == '\r' && s[1] == '\n')
825-
s++;
826-
*d++ = *s++;
827-
}
828-
SvCUR(sv) -= s - d;
829-
return;
830-
}
831-
}
832-
}
833-
834-
STATIC I32
835-
S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen)
836-
{
837-
const I32 count = FILTER_READ(idx+1, sv, maxlen);
838-
if (count > 0 && !maxlen)
839-
strip_return(sv);
840-
return count;
841-
}
842-
#endif
843-
844803
STATIC void
845804
S_yyerror_non_ascii_message(pTHX_ const U8 * const s)
846805
{
@@ -5126,11 +5085,6 @@ S_filter_gets(pTHX_ SV *sv, STRLEN append)
51265085
{
51275086
PERL_ARGS_ASSERT_FILTER_GETS;
51285087

5129-
#ifdef PERL_CR_FILTER
5130-
if (!PL_rsfp_filters) {
5131-
filter_add(S_cr_textfilter,NULL);
5132-
}
5133-
#endif
51345088
if (PL_rsfp_filters) {
51355089
if (!append)
51365090
SvCUR_set(sv, 0); /* start with empty line */
@@ -13091,6 +13045,11 @@ S_swallow_bom(pTHX_ U8 *s)
1309113045

1309213046

1309313047
#ifndef PERL_NO_UTF16_FILTER
13048+
/*
13049+
* experimental text filter for utf16-to-utf8 and
13050+
* utf16-to-utf8-reversed.
13051+
*/
13052+
1309413053
static I32
1309513054
S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen)
1309613055
{

0 commit comments

Comments
 (0)