3 * fmt_new.c -- read format file/string and normalize
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
15 static char *formats = 0;
20 static void normalize (char *);
24 * Get new format string
28 new_fs (char *form, char *format, char *default_fs)
37 if ((fp = fopen (etcpath (form), "r")) == NULL)
38 adios (form, "unable to open format file");
40 if (fstat (fileno (fp), &st) == -1)
41 adios (form, "unable to stat format file");
43 formats = mh_xmalloc ((size_t) st.st_size + 1);
45 if (read (fileno(fp), formats, (int) st.st_size) != st.st_size)
46 adios (form, "error reading format file");
48 formats[st.st_size] = '\0';
52 formats = getcpy (format ? format : default_fs);
55 normalize (formats); /* expand escapes */
62 * Expand escapes in format strings
70 for (dp = cp; *cp; cp++) {