示例#1
0
LIBSBML_EXTERN
int
util_bsearchStringsI (const char **strings, const char *s, int lo, int hi)
{
  int cond;
  int mid;
  int result = hi + 1;


  if (s == NULL || strings == NULL) return result;

  while (lo <= hi)
  {
    mid  = (lo + hi) / 2;
    cond = strcmp_insensitive(s, strings[mid]);
      
    if (cond < 0)
    {
      hi = mid - 1;
    }
    else if (cond > 0)
    {
      lo = mid + 1;
    }
    else
    {
      result = mid;
      break;
    }
  }

  return result;
}
示例#2
0
/**
 * Converts the given Token (which must be of type TT_NAME) to a TT_REAL
 * NaN or Inf as appropriate.
 */
void
Token_convertNaNInf (Token_t *t)
{
  if ( !strcmp_insensitive(t->value.name, "NaN") )
  {
    safe_free(t->value.name);
    t->type       = TT_REAL;
    t->value.real = util_NaN();
  }
  else if ( !strcmp_insensitive(t->value.name, "Inf") )
  {
    safe_free(t->value.name);
    t->type       = TT_REAL;
    t->value.real = util_PosInf();
  }
}
uint32 gft_get_by_name(char* name)
{
	for (uint32 i = 0; i < gft.count; i++)
		if (strcmp_insensitive(name, gft[i].file_node->name) == 0)
			return i;

	return INVALID_FD;
}
示例#4
0
文件: TestUtil.c 项目: sn248/Rcppsbml
END_TEST


START_TEST (test_util_strcmp_insensitive)
{
  fail_unless( strcmp_insensitive("foobar", "foobar") == 0 );
  fail_unless( strcmp_insensitive("foobar", "FooBar") == 0 );

  fail_unless( strcmp_insensitive("foobar", "FooBaz") < 0 );
  fail_unless( strcmp_insensitive("foobar", "FooBaZ") < 0 );

  fail_unless( strcmp_insensitive("foobar", "FooBab") > 0 );
  fail_unless( strcmp_insensitive("foobar", "FooBaB") > 0 );

  fail_unless( strcmp_insensitive("", "")  == 0 );

  fail_unless( strcmp_insensitive("", "a") < 0 );
  fail_unless( strcmp_insensitive("a", "") > 0 );
}
示例#5
0
char*
find_audio_ts_file(const char* audio_ts_path, const char* filename)
{
    DIR* dir = opendir(audio_ts_path);
    struct dirent* dirent;
    if (!dir) {
        return NULL;
    }

    for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) {
        /*convert directory entry to upper-case*/
        if (!strcmp_insensitive(filename, dirent->d_name)) {
            /*if the filename matches,
              join audio_ts path and name into a single path
              and return it*/

            const size_t dirent_len = strlen(dirent->d_name);

            const size_t full_path_len = (strlen(audio_ts_path) +
                                          1 + /*path separator*/
                                          dirent_len +
                                          1 /*NULL*/);
            char* full_path = malloc(full_path_len);

            snprintf(full_path, full_path_len,
                     "%s/%s", audio_ts_path, dirent->d_name);

            closedir(dir);
            return full_path;
        }
    }

    /*gone through entire directory without a match*/
    closedir(dir);
    return NULL;
}