[Python-checkins] CVS: python/dist/src/Modules getpath.c,1.30,1.31

Jeremy Hylton python-dev@python.org
Mon, 25 Sep 2000 10:00:40 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv26179/Modules

Modified Files:
	getpath.c 
Log Message:
fix bug #114290: when interpreter's argv[0] has a relative path make
    it absolute by joining it with getcwd result.  avoid including
    unnecessary ./ in path but do not test for ../ (more complicated)


Index: getpath.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/getpath.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** getpath.c	2000/09/01 23:29:26	1.30
--- getpath.c	2000/09/25 17:00:24	1.31
***************
*** 220,223 ****
--- 220,240 ----
  }
  
+ static void
+ init_path_from_argv0(char *path, char *argv0_path)
+ {
+     if (argv0_path[0] == '/')
+ 	strcpy(path, argv0_path);
+     else if (argv0_path[0] == '.') {
+ 	getcwd(path, MAXPATHLEN);
+ 	if (argv0_path[1] == '/') 
+ 	    joinpath(path, argv0_path + 2);
+ 	else
+ 	    joinpath(path, argv0_path);
+     }
+     else {
+ 	getcwd(path, MAXPATHLEN);
+ 	joinpath(path, argv0_path);
+     }
+ }
  
  static int
***************
*** 265,269 ****
  
      /* Search from argv0_path, until root is found */
!     strcpy(prefix, argv0_path);
      do {
          n = strlen(prefix);
--- 282,286 ----
  
      /* Search from argv0_path, until root is found */
!     init_path_from_argv0(prefix, argv0_path);
      do {
          n = strlen(prefix);
***************
*** 315,319 ****
  
      /* Search from argv0_path, until root is found */
!     strcpy(exec_prefix, argv0_path);
      do {
          n = strlen(exec_prefix);
--- 332,336 ----
  
      /* Search from argv0_path, until root is found */
!     init_path_from_argv0(exec_prefix, argv0_path);
      do {
          n = strlen(exec_prefix);