fs_value fn_less_than_equal(fs_query *q, fs_value a, fs_value b) { #if 0 fs_value_print(a); printf(" <= "); fs_value_print(b); printf("\n"); #endif if (a.valid & fs_valid_bit(FS_V_TYPE_ERROR)) { return a; } if (b.valid & fs_valid_bit(FS_V_TYPE_ERROR)) { return b; } /* URIs and bNodes don't compare */ if (FS_IS_URI_BN(a.rid) || FS_IS_URI_BN(b.rid)) { return fs_value_boolean(0); } /* If it's simply the same term it must be <= itsself */ fs_value term_eq = fn_rdfterm_equal(q, a, b); if (term_eq.in == 1) { return term_eq; } if (a.attr == fs_c.xsd_datetime && b.attr == fs_c.xsd_datetime) return fn_not(q, fn_datetime_greater_than(q, a, b)); if (fs_is_numeric(&a) && fs_is_numeric(&b)) return fn_logical_or(q, fn_numeric_less_than(q, a, b), fn_numeric_equal(q, a, b)); if (a.lex && b.lex) return fn_not(q, fn_numeric_equal(q, fn_compare(q, a, b), fs_value_integer(1))); return fs_value_error(FS_ERROR_INVALID_TYPE, NULL); }
fs_value fn_greater_than(fs_query *q, fs_value a, fs_value b) { if (a.valid & fs_valid_bit(FS_V_TYPE_ERROR)) { return a; } if (b.valid & fs_valid_bit(FS_V_TYPE_ERROR)) { return b; } if (a.attr == fs_c.xsd_datetime && b.attr == fs_c.xsd_datetime) return fn_datetime_greater_than(q, a, b); if (fs_is_numeric(&a)) return fn_numeric_greater_than(q, a, b); if (a.lex && b.lex) return fn_numeric_equal(q, fn_compare(q, a, b), fs_value_integer(1)); return fs_value_error(FS_ERROR_INVALID_TYPE, NULL); }