Ignore:
Timestamp:
May 3, 2013 8:47:14 AM (11 years ago)
Author:
riza
Message:

Re #1643: - Modification to shortcut handling(execution&display).

  • Add exact match check to the parse input command process.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c

    r4484 r4513  
    182182    struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe; 
    183183 
    184     send_data.ptr = &data_str[0]; 
     184    send_data.ptr = data_str; 
    185185    send_data.slen = 0; 
    186186     
     
    202202    struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe; 
    203203 
    204     send_data.ptr = &data_str[0]; 
     204    send_data.ptr = data_str; 
    205205    send_data.slen = 0; 
    206206 
     
    273273    static const pj_str_t sc_type = {"sc", 2}; 
    274274    static const pj_str_t choice_type = {"choice", 6}; 
    275     send_data.ptr = &data[0]; 
     275    send_data.ptr = data; 
    276276    send_data.slen = 0; 
    277277     
     
    288288    for (i=0;i<info->hint_cnt;++i) { 
    289289        if ((&hint[i].type) && (hint[i].type.slen > 0)) {            
    290             if (pj_stricmp(&hint[i].type, &sc_type) == 0) { 
    291                 //Additional delimiter " | " 
    292                 cmd_length += (hint[i].name.slen + 3); 
     290            if (pj_stricmp(&hint[i].type, &sc_type) == 0) {              
     291                if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) { 
     292                    cmd_length += (hint[i].name.slen + 3); 
     293                } else { 
     294                    cmd_length = hint[i].name.slen; 
     295                }                
    293296            } else { 
    294297                cmd_length = hint[i].name.slen; 
     
    304307 
    305308    cmd_length = 0; 
    306     for (i=0;i<info->hint_cnt;++i) {     
     309    for (i=0;i<info->hint_cnt;++i) { 
    307310        if ((&hint[i].type) && (hint[i].type.slen > 0)) {            
    308311            if (pj_stricmp(&hint[i].type, &sc_type) == 0) { 
     
    317320        } 
    318321 
    319         if ((parse_state != OP_SHORTCUT)) { 
    320             if (cmd_desc) { 
    321                 /* Print data if previous hint is shortcut */ 
    322                 send_hint_arg(&send_data, cmd_desc, cmd_length, max_length); 
    323                 cmd_desc = 0; 
    324             } 
     322        if (parse_state != OP_SHORTCUT) { 
    325323            pj_strcat2(&send_data, "\r\n  "); 
    326324            cmd_length = hint[i].name.slen; 
     
    338336            pj_strcat2(&send_data, ">");         
    339337            break; 
    340         case OP_SHORTCUT:            
    341             pj_strcat2(&send_data, " | "); 
    342             pj_strcat(&send_data, &hint[i].name); 
    343             cmd_length += (hint[i].name.slen + 3); 
     338        case OP_SHORTCUT: 
     339            /* Format : "Command | sc |  description" */ 
     340            {            
     341                cmd_length += hint[i].name.slen; 
     342                if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) { 
     343                    pj_strcat2(&send_data, " | "); 
     344                    cmd_length += 3;                 
     345                } else { 
     346                    pj_strcat2(&send_data, "\r\n  "); 
     347                } 
     348                pj_strcat(&send_data, &hint[i].name);    
     349            } 
    344350            break; 
    345351        default: 
     
    350356         
    351357        if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) ||  
    352             ((i+1) >= info->hint_cnt))  
     358            ((i+1) >= info->hint_cnt) || 
     359            (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen)))  
    353360        { 
    354361            /* Add description info */ 
    355362            send_hint_arg(&send_data, &hint[i].desc, cmd_length, max_length); 
     363 
     364            cmd_length = 0; 
    356365        } 
    357366    }   
Note: See TracChangeset for help on using the changeset viewer.