Ejemplo n.º 1
0
int fmsgcmp(struct fix_message *expected, struct fix_message *actual)
{
	int i;
	int ret = 1;
	struct fix_field *actual_field;
	struct fix_field *expected_field;

	if (expected->body_length && expected->body_length != actual->body_length)
		goto exit;

	if (expected->msg_seq_num && expected->msg_seq_num != actual->msg_seq_num)
		goto exit;

	if (fstrcmp(expected->sender_comp_id, actual->sender_comp_id))
		goto exit;

	if (fstrcmp(expected->target_comp_id, actual->target_comp_id))
		goto exit;

	if (fstrcmp(expected->begin_string, actual->begin_string))
		goto exit;

	if (fstrcmp(expected->msg_type, actual->msg_type))
		goto exit;

	for (i = 0; i < expected->nr_fields; i++) {
		expected_field = &expected->fields[i];
		actual_field = fix_get_field(actual, expected_field->tag);

		if (!actual_field)
			goto exit;

		switch (expected_field->type) {
			case FIX_TYPE_STRING:
				if (fstrcmp(expected_field->string_value, actual_field->string_value))
					goto exit;
				break;
			case FIX_TYPE_FLOAT:
				if (expected_field->float_value != actual_field->float_value)
					goto exit;
				break;
			case FIX_TYPE_CHAR:
				if (fstrcasecmp(&expected_field->char_value, &actual_field->char_value))
					goto exit;
				break;
			case FIX_TYPE_CHECKSUM:
			case FIX_TYPE_INT:
				if (expected_field->int_value != actual_field->int_value)
					goto exit;
				break;
			default:
				break;
		}
	}

	return 0;

exit:
	return ret;
}
Ejemplo n.º 2
0
static int filename_comp(char *name1,char *name2)

    {
    char abs1[512],abs2[512];

    /* First do a straight compare */
    if (!fstrcmp(name1,name2))
        return(0);
    /* Convert to absolute path and compare */
    strcpy(abs1,name1);
    wfile_make_absolute(abs1);
    strcpy(abs2,name2);
    wfile_make_absolute(abs2);
    return(fstrcmp(abs1,abs2));
    }
Ejemplo n.º 3
0
static void
symtab_query_fuzzy_inner(symtab_ty *stp, string_ty *key, double *best_weight,
    string_ty **best_key, void **best_result)
{
    str_hash_ty     idx;
    symtab_row_ty   *p;

    trace(("symtab_query_fuzzy_inner(stp = %08lX, key = \"%s\")\n{\n",
        (long)stp, key->str_text));

    for (idx = 0; idx < stp->hash_modulus; ++idx)
    {
        for (p = stp->hash_table[idx]; p; p = p->overflow)
        {
            double      w;

            w = fstrcmp(key->str_text, p->key->str_text);
            if (w > *best_weight)
            {
                *best_key = p->key;
                *best_weight = w;
                *best_result = p->data;
            }
        }
    }
    trace(("}\n"));
}
Ejemplo n.º 4
0
const char *
get_rsc_approx (const char *rsc_name)
{
  int i;
  const char *res = 0;
  double best_weight = 0.7;

  for (i = MIN_HASH_VALUE; i <= MAX_HASH_VALUE; ++i) {
    if (rsc_set[i].name[0]) {
      double weight = fstrcmp (rsc_name, rsc_set[i].name);
      if (weight > best_weight) {
        best_weight = weight;
	res = rsc_set[i].name;
      }
    }
  }
  return res;
}
Ejemplo n.º 5
0
double
fuzzy_search_goal_function (const message_ty *mp,
			    const char *msgctxt, const char *msgid)
{
  /* The use of 'volatile' guarantees that excess precision bits are dropped
     before the addition and before the following comparison at the caller's
     site.  It is necessary on x86 systems where double-floats are not IEEE
     compliant by default, to avoid that msgmerge results become platform and
     compiler option dependent.  'volatile' is a portable alternative to gcc's
     -ffloat-store option.  */
  volatile double weight = fstrcmp (msgid, mp->msgid);
  /* A translation for a context is a good proposal also for another.  But
     give mp a small advantage if mp is valid regardless of any context or
     has the same context as the one being looked up.  */
  if (mp->msgctxt == NULL
      || (msgctxt != NULL && strcmp (msgctxt, mp->msgctxt) == 0))
    weight += 0.00001;
  return weight;
}
Ejemplo n.º 6
0
xt_t findword(const char *s1)
{
	ucell tmplfa, len;

	if (!last)
		return 0;

	tmplfa = read_ucell(last);

	len = strlen(s1);

	while (tmplfa) {
		ucell nfa = lfa2nfa(tmplfa);

		if (len == fstrlen(nfa) && !fstrcmp(s1, nfa)) {
			return lfa2cfa(tmplfa);
		}

		tmplfa = read_ucell(cell2pointer(tmplfa));
	}

	return 0;
}
Ejemplo n.º 7
0
double StringUtils::CompareFuzzy(const std::string &left, const std::string &right)
{
  return (0.5 + fstrcmp(left.c_str(), right.c_str(), 0.0) * (left.length() + right.length())) / 2.0;
}