X-Git-Url: http://git.savannah.gnu.org/gitweb/?p=enscript.git;a=blobdiff_plain;f=src%2Futil.c;h=0b4be6a6094f959111fe72fdb1042b37c4663218;hp=d53d8f02c2c5402d112fc1555e97596c965d9fa9;hb=3ca061ac1462c6f9aad2e9542bba3d763a90ec38;hpb=0779ca6512bf93e8f8dfe53c1a3446adb2475acc diff --git a/src/util.c b/src/util.c index d53d8f0..0b4be6a 100644 --- a/src/util.c +++ b/src/util.c @@ -23,6 +23,7 @@ */ #include "gsint.h" +#include /* * Types and definitions. @@ -92,6 +93,19 @@ static struct 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) { @@ -138,6 +152,7 @@ read_config (char *path, char *file) { token2 = GET_TOKEN (NULL); CHECK_TOKEN (); + search_and_replace(token2,"$HOME",getenv("HOME")); xfree (afm_path); afm_path = xstrdup (token2); } @@ -587,6 +602,7 @@ paste_file (char *name, char *suffix) (void **) &cp2)) { /* Not it is not, we must include this resource. */ +#include fprintf (ofp, "%%%%IncludeResource: font %s\n", cp); /*