3 * fmt_new.c -- read format file/string and normalize
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
16 static char *formats = 0;
21 static void normalize (char *);
25 * Get new format string
29 new_fs (char *form, char *format, char *default_fs)
38 if ((fp = fopen (etcpath (form), "r")) == NULL)
39 adios (form, "unable to open format file");
41 if (fstat (fileno (fp), &st) == -1)
42 adios (form, "unable to stat format file");
44 if (!(formats = malloc ((size_t) st.st_size + 1)))
45 adios (form, "unable to allocate space for format");
47 if (read (fileno(fp), formats, (int) st.st_size) != st.st_size)
48 adios (form, "error reading format file");
50 formats[st.st_size] = '\0';
54 formats = getcpy (format ? format : default_fs);
57 normalize (formats); /* expand escapes */
64 * Expand escapes in format strings
72 for (dp = cp; *cp; cp++) {