]>
diplodocus.org Git - nmh/blob - sbr/fmt_new.c
97e2a7ad3dbf6e90523c83f740a74b871de05a02
1 /* fmt_new.c -- read format file/string and normalize
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
14 static char *formats
= 0;
19 static void normalize (char *);
23 * Get new format string
27 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);
43 if (read (fileno(fp
), formats
, (int) st
.st_size
) != st
.st_size
)
44 adios (form
, "error reading format file");
46 formats
[st
.st_size
] = '\0';
50 formats
= getcpy (format
? format
: default_fs
);
53 normalize (formats
); /* expand escapes */
68 * Expand escapes in format strings
76 for (dp
= cp
; *cp
; cp
++) {