]>
diplodocus.org Git - nmh/blob - sbr/fmt_new.c
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.
17 static char *formats
= 0;
22 static void normalize (char *);
26 * Get new format string
30 new_fs (char *form
, char *format
, char *default_fs
)
39 if ((fp
= fopen (etcpath (form
), "r")) == NULL
)
40 adios (form
, "unable to open format file");
42 if (fstat (fileno (fp
), &st
) == -1)
43 adios (form
, "unable to stat format file");
45 formats
= mh_xmalloc ((size_t) st
.st_size
+ 1);
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
++) {