summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-02-01 06:27:35 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-02-01 06:27:35 +0000
commit80252599d4b7fb26eec4e3a0f451b4387c5dcc19 (patch)
treeaf33a52bae818e292c641108bbbc11b8b1b4f8c2 /win32
parent34f744a4168d1ae5fad32a9241fb076a6b2c3fa8 (diff)
downloadperl-80252599d4b7fb26eec4e3a0f451b4387c5dcc19.tar.gz
various win32-ish changes merged from maint-5.005
p4raw-id: //depot/perl@2746
Diffstat (limited to 'win32')
-rw-r--r--win32/Makefile27
-rw-r--r--win32/config.bc2
-rw-r--r--win32/config.vc2
-rw-r--r--win32/config_sh.PL15
-rw-r--r--win32/makefile.mk33
-rw-r--r--win32/runperl.c24
-rw-r--r--win32/win32.c148
7 files changed, 165 insertions, 86 deletions
diff --git a/win32/Makefile b/win32/Makefile
index bee48c0764..3b3c4d4894 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -111,12 +111,8 @@ INST_VER = \5.00554
# set the install locations of the compiler include/libraries
# Running VCVARS32.BAT is *required* when using Visual C.
# Some versions of Visual C don't define MSVCDIR in the environment,
-# so you may have to set CCHOME explicitly.
-#
-# If the path contains spaces, you can try putting it in double
-# quotes, but support for this is not well-tested, and various
-# other things may break, so you're kinda on your own if you are
-# into specious paths. :-)
+# so you may have to set CCHOME explicitly (spaces in the path name should
+# not be quoted)
#
#CCHOME = f:\msvc20
CCHOME = $(MSVCDIR)
@@ -135,7 +131,8 @@ CCLIBDIR = $(CCHOME)\lib
#BUILDOPT = -DPERL_POLLUTE
#
-# specify space-separated list of extra directories to look for libraries
+# specify semicolon-separated list of extra directories that modules will
+# look for libraries (spaces in path names need not be quoted)
#
EXTRALIBDIRS =
@@ -590,14 +587,14 @@ CFG_VARS = \
"INST_VER=$(INST_VER)" \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
- "ccflags=$(OPTIMIZE) $(DEFINES) $(OBJECT)" \
+ "ccflags=$(OPTIMIZE:"=\") $(DEFINES) $(OBJECT)" \
"cf_email=$(EMAIL)" \
"d_crypt=$(D_CRYPT)" \
"d_mymalloc=$(PERL_MALLOC)" \
"libs=$(LIBFILES)" \
- "incpath=$(CCINCDIR)" \
- "libperl=$(PERLIMPLIB:..\=)" \
- "libpth=$(CCLIBDIR) $(EXTRALIBDIRS)" \
+ "incpath=$(CCINCDIR:"=\")" \
+ "libperl=$(PERLIMPLIB:..\=)" \
+ "libpth=$(CCLIBDIR:"=\");$(EXTRALIBDIRS:"=\")" \
"libc=$(LIBC)" \
"make=nmake" \
"static_ext=$(STATIC_EXT)" \
@@ -605,8 +602,8 @@ CFG_VARS = \
"nonxs_ext=$(NONXS_EXT)" \
"usethreads=$(USE_THREADS)" \
"usemultiplicity=$(USE_MULTI)" \
- "LINK_FLAGS=$(LINK_FLAGS)" \
- "optimize=$(OPTIMIZE)"
+ "LINK_FLAGS=$(LINK_FLAGS:"=\")" \
+ "optimize=$(OPTIMIZE:"=\")"
#
# Top targets
@@ -645,7 +642,7 @@ regen_config_h:
perl configpm
cd win32
-del /f $(CFGH_TMPL)
- -mkdir ..\lib\CORE
+ -mkdir $(COREDIR)
-perl -I..\lib config_h.PL "INST_VER=$(INST_VER)"
rename config.h $(CFGH_TMPL)
@@ -657,7 +654,7 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl
$(XCOPY) ..\ext\re\re.pm $(LIBDIR)\*.*
$(RCOPY) include $(COREDIR)\*.*
$(MINIPERL) -I..\lib config_h.PL "INST_VER=$(INST_VER)" \
- || $(MAKE) $(MAKEFLAGS) $(CONFIGPM)
+ || $(MAKE) /$(MAKEFLAGS) $(CONFIGPM)
$(MINIPERL) : $(MINIDIR) $(MINI_OBJ)
$(LINK32) -subsystem:console -out:$@ @<<
diff --git a/win32/config.bc b/win32/config.bc
index c460453782..d91fbb977a 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -546,7 +546,7 @@ shrpenv=''
shsharp='true'
sig_name='ZERO NUM01 INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM USR1 USR2 CHLD NUM19 USR3 BREAK ABRT STOP NUM24 CONT CLD'
sig_name_init='"ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "NUM19", "USR3", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0'
-sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 18 '
+sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 18 0'
sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 0'
signal_t='void'
sitearch='~INST_TOP~\site~INST_VER~\lib\~archname~'
diff --git a/win32/config.vc b/win32/config.vc
index 81bd72435e..1a99dd99e4 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -546,7 +546,7 @@ shrpenv=''
shsharp='true'
sig_name='ZERO NUM01 INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD'
sig_name_init='"ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0'
-sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 '
+sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 0'
sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0'
signal_t='void'
sitearch='~INST_TOP~\site~INST_VER~\lib\~archname~'
diff --git a/win32/config_sh.PL b/win32/config_sh.PL
index 59e64f9675..1d4b2fb5c3 100644
--- a/win32/config_sh.PL
+++ b/win32/config_sh.PL
@@ -1,3 +1,15 @@
+# take a semicolon separated path list and turn it into a quoted
+# list of paths that Text::Parsewords will grok
+sub mungepath {
+ my $p = shift;
+ # remove leading/trailing semis/spaces
+ $p =~ s/^[ ;]+//;
+ $p =~ s/[ ;]+$//;
+ $p =~ s/'/"/g;
+ my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p;
+ return join(' ', @p);
+}
+
my %opt;
while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
{
@@ -17,6 +29,9 @@ $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
unless $opt{'cf_email'};
$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
+$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
+$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
+
while (<>)
{
s/~([\w_]+)~/$opt{$1}/g;
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 56f17ea77c..dab54d643b 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -122,12 +122,8 @@ CCTYPE *= BORLAND
# set the install locations of the compiler include/libraries
# Running VCVARS32.BAT is *required* when using Visual C.
# Some versions of Visual C don't define MSVCDIR in the environment,
-# so you may have to set CCHOME explicitly.
-#
-# If the path contains spaces, you can try putting it in double
-# quotes, but support for this is not well-tested, and various
-# other things may break, so you're kinda on your own if you are
-# into specious paths. :-)
+# so you may have to set CCHOME explicitly (spaces in the path name should
+# not be quoted)
#
CCHOME *= C:\bc5
#CCHOME *= $(MSVCDIR)
@@ -147,7 +143,8 @@ CCLIBDIR *= $(CCHOME)\lib
#BUILDOPT *= -DPERL_POLLUTE
#
-# specify space-separated list of extra directories to look for libraries
+# specify semicolon-separated list of extra directories that modules will
+# look for libraries (spaces in path names need not be quoted)
#
EXTRALIBDIRS *=
@@ -220,7 +217,7 @@ IMPLIB = implib -c
# Options
#
RUNTIME = -D_RTLDLL
-INCLUDES = -I$(COREDIR) -I.\include -I. -I.. -I$(CCINCDIR)
+INCLUDES = -I$(COREDIR) -I.\include -I. -I.. -I"$(CCINCDIR)"
#PCHFLAGS = -H -Hc -H=c:\temp\bcmoduls.pch
DEFINES = -DWIN32 $(BUILDOPT) $(CRYPT_FLAG)
LOCDEFS = -DPERLDLL -DPERL_CORE
@@ -240,7 +237,7 @@ LINK_DBG =
CFLAGS = -w -g0 -tWM -tWD $(INCLUDES) $(DEFINES) $(LOCDEFS) \
$(PCHFLAGS) $(OPTIMIZE)
-LINK_FLAGS = $(LINK_DBG) -L$(CCLIBDIR) $(EXTRALIBDIRS:^"-L")
+LINK_FLAGS = $(LINK_DBG) -L"$(CCLIBDIR)"
OBJOUT_FLAG = -o
EXEOUT_FLAG = -e
LIBOUT_FLAG =
@@ -278,7 +275,7 @@ LINK_DBG =
.ENDIF
CFLAGS = $(INCLUDES) $(DEFINES) $(LOCDEFS) $(OPTIMIZE)
-LINK_FLAGS = $(LINK_DBG) -L$(CCLIBDIR) $(EXTRALIBDIRS:^"-L")
+LINK_FLAGS = $(LINK_DBG) -L"$(CCLIBDIR)"
OBJOUT_FLAG = -o
EXEOUT_FLAG = -o
LIBOUT_FLAG =
@@ -705,14 +702,14 @@ CFG_VARS = \
"INST_VER=$(INST_VER)" \
"archname=$(ARCHNAME)" \
"cc=$(CC)" \
- "ccflags=$(OPTIMIZE) $(DEFINES) $(OBJECT)" \
+ "ccflags=$(OPTIMIZE:s/"/\"/) $(DEFINES) $(OBJECT)" \
"cf_email=$(EMAIL)" \
"d_crypt=$(D_CRYPT)" \
"d_mymalloc=$(PERL_MALLOC)" \
"libs=$(LIBFILES:f)" \
- "incpath=$(CCINCDIR)" \
+ "incpath=$(CCINCDIR:s/"/\"/)" \
"libperl=$(PERLIMPLIB:f)" \
- "libpth=$(strip $(CCLIBDIR) $(EXTRALIBDIRS) $(LIBFILES:d))" \
+ "libpth=$(CCLIBDIR:s/"/\"/);$(EXTRALIBDIRS:s/"/\"/)" \
"libc=$(LIBC)" \
"make=dmake" \
"_o=$(o)" "obj_ext=$(o)" \
@@ -722,8 +719,8 @@ CFG_VARS = \
"nonxs_ext=$(NONXS_EXT)" \
"usethreads=$(USE_THREADS)" \
"usemultiplicity=$(USE_MULTI)" \
- "LINK_FLAGS=$(LINK_FLAGS)" \
- "optimize=$(OPTIMIZE)"
+ "LINK_FLAGS=$(LINK_FLAGS:s/"/\"/)" \
+ "optimize=$(OPTIMIZE:s/"/\"/)"
#
# Top targets
@@ -738,9 +735,9 @@ $(DYNALOADER)$(o) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c
$(GLOBEXE) : perlglob$(o)
.IF "$(CCTYPE)" == "BORLAND"
- $(CC) -c -w -v -tWM -I$(CCINCDIR) perlglob.c
+ $(CC) -c -w -v -tWM -I"$(CCINCDIR)" perlglob.c
$(LINK32) -Tpe -ap $(LINK_FLAGS) c0x32$(o) perlglob$(o) \
- $(CCLIBDIR)\32BIT\wildargs$(o),$@,,import32.lib cw32mt.lib,
+ "$(CCLIBDIR)\32BIT\wildargs$(o)",$@,,import32.lib cw32mt.lib,
.ELIF "$(CCTYPE)" == "GCC"
$(LINK32) $(LINK_FLAGS) -o $@ perlglob$(o) $(LIBFILES)
.ELSE
@@ -768,7 +765,7 @@ regen_config_h:
-cd .. && del /f perl.exe
cd .. && perl configpm
-del /f $(CFGH_TMPL)
- -mkdir ..\lib\CORE
+ -mkdir $(COREDIR)
-perl -I..\lib config_h.PL "INST_VER=$(INST_VER)"
rename config.h $(CFGH_TMPL)
diff --git a/win32/runperl.c b/win32/runperl.c
index 3947f9ef37..8cf521d4ea 100644
--- a/win32/runperl.c
+++ b/win32/runperl.c
@@ -1,9 +1,8 @@
-
-#ifdef PERL_OBJECT
-#define USE_SOCKETS_AS_HANDLES
#include "EXTERN.h"
#include "perl.h"
+#ifdef PERL_OBJECT
+
#define NO_XSLOCKS
#include "XSUB.H"
#include "win32iop.h"
@@ -37,8 +36,17 @@ main(int argc, char **argv, char **env)
{
CPerlHost host;
int exitstatus = 1;
+#ifndef __BORLANDC__
+ /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
+ * want to free() argv after main() returns. As luck would have it,
+ * Borland's CRT does the right thing to argv[0] already. */
+ char szModuleName[MAX_PATH];
+
+ GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
+ argv[0] = szModuleName;
+#endif
- if(!host.PerlCreate())
+ if (!host.PerlCreate())
exit(exitstatus);
exitstatus = host.PerlParse(xs_init, argc, argv, NULL);
@@ -74,6 +82,14 @@ __declspec(dllimport) int RunPerl(int argc, char **argv, char **env, void *ios);
int
main(int argc, char **argv, char **env)
{
+#ifndef __BORLANDC__
+ /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
+ * want to free() argv after main() returns. As luck would have it,
+ * Borland's CRT does the right thing to argv[0] already. */
+ char szModuleName[MAX_PATH];
+ GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
+ argv[0] = szModuleName;
+#endif
return RunPerl(argc, argv, env, (void*)0);
}
diff --git a/win32/win32.c b/win32/win32.c
index e9619d637c..2c74fc25af 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -191,9 +191,9 @@ get_emd_part(char *prev_path, char *trailing_path, ...)
sprintf(base, "%5.3f", (double) 5 + ((double) PATCHLEVEL / (double) 1000));
- GetModuleFileName((w32_perldll_handle == INVALID_HANDLE_VALUE)
- ? GetModuleHandle(NULL)
- : w32_perldll_handle, mod_name, sizeof(mod_name));
+ GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
+ ? GetModuleHandle(NULL) : w32_perldll_handle),
+ mod_name, sizeof(mod_name));
ptr = strrchr(mod_name, '\\');
while (ptr && strip) {
/* look for directories to skip back */
@@ -201,8 +201,11 @@ get_emd_part(char *prev_path, char *trailing_path, ...)
*ptr = '\0';
ptr = strrchr(mod_name, '\\');
if (!ptr || stricmp(ptr+1, strip) != 0) {
- *optr = '\\';
- ptr = optr;
+ if(!(*strip == '5' && *(ptr+1) == '5' && strncmp(strip, base, 5) == 0
+ && strncmp(ptr+1, base, 5) == 0)) {
+ *optr = '\\';
+ ptr = optr;
+ }
}
strip = va_arg(ap, char *);
}
@@ -494,7 +497,7 @@ do_aspawn(void *vreally, void **vmark, void **vsp)
(const char*)(really ? SvPV(really,n_a) : argv[0]),
(const char* const*)argv);
- if (status < 0 && errno == ENOEXEC) {
+ if (status < 0 && (errno == ENOEXEC || errno == ENOENT)) {
/* possible shell-builtin, invoke with shell */
int sh_items;
sh_items = w32_perlshell_items;
@@ -1773,51 +1776,102 @@ win32_pclose(FILE *pf)
DllExport int
win32_rename(const char *oname, const char *newname)
{
- char szNewWorkName[MAX_PATH+1];
- WIN32_FIND_DATA fdOldFile, fdNewFile;
- HANDLE handle;
- char *ptr;
-
- if ((strchr(oname, '\\') || strchr(oname, '/'))
- && strchr(newname, '\\') == NULL
- && strchr(newname, '/') == NULL)
- {
- strcpy(szNewWorkName, oname);
- if ((ptr = strrchr(szNewWorkName, '\\')) == NULL)
- ptr = strrchr(szNewWorkName, '/');
- strcpy(++ptr, newname);
+ /* XXX despite what the documentation says about MoveFileEx(),
+ * it doesn't work under Windows95!
+ */
+ if (IsWinNT()) {
+ if (!MoveFileEx(oname,newname,
+ MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING)) {
+ DWORD err = GetLastError();
+ switch (err) {
+ case ERROR_BAD_NET_NAME:
+ case ERROR_BAD_NETPATH:
+ case ERROR_BAD_PATHNAME:
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_FILENAME_EXCED_RANGE:
+ case ERROR_INVALID_DRIVE:
+ case ERROR_NO_MORE_FILES:
+ case ERROR_PATH_NOT_FOUND:
+ errno = ENOENT;
+ break;
+ default:
+ errno = EACCES;
+ break;
+ }
+ return -1;
+ }
+ return 0;
}
- else
- strcpy(szNewWorkName, newname);
-
- if (stricmp(oname, szNewWorkName) != 0) {
- // check that we're not being fooled by relative paths
- // and only delete the new file
- // 1) if it exists
- // 2) it is not the same file as the old file
- // 3) old file exist
- // GetFullPathName does not return the long file name on some systems
- handle = FindFirstFile(oname, &fdOldFile);
- if (handle != INVALID_HANDLE_VALUE) {
- FindClose(handle);
-
- handle = FindFirstFile(szNewWorkName, &fdNewFile);
-
- if (handle != INVALID_HANDLE_VALUE)
- FindClose(handle);
+ else {
+ int retval = 0;
+ char tmpname[MAX_PATH+1];
+ char dname[MAX_PATH+1];
+ char *endname = Nullch;
+ STRLEN tmplen = 0;
+ DWORD from_attr, to_attr;
+
+ /* if oname doesn't exist, do nothing */
+ from_attr = GetFileAttributes(oname);
+ if (from_attr == 0xFFFFFFFF) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* if newname exists, rename it to a temporary name so that we
+ * don't delete it in case oname happens to be the same file
+ * (but perhaps accessed via a different path)
+ */
+ to_attr = GetFileAttributes(newname);
+ if (to_attr != 0xFFFFFFFF) {
+ /* if newname is a directory, we fail
+ * XXX could overcome this with yet more convoluted logic */
+ if (to_attr & FILE_ATTRIBUTE_DIRECTORY) {
+ errno = EACCES;
+ return -1;
+ }
+ tmplen = strlen(newname);
+ strcpy(tmpname,newname);
+ endname = tmpname+tmplen;
+ for (; endname > tmpname ; --endname) {
+ if (*endname == '/' || *endname == '\\') {
+ *endname = '\0';
+ break;
+ }
+ }
+ if (endname > tmpname)
+ endname = strcpy(dname,tmpname);
else
- fdNewFile.cFileName[0] = '\0';
-
- if (strcmp(fdOldFile.cAlternateFileName,
- fdNewFile.cAlternateFileName) != 0
- && strcmp(fdOldFile.cFileName, fdNewFile.cFileName) != 0)
- {
- // file exists and not same file
- DeleteFile(szNewWorkName);
+ endname = ".";
+
+ /* get a temporary filename in same directory
+ * XXX is this really the best we can do? */
+ if (!GetTempFileName((LPCTSTR)endname, "plr", 0, tmpname)) {
+ errno = ENOENT;
+ return -1;
+ }
+ DeleteFile(tmpname);
+
+ retval = rename(newname, tmpname);
+ if (retval != 0) {
+ errno = EACCES;
+ return retval;
}
}
+
+ /* rename oname to newname */
+ retval = rename(oname, newname);
+
+ /* if we created a temporary file before ... */
+ if (endname != Nullch) {
+ /* ...and rename succeeded, delete temporary file/directory */
+ if (retval == 0)
+ DeleteFile(tmpname);
+ /* else restore it to what it was */
+ else
+ (void)rename(tmpname, newname);
+ }
+ return retval;
}
- return rename(oname, newname);
}
DllExport int
@@ -2346,7 +2400,7 @@ XS(w32_Spawn)
if (items != 3)
croak("usage: Win32::Spawn($cmdName, $args, $PID)");
- cmd = SvPV(ST(0), n_a);
+ cmd = SvPV(ST(0),n_a);
args = SvPV(ST(1), n_a);
memset(&stStartInfo, 0, sizeof(stStartInfo)); /* Clear the block */