Răsfoiți Sursa

* Ported [2644] to 1.2.9
- fix_tilde() -> expand_tilde()


svn: 2645

Bryan Drewery 20 ani în urmă
părinte
comite
fa79c3add7
4 a modificat fișierele cu 13 adăugiri și 12 ștergeri
  1. 2 2
      src/conf.c
  2. 1 1
      src/main.c
  3. 9 8
      src/shell.c
  4. 1 1
      src/shell.h

+ 2 - 2
src/conf.c

@@ -315,7 +315,7 @@ confedit()
 
   tmpconf.my_close();
   readconf((const char *) tmpconf.file, 0);               /* read cleartext conf tmp into &settings */
-  fix_tilde(&conf.binpath);
+  expand_tilde(&conf.binpath);
   unlink(tmpconf.file);
   conf_to_bin(&conf, 0, -1);
   if (localhub_pid)
@@ -1014,7 +1014,7 @@ bin_to_conf(void)
   conf.tempdir = strdup(settings.tempdir);
   conf.homedir = strdup(settings.homedir);
   conf.binpath = strdup(settings.binpath);
-  fix_tilde(&conf.binpath);
+  expand_tilde(&conf.binpath);
   conf.binname = strdup(settings.binname);
   conf.portmin = atol(settings.portmin);
   conf.portmax = atol(settings.portmax);

+ 1 - 1
src/main.c

@@ -294,7 +294,7 @@ static void dtx_arg(int argc, char *argv[])
         exit(0);
       case '4':
         readconf(optarg, CONF_ENC);
-        fix_tilde(&conf.binpath);
+        expand_tilde(&conf.binpath);
         parseconf(0);
         conf_to_bin(&conf, 0, 6);		/* this will exit() in write_settings() */
       case 'a':

+ 9 - 8
src/shell.c

@@ -841,18 +841,19 @@ char *my_username()
   return username;
 }
 
-void fix_tilde(char **binptr)
+void expand_tilde(char **ptr)
 {
-  char *binpath = binptr ? *binptr : NULL;
+  char *str = ptr ? *ptr : NULL;
 
-  if (binpath && strchr(binpath, '~')) {
+  if (str && strchr(str, '~')) {
     char *p = NULL;
+    size_t siz = strlen(str);
 
-    if (binpath[strlen(binpath) - 1] == '/')
-      binpath[strlen(binpath) - 1] = 0;
+    if (str[siz - 1] == '/')
+      str[siz - 1] = 0;
 
-    if ((p = replace(binpath, "~", homedir())))
-      str_redup(binptr, p);
+    if ((p = replace(str, "~", homedir())))
+      str_redup(ptr, p);
     else
       fatal("Unforseen error expanding '~'", 0);
   }
@@ -887,7 +888,7 @@ char *move_bin(const char *ipath, const char *file, bool run)
 {
   char *path = strdup(ipath);
 
-  fix_tilde(&path);
+  expand_tilde(&path);
 
   /* move the binary to the correct place */
   static char newbin[DIRMAX] = "";

+ 1 - 1
src/shell.h

@@ -47,7 +47,7 @@ char *my_uname();
 #ifndef CYGWIN_HACKS 
 char *move_bin(const char *, const char *, bool);
 #endif /* !CYGWIN_HACKS */
-void fix_tilde(char **);
+void expand_tilde(char **);
 void baduname(char *, char *);
 int email(char *, char *, int);
 int shell_exec(char *, char *, char **, char **);