Changeset 460

Show
Ignore:
Timestamp:
08/07/07 15:57:26 (1 year ago)
Author:
takkaria
Message:

Remove unused code, and make some other code (possibly) more efficient.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/util.c

    r455 r460  
    33993399 
    34003400 
    3401 /* 
    3402  * Same as above, but always maximal 
    3403  */ 
    3404 int maxroll(int num, int sides) 
    3405 { 
    3406         return (num * sides); 
    3407 } 
    3408  
    3409  
    34103401 
    34113402 
     
    34153406bool is_a_vowel(int ch) 
    34163407{ 
    3417         switch (ch
     3408        switch (tolower((unsigned char) ch)
    34183409        { 
    34193410                case 'a': 
     
    34223413                case 'o': 
    34233414                case 'u': 
    3424                 case 'A': 
    3425                 case 'E': 
    3426                 case 'I': 
    3427                 case 'O': 
    3428                 case 'U': 
    3429                 return (TRUE); 
     3415                        return (TRUE); 
    34303416        } 
    34313417 
     
    35213507} 
    35223508 
    3523  
    3524  
    3525 #if 0 
    3526  
    3527 /* 
    3528  * Replace the first instance of "target" in "buf" with "insert" 
    3529  * If "insert" is NULL, just remove the first instance of "target" 
    3530  * In either case, return TRUE if "target" is found. 
    3531  * 
    3532  * Could be made more efficient, especially in the case where "insert" 
    3533  * is smaller than "target". 
    3534  */ 
    3535 static bool insert_str(char *buf, cptr target, cptr insert) 
    3536 { 
    3537         int i, len; 
    3538         int b_len, t_len, i_len; 
    3539  
    3540         /* Attempt to find the target (modify "buf") */ 
    3541         buf = strstr(buf, target); 
    3542  
    3543         /* No target found */ 
    3544         if (!buf) return (FALSE); 
    3545  
    3546         /* Be sure we have an insertion string */ 
    3547         if (!insert) insert = ""; 
    3548  
    3549         /* Extract some lengths */ 
    3550         t_len = strlen(target); 
    3551         i_len = strlen(insert); 
    3552         b_len = strlen(buf); 
    3553  
    3554         /* How much "movement" do we need? */ 
    3555         len = i_len - t_len; 
    3556  
    3557         /* We need less space (for insert) */ 
    3558         if (len < 0) 
    3559         { 
    3560                 for (i = t_len; i < b_len; ++i) buf[i+len] = buf[i]; 
    3561         } 
    3562  
    3563         /* We need more space (for insert) */ 
    3564         else if (len > 0) 
    3565         { 
    3566                 for (i = b_len-1; i >= t_len; --i) buf[i+len] = buf[i]; 
    3567         } 
    3568  
    3569         /* If movement occured, we need a new terminator */ 
    3570         if (len) buf[b_len+len] = '\0'; 
    3571  
    3572         /* Now copy the insertion string */ 
    3573         for (i = 0; i < i_len; ++i) buf[i] = insert[i]; 
    3574  
    3575         /* Successful operation */ 
    3576         return (TRUE); 
    3577 } 
    3578  
    3579  
    3580 #endif 
    35813509 
    35823510