home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug103.arc / SCAN.C < prev    next >
Text File  |  1979-12-31  |  768b  |  34 lines

  1. /*
  2. ** scanning functions
  3. */
  4. #include <stdio.h>
  5. #include "mac.h"
  6. #define NOCCARGC
  7.  
  8. atend(ch) int ch; {            /* is ch at end of line? */
  9.   switch(ch) {
  10.     case COMMENT: case NULL: case '\n': return (YES);
  11.     }
  12.   return (NO);
  13.   }
  14.  
  15. fldcmp(s, t) char *s, *t; {        /* compare fields in a line */
  16.   while(lexorder(*s, *t) == 0) {
  17.     if(!isgraph(*s)) return (0);
  18.     ++s; ++t;
  19.     }
  20.   if((isspace(*s) || atend(*s)) &&
  21.      (isspace(*t) || atend(*t))) return (0);
  22.   return (*s - *t);
  23.   }
  24.  
  25. skip(n, str) int n; char str[]; {    /* find nth non-blank field in str */
  26.   char *cp; cp = str;
  27.   while(isspace(*cp)) ++cp;
  28.   while(--n) {
  29.     while(isgraph(*cp)) ++cp;
  30.     while(isspace(*cp)) ++cp;
  31.     }
  32.   return (cp);
  33.   }
  34.