1 | /* Copyright Richard A. O'Keefe. |
2 | Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab |
3 | Copyright (c) 2009-2011, Monty Program Ab |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are |
7 | met: |
8 | |
9 | 1. Redistributions of source code must retain the above copyright |
10 | notice, this list of conditions and the following disclaimer. |
11 | |
12 | 2. Redistributions in binary form must the following disclaimer in |
13 | the documentation and/or other materials provided with the |
14 | distribution. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY |
17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR |
20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
23 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
26 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | SUCH DAMAGE. |
28 | */ |
29 | |
30 | /* File : strxmov.c |
31 | Author : Richard A. O'Keefe. |
32 | Updated: 25 may 1984 |
33 | Defines: strxmov() |
34 | |
35 | strxmov(dst, src1, ..., srcn, NullS) |
36 | moves the concatenation of src1,...,srcn to dst, terminates it |
37 | with a NUL character, and returns a pointer to the terminating NUL. |
38 | It is just like strmov except that it concatenates multiple sources. |
39 | Beware: the last argument should be the null character pointer. |
40 | Take VERY great care not to omit it! Also be careful to use NullS |
41 | and NOT to use 0, as on some machines 0 is not the same size as a |
42 | character pointer, or not the same bit pattern as NullS. |
43 | */ |
44 | |
45 | #include "strings_def.h" |
46 | |
47 | char *strxmov(char *dst,const char *src, ...) |
48 | { |
49 | va_list pvar; |
50 | |
51 | va_start(pvar,src); |
52 | while (src != NullS) { |
53 | while ((*dst++ = *src++)) ; |
54 | dst--; |
55 | src = va_arg(pvar, char *); |
56 | } |
57 | va_end(pvar); |
58 | *dst = 0; /* there might have been no sources! */ |
59 | return dst; |
60 | } |
61 | |