Exemple #1
0
long
weeurl_get_mask_value (struct t_url_constant *constants,
                       const char *string_mask)
{
    char **items, *item;
    int num_items, i, index;
    long mask;

    mask = 0;

    items = string_split (string_mask, "+", 0, 0, &num_items);
    if (items)
    {
        for (i = 0; i < num_items; i++)
        {
            item = string_remove_quotes(items[i], "'\"");
            if (item)
            {
                index = weeurl_search_constant (constants, item);
                if (index >= 0)
                    mask |= constants[index].value;
                free (item);
            }
        }
        string_free_split (items);
    }

    return mask;
}
Exemple #2
0
TEST(String, RemoveQuotes)
{
    POINTERS_EQUAL(NULL, string_remove_quotes (NULL, NULL));
    POINTERS_EQUAL(NULL, string_remove_quotes (NULL, "abc"));
    POINTERS_EQUAL(NULL, string_remove_quotes ("abc", NULL));
    STRCMP_EQUAL("", string_remove_quotes("", ""));
    STRCMP_EQUAL("", string_remove_quotes("", "\"'"));
    STRCMP_EQUAL("abc", string_remove_quotes("abc", "\"'"));
    STRCMP_EQUAL(" abc ", string_remove_quotes(" abc ", "\"'"));
    STRCMP_EQUAL("abc", string_remove_quotes("'abc'", "\"'"));
    STRCMP_EQUAL("abc", string_remove_quotes(" 'abc' ", "\"'"));
    STRCMP_EQUAL("'abc'", string_remove_quotes("\"'abc'\"", "\"'"));
    STRCMP_EQUAL("'abc'", string_remove_quotes(" \"'abc'\" ", "\"'"));
    STRCMP_EQUAL("'a'b'c'", string_remove_quotes("\"'a'b'c'\"", "\"'"));
    STRCMP_EQUAL("'a'b'c'", string_remove_quotes(" \"'a'b'c'\" ", "\"'"));
}
Exemple #3
0
TEST(String, RemoveQuotes)
{
    char *str;

    WEE_TEST_STR(NULL, string_remove_quotes (NULL, NULL));
    WEE_TEST_STR(NULL, string_remove_quotes (NULL, "abc"));
    WEE_TEST_STR(NULL, string_remove_quotes ("abc", NULL));
    WEE_TEST_STR("", string_remove_quotes("", ""));
    WEE_TEST_STR("", string_remove_quotes("", "\"'"));
    WEE_TEST_STR("abc", string_remove_quotes("abc", "\"'"));
    WEE_TEST_STR(" abc ", string_remove_quotes(" abc ", "\"'"));
    WEE_TEST_STR("abc", string_remove_quotes("'abc'", "\"'"));
    WEE_TEST_STR("abc", string_remove_quotes(" 'abc' ", "\"'"));
    WEE_TEST_STR("'abc'", string_remove_quotes("\"'abc'\"", "\"'"));
    WEE_TEST_STR("'abc'", string_remove_quotes(" \"'abc'\" ", "\"'"));
    WEE_TEST_STR("'a'b'c'", string_remove_quotes("\"'a'b'c'\"", "\"'"));
    WEE_TEST_STR("'a'b'c'", string_remove_quotes(" \"'a'b'c'\" ", "\"'"));
}