]> www.ginac.de Git - cln.git/blob - src/base/string/cl_st_concat1.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / base / string / cl_st_concat1.cc
1 // cl_string concatenation.
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/string.h"
8
9
10 // Implementation.
11
12 #undef MAYBE_INLINE
13 #define MAYBE_INLINE inline
14 #include "cl_st_make0.cc"
15
16 namespace cln {
17
18 const cl_string operator+ (const cl_string& str1, const cl_string& str2)
19 {
20     unsigned long len1 = strlen(str1);
21     unsigned long len2 = strlen(str2);
22     var cl_heap_string* str = cl_make_heap_string(len1+len2);
23     var char * ptr = &str->data[0];
24     {
25         var const char * ptr1 = asciz(str1);
26         for (var unsigned long count = len1; count > 0; count--)
27             *ptr++ = *ptr1++;
28     }
29     {
30         var const char * ptr2 = asciz(str2);
31         for (var unsigned long count = len2; count > 0; count--)
32             *ptr++ = *ptr2++;
33     }
34     *ptr++ = '\0';
35     return str;
36 }
37
38 }  // namespace cln