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)
{
{
token2 = GET_TOKEN (NULL);
CHECK_TOKEN ();
+ search_and_replace(token2,"$HOME",getenv("HOME"));
xfree (afm_path);
afm_path = xstrdup (token2);
}
{
token2 = GET_TOKEN (NULL);
CHECK_TOKEN ();
+#ifdef LC_PAPER
+ if (!strcasecmp("LC_PAPER", token2))
+ {
+ unsigned int paperheight = (unsigned int)nl_langinfo(_NL_PAPER_HEIGHT);
+ if (paperheight && paperheight == 279)
+ token2 = "letter";
+ else
+ token2 = "a4";
+ }
+#endif
xfree (media_name);
media_name = xstrdup (token2);
}
if (j >= sizeof (name) - 1)
FATAL ((stderr, _("%s:%d: %%Format: too long name, maxlen=%d"),
- buffer_ptr (ctx.fullname), line, sizeof (name) - 1));
+ buffer_ptr (ctx.fullname), line, (int)(sizeof (name) - 1)));
/* Find the start of the format string. */
for (; buf[i] && isspace (buf[i]); i++)
break;
case 'c': /* `%c' trailing component of pwd. */
- getcwd (buf, sizeof (buf));
+ if (!getcwd (buf, sizeof (buf)))
+ perror("getcwd");
cp = strrchr (buf, '/');
if (cp)
cp++;
break;
case 'd': /* `%d' current working directory */
- getcwd (buf, sizeof (buf));
+ if (!getcwd (buf, sizeof (buf)))
+ perror("getcwd");
APPEND_STR (buf);
break;
case 'l':
if (horizontal)
- val *= CHAR_WIDTH ('m');
+ val *= FNT_CHAR_WIDTH ('m');
else
val *= LINESKIP;
break;