annotate RISCOS/Modules/getpath_riscos.c @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents f546623ef0c6
children fd25030223b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #include "Python.h"
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 #include "osdefs.h"
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
21087
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
4 static char *prefix, *exec_prefix, *progpath, *module_search_path=NULL;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 static void
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 calculate_path()
21087
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
8 {
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
9 char *pypath = getenv("Python$Path");
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
10 if (pypath) {
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
11 int pathlen = strlen(pypath);
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
12 module_search_path = malloc(pathlen + 1);
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
13 if (module_search_path)
21436
f546623ef0c6 SF patch 493739 2 Bugfixes for 2.2c1 (RISC OS specific), from
Tim Peters <tim.peters@gmail.com>
parents: 21087
diff changeset
14 strncpy(module_search_path, pypath, pathlen + 1);
21087
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
15 else {
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
16 fprintf(stderr,
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
17 "Not enough memory for dynamic PYTHONPATH.\n"
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
18 "Using default static PYTHONPATH.\n");
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
19 }
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
20 }
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
21 if (!module_search_path)
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
22 module_search_path = "<Python$Dir>.Lib";
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
23 prefix = "<Python$Dir>";
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
24 exec_prefix = prefix;
41ea2abb74fb Use strncpy() instead of sprintf() in calculate_path().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20652
diff changeset
25 progpath = Py_GetProgramName();
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 /* External interface */
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 char *
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 Py_GetPath()
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 {
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 if (!module_search_path)
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 calculate_path();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 return module_search_path;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 char *
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 Py_GetPrefix()
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 {
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 if (!module_search_path)
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 calculate_path();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 return prefix;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 char *
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 Py_GetExecPrefix()
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 {
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 if (!module_search_path)
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 calculate_path();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 return exec_prefix;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 char *
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 Py_GetProgramFullPath()
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 {
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 if (!module_search_path)
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 calculate_path();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 return progpath;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 }