]>
diplodocus.org Git - nmh/blob - sbr/fmt_new.c
3ad71b81cbf7883531157bdbf487cd95d4cca112
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.
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 */
67 * Expand escapes in format strings
75 for (dp
= cp
; *cp
; cp
++) {