[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: convert-ly, musicxml2ly, etc. problems
From: |
Jan Nieuwenhuizen |
Subject: |
Re: convert-ly, musicxml2ly, etc. problems |
Date: |
Fri, 01 Dec 2006 19:07:25 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (gnu/linux) |
Han-Wen Nienhuys <address@hidden> writes:
> Jan,
>
> do you know how Python 2.4/mingw found out where to locate its modules?
The path is set through argv0 relocation, but I had to patch
calculate_path in Modules/getpath.c, see below. I haven't checked if
this is the new patch bomb, or what changed in python 2.5.
Jan.
@@ -384,13 +407,23 @@ calculate_path(void)
unsigned long nsexeclength = MAXPATHLEN;
#endif
- /* If there is no slash in the argv0 path, then we have to
- * assume python is on the user's $PATH, since there's no
- * other way to find a directory to start the search from. If
- * $PATH isn't exported, you lose.
- */
- if (strchr(prog, SEP))
- strncpy(progpath, prog, MAXPATHLEN);
+ /* If PROG is an absolute name, then we're done. If PROG is not
+ * an absolute name and contains SEP/ALTSEP, then it must be
+ * reachable from CWD. Otherwise, python is on the user's $PATH,
+ * since there's no other way to find a directory to start the
+ * search from. If $PATH isn't exported, you lose.
+ */
+ if (IS_ABSOLUTE(prog))
+ strncpy(progpath, prog, MAXPATHLEN);
+ else if (strchr(prog, SEP)
+#ifdef ALTSEP
+ || strchr(prog, ALTSEP)
+#endif /* ALTSEP */
+ )
+ {
+ getcwd(progpath, MAXPATHLEN);
+ joinpath(progpath, prog);
+ }
#ifdef __APPLE__
/* On Mac OS X, if a script uses an interpreter of the form
* "#!/opt/python2.3/bin/python", the kernel only passes "python"
@@ -406,6 +439,9 @@ calculate_path(void)
;
#endif /* __APPLE__ */
else if (path) {
+#ifdef __MINGW32__
+ char const *ext = strchr(prog, '.') ? "" : ".exe";
+#endif
while (1) {
char *delim = strchr(path, DELIM);
@@ -420,9 +456,11 @@ calculate_path(void)
strncpy(progpath, path, MAXPATHLEN);
joinpath(progpath, prog);
+#ifdef __MINGW32__
+ strcat(progpath, ext);
+#endif
if (isxfile(progpath))
break;
-
if (!delim) {
progpath[0] = '\0';
break;
@@ -432,7 +470,7 @@ calculate_path(void)
}
else
progpath[0] = '\0';
- if (progpath[0] != SEP)
+ if (!IS_ABSOLUTE(progpath))
absolutize(progpath);
strncpy(argv0_path, progpath, MAXPATHLEN);
argv0_path[MAXPATHLEN] = '\0';
@@ -478,7 +516,7 @@ calculate_path(void)
while (linklen != -1) {
/* It's not null terminated! */
tmpbuffer[linklen] = '\0';
- if (tmpbuffer[0] == SEP)
+ if (IS_ABSOLUTE(tmpbuffer))
/* tmpbuffer should never be longer than MAXPATHLEN,
but extra check does not hurt */
strncpy(argv0_path, tmpbuffer, MAXPATHLEN);
@@ -545,7 +583,7 @@ calculate_path(void)
while (1) {
char *delim = strchr(defpath, DELIM);
- if (defpath[0] != SEP)
+ if (!IS_ABSOLUTE(defpath))
/* Paths are relative to prefix */
bufsz += prefixsz;
@@ -590,7 +628,7 @@ calculate_path(void)
while (1) {
char *delim = strchr(defpath, DELIM);
- if (defpath[0] != SEP) {
+ if (!IS_ABSOLUTE(defpath)) {
strcat(buf, prefix);
strcat(buf, separator);
}
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org