home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 419b.lha / TERMLIB / tutil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-05  |  761 b   |  52 lines

  1. /* TERMLIB: Terminal independant database.
  2.  *
  3.  * Module: tutil.c
  4.  *
  5.  * Purpose: Utility routines for TERMLIB functions.
  6.  *
  7.  */
  8.  
  9. /* tutil.c (libtermlib.a)
  10.  * Utility routines for termlib
  11.  *
  12.  */
  13.  
  14. _match(s1, s2)                 /* returns length of text common to s1 and s2 */
  15. char *s1, *s2;
  16. {
  17.     int i = 0;
  18.  
  19.     while(s1[i] && s1[i] == s2[i])
  20.         i++;
  21.  
  22.     return i;
  23. }
  24.  
  25. char *
  26. _find(s, set)   /* finds next c in s that's a member of set, returns pointer */
  27. char *s, *set;
  28. {
  29.     for(; *s; s++) {
  30.         char    *ptr = set;
  31.  
  32.         while(*ptr && *s != *ptr)
  33.             ptr++;
  34.  
  35.         if(*ptr)
  36.             return s;
  37.     }
  38.  
  39.     return s;
  40. }
  41.  
  42. char *
  43. _addfmt(buf, fmt, val)             /* add val to buf according to format fmt */
  44. char *buf, *fmt;
  45. int val;
  46. {
  47.     sprintf(buf, fmt, val);
  48.     while(*buf)
  49.         buf++;
  50.     return buf;
  51. }
  52.