int main(int argc, const char ** argv)
{
    unsigned x = 0;
    int argi = 1;
    predef_info ** predefs = 0;
    unsigned predef_count = 0;
    unsigned * i = &first_predef_info.tag;
    unsigned * e = &last_predef_info.tag;
    while (i < e)
    {
        i += 1;
        if (*i == 0x67890DEF)
        {
            predef_count += 1;
            predefs = (predef_info**)realloc(predefs,predef_count*sizeof(predef_info*));
            predefs[predef_count-1] = (predef_info*)i;
        }
    }
    qsort(predefs,predef_count,sizeof(predef_info*),predef_info_compare);
    for (argi = 1; argi < argc; ++argi)
    {
        const char * exp = argv[argi];
        const char * exp_name = str_token(&exp, whitespace);
        const char * exp_op = str_token(&exp, whitespace);
        const char * exp_val = str_token(&exp, whitespace);
        unsigned exp_version = 0;
        if (*exp_val != 0)
        {
            exp = exp_val;
            const char * exp_val_a = str_token(&exp, dot);
            const char * exp_val_b = str_token(&exp, dot);
            const char * exp_val_c = str_token(&exp, dot);
            exp_version = BOOST_VERSION_NUMBER(atoi(exp_val_a), atoi(exp_val_b),atoi(exp_val_c));
        }
        for (x = 0; x < predef_count; ++x)
        {
            if (*exp_op == 0 &&
                predefs[x]->value == 0 &&
                strcmp(exp_name, predefs[x]->name) == 0)
            {
                return argi;
            }
            else if (*exp_op != 0 && *exp_val != 0 &&
                     strcmp(exp_name, predefs[x]->name) == 0)
            {
                if (0 == strcmp(">",exp_op) && !(predefs[x]->value > exp_version)) return argi;
                if (0 == strcmp("<",exp_op) && !(predefs[x]->value < exp_version)) return argi;
                if (0 == strcmp(">=",exp_op) && !(predefs[x]->value >= exp_version)) return argi;
                if (0 == strcmp("<=",exp_op) && !(predefs[x]->value <= exp_version)) return argi;
                if (0 == strcmp("==",exp_op) && !(predefs[x]->value == exp_version)) return argi;
                if (0 == strcmp("!=",exp_op) && !(predefs[x]->value != exp_version)) return argi;
            }
        }
    }
    return 0;
}
Beispiel #2
0
void test_BOOST_VERSION_NUMBER()
{
    PREDEF_CHECK(BOOST_VERSION_NUMBER(0,0,1) == 1L);
    PREDEF_CHECK(BOOST_VERSION_NUMBER(99,99,99999) == 999999999L);
    PREDEF_CHECK(BOOST_VERSION_NUMBER(299,99,99999) != 2999999999L);
    PREDEF_CHECK(BOOST_VERSION_NUMBER(100,99,99999) != 1009999999L);
    PREDEF_CHECK(BOOST_VERSION_NUMBER(100,99,99999) == 9999999L);
    PREDEF_CHECK(BOOST_VERSION_NUMBER(100,100,100000) == 0L);
}
Beispiel #3
0
void test_BOOST_VERSION_NUMBER()
{
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRP(0xFFF) == BOOST_VERSION_NUMBER(0xF,0xF,0xF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRP(0xFFFF) == BOOST_VERSION_NUMBER(0xFF,0xF,0xF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRPP(0xFFFF) == BOOST_VERSION_NUMBER(0xF,0xF,0xFF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRR(0xFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0x0));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRRPPPP(0xFFFFFFF) == BOOST_VERSION_NUMBER(0xF,0xFF,0xFFFF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRRP(0xFFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0xF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VRRPP000(0xFFFFF000) == BOOST_VERSION_NUMBER(0xF,0xFF,0xFF));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_0X_VVRRPP(0xFFFFFF) == BOOST_VERSION_NUMBER(0xFF,0xFF,0xFF));

    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRP(999) == BOOST_VERSION_NUMBER(9,9,9));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VPPP(9999) == BOOST_VERSION_NUMBER(9,0,999));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRRPP(999999) == BOOST_VERSION_NUMBER(99,99,99));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR(9999) == BOOST_VERSION_NUMBER(99,99,0));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRPP(9999) == BOOST_VERSION_NUMBER(9,9,99));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRRPP(99999) == BOOST_VERSION_NUMBER(9,99,99));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRP000(999000) == BOOST_VERSION_NUMBER(9,9,9));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRR000(999000) == BOOST_VERSION_NUMBER(9,99,0));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR00PP00(2199009900u) == BOOST_VERSION_NUMBER(21,99,99));
    /* PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR00PP00(9999009900ull) == BOOST_VERSION_NUMBER(99,99,99)); */
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR0PP00(999909900) == BOOST_VERSION_NUMBER(99,99,99));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VV00(9900) == BOOST_VERSION_NUMBER(99,00,00));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VVRR0PPPP(999909999) == BOOST_VERSION_NUMBER(99,99,9999));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_10_VRR(999) == BOOST_VERSION_NUMBER(9,99,00));

    PREDEF_CHECK(BOOST_PREDEF_MAKE_DATE(1971,1,1) == BOOST_VERSION_NUMBER(1,1,1));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(19700101) == BOOST_VERSION_NUMBER(0,1,1));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(19710101) == BOOST_VERSION_NUMBER(1,1,1));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMMDD(20691231) == BOOST_VERSION_NUMBER(99,12,31));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(197001) == BOOST_VERSION_NUMBER(0,1,1));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(197101) == BOOST_VERSION_NUMBER(1,1,1));
    PREDEF_CHECK(BOOST_PREDEF_MAKE_YYYYMM(206912) == BOOST_VERSION_NUMBER(99,12,1));
}