added missing case in for ENC_ISO_8859_15 in src/util.c:read_font_info
[enscript.git] / src / util.c
index 4fca6e4..cb8c082 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "gsint.h"
+#include<langinfo.h>
 
 /*
  * 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<langinfo.h>
                    fprintf (ofp, "%%%%IncludeResource: font %s\n", cp);
 
                    /*
@@ -639,7 +655,7 @@ paste_file (char *name, char *suffix)
 
          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++)
@@ -962,6 +978,11 @@ read_font_info (void)
                                        enc_flags);
              break;
 
+           case ENC_ISO_8859_15:
+             (void) afm_font_encoding (font, AFM_ENCODING_ISO_8859_15,
+                                       enc_flags);
+             break;
+
            case ENC_ASCII:
              (void) afm_font_encoding (font, AFM_ENCODING_ASCII, enc_flags);
              break;
@@ -1370,7 +1391,8 @@ format_user_string (char *context_name, char *str)
                  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++;
@@ -1386,7 +1408,8 @@ format_user_string (char *context_name, char *str)
                  break;
 
                case 'd':       /* `%d' current working directory */
-                 getcwd (buf, sizeof (buf));
+                 if (!getcwd (buf, sizeof (buf)))
+                   perror("getcwd");
                  APPEND_STR (buf);
                  break;
 
@@ -1854,7 +1877,7 @@ parse_float (char *string, int units, int horizontal)
 
        case 'l':
          if (horizontal)
-           val *= CHAR_WIDTH ('m');
+           val *= FNT_CHAR_WIDTH ('m');
          else
            val *= LINESKIP;
          break;