# if defined(CRIPPLED_CC)
#define uni S_uni
# endif
-# if defined(WIN32)
-#define win32_textfilter S_win32_textfilter
+# if defined(PERL_CR_FILTER)
+#define cr_textfilter S_cr_textfilter
# endif
#endif
#if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
# if defined(CRIPPLED_CC)
#define uni(a,b) S_uni(aTHX_ a,b)
# endif
-# if defined(WIN32)
-#define win32_textfilter(a,b,c) S_win32_textfilter(aTHX_ a,b,c)
+# if defined(PERL_CR_FILTER)
+#define cr_textfilter(a,b,c) S_cr_textfilter(aTHX_ a,b,c)
# endif
#endif
#if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
#define S_uni CPerlObj::S_uni
#define uni S_uni
# endif
-# if defined(WIN32)
-#define S_win32_textfilter CPerlObj::S_win32_textfilter
-#define win32_textfilter S_win32_textfilter
+# if defined(PERL_CR_FILTER)
+#define S_cr_textfilter CPerlObj::S_cr_textfilter
+#define cr_textfilter S_cr_textfilter
# endif
#endif
#if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
# if defined(CRIPPLED_CC)
s |int |uni |I32 f|char *s
# endif
-# if defined(WIN32)
-s |I32 |win32_textfilter |int idx|SV *sv|int maxlen
+# if defined(PERL_CR_FILTER)
+s |I32 |cr_textfilter |int idx|SV *sv|int maxlen
# endif
#endif
#if defined(PERL_IN_TOKE_C) || defined(PERL_DECL_PROT)
# if defined(CRIPPLED_CC)
# endif
-# if defined(WIN32)
+# if defined(PERL_CR_FILTER)
# endif
#endif
#if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
Rudimentary support for building under command.com in Windows 95
has been added.
+Scripts are read in binary mode by default to allow ByteLoader (and
+the filter mechanism in general) to work properly. For compatibility,
+the DATA filehandle continues to be set to text mode.
+
[TODO - GSAR]
=head1 New tests
# if defined(CRIPPLED_CC)
STATIC int S_uni(pTHX_ I32 f, char *s);
# endif
-# if defined(WIN32)
-STATIC I32 S_win32_textfilter(pTHX_ int idx, SV *sv, int maxlen);
+# if defined(PERL_CR_FILTER)
+STATIC I32 S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen);
# endif
#endif
}
}
-#ifdef WIN32
- win32_strip_return(sv);
-#endif
-
return (SvCUR(sv) - append) ? SvPVX(sv) : Nullch;
}
* utf16-to-utf8-reversed.
*/
-#ifdef WIN32
+#ifdef PERL_CR_FILTER
+static void
+strip_return(SV *sv)
+{
+ register char *s = SvPVX(sv);
+ register char *e = s + SvCUR(sv);
+ /* outer loop optimized to do nothing if there are no CR-LFs */
+ while (s < e) {
+ if (*s++ == '\r' && *s == '\n') {
+ /* hit a CR-LF, need to copy the rest */
+ register char *d = s - 1;
+ *d++ = *s++;
+ while (s < e) {
+ if (*s == '\r' && s[1] == '\n')
+ s++;
+ *d++ = *s++;
+ }
+ SvCUR(sv) -= s - d;
+ return;
+ }
+ }
+}
STATIC I32
-S_win32_textfilter(pTHX_ int idx, SV *sv, int maxlen)
+S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen)
{
- I32 count = FILTER_READ(idx+1, sv, maxlen);
- if (count > 0 && !maxlen)
- win32_strip_return(sv);
- return count;
+ I32 count = FILTER_READ(idx+1, sv, maxlen);
+ if (count > 0 && !maxlen)
+ strip_return(sv);
+ return count;
}
#endif
STATIC char *
S_filter_gets(pTHX_ register SV *sv, register PerlIO *fp, STRLEN append)
{
-#ifdef WIN32FILTER
+#ifdef PERL_CR_FILTER
if (!PL_rsfp_filters) {
- filter_add(win32_textfilter,NULL);
+ filter_add(S_cr_textfilter,NULL);
}
#endif
if (PL_rsfp_filters) {
IoTYPE(GvIOp(gv)) = '-';
else
IoTYPE(GvIOp(gv)) = '<';
+#if defined(WIN32) && !defined(PERL_TEXTMODE_SCRIPTS)
+ /* if the script was opened in binmode, we need to revert
+ * it to text mode for compatibility.
+ * XXX this is a questionable hack at best. */
+ {
+ Off_t loc = 0;
+ if (IoTYPE(GvIOp(gv)) == '<') {
+ loc = PerlIO_tell(PL_rsfp);
+ (void)PerlIO_seek(PL_rsfp, 0L, 0);
+ }
+ if (PerlLIO_setmode(PerlIO_fileno(PL_rsfp), O_TEXT) != -1) {
+#if defined(__BORLANDC__)
+ /* XXX see note in do_binmode() */
+ ((FILE*)PL_rsfp)->flags |= _F_BIN;
+#endif
+ if (loc > 0)
+ PerlIO_seek(PL_rsfp, loc, 0);
+ }
+ }
+#endif
PL_rsfp = Nullfp;
}
goto fake_eof;
CCLIBDIR = $(CCHOME)\lib
#
-# additional compiler flags can be specified here.
+# Additional compiler flags can be specified here.
#
-# Adding -DPERL_POLLUTE enables support for old symbols, at the expense of
-# extreme pollution. You most probably want this if you're compiling modules
-# from CPAN, or other such serious uses of this experimental perl release.
-# We don't enable this by default because we want the modules to get fixed
-# instead of clinging to shortcuts like this one.
+
+#
+# This should normally be disabled. Adding -DPERL_POLLUTE enables support
+# for old symbols by default, at the expense of extreme pollution. You most
+# probably just want to build modules that won't compile with
+# perl Makefile.PL POLLUTE=1
+# instead of enabling this. Please report such modules to the respective
+# authors.
#
#BUILDOPT = $(BUILDOPT) -DPERL_POLLUTE
#
-# enable this to disable the File::Glob implementation of CORE::glob
+# This should normally be disabled. Enabling it will disable the File::Glob
+# implementation of CORE::glob.
#
#BUILDOPT = $(BUILDOPT) -DPERL_EXTERNAL_GLOB
-# Enabling this causes perl to do its own CR/LF conversions, and is required
-# if you want to be able to use the bytecode compiler and ByteLoader
-BUILDOPT = $(BUILDOPT) -DUSE_BINMODE_SCRIPTS
+#
+# This should normally be disabled. Enabling it causes perl to read scripts
+# in text mode (which is the 5.005 behavior) and will break ByteLoader.
+#BUILDOPT = $(BUILDOPT) -DUSE_TEXTMODE_SCRIPTS
-# Enabling this runs a cloned toplevel interpreter (*EXPERIMENTAL*, fails tests)
+#
+# This should normally be disabled. Enabling it runs a cloned toplevel
+# interpreter (*EXPERIMENTAL*, fails tests)
#BUILDOPT = $(BUILDOPT) -DTOP_CLONE
+#
# specify semicolon-separated list of extra directories that modules will
# look for libraries (spaces in path names need not be quoted)
#
CCLIBDIR *= $(CCHOME)\lib
#
-# additional compiler flags can be specified here.
+# Additional compiler flags can be specified here.
#
-# Adding -DPERL_POLLUTE enables support for old symbols, at the expense of
-# extreme pollution. You most probably want this if you're compiling modules
-# from CPAN, or other such serious uses of this experimental perl release.
-# We don't enable this by default because we want the modules to get fixed
-# instead of clinging to shortcuts like this one.
+
+#
+# This should normally be disabled. Adding -DPERL_POLLUTE enables support
+# for old symbols by default, at the expense of extreme pollution. You most
+# probably just want to build modules that won't compile with
+# perl Makefile.PL POLLUTE=1
+# instead of enabling this. Please report such modules to the respective
+# authors.
#
#BUILDOPT += -DPERL_POLLUTE
#
-# enable this to disable the File::Glob implementation of CORE::glob
+# This should normally be disabled. Enabling it will disable the File::Glob
+# implementation of CORE::glob.
#
#BUILDOPT += -DPERL_EXTERNAL_GLOB
-# Enabling this causes perl to do its own CR/LF conversions, and is required
-# if you want to be able to use the bytecode compiler and ByteLoader
-BUILDOPT += -DUSE_BINMODE_SCRIPTS
+#
+# This should normally be disabled. Enabling it causes perl to read scripts
+# in text mode (which is the 5.005 behavior) and will break ByteLoader.
+#BUILDOPT += -DUSE_TEXTMODE_SCRIPTS
-# Enabling this runs a cloned toplevel interpreter (*EXPERIMENTAL*, fails tests)
+#
+# This should normally be disabled. Enabling it runs a cloned toplevel
+# interpreter (*EXPERIMENTAL*, fails tests)
#BUILDOPT += -DTOP_CLONE
#
MALLOC_INIT;
}
-#ifdef USE_BINMODE_SCRIPTS
-
-void
-win32_strip_return(SV *sv)
-{
- char *s = SvPVX(sv);
- char *e = s+SvCUR(sv);
- char *d = s;
- while (s < e)
- {
- if (*s == '\r' && s[1] == '\n')
- {
- *d++ = '\n';
- s += 2;
- }
- else
- {
- *d++ = *s++;
- }
- }
- SvCUR_set(sv,d-SvPVX(sv));
-}
-
-#endif
-
#ifdef USE_ITHREADS
# ifdef PERL_OBJECT
#define PERL_CORE
#endif
-#ifdef USE_BINMODE_SCRIPTS
-#define PERL_SCRIPT_MODE "rb"
-EXT void win32_strip_return(struct sv *sv);
+#ifdef USE_TEXTMODE_SCRIPTS
+# define PERL_SCRIPT_MODE "r"
#else
-#define PERL_SCRIPT_MODE "r"
-#define win32_strip_return(sv) NOOP
+# define PERL_SCRIPT_MODE "rb"
#endif
/*