1: #include <stdio.h>
   2: #include "def.h"
   3: #include "1.defs.h"
   4: 
   5: str_copy(s,ptr,length)  /* copy s at ptr, return length of s */
   6: char *s, *ptr;
   7: int length;
   8:     {int i;
   9:     for (i = 0; i < length; i++)
  10:         {
  11:         ptr[i] = s[i];
  12:         if (ptr[i] == '\0')
  13:             return(i + 1);
  14:         }
  15:     faterr("string too long to be copied at given address:\n",s,"");
  16:     }
  17: 
  18: 
  19: find(s,ar,size)
  20: char *s,*ar[];
  21: int size;
  22:     {
  23:     int i;
  24:     for (i=0; i < size; i++)
  25:         {if (str_eq(s, ar[i])) return(i);}
  26:     return(-1);
  27:     }
  28: 
  29: 
  30: str_eq(s,t)
  31: char s[],t[];
  32:     {int j;
  33:     for (j = 0; s[j] == t[j]; j++)
  34:         {if (s[j] == '\0') return(1);}
  35:     return(0);
  36:     }
  37: 
  38: 
  39: classmatch(c,i)
  40: char c;
  41: int i;
  42:     {switch(i)
  43:         {case _digit:
  44:             if ('0' <= c && c <= '9')  return(1);
  45:             else return(0);
  46: 
  47:         case _letter:
  48:             if ( ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'))
  49:                 return(1);
  50:             else return(0);
  51: 
  52:         case _diglet:  return(classmatch(c,_digit)||classmatch(c,_letter) );
  53: 
  54:         case _arith:
  55:             if (050 <= c && c<= 057)  return(1);
  56:             else return(0);
  57:         case _nl:
  58:             return(c=='\n');
  59:         case _other:
  60:             return(1);
  61:         }
  62:     }
  63: 
  64: 
  65: copychars(cbeg,target,n)        /* copy n chars from cbeg to target */
  66: char *cbeg, *target;
  67: int n;
  68:     {
  69:     int i;
  70:     for (i = 0; i < n; i++)
  71:         target[i] = cbeg[i];
  72:     }
  73: 
  74: 
  75: 
  76: copycs(cbeg,target,n)           /* copy n chars from cbeg to target, add '\0' */
  77: char *cbeg, *target;
  78: int n;
  79:     {
  80:     copychars(cbeg,target,n);
  81:     target[n] = '\0';
  82:     }
  83: 
  84: 
  85: slength(s)          /* return number of chars in s, not counting '\0' */
  86: char *s;
  87:     {
  88:     int i;
  89:     if (!s) return(-1);
  90:     for (i = 0; s[i] != '\0'; i++);
  91:     return(i);
  92:     }
  93: 
  94: 
  95: concat(x,y)         /* allocate space, return xy */
  96: char *x, *y;
  97:     {
  98:     char *temp;
  99:     int i,j;
 100:     i = slength(x);
 101:     j = slength(y);
 102:     temp = galloc(i + j + 1);
 103:     sprintf(temp,"%s",x);
 104:     sprintf(&temp[i],"%s",y);
 105:     return(temp);
 106:     }

Defined functions

classmatch defined in line 39; used 4 times
concat defined in line 95; used 5 times
copychars defined in line 65; used 1 times
  • in line 80
copycs defined in line 76; used 1 times
find defined in line 19; used 1 times
slength defined in line 85; used 2 times
str_copy defined in line 5; never used
str_eq defined in line 30; used 1 times
  • in line 25
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 633
Valid CSS Valid XHTML 1.0 Strict