summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-02-08 20:58:02 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-02-08 20:58:02 +0000
commit1761cee512762c09b2a848d3c6cbd5a3b4232ffa (patch)
tree6e211068ee1368390669709334240812fd0a67de /win32
parent3dc6ede7f49a7b2b348c8780a45fe232aa5beb97 (diff)
downloadperl-1761cee512762c09b2a848d3c6cbd5a3b4232ffa.tar.gz
Integrate with Sarathy.
p4raw-id: //depot/cfgperl@5043
Diffstat (limited to 'win32')
-rw-r--r--win32/Makefile6
-rw-r--r--win32/bin/exetype.pl61
-rw-r--r--win32/config.bc1
-rw-r--r--win32/config.gc1
-rw-r--r--win32/config.vc1
-rw-r--r--win32/config_H.bc18
-rw-r--r--win32/config_H.gc18
-rw-r--r--win32/config_H.vc18
-rw-r--r--win32/makefile.mk8
-rw-r--r--win32/perllib.c10
-rw-r--r--win32/win32.c64
-rw-r--r--win32/win32.h16
12 files changed, 148 insertions, 74 deletions
diff --git a/win32/Makefile b/win32/Makefile
index e4f3d86c5e..6bf5e6ec33 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -29,7 +29,7 @@ INST_TOP = $(INST_DRV)\perl
# versioned installation can be obtained by setting INST_TOP above to a
# path that includes an arbitrary version string.
#
-INST_VER = \5.5.640
+INST_VER = \5.5.650
#
# Comment this out if you DON'T want your perl installation to have
@@ -432,7 +432,7 @@ $(o).dll:
-out:$@ $(LINK_FLAGS) $(LIBFILES) $< $(LIBPERL)
.rc.res:
- $(RSC) $<
+ $(RSC) -i.. $<
#
# various targets
@@ -854,7 +854,7 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
$(LINK32) -subsystem:console -out:$@ $(LINK_FLAGS) $(LIBFILES) \
$(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES)
copy $(PERLEXE) $(WPERLEXE)
- editbin /subsystem:windows $(WPERLEXE)
+ $(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
copy splittree.pl ..
$(MINIPERL) -I..\lib ..\splittree.pl "../LIB" $(AUTODIR)
diff --git a/win32/bin/exetype.pl b/win32/bin/exetype.pl
new file mode 100644
index 0000000000..5846b3ee3b
--- /dev/null
+++ b/win32/bin/exetype.pl
@@ -0,0 +1,61 @@
+#!perl -w
+use strict;
+unless (@ARGV == 2) {
+ print "Usage: $0 exefile [CONSOLE|WINDOWS]\n";
+ exit;
+}
+unless ($ARGV[1] =~ /^(console|windows)$/i) {
+ print "Invalid subsystem $ARGV[1], please use CONSOLE or WINDOWS\n";
+ exit;
+}
+my ($record,$magic,$offset,$size);
+open EXE, "+< $ARGV[0]" or die "Cannot open $ARGV[0]: $!";
+binmode EXE;
+read EXE, $record, 32*4;
+($magic,$offset) = unpack "Sx58L", $record;
+die "Not an MSDOS executable file" unless $magic == 0x5a4d;
+seek EXE, $offset, 0;
+read EXE, $record, 24;
+($magic,$size) = unpack "Lx16S", $record;
+die "PE header not found" unless $magic == 0x4550;
+die "Optional header not in NT32 format" unless $size == 224;
+seek EXE, $offset+24+68, 0;
+print EXE pack "S", uc($ARGV[1]) eq 'CONSOLE' ? 3 : 2;
+close EXE;
+__END__
+
+=head1 NAME
+
+exetype - Change executable subsystem type between "Console" and "Windows"
+
+=head1 SYNOPSIS
+
+ C:\perl\bin> copy perl.exe guiperl.exe
+ C:\perl\bin> exetype guiperl.exe windows
+
+=head1 DESCRIPTION
+
+This program edits an executable file to indicate which subsystem the
+operating system must invoke for execution.
+
+You can specify any of the following subsystems:
+
+=over
+
+=item CONSOLE
+
+The CONSOLE subsystem handles a Win32 character-mode application that
+use a console supplied by the operating system.
+
+=item WINDOWS
+
+The WINDOWS subsystem handles an application that does not require a
+console and creates its own windows, if required.
+
+=back
+
+=head1 AUTHOR
+
+Jan Dubois <jand@activestate.com>
+
+=cut
diff --git a/win32/config.bc b/win32/config.bc
index 137347e349..fd70a3f560 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -472,6 +472,7 @@ i_varhdr='varargs.h'
i_vfork='undef'
ignore_versioned_solibs=''
inc_version_list=''
+inc_version_list_init='0'
incpath=''
inews=''
installarchlib='~INST_TOP~~INST_VER~\lib~INST_ARCH~'
diff --git a/win32/config.gc b/win32/config.gc
index abfc288cc2..10a1c778f9 100644
--- a/win32/config.gc
+++ b/win32/config.gc
@@ -472,6 +472,7 @@ i_varhdr='varargs.h'
i_vfork='undef'
ignore_versioned_solibs=''
inc_version_list=''
+inc_version_list_init='0'
incpath=''
inews=''
installarchlib='~INST_TOP~~INST_VER~\lib~INST_ARCH~'
diff --git a/win32/config.vc b/win32/config.vc
index 729beb8cd4..5514827e86 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -472,6 +472,7 @@ i_varhdr='varargs.h'
i_vfork='undef'
ignore_versioned_solibs=''
inc_version_list=''
+inc_version_list_init='0'
incpath=''
inews=''
installarchlib='~INST_TOP~~INST_VER~\lib~INST_ARCH~'
diff --git a/win32/config_H.bc b/win32/config_H.bc
index 399111f2b1..e89f71eecd 100644
--- a/win32/config_H.bc
+++ b/win32/config_H.bc
@@ -1082,7 +1082,7 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "c:\\perl\\5.5.640\\lib\\MSWin32-x86" /**/
+#define ARCHLIB "c:\\perl\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define ARCHLIB_EXP "" /**/
/* ARCHNAME:
@@ -1113,8 +1113,8 @@
* This symbol is the filename expanded version of the BIN symbol, for
* programs that do not want to deal with that at run-time.
*/
-#define BIN "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
-#define BIN_EXP "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
+#define BIN "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
+#define BIN_EXP "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
/* PERL_BINCOMPAT_5005:
* This symbol, if defined, indicates that Perl 5.006 should be
@@ -2305,7 +2305,7 @@
* for a C initialization string. See the inc_version_list entry
* in Porting/Glossary for more details.
*/
-#define PERL_INC_VERSION_LIST /**/
+#define PERL_INC_VERSION_LIST 0 /**/
/* HAS_OFF64_T:
* This symbol will be defined if the C compiler supports off64_t.
@@ -2540,8 +2540,8 @@
* This symbol contains the ~name expanded version of PRIVLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define PRIVLIB "c:\\perl\\5.5.640\\lib" /**/
-#define PRIVLIB_EXP (win32_get_privlib("5.5.640")) /**/
+#define PRIVLIB "c:\\perl\\5.5.650\\lib" /**/
+#define PRIVLIB_EXP (win32_get_privlib("5.5.650")) /**/
/* PTRSIZE:
* This symbol contains the size of a pointer, so that the C preprocessor
@@ -2639,7 +2639,7 @@
* This symbol contains the ~name expanded version of SITEARCH, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITEARCH "c:\\perl\\site\\5.5.640\\lib\\MSWin32-x86" /**/
+#define SITEARCH "c:\\perl\\site\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define SITEARCH_EXP "" /**/
/* SITELIB:
@@ -2657,8 +2657,8 @@
* This symbol contains the ~name expanded version of SITELIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITELIB "c:\\perl\\site\\5.5.640\\lib" /**/
-#define SITELIB_EXP (win32_get_sitelib("5.5.640")) /**/
+#define SITELIB "c:\\perl\\site\\5.5.650\\lib" /**/
+#define SITELIB_EXP (win32_get_sitelib("5.5.650")) /**/
/* Size_t:
* This symbol holds the type used to declare length parameters
diff --git a/win32/config_H.gc b/win32/config_H.gc
index 9575e4325e..d9adb8f8d7 100644
--- a/win32/config_H.gc
+++ b/win32/config_H.gc
@@ -1082,7 +1082,7 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "c:\\perl\\5.5.640\\lib\\MSWin32-x86" /**/
+#define ARCHLIB "c:\\perl\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define ARCHLIB_EXP "" /**/
/* ARCHNAME:
@@ -1113,8 +1113,8 @@
* This symbol is the filename expanded version of the BIN symbol, for
* programs that do not want to deal with that at run-time.
*/
-#define BIN "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
-#define BIN_EXP "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
+#define BIN "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
+#define BIN_EXP "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
/* PERL_BINCOMPAT_5005:
* This symbol, if defined, indicates that Perl 5.006 should be
@@ -2305,7 +2305,7 @@
* for a C initialization string. See the inc_version_list entry
* in Porting/Glossary for more details.
*/
-#define PERL_INC_VERSION_LIST /**/
+#define PERL_INC_VERSION_LIST 0 /**/
/* HAS_OFF64_T:
* This symbol will be defined if the C compiler supports off64_t.
@@ -2540,8 +2540,8 @@
* This symbol contains the ~name expanded version of PRIVLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define PRIVLIB "c:\\perl\\5.5.640\\lib" /**/
-#define PRIVLIB_EXP (win32_get_privlib("5.5.640")) /**/
+#define PRIVLIB "c:\\perl\\5.5.650\\lib" /**/
+#define PRIVLIB_EXP (win32_get_privlib("5.5.650")) /**/
/* PTRSIZE:
* This symbol contains the size of a pointer, so that the C preprocessor
@@ -2639,7 +2639,7 @@
* This symbol contains the ~name expanded version of SITEARCH, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITEARCH "c:\\perl\\site\\5.5.640\\lib\\MSWin32-x86" /**/
+#define SITEARCH "c:\\perl\\site\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define SITEARCH_EXP "" /**/
/* SITELIB:
@@ -2657,8 +2657,8 @@
* This symbol contains the ~name expanded version of SITELIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITELIB "c:\\perl\\site\\5.5.640\\lib" /**/
-#define SITELIB_EXP (win32_get_sitelib("5.5.640")) /**/
+#define SITELIB "c:\\perl\\site\\5.5.650\\lib" /**/
+#define SITELIB_EXP (win32_get_sitelib("5.5.650")) /**/
/* Size_t:
* This symbol holds the type used to declare length parameters
diff --git a/win32/config_H.vc b/win32/config_H.vc
index dc019993ae..1cd5e65a60 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -1082,7 +1082,7 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "c:\\perl\\5.5.640\\lib\\MSWin32-x86" /**/
+#define ARCHLIB "c:\\perl\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define ARCHLIB_EXP "" /**/
/* ARCHNAME:
@@ -1113,8 +1113,8 @@
* This symbol is the filename expanded version of the BIN symbol, for
* programs that do not want to deal with that at run-time.
*/
-#define BIN "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
-#define BIN_EXP "c:\\perl\\5.5.640\\bin\\MSWin32-x86" /**/
+#define BIN "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
+#define BIN_EXP "c:\\perl\\5.5.650\\bin\\MSWin32-x86" /**/
/* PERL_BINCOMPAT_5005:
* This symbol, if defined, indicates that Perl 5.006 should be
@@ -2305,7 +2305,7 @@
* for a C initialization string. See the inc_version_list entry
* in Porting/Glossary for more details.
*/
-#define PERL_INC_VERSION_LIST /**/
+#define PERL_INC_VERSION_LIST 0 /**/
/* HAS_OFF64_T:
* This symbol will be defined if the C compiler supports off64_t.
@@ -2540,8 +2540,8 @@
* This symbol contains the ~name expanded version of PRIVLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define PRIVLIB "c:\\perl\\5.5.640\\lib" /**/
-#define PRIVLIB_EXP (win32_get_privlib("5.5.640")) /**/
+#define PRIVLIB "c:\\perl\\5.5.650\\lib" /**/
+#define PRIVLIB_EXP (win32_get_privlib("5.5.650")) /**/
/* PTRSIZE:
* This symbol contains the size of a pointer, so that the C preprocessor
@@ -2639,7 +2639,7 @@
* This symbol contains the ~name expanded version of SITEARCH, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITEARCH "c:\\perl\\site\\5.5.640\\lib\\MSWin32-x86" /**/
+#define SITEARCH "c:\\perl\\site\\5.5.650\\lib\\MSWin32-x86" /**/
/*#define SITEARCH_EXP "" /**/
/* SITELIB:
@@ -2657,8 +2657,8 @@
* This symbol contains the ~name expanded version of SITELIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITELIB "c:\\perl\\site\\5.5.640\\lib" /**/
-#define SITELIB_EXP (win32_get_sitelib("5.5.640")) /**/
+#define SITELIB "c:\\perl\\site\\5.5.650\\lib" /**/
+#define SITELIB_EXP (win32_get_sitelib("5.5.650")) /**/
/* Size_t:
* This symbol holds the type used to declare length parameters
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 6d13e10a4c..64f89fdbb3 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -33,7 +33,7 @@ INST_TOP *= $(INST_DRV)\perl
# versioned installation can be obtained by setting INST_TOP above to a
# path that includes an arbitrary version string.
#
-INST_VER *= \5.5.640
+INST_VER *= \5.5.650
#
# Comment this out if you DON'T want your perl installation to have
@@ -540,7 +540,7 @@ $(o).dll:
.ENDIF
.rc.res:
- $(RSC) $<
+ $(RSC) -i.. $<
#
# various targets
@@ -1094,9 +1094,9 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
.ELSE
$(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) $(LIBFILES) \
$(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES)
- copy $(PERLEXE) $(WPERLEXE)
- editbin /subsystem:windows $(WPERLEXE)
.ENDIF
+ copy $(PERLEXE) $(WPERLEXE)
+ $(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
copy splittree.pl ..
$(MINIPERL) -I..\lib ..\splittree.pl "../LIB" $(AUTODIR)
diff --git a/win32/perllib.c b/win32/perllib.c
index 84a2a6dc4b..26135f864e 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -259,13 +259,19 @@ static DWORD g_TlsAllocIndex;
EXTERN_C DllExport bool
SetPerlInterpreter(void *interp)
{
- return TlsSetValue(g_TlsAllocIndex, interp);
+ DWORD dwErr = GetLastError();
+ bool bResult = TlsSetValue(g_TlsAllocIndex, interp);
+ SetLastError(dwErr);
+ return bResult;
}
EXTERN_C DllExport void*
GetPerlInterpreter(void)
{
- return TlsGetValue(g_TlsAllocIndex);
+ DWORD dwErr = GetLastError();
+ LPVOID pResult = TlsGetValue(g_TlsAllocIndex);
+ SetLastError(dwErr);
+ return pResult;
}
EXTERN_C DllExport int
diff --git a/win32/win32.c b/win32/win32.c
index 86bfbb99be..71097ea1ae 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1037,6 +1037,7 @@ win32_stat(const char *path, struct stat *sbuf)
int l = strlen(path);
int res;
WCHAR wbuffer[MAX_PATH+1];
+ WCHAR* pwbuffer;
HANDLE handle;
int nlink = 1;
@@ -1069,12 +1070,13 @@ win32_stat(const char *path, struct stat *sbuf)
/* This also gives us an opportunity to determine the number of links. */
if (USING_WIDE()) {
A2WHELPER(path, wbuffer, sizeof(wbuffer));
- wcscpy(wbuffer, PerlDir_mapW(wbuffer));
- handle = CreateFileW(wbuffer, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ pwbuffer = PerlDir_mapW(wbuffer);
+ handle = CreateFileW(pwbuffer, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
}
else {
- strcpy(buffer, PerlDir_mapA(path));
- handle = CreateFileA(buffer, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ path = PerlDir_mapA(path);
+ l = strlen(path);
+ handle = CreateFileA(path, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
}
if (handle != INVALID_HANDLE_VALUE) {
BY_HANDLE_FILE_INFORMATION bhi;
@@ -1083,12 +1085,12 @@ win32_stat(const char *path, struct stat *sbuf)
CloseHandle(handle);
}
- /* wbuffer or path will be mapped correctly above */
+ /* pwbuffer or path will be mapped correctly above */
if (USING_WIDE()) {
- res = _wstat(wbuffer, (struct _stat *)sbuf);
+ res = _wstat(pwbuffer, (struct _stat *)sbuf);
}
else {
- res = stat(buffer, sbuf);
+ res = stat(path, sbuf);
}
sbuf->st_nlink = nlink;
@@ -1099,10 +1101,10 @@ win32_stat(const char *path, struct stat *sbuf)
* Windows of 1995) */
DWORD r;
if (USING_WIDE()) {
- r = GetFileAttributesW(wbuffer);
+ r = GetFileAttributesW(pwbuffer);
}
else {
- r = GetFileAttributesA(buffer);
+ r = GetFileAttributesA(path);
}
if (r != 0xffffffff && (r & FILE_ATTRIBUTE_DIRECTORY)) {
/* sbuf may still contain old garbage since stat() failed */
@@ -1120,8 +1122,8 @@ win32_stat(const char *path, struct stat *sbuf)
{
/* The drive can be inaccessible, some _stat()s are buggy */
if (USING_WIDE()
- ? !GetVolumeInformationW(wbuffer,NULL,0,NULL,NULL,NULL,NULL,0)
- : !GetVolumeInformationA(buffer,NULL,0,NULL,NULL,NULL,NULL,0)) {
+ ? !GetVolumeInformationW(pwbuffer,NULL,0,NULL,NULL,NULL,NULL,0)
+ : !GetVolumeInformationA(path,NULL,0,NULL,NULL,NULL,NULL,0)) {
errno = ENOENT;
return -1;
}
@@ -1396,35 +1398,35 @@ win32_unlink(const char *filename)
if (USING_WIDE()) {
WCHAR wBuffer[MAX_PATH+1];
+ WCHAR* pwBuffer;
A2WHELPER(filename, wBuffer, sizeof(wBuffer));
- wcscpy(wBuffer, PerlDir_mapW(wBuffer));
- attrs = GetFileAttributesW(wBuffer);
+ pwBuffer = PerlDir_mapW(wBuffer);
+ attrs = GetFileAttributesW(pwBuffer);
if (attrs == 0xFFFFFFFF)
goto fail;
if (attrs & FILE_ATTRIBUTE_READONLY) {
- (void)SetFileAttributesW(wBuffer, attrs & ~FILE_ATTRIBUTE_READONLY);
- ret = _wunlink(wBuffer);
+ (void)SetFileAttributesW(pwBuffer, attrs & ~FILE_ATTRIBUTE_READONLY);
+ ret = _wunlink(pwBuffer);
if (ret == -1)
- (void)SetFileAttributesW(wBuffer, attrs);
+ (void)SetFileAttributesW(pwBuffer, attrs);
}
else
- ret = _wunlink(wBuffer);
+ ret = _wunlink(pwBuffer);
}
else {
- char buffer[MAX_PATH+1];
- strcpy(buffer, PerlDir_mapA(filename));
- attrs = GetFileAttributesA(buffer);
+ filename = PerlDir_mapA(filename);
+ attrs = GetFileAttributesA(filename);
if (attrs == 0xFFFFFFFF)
goto fail;
if (attrs & FILE_ATTRIBUTE_READONLY) {
- (void)SetFileAttributesA(buffer, attrs & ~FILE_ATTRIBUTE_READONLY);
- ret = unlink(buffer);
+ (void)SetFileAttributesA(filename, attrs & ~FILE_ATTRIBUTE_READONLY);
+ ret = unlink(filename);
if (ret == -1)
- (void)SetFileAttributesA(buffer, attrs);
+ (void)SetFileAttributesA(filename, attrs);
}
else
- ret = unlink(buffer);
+ ret = unlink(filename);
}
return ret;
fail:
@@ -1442,17 +1444,17 @@ win32_utime(const char *filename, struct utimbuf *times)
FILETIME ftWrite;
struct utimbuf TimeBuffer;
WCHAR wbuffer[MAX_PATH+1];
- char buffer[MAX_PATH+1];
+ WCHAR* pwbuffer;
int rc;
if (USING_WIDE()) {
A2WHELPER(filename, wbuffer, sizeof(wbuffer));
- wcscpy(wbuffer, PerlDir_mapW(wbuffer));
- rc = _wutime(wbuffer, (struct _utimbuf*)times);
+ pwbuffer = PerlDir_mapW(wbuffer);
+ rc = _wutime(pwbuffer, (struct _utimbuf*)times);
}
else {
- strcpy(buffer, PerlDir_mapA(filename));
- rc = utime(buffer, times);
+ filename = PerlDir_mapA(filename);
+ rc = utime(filename, times);
}
/* EACCES: path specifies directory or readonly file */
if (rc == 0 || errno != EACCES /* || !IsWinNT() */)
@@ -1466,12 +1468,12 @@ win32_utime(const char *filename, struct utimbuf *times)
/* This will (and should) still fail on readonly files */
if (USING_WIDE()) {
- handle = CreateFileW(wbuffer, GENERIC_READ | GENERIC_WRITE,
+ handle = CreateFileW(pwbuffer, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
}
else {
- handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE,
+ handle = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
}
diff --git a/win32/win32.h b/win32/win32.h
index f8e8dc7d79..65d24e4c65 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -422,15 +422,17 @@ struct interp_intern {
/* Use CP_ACP when mode is ANSI */
/* Use CP_UTF8 when mode is UTF8 */
-#define A2WHELPER(lpa, lpw, nBytes)\
- lpw[0] = 0, MultiByteToWideChar((IN_BYTE) ? CP_ACP : CP_UTF8, 0, \
- lpa, -1, lpw, (nBytes/sizeof(WCHAR)))
+#define A2WHELPER_LEN(lpa, alen, lpw, nBytes)\
+ (lpw[0] = 0, MultiByteToWideChar((IN_BYTE) ? CP_ACP : CP_UTF8, 0, \
+ lpa, alen, lpw, (nBytes/sizeof(WCHAR))))
+#define A2WHELPER(lpa, lpw, nBytes) A2WHELPER_LEN(lpa, -1, lpw, nBytes)
-#define W2AHELPER(lpw, lpa, nChars)\
- lpa[0] = '\0', WideCharToMultiByte((IN_BYTE) ? CP_ACP : CP_UTF8, 0, \
- lpw, -1, (LPSTR)lpa, nChars, NULL, NULL)
+#define W2AHELPER_LEN(lpw, wlen, lpa, nChars)\
+ (lpa[0] = '\0', WideCharToMultiByte((IN_BYTE) ? CP_ACP : CP_UTF8, 0, \
+ lpw, wlen, (LPSTR)lpa, nChars,NULL,NULL))
+#define W2AHELPER(lpw, lpa, nChars) W2AHELPER_LEN(lpw, -1, lpa, nChars)
-#define USING_WIDE() (PL_bigchar && PerlEnv_os_id() == VER_PLATFORM_WIN32_NT)
+#define USING_WIDE() (PL_widesyscalls && PerlEnv_os_id() == VER_PLATFORM_WIN32_NT)
#ifdef USE_ITHREADS
# define PERL_WAIT_FOR_CHILDREN \