Logo Search packages:      
Sourcecode: dballe version File versions

void dba_record_diff ( dba_record  rec1,
dba_record  rec2,
int *  diffs,
FILE *  out 
)

Print the difference between two records to an output stream. If there is no difference, it does not print anything.

Parameters:
rec1 The first record to compare
rec2 The second record to compare
Return values:
diffs Incremented by 1 if the variables differ
Parameters:
out The output stream to use for printing

Definition at line 847 of file dba_record.c.

References DBA_VAR_F, DBA_VAR_X, and DBA_VAR_Y.

{
      int i;
      dba_record_cursor cur;

      /* First compare the keywords */
      for (i = 0; i < KEYWORD_TABLE_SIZE; i++)
      {
            if (rec1->keydata[i] == NULL && rec2->keydata[i] == NULL)
                  continue;
            else
                  dba_var_diff(rec1->keydata[i], rec2->keydata[i], diffs, out);
      }

      /* Then compare the hash tables */
      for (cur = dba_record_iterate_first(rec1); cur != NULL; cur = dba_record_iterate_next(rec1, cur))
      {
            dba_varcode code = dba_var_code(cur->var);
            if (!dba_record_has_item(rec2, code))
            {
                  fprintf(out, "Variable %d%02d%03d only exists in first record\n",
                              DBA_VAR_F(code), DBA_VAR_X(code), DBA_VAR_Y(code));
                  (*diffs)++;
            }
            {
                  dba_item item2;
                  for (item2 = rec2->vars; item2 != NULL; item2 = item2->next)
                        if (dba_var_code(item2->var) == code)
                        {
                              dba_var_diff(cur->var, item2->var, diffs, out);
                              break;
                        }
            }
      }

      /* Check for the items in the second one not present in the first one */
      for (cur = dba_record_iterate_first(rec2); cur != NULL; cur = dba_record_iterate_next(rec2, cur))
      {
            dba_varcode code = dba_var_code(cur->var);
            if (!dba_record_has_item(rec1, code))
            {
                  fprintf(out, "Variable %d%02d%03d only exists in second record\n",
                              DBA_VAR_F(code), DBA_VAR_X(code), DBA_VAR_Y(code));
                  (*diffs)++;
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index