import less(1)
[unleashed/tickless.git] / usr / src / lib / libast / common / string / strlcat.c
blob7a56c7540b5724ba1f60439b7b973b5e30c5297a
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
24 * strlcat implementation
27 #define strlcat ______strlcat
29 #include <ast.h>
31 #undef strlcat
33 #undef _def_map_ast
34 #include <ast_map.h>
36 #if _lib_strlcat
38 NoN(strlcat)
40 #else
43 * append t onto s limiting total size of s to n
44 * s 0 terminated if n>0
45 * min(n,strlen(s))+strlen(t) returned
48 #if defined(__EXPORT__)
49 #define extern __EXPORT__
50 #endif
52 extern size_t
53 strlcat(register char* s, register const char* t, register size_t n)
55 register size_t m;
56 const char* o = t;
58 if (m = n)
60 while (n && *s)
62 n--;
63 s++;
65 m -= n;
66 if (n)
69 if (!--n)
71 *s = 0;
72 break;
74 } while (*s++ = *t++);
75 else
76 *s = 0;
78 if (!n)
79 while (*t++);
80 return (t - o) + m - 1;
83 #endif