home *** CD-ROM | disk | FTP | other *** search
- /*
- checkline: check the input line just read in against what we expect
- to find and report any problems. Actually, most of the work is done
- by check_item. We just identify what needs to be checked.
-
- Kenneth Ingham
-
- Copyright (C) 1987 The University of New Mexico
- */
-
- #include "defs.h"
-
- checkline(cmd, line, prev_res)
- struct cmd_st *cmd;
- char *line;
- struct old_cmd_st *prev_res;
- {
- extern int line_ok;
- extern FILE *hf;
- struct change_fmt_st *cf;
- union out_fmt_u of;
- union all_u *prev_value;
- char value[MAX_STR];
- char key_val[MAX_STR];
- char *cmd_name;
-
- cmd_name = (cmd->alias != NULL ? cmd->alias : cmd->pipeline);
-
- save_key(cmd, line, key_val); /* side effect: return key value */
- /* for each change format item */
- line_ok = True;
- for (cf=cmd->change_fmt; cf; cf=cf->next) {
- /* find the output format entry for this item */
- if (!find_of(cmd->out_type, cf->name, cmd->out_fmt, &of)) {
- fprintf(stderr, "Warning: %s appears in change list ",
- cf->name);
- fprintf(stderr, "but not in output format for %s\n",
- cmd_name);
- continue;
- }
-
- /*
- find the part of the line corresponding to check.
- Also find the previous results corresponding to the
- key for this line (if any).
- */
- switch (cmd->out_type) {
- case RELATIVE:
- find_prev_value(prev_res, of.rel_fmt->name,
- key_val, &prev_value);
- if (get_rel_field(line, of.rel_fmt->field, value) !=
- NULL)
- check_item(cf, value, cmd_name, line,
- prev_value);
- break;
- case COLUMN:
- find_prev_value(prev_res, of.rel_fmt->name,
- key_val, &prev_value);
- if (get_col_field(line, of.col_fmt->start, of.col_fmt->end, value) != NULL)
- check_item(cf, value, cmd_name, line,
- prev_value);
- break;
- }
-
- /*
- save the value in the history file for future
- comparisons.
- */
- if (cmd->key.rel_fmt != NULL)
- fprintf(hf, "\t\t%s %c %s\n", cf->name,
- TCHAR(cf->type), value);
- }
- if (!line_ok)
- printf("---------\n");
- }
-