2 ** fmt_new.c -- read format file/string and normalize
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
12 static char *formats = NULL;
17 static void normalize(char *);
21 ** Copy format string (selected by precedence) and store in static memory.
25 new_fs(char *form, char *format, char *default_fs)
35 if ((fp = fopen(etcpath(form), "r")) == NULL) {
36 adios(form, "unable to open format file");
38 if (fstat(fileno(fp), &st) == -1) {
39 adios(form, "unable to stat format file");
41 formats = mh_xmalloc((size_t) st.st_size + 1);
42 if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
43 adios(form, "error reading format file");
45 formats[st.st_size] = '\0';
49 formats = getcpy(format);
52 formats = getcpy(default_fs);
54 normalize(formats); /* expand escapes */
61 ** Expand escapes in format strings
68 for (dp = cp; *cp; cp++) {