1: /* smatch.c - match a switch */
   2: 
   3: #include "../h/mh.h"
   4: 
   5: 
   6: #define abs(i) (i < 0 ? -i : i)
   7: 
   8: 
   9: smatch(string, swp)
  10: register char *string;
  11: register struct swit *swp;
  12: {
  13:     register char  *sp,
  14:                    *tcp;
  15:     struct swit *tp;
  16:     int     firstone,
  17:             stringlen;
  18: 
  19:     firstone = UNKWNSW;
  20: 
  21:     for (stringlen = strlen (string), tp = swp; tcp = tp -> sw; tp++) {
  22:     if (stringlen < abs (tp -> minchars))
  23:         continue;       /* no match */
  24:     for (sp = string; *sp == *tcp++;) {
  25:         if (*sp++ == 0)
  26:         return (tp - swp);/* exact match */
  27:     }
  28:     if (*sp != 0) {
  29:         if (*sp != ' ')
  30:         continue;   /* no match */
  31:         if (*--tcp == 0)
  32:         return (tp - swp);/* exact match */
  33:     }
  34:     if (firstone == UNKWNSW)
  35:         firstone = tp - swp;
  36:     else
  37:         firstone = AMBIGSW;
  38:     }
  39: 
  40:     return (firstone);
  41: }

Defined functions

smatch defined in line 9; used 2 times

Defined macros

abs defined in line 6; used 1 times
  • in line 22
Last modified: 1985-09-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 827
Valid CSS Valid XHTML 1.0 Strict