HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
Getting base path dynamically so I don't need to build into the program.
Formerly I had logic in the build script to create stub .c files (in the obj directory) containing the base path of the program. Now I get it dynamically using /proc/self/exe. This is equivalent to the $0 in the /bin/sh program. See get_base_path in file.c. This is good preparation for possibly removing the direct linkage with the libfexl.so library, instead treating it like any other independent library such as openssl. I moved reduce_base_path from meta.c to file.c so it's closer to other things related to readlink. Note also how in fexl.c I'm using Fexl strings when building the full path instead of calling buf operations directly. Using Fexl strings avoids much of the tedium of string manipulation, and makes things more clearly correct. For another example of this, look how much simpler the safe_readlink routine is in file.c, now that it returns a Fexl string instead of setting complicated pointers passed in as arguments. This also made reduce2_readlink far simpler.
- Loading branch information...
Showing with 102 additions and 109 deletions.
|@@ -1,6 +0,0 @@|
|-This is the base path of the Fexl executable program. Its actual value is not|
|-specified anywhere in the src directory, but is created by special logic in|
|-the build script, depending on whether we're doing a local or install build.|
|-extern char *base;|
|@@ -1,2 +1,3 @@|
|-extern void safe_readlink(const char *path,|
|- char **result, long *result_len, long *result_size);|
|+extern value safe_readlink(const char *path);|
|+extern value get_base_path(void);|
|+extern value get_full_path(const char *name);|