aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2008-05-11 13:26:08 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2008-05-11 13:26:08 +0000
commit42ae63a25ca45c613277315973dee6377fa6ba9c (patch)
treed18f66509f38c75759f7716d26f1aa4831f1df61 /packages
parent177fa2d8ad04f93ae5411d5c3a8c715cf5ea4534 (diff)
created sys_expandpath() to replace ~ with /Users/hans and expand env vars on Windows. This function is then used in sys_trytoopenone() so that ~ works with all opening operations.
svn path=/trunk/; revision=9780
Diffstat (limited to 'packages')
-rw-r--r--packages/patches/add_tilde_support_toopen-0.41.4.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/packages/patches/add_tilde_support_toopen-0.41.4.patch b/packages/patches/add_tilde_support_toopen-0.41.4.patch
new file mode 100644
index 00000000..3661823a
--- /dev/null
+++ b/packages/patches/add_tilde_support_toopen-0.41.4.patch
@@ -0,0 +1,67 @@
+Index: s_path.c
+===================================================================
+--- s_path.c (revision 9773)
++++ s_path.c (working copy)
+@@ -30,6 +30,10 @@
+ #include <io.h>
+ #endif
+
++#ifdef MSW
++#include <windows.h>
++#endif
++
+ #include <string.h>
+ #include "m_pd.h"
+ #include "m_imp.h"
+@@ -70,6 +70,30 @@
+ *to = 0;
+ }
+
++/* expand env vars and ~ at the beginning of a path and make a copy to return */
++static void sys_expandpath(const char *from, char *to)
++{
++ if ((strlen(from) == 1 && from[0] == '~') || (strncmp(from,"~/", 2) == 0))
++ {
++#ifdef MSW
++ const char *home = getenv("USERPROFILE");
++#else
++ const char *home = getenv("HOME");
++#endif
++ if(home)
++ {
++ strncpy(to, home, FILENAME_MAX - 1);
++ strncat(to, from + 1, FILENAME_MAX - strlen(from) - 2);
++ }
++ }
++ else
++ strncpy(to, from, FILENAME_MAX - 1);
++#ifdef MSW
++ char buf[FILENAME_MAX];
++ ExpandEnvironmentStrings(to, buf, FILENAME_MAX - 2);
++ strncpy(to, buf, FILENAME_MAX - 1);
++#endif
++}
+ /******************* Utility functions used below ******************/
+
+ /*!
+@@ -199,7 +223,7 @@
+ int fd;
+ if (strlen(dir) + strlen(name) + strlen(ext) + 4 > size)
+ return (-1);
+- strcpy(dirresult, dir);
++ sys_expandpath(dir, dirresult);
+ if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
+ strcat(dirresult, "/");
+ strcat(dirresult, name);
+@@ -251,9 +275,9 @@
+ int sys_open_absolute(const char *name, const char* ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp)
+ {
+- if (name[0] == '/'
++ if (name[0] == '/' || name[0] == '~'
+ #ifdef MSW
+- || (name[1] == ':' && name[2] == '/')
++ || name[0] == '%' || (name[1] == ':' && name[2] == '/')
+ #endif
+ )
+ {