mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
append the default path to $PYTHONPATH; ignore empty $PYTHONPATH.
default DATE is now 3 Jun 1992
This commit is contained in:
parent
73b715e259
commit
c888bf7cae
1 changed files with 19 additions and 5 deletions
|
|
@ -24,6 +24,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* Configurable Python configuration file */
|
/* Configurable Python configuration file */
|
||||||
|
|
||||||
|
#include "PROTO.h"
|
||||||
|
#include "malloc.h"
|
||||||
|
|
||||||
#include "patchlevel.h"
|
#include "patchlevel.h"
|
||||||
|
|
||||||
#define VERSION "0.9.%d (%s)"
|
#define VERSION "0.9.%d (%s)"
|
||||||
|
|
@ -31,7 +34,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#ifdef __DATE__
|
#ifdef __DATE__
|
||||||
#define DATE __DATE__
|
#define DATE __DATE__
|
||||||
#else
|
#else
|
||||||
#define DATE ">= 6 Apr 1992"
|
#define DATE ">= 3 Jun 1992"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -82,7 +85,7 @@ donecalls()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PYTHONPATH
|
#ifndef PYTHONPATH
|
||||||
#define PYTHONPATH ".:/usr/local/lib/python"
|
#define PYTHONPATH ".:/usr/local/lib/python"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *getenv();
|
extern char *getenv();
|
||||||
|
|
@ -91,9 +94,20 @@ char *
|
||||||
getpythonpath()
|
getpythonpath()
|
||||||
{
|
{
|
||||||
char *path = getenv("PYTHONPATH");
|
char *path = getenv("PYTHONPATH");
|
||||||
if (path == 0)
|
char *defpath = PYTHONPATH;
|
||||||
path = PYTHONPATH;
|
char *buf;
|
||||||
return path;
|
int n;
|
||||||
|
|
||||||
|
if (path == 0 || *path == '\0')
|
||||||
|
return defpath;
|
||||||
|
n = strlen(path) + strlen(defpath) + 2;
|
||||||
|
buf = malloc(n);
|
||||||
|
if (buf == NULL)
|
||||||
|
return path; /* XXX too bad -- but not likely */
|
||||||
|
strcpy(buf, path);
|
||||||
|
strcat(buf, ":");
|
||||||
|
strcat(buf, defpath);
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue