diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-29 18:11:34 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-29 18:11:34 +0000 |
commit | 729a02f2394e6a50fe8352c9471391b53e54ac40 (patch) | |
tree | 2a6312b320ed2281bb204f6b7de63b23d0b66ca7 /win32 | |
parent | 4d6cd4d833a6068f248475b5c22081cd80bd7a5e (diff) | |
download | perl-729a02f2394e6a50fe8352c9471391b53e54ac40.tar.gz |
utf8-ize @ARGV when -C switch is used on Windows
p4raw-id: //depot/perl@5364
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 4 | ||||
-rw-r--r-- | win32/makefile.mk | 4 | ||||
-rw-r--r-- | win32/win32.c | 29 | ||||
-rw-r--r-- | win32/win32.h | 1 |
4 files changed, 34 insertions, 4 deletions
diff --git a/win32/Makefile b/win32/Makefile index 27e597f738..88e270d63a 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -294,7 +294,7 @@ ARCHNAME = $(ARCHNAME)-thread # VC 6.0 can load the socket dll on demand. Makes the test suite # run in about 10% less time. -DELAYLOAD = -DELAYLOAD:wsock32.dll delayimp.lib +DELAYLOAD = -DELAYLOAD:wsock32.dll -DELAYLOAD:shell32.dll delayimp.lib # VC 6.0 seems capable of compiling perl correctly with optimizations # enabled. Anything earlier fails tests. @@ -818,7 +818,7 @@ perldll.def : $(MINIPERL) $(CONFIGPM) ..\global.sym ..\pp.sym ..\makedef.pl $(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) $(LINK32) -dll -def:perldll.def -out:$@ @<< - $(LINK_FLAGS) $(LIBFILES) $(PERLDLL_OBJ) $(PERLDLL_RES) + $(LINK_FLAGS) /base:0x28000000 $(LIBFILES) $(PERLDLL_OBJ) $(PERLDLL_RES) << $(XCOPY) $(PERLIMPLIB) $(COREDIR) diff --git a/win32/makefile.mk b/win32/makefile.mk index 44b5b3a2d7..724fb6304f 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -297,7 +297,7 @@ ARCHNAME !:= $(ARCHNAME)-thread # VC 6.0 can load the socket dll on demand. Makes the test suite # run in about 10% less time. -DELAYLOAD *= -DELAYLOAD:wsock32.dll delayimp.lib +DELAYLOAD *= -DELAYLOAD:wsock32.dll -DELAYLOAD:shell32.dll delayimp.lib # VC 6.0 seems capable of compiling perl correctly with optimizations # enabled. Anything earlier fails tests. @@ -1042,7 +1042,7 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) perl.exp $(LKPOST)) .ELSE $(LINK32) -dll -def:perldll.def -out:$@ \ - @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(PERLDLL_RES) $(PERLDLL_OBJ:s,\,\\)) + @$(mktmp $(BLINK_FLAGS) $(LIBFILES) /base:0x28000000 $(PERLDLL_RES) $(PERLDLL_OBJ:s,\,\\)) .ENDIF $(XCOPY) $(PERLIMPLIB) $(COREDIR) diff --git a/win32/win32.c b/win32/win32.c index ff52692fec..87d4111609 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -15,6 +15,7 @@ #define Win32_Winsock #endif #include <windows.h> +#include <shellapi.h> #include <winnt.h> #include <io.h> @@ -4004,3 +4005,31 @@ Perl_sys_intern_dup(pTHX_ struct interp_intern *src, struct interp_intern *dst) } #endif +static void +win32_free_argvw(pTHXo_ void *ptr) +{ + char** argv = (char**)ptr; + while(*argv) { + Safefree(*argv); + *argv++ = Nullch; + } +} + +void +win32_argv2utf8(pTHX_ int argc, char** argv) +{ + char* psz; + int length, wargc; + LPWSTR* lpwStr = CommandLineToArgvW(GetCommandLineW(), &wargc); + if (lpwStr && argc) { + while (argc--) { + length = WideCharToMultiByte(CP_UTF8, 0, lpwStr[--wargc], -1, NULL, 0, NULL, NULL); + Newz(0, psz, length, char); + WideCharToMultiByte(CP_UTF8, 0, lpwStr[wargc], -1, psz, length, NULL, NULL); + argv[argc] = psz; + } + call_atexit(win32_free_argvw, argv); + } + GlobalFree((HGLOBAL)lpwStr); +} + diff --git a/win32/win32.h b/win32/win32.h index 6f4c0d061e..a96e20598a 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -321,6 +321,7 @@ extern char * win32_get_privlib(char *pl); extern char * win32_get_sitelib(char *pl); extern int IsWin95(void); extern int IsWinNT(void); +extern void win32_argv2utf8(pTHX_ int argc, char** argv); extern char * staticlinkmodules[]; |