- /* Note that a field written to a place where a field has
- already been written truncates the record. `PRINT /A B
- (T10,F8,T1,F8).' only outputs B. */
- for (i = t->spec; i; i = i->next)
- switch (i->type)
- {
- case PRT_NEWLINE:
- if (t->writer == NULL)
- {
- buf[len] = 0;
- tab_output_text (TAB_FIX | TAT_NOWRAP, buf);
- }
- else
- {
- if ((t->options & PRT_CMD_MASK) == PRT_PRINT
- || !(t->options & PRT_BINARY))
- {
- /* PORTME: Line ends. */
-#ifdef __MSDOS__
- buf[len++] = '\r';
-#endif
- buf[len++] = '\n';
- }
-
- dfm_put_record (t->writer, buf, len);
- }
-
- memset (buf, ' ', t->max_width);
- len = 0;
- break;
-
- case PRT_CONST:
- /* FIXME: Should be revised to keep track of the string's
- length outside the loop, probably in i->u.c[0]. */
- memcpy (&buf[i->fc], i->u.c, strlen (i->u.c));
- len = i->fc + strlen (i->u.c);
- break;
-
- case PRT_VAR:
- data_out (&buf[i->fc], &i->u.v.f, case_data (c, i->u.v.v->fv));
- len = i->fc + i->u.v.f.w;
- break;
-
- case PRT_SPACE:
- /* PRT_SPACE always immediately follows PRT_VAR. */
- buf[len++] = ' ';
- break;
-
- case PRT_ERROR:
- assert (0);
- break;
- }
-
- if (t->writer != NULL && dfm_write_error (t->writer))
- return TRNS_ERROR;
- return TRNS_CONTINUE;
-}
-
-/* Frees all the data inside print_trns T. Does not free T. */
-static bool
-print_trns_free (void *prt_)
-{
- struct print_trns *prt = prt_;
- struct prt_out_spec *i, *n;
- bool ok = true;
-
- for (i = prt->spec; i; i = n)
- {
- switch (i->type)
- {
- case PRT_CONST:
- free (i->u.c);
- /* fall through */
- case PRT_NEWLINE:
- case PRT_VAR:
- case PRT_SPACE:
- /* nothing to do */
- break;
- case PRT_ERROR:
- assert (0);
- break;
- }
- n = i->next;
- free (i);
- }
- if (prt->writer != NULL)
- ok = dfm_close_writer (prt->writer);
- free (prt->line);
- free (prt);
- return ok;
-}
-\f
-/* PRINT SPACE. */
-
-/* PRINT SPACE transformation. */
-struct print_space_trns
-{
- struct dfm_writer *writer; /* Output data file. */
- struct expression *e; /* Number of lines; NULL=1. */
-}
-print_space_trns;
-
-static trns_proc_func print_space_trns_proc;
-static trns_free_func print_space_trns_free;
-
-int
-cmd_print_space (void)
-{
- struct print_space_trns *t;
- struct file_handle *fh;
- struct expression *e;
- struct dfm_writer *writer;
-
- if (lex_match_id ("OUTFILE"))
- {
- lex_match ('=');
-
- fh = fh_parse (FH_REF_FILE);
- if (fh == NULL)
- return CMD_FAILURE;
- lex_get ();
- }
- else
- fh = NULL;
-
- if (token != '.')