]>
diplodocus.org Git - nmh/blob - sbr/fmt_new.c
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
)
36 if ((fp
= fopen (etcpath (form
), "r")) == NULL
)
37 adios (form
, "unable to open format file");
39 if (fstat (fileno (fp
), &st
) == -1)
40 adios (form
, "unable to stat format file");
42 formats
= mh_xmalloc ((size_t) st
.st_size
+ 1);
44 if (read (fileno(fp
), formats
, (int) st
.st_size
) != st
.st_size
)
45 adios (form
, "error reading format file");
47 formats
[st
.st_size
] = '\0';
51 formats
= getcpy (format
? format
: default_fs
);
54 normalize (formats
); /* expand escapes */
68 * Expand escapes in format strings
76 for (dp
= cp
; *cp
; cp
++) {