viewing paste Unknown #6952 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
void op_3(struct script_state* st, int op)
{
    struct script_data* data;
    int flag = 0;
 
    data = script_getdatatop(st, -3);
    script->get_val(st, data);
 
    if( data_isstring(data) )
        flag = data->u.str[0];// "" -> false
    else if( data_isint(data) )
        flag = data->u.num == 0 ? 1 : 0;// 0 -> false
    else
    {
        ShowError("script:op_3: invalid data for the ternary operator test\n");
        script_reportdata(data);
        script_reportsrc(st);
        script_removetop(st, -3, 0);
        script_pushnil(st);
        return;
    }
    if( flag )
        script_pushcopytop(st, -2);
    else
        script_pushcopytop(st, -1);
    script_removetop(st, -4, -1);
}
 
Viewed 718 times, submitted by Guest.