Skip to content

Commit

Permalink
Get PerlIO building on Win32
Browse files Browse the repository at this point in the history
Message-ID: <20001113230808.18659.qmail@web6305.mail.yahoo.com>

p4raw-id: //depot/perl@7679
  • Loading branch information
Benjamin Stuhl authored and jhi committed Nov 14, 2000
1 parent 0db725d commit e601c43
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 108 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ warnings.h The warning numbers
warnings.pl Program to write warnings.h and lib/warnings.pm
win32/Makefile Win32 makefile for NMAKE (Visual C++ build)
win32/bin/exetype.pl Set executable type to CONSOLE or WINDOWS
win32/bin/mdelete.bat multifile delete
win32/bin/perlglob.pl Win32 globbing
win32/bin/pl2bat.pl wrap perl scripts into batch files
win32/bin/runperl.pl run perl script via batch file namesake
Expand Down
21 changes: 15 additions & 6 deletions ext/SDBM_File/Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ExtUtils::MakeMaker;
use Config;

# The existence of the ./sdbm/Makefile.PL file causes MakeMaker
# to automatically include Makefile code for the targets
Expand All @@ -21,18 +22,26 @@ WriteMakefile(

sub MY::postamble {
if ($^O =~ /MSWin32/ && Win32::IsWin95()) {
# XXX: dmake-specific, like rest of Win95 port
return
'
if ($Config{'make'} =~ /dmake/i) {
# dmake-specific
return <<EOT;
$(MYEXTLIB): sdbm/Makefile
@[
cd sdbm
$(MAKE) all
cd ..
]
';
}
elsif ($^O ne 'VMS') {
EOT
} elsif ($Config{'make'} =~ /nmake/i) {
#
return <<'EOT';
$(MYEXTLIB): sdbm/Makefile
cd sdbm
$(MAKE) all
cd ..
EOT
}
} elsif ($^O ne 'VMS') {
'
$(MYEXTLIB): sdbm/Makefile
cd sdbm && $(MAKE) all
Expand Down
17 changes: 13 additions & 4 deletions lib/ExtUtils/MM_Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3288,17 +3288,26 @@ sub subdir_x {
my($self, $subdir) = @_;
my(@m);
if ($Is_Win32 && Win32::IsWin95()) {
# XXX: dmake-specific, like rest of Win95 port
return <<EOT;
if ($Config{'make'} =~ /dmake/i) {
# dmake-specific
return <<EOT;
subdirs ::
@[
cd $subdir
\$(MAKE) all \$(PASTHRU)
cd ..
]
EOT
}
else {
} elsif ($Config{'make'} =~ /nmake/i) {
# nmake-specific
return <<EOT;
subdirs ::
cd $subdir
\$(MAKE) all \$(PASTHRU)
cd ..
EOT
}
} else {
return <<EOT;
subdirs ::
Expand Down
86 changes: 45 additions & 41 deletions makedef.pl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
}
elsif ($PLATFORM eq 'win32') {
$CCTYPE = "MSVC" unless defined $CCTYPE;
foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
$pp_sym, $globvar_sym, $perlio_sym) {
s!^!..\\!;
}
}
Expand Down Expand Up @@ -572,42 +573,15 @@ sub try_symbol {

if ($PLATFORM eq 'win32') {
foreach my $symbol (qw(
setuid
setgid
boot_DynaLoader
Perl_init_os_extras
Perl_thread_create
Perl_win32_init
RunPerl
win32_errno
win32_environ
win32_stdin
win32_stdout
win32_stderr
win32_ferror
win32_feof
win32_strerror
win32_fprintf
win32_printf
win32_vfprintf
win32_vprintf
win32_fread
win32_fwrite
win32_fopen
win32_fdopen
win32_freopen
win32_fclose
win32_fputs
win32_fputc
win32_ungetc
win32_getc
win32_fileno
win32_clearerr
win32_fflush
win32_ftell
win32_fseek
win32_fgetpos
win32_fsetpos
win32_rewind
win32_tmpfile
win32_abort
win32_fstat
win32_stat
Expand Down Expand Up @@ -678,17 +652,6 @@ sub try_symbol {
win32_getenv
win32_putenv
win32_perror
win32_setbuf
win32_setvbuf
win32_flushall
win32_fcloseall
win32_fgets
win32_gets
win32_fgetc
win32_putc
win32_puts
win32_getchar
win32_putchar
win32_malloc
win32_calloc
win32_realloc
Expand Down Expand Up @@ -720,6 +683,47 @@ sub try_symbol {
win32_getpid
win32_crypt
win32_dynaload

win32_stdin
win32_stdout
win32_stderr
win32_ferror
win32_feof
win32_strerror
win32_fprintf
win32_printf
win32_vfprintf
win32_vprintf
win32_fread
win32_fwrite
win32_fopen
win32_fdopen
win32_freopen
win32_fclose
win32_fputs
win32_fputc
win32_ungetc
win32_getc
win32_fileno
win32_clearerr
win32_fflush
win32_ftell
win32_fseek
win32_fgetpos
win32_fsetpos
win32_rewind
win32_tmpfile
win32_setbuf
win32_setvbuf
win32_flushall
win32_fcloseall
win32_fgets
win32_gets
win32_fgetc
win32_putc
win32_puts
win32_getchar
win32_putchar
))
{
try_symbol($symbol);
Expand Down
28 changes: 14 additions & 14 deletions perlio.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ PerlIO_debug(char *fmt,...)
static int dbg = 0;
if (!dbg)
{
char *s = getenv("PERLIO_DEBUG");
char *s = PerlEnv_getenv("PERLIO_DEBUG");
if (s && *s)
dbg = open(s,O_WRONLY|O_CREAT|O_APPEND,0666);
dbg = PerlLIO_open3(s,O_WRONLY|O_CREAT|O_APPEND,0666);
else
dbg = -1;
}
Expand All @@ -128,7 +128,7 @@ PerlIO_debug(char *fmt,...)
Perl_sv_vcatpvf(aTHX_ sv, fmt, &ap);

s = SvPV(sv,len);
write(dbg,s,len);
PerlLIO_write(dbg,s,len);
va_end(ap);
SvREFCNT_dec(sv);
}
Expand Down Expand Up @@ -354,7 +354,7 @@ PerlIO_default_layer(I32 n)
int len;
if (!PerlIO_layer_hv)
{
char *s = getenv("PERLIO");
char *s = PerlEnv_getenv("PERLIO");
newXS("perlio::import",XS_perlio_import,__FILE__);
newXS("perlio::unimport",XS_perlio_unimport,__FILE__);
PerlIO_layer_hv = get_hv("perlio::layers",GV_ADD|GV_ADDMULTI);
Expand All @@ -370,13 +370,13 @@ PerlIO_default_layer(I32 n)
{
while (*s)
{
while (*s && isspace((unsigned char)*s))
while (*s && isSPACE((unsigned char)*s))
s++;
if (*s)
{
char *e = s;
SV *layer;
while (*e && !isspace((unsigned char)*e))
while (*e && !isSPACE((unsigned char)*e))
e++;
layer = PerlIO_find_layer(s,e-s);
if (layer)
Expand Down Expand Up @@ -902,7 +902,7 @@ PerlIOUnix_open(PerlIO_funcs *self, const char *path,const char *mode)
int oflags = PerlIOUnix_oflags(mode);
if (oflags != -1)
{
int fd = open(path,oflags,0666);
int fd = PerlLIO_open3(path,oflags,0666);
if (fd >= 0)
{
PerlIOUnix *s = PerlIOSelf(PerlIO_push(f = PerlIO_allocate(),self,mode),PerlIOUnix);
Expand All @@ -923,7 +923,7 @@ PerlIOUnix_reopen(const char *path, const char *mode, PerlIO *f)
(*PerlIOBase(f)->tab->Close)(f);
if (oflags != -1)
{
int fd = open(path,oflags,0666);
int fd = PerlLIO_open3(path,oflags,0666);
if (fd >= 0)
{
s->fd = fd;
Expand All @@ -943,7 +943,7 @@ PerlIOUnix_read(PerlIO *f, void *vbuf, Size_t count)
return 0;
while (1)
{
SSize_t len = read(fd,vbuf,count);
SSize_t len = PerlLIO_read(fd,vbuf,count);
if (len >= 0 || errno != EINTR)
{
if (len < 0)
Expand All @@ -961,7 +961,7 @@ PerlIOUnix_write(PerlIO *f, const void *vbuf, Size_t count)
int fd = PerlIOSelf(f,PerlIOUnix)->fd;
while (1)
{
SSize_t len = write(fd,vbuf,count);
SSize_t len = PerlLIO_write(fd,vbuf,count);
if (len >= 0 || errno != EINTR)
{
if (len < 0)
Expand All @@ -974,23 +974,23 @@ PerlIOUnix_write(PerlIO *f, const void *vbuf, Size_t count)
IV
PerlIOUnix_seek(PerlIO *f, Off_t offset, int whence)
{
Off_t new = lseek(PerlIOSelf(f,PerlIOUnix)->fd,offset,whence);
Off_t new = PerlLIO_lseek(PerlIOSelf(f,PerlIOUnix)->fd,offset,whence);
PerlIOBase(f)->flags &= ~PERLIO_F_EOF;
return (new == (Off_t) -1) ? -1 : 0;
}

Off_t
PerlIOUnix_tell(PerlIO *f)
{
return lseek(PerlIOSelf(f,PerlIOUnix)->fd,0,SEEK_CUR);
return PerlLIO_lseek(PerlIOSelf(f,PerlIOUnix)->fd,0,SEEK_CUR);
}

IV
PerlIOUnix_close(PerlIO *f)
{
int fd = PerlIOSelf(f,PerlIOUnix)->fd;
int code = 0;
while (close(fd) != 0)
while (PerlLIO_close(fd) != 0)
{
if (errno != EINTR)
{
Expand Down Expand Up @@ -2269,7 +2269,7 @@ PerlIO_tmpfile(void)
{
PerlIOBase(f)->flags |= PERLIO_F_TEMP;
}
unlink(SvPVX(sv));
PerlLIO_unlink(SvPVX(sv));
SvREFCNT_dec(sv);
}
return f;
Expand Down
Loading

0 comments on commit e601c43

Please sign in to comment.