home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / crossref / cref / esccref.c < prev    next >
C/C++ Source or Header  |  1988-11-25  |  2KB  |  67 lines

  1. /* esc() - escaped character processing.
  2.  
  3.     Author: Jeff Taylor, The Toolsmith (c) copyright 1985
  4.     Environment: UNIX 4.2 BSD; cc compiler.
  5. */
  6.  
  7. #include "style.h"
  8.  
  9. #define ESCAPE  '\\'
  10.  
  11. char real[] = "\t\f\n\010";     /* \010 otherwise known as '\b' */
  12. char symb[] = "tfnb";
  13.  
  14. /* esc - map string into escaped cahracter if appropriate */
  15. char esc(s)
  16.     /*register*/ char **s;
  17.     {
  18.     register int i;
  19.     
  20.     if (**s == ESCAPE && *(*s + 1) != EOS)  /* not special at end */
  21.         {
  22.         ++s;
  23.         for (i = 0; i < sizeof(symb) -1; ++i)
  24.             {
  25.             if (symb[i] == **s)
  26.                 return(real[i]);
  27.             }
  28.         }
  29.     return(**s);
  30.     }
  31.     
  32. /* lexcmp() - alphabetical comparison.
  33.     
  34.     Author: Jeff Taylor, The Toolsmith (c) copyright 1985
  35.     Environment: UNIX 4.2 BSD; cc compiler.
  36. */
  37.  
  38. #include <ctype.h>
  39. #include "style.h"
  40.  
  41. #define lower(c)        (isupper(c)? tolower(c) : (c))
  42.  
  43. /* lexcmp - alphabetical comparison, similar to strcmp() */
  44. int lexcmp(aa, bb)
  45.     char *aa, *bb;
  46.     {
  47.     register char *a, *b;
  48.     
  49.     for (a = aa, b = bb; ; a++, b++)
  50.         {
  51.         if (lower(*a) != lower(*b))
  52.             return(lower(*a) - lower(*b));
  53.         if (*a == EOS)
  54.             break;
  55.         }
  56.     for (a = aa, b = bb; ; a++, b++)
  57.         {
  58.         if (*a != *b)
  59.             return(*a - *b);
  60.         if (*a == EOS)
  61.             break;
  62.         }
  63.     return(0);      /* equal, if made it this far */
  64.     }
  65.     
  66.     
  67.