source:
buchla-68k/libsm/strncat.c@
57425b6
Last change on this file since 57425b6 was dade7a0, checked in by , 7 years ago | |
---|---|
|
|
File size: 567 bytes |
Rev | Line | |
---|---|---|
[f40a309] | 1 | /* |
2 | ============================================================================= | |
3 | strncat.c -- concatenate strings | |
4 | Version 1 -- 1987-06-12 | |
5 | ||
6 | Concatenate s2 on the end of s1. S1's space must be large enough. | |
7 | At most n characters are moved. | |
8 | Return s1. | |
9 | ============================================================================= | |
10 | */ | |
11 | ||
[b28a12e] | 12 | #include "ram.h" |
[6262b5c] | 13 | |
[7258c6a] | 14 | int8_t *strncat(int8_t *s1, int8_t *s2, int16_t n) |
[f40a309] | 15 | { |
[7258c6a] | 16 | register int8_t *os1; |
[f40a309] | 17 | |
18 | os1 = s1; | |
19 | ||
[dade7a0] | 20 | while (*s1++) |
[f40a309] | 21 | ; |
22 | ||
23 | --s1; | |
24 | ||
[dade7a0] | 25 | while ((*s1++ = *s2++)) |
[f40a309] | 26 | if(--n < 0) { |
27 | ||
28 | *--s1 = '\0'; | |
29 | break; | |
30 | } | |
31 | ||
32 | return(os1); | |
33 | } |
Note:
See TracBrowser
for help on using the repository browser.