summaryrefslogtreecommitdiff
path: root/win32/perllib.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2006-12-28 10:59:40 -0800
committerSteve Hay <SteveHay@planit.com>2007-01-03 17:56:16 +0000
commitaa2b96eccca93a6fe7c95af71c0b4a027561512b (patch)
treeff5fb2fd50f7445230b65a61d28265c94d919226 /win32/perllib.c
parent23175d88b839c4a83ec070928df0fae32557300b (diff)
downloadperl-aa2b96eccca93a6fe7c95af71c0b4a027561512b.tar.gz
[PATCH] Use short pathnames in $^X and @INC if the long form cannot be represented in the current codepage
Date: Thu, 28 Dec 2006 18:59:40 -0800 Message-ID: <vq09p2p09k6rcu6c9t0mab3vnc335ghg9m@4ax.com> Subject: Re: [PATCH] Use short pathnames in $^X and @INC if the long form cannot be represented in the current codepage From: Jan Dubois <jand@ActiveState.com> Date: Wed, 03 Jan 2007 08:12:35 -0800 Message-ID: <orknp2pj17265modfosjkp2qtt4bdgtgjp@4ax.com> p4raw-id: //depot/perl@29675
Diffstat (limited to 'win32/perllib.c')
-rw-r--r--win32/perllib.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/win32/perllib.c b/win32/perllib.c
index 1e4ba09001..9b488d190f 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -207,17 +207,24 @@ RunPerl(int argc, char **argv, char **env)
{
int exitstatus;
PerlInterpreter *my_perl, *new_perl = NULL;
-
-#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. */
+ OSVERSIONINFO osver;
char szModuleName[MAX_PATH];
+ char *arg0 = argv[0];
+ char *ansi = NULL;
- Win_GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
- (void)win32_longpath(szModuleName);
- argv[0] = szModuleName;
-#endif
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ GetVersionEx(&osver);
+
+ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ WCHAR widename[MAX_PATH];
+ GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
+ argv[0] = ansi = win32_ansipath(widename);
+ }
+ else {
+ Win_GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
+ (void)win32_longpath(szModuleName);
+ argv[0] = szModuleName;
+ }
#ifdef PERL_GLOBAL_STRUCT
#define PERLVAR(var,type) /**/
@@ -259,6 +266,11 @@ RunPerl(int argc, char **argv, char **env)
}
#endif
+ /* At least the Borland RTL wants to free argv[] after main() returns. */
+ argv[0] = arg0;
+ if (ansi)
+ win32_free(ansi);
+
PERL_SYS_TERM();
return (exitstatus);