Exemple #1
0
bool
transaction_eq(const Transaction *a, const Transaction *b)
{
    if (a->date != b->date) {
        return false;
    }
    if (strcmp(a->description, b->description) != 0) {
        return false;
    }
    if (strcmp(a->payee, b->payee) != 0) {
        return false;
    }
    if (strcmp(a->checkno, b->checkno) != 0) {
        return false;
    }
    if (strcmp(a->notes, b->notes) != 0) {
        return false;
    }
    if (a->splitcount != b->splitcount) {
        return false;
    }
    for (int i=0; i<a->splitcount; i++) {
        // We don't require splits to be in the same order
        bool found = false;
        for (int j=0; j<b->splitcount; j++) {
            if (split_eq(&a->splits[i], &b->splits[j])) {
                found = true;
            }
        }
        if (!found) {
            return false;
        }
    }
    return true;
}
ulong split_eq(string *dest, char *key, ulong str_num = 0) {
string_item *si=dest->getsi(str_num);
char *src;
ulong r;
  src=(char*)malloc(si->length+1);
  memcpy(src, si->s, si->length+1);
  r=split_eq(dest, key, src);
  free(src);
  return r;
}
ulong split_eq(string *dest, char *key, string *src, ulong str_num = 0) { return split_eq(dest, key, strptr(src, str_num)); }