home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / STRLEN.C < prev    next >
Text File  |  1984-12-31  |  1KB  |  38 lines

  1. /*  File   : strlen.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 23 April 1984
  4.     Defines: strlen()
  5.  
  6.     strlen(s) returns the number of characters in s, that is, the number
  7.     of non-NUL characters found before the closing NULEosCh.  Note: some
  8.     non-standard C compilers for 32-bit machines take int to be 16 bits,
  9.     either put up with short strings or change int  to  long  throughout
  10.     this package.  Better yet, BOYCOTT such shoddy compilers.
  11.     Beware: the asm version works only if strlen(s) < 65536.
  12. */
  13.  
  14. #include "strings.h"
  15.  
  16. #if    VaxAsm
  17.  
  18. int strlen(s)
  19.     char *s;
  20.     {
  21.     asm("locc  $0,$65535,*4(ap)");
  22.     asm("subl3 r0,$65535,r0");
  23.     }
  24.  
  25. #else  ~VaxAsm
  26.  
  27. int strlen(s)
  28.     register char *s;
  29.     {
  30.     register int L;
  31.     
  32.     for (L = 0; *s++; L++) ;
  33.     return L;
  34.     }
  35.  
  36. #endif    VaxAsm
  37.