- /* Compile format string */
- ncomps = fmt_compile(fmtstr, &fmt) + 1;
-
- FINDCOMP(datecomp, "date");
- nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
- sizeof(char *));
- if (!nxtbuf)
- adios(NULL, "unable to allocate component buffers");
- used_buf = (struct comp **) calloc((size_t) (ncomps+1),
- sizeof(struct comp *));
- if (!used_buf)
- adios(NULL, "unable to allocate component buffer stack");
+ if (fmtstr) {
+ if (width == 0) {
+ if ((width = sc_width()) < WIDTH/2)
+ width = WIDTH/2;
+ else if (width > MAXSCANL)
+ width = MAXSCANL;
+ }
+ dat[3] = slwidth = width;
+ scanl = mh_xcalloc(slwidth + 2, SCAN_CHARWIDTH); /* probably for \n and \0 */
+ /* Compile format string */
+ ncomps = fmt_compile(fmtstr, &fmt) + 1;
+ FINDCOMP(datecomp, "date");
+ } else {
+ ncomps = 1;
+ datecomp = NULL;
+ }
+
+ nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof(char *));
+ used_buf = mh_xcalloc(ncomps+1, sizeof(struct comp *));