home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / string / strncat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  452 b   |  45 lines

  1. #ifndef mc68000
  2.  
  3. #include <string.h>
  4.  
  5. char *strncat(char *s1,const char *s2,size_t n)
  6. {
  7.   if (n != 0)
  8.   {
  9.     char *s=s1;
  10.  
  11.     while(*s++)
  12.       ;
  13.  
  14.     --s;
  15.  
  16.     while((*s++=*s2++) && (--n != 0))
  17.       ;
  18.  
  19.     *s=0;
  20.   }
  21.   return s1;
  22.  
  23. #else
  24.  
  25. asm("
  26.     .globl    _strncat
  27. _strncat:
  28.     moveml    sp@(4:W),d0/a0
  29.     movel    d0,a1
  30.     movel    sp@(12),d1
  31.     jeq    L1
  32. L3:    tstb    a1@+
  33.     jne    L3
  34.     subqw    #1,a1
  35. L2:    moveb    a0@+,a1@+
  36.     jeq    L1
  37.     subql    #1,d1
  38.     jne    L2
  39.     clrb    a0@
  40. L1:    rts
  41. ");
  42.  
  43. #endif
  44.