src/console/conio.c
static unsigned do_smap(unsigned c)
{
    char str[MAX_STAB];
    int len = 0;
    stab_t *tstab;
    int i, found;
    unsigned cm;

    len = 1;
    str[0] = c;
    str[1] = 0;

    cm = char_map[c];
    if (cm == 0) {
       return c;
    } else {
       c = cm;
    }
    for ( ;; ) {
       found = 0;
       for (i=len-1; i<MAX_STAB; i++) {
          for (tstab=stab[i]; tstab; tstab=tstab->next) {
             if (strncmp(str, tstab->str, len) == 0) {
                if (len == tstab->len) {
                   return tstab->func;
                }
                found = 1;
                break;                /* found possibility continue searching */
             }
          }
       }
       if (!found) {
          return len==1?c:0;
       }
       /* found partial match, so get next character and retry */
       str[len++] = t_gnc();
       str[len] = 0;
    }
}
/*
 * New style string mapping to function code
 */
New style string mapping to function code
New style string mapping to function code
static unsigned do_smap(unsigned c)
{
    char str[MAX_STAB];
    int len = 0;
    stab_t *tstab;
    int i, found;
    unsigned cm;
    len = 1;
    str[0] = c;
    str[1] = 0;
    cm = char_map[c];
    if (cm == 0) {
       return c;
    } else {
       c = cm;
    }
    for ( ;; ) {
       found = 0;
       for (i=len-1; i<MAX_STAB; i++) {
          for (tstab=stab[i]; tstab; tstab=tstab->next) {
             if (strncmp(str, tstab->str, len) == 0) {
                if (len == tstab->len) {
                   return tstab->func;
                }
                found = 1;
                break;                
             }
          }
       }
       if (!found) {
          return len==1?c:0;
       }
       str[len++] = t_gnc();
       str[len] = 0;
    }
}
static unsigned do_smap ( unsigned c ) { char str [ MAX_STAB ] ; int len = 0 ; stab_t * tstab ; int i , found ; unsigned cm ; len = 1 ; str [ 0 ] = c ; str [ 1 ] = 0 ; cm = char_map [ c ] ; if ( cm == 0 ) { return c ; } else { c = cm ; } for ( ; ; ) { found = 0 ; for ( i = len - 1 ; i < MAX_STAB ; i ++ ) { for ( tstab = stab [ i ] ; tstab ; tstab = tstab -> next ) { if ( strncmp ( str , tstab -> str , len ) == 0 ) { if ( len == tstab -> len ) { return tstab -> func ; } found = 1 ; break ; } } } if ( ! found ) { return len == 1 ? c : 0 ; } str [ len ++ ] = t_gnc ( ) ; str [ len ] = 0 ; } }
New style string mapping to function code
New style string mapping to function code
/* found possibility continue searching */ /* found partial match, so get next character and retry */