git@sv
/
enscript.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f2eef58
)
Added the $HOME variable to be used in AFMPATH
author
Wim Stockman
<wim@thinkerwim.org>
Mon, 13 Mar 2023 13:13:10 +0000
(14:13 +0100)
committer
Wim Stockman
<wim@thinkerwim.org>
Mon, 13 Mar 2023 13:13:10 +0000
(14:13 +0100)
src/util.c
patch
|
blob
|
history
diff --git
a/src/util.c
b/src/util.c
index d53d8f02c2c5402d112fc1555e97596c965d9fa9..a0daecfe38bb13b9862a361d6e6bc90d5f556055 100644
(file)
--- a/
src/util.c
+++ b/
src/util.c
@@
-92,6
+92,19
@@
static struct
if (token2 == NULL) \
CFG_FATAL ((stderr, _("missing argument: %s"), token));
if (token2 == NULL) \
CFG_FATAL ((stderr, _("missing argument: %s"), token));
+void search_and_replace(char *str, char *search, char *replace) {
+ char *pos;
+ int search_len = strlen(search);
+ int replace_len = strlen(replace);
+
+ while ((pos = strstr(str, search)) != NULL) {
+ char tmp[strlen(str) + 1];
+ strcpy(tmp, pos + search_len);
+ strcpy(pos, replace);
+ strcpy(pos + replace_len, tmp);
+ str = pos + replace_len;
+ }
+}
int
read_config (char *path, char *file)
{
int
read_config (char *path, char *file)
{
@@
-138,6
+151,7
@@
read_config (char *path, char *file)
{
token2 = GET_TOKEN (NULL);
CHECK_TOKEN ();
{
token2 = GET_TOKEN (NULL);
CHECK_TOKEN ();
+ search_and_replace(token2,"$HOME",getenv("HOME"));
xfree (afm_path);
afm_path = xstrdup (token2);
}
xfree (afm_path);
afm_path = xstrdup (token2);
}