1*1031c584SApple OSS Distributions /*
2*1031c584SApple OSS Distributions * Copyright (c) 2019 Apple Inc. All rights reserved.
3*1031c584SApple OSS Distributions *
4*1031c584SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*1031c584SApple OSS Distributions *
6*1031c584SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*1031c584SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*1031c584SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*1031c584SApple OSS Distributions * compliance with the License. The rights granted to you under the License
10*1031c584SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
11*1031c584SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
12*1031c584SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
13*1031c584SApple OSS Distributions * terms of an Apple operating system software license agreement.
14*1031c584SApple OSS Distributions *
15*1031c584SApple OSS Distributions * Please obtain a copy of the License at
16*1031c584SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*1031c584SApple OSS Distributions *
18*1031c584SApple OSS Distributions * The Original Code and all software distributed under the License are
19*1031c584SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*1031c584SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*1031c584SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*1031c584SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*1031c584SApple OSS Distributions * Please see the License for the specific language governing rights and
24*1031c584SApple OSS Distributions * limitations under the License.
25*1031c584SApple OSS Distributions *
26*1031c584SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*1031c584SApple OSS Distributions */
28*1031c584SApple OSS Distributions /* IOString.m created by rsulack on Wed 17-Sep-1997 */
29*1031c584SApple OSS Distributions /* IOString.cpp converted to C++ on Tue 1998-9-22 */
30*1031c584SApple OSS Distributions
31*1031c584SApple OSS Distributions #define IOKIT_ENABLE_SHARED_PTR
32*1031c584SApple OSS Distributions
33*1031c584SApple OSS Distributions #include <string.h>
34*1031c584SApple OSS Distributions
35*1031c584SApple OSS Distributions #include <libkern/c++/OSString.h>
36*1031c584SApple OSS Distributions #include <libkern/c++/OSSerialize.h>
37*1031c584SApple OSS Distributions #include <libkern/c++/OSSharedPtr.h>
38*1031c584SApple OSS Distributions #include <libkern/c++/OSLib.h>
39*1031c584SApple OSS Distributions #include <libkern/c++/OSData.h>
40*1031c584SApple OSS Distributions #include <string.h>
41*1031c584SApple OSS Distributions
42*1031c584SApple OSS Distributions #define super OSObject
43*1031c584SApple OSS Distributions
44*1031c584SApple OSS Distributions OSDefineMetaClassAndStructorsWithZone(OSString, OSObject,
45*1031c584SApple OSS Distributions (zone_create_flags_t) (ZC_CACHING | ZC_ZFREE_CLEARMEM))
46*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 0);
47*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 1);
48*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 2);
49*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 3);
50*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 4);
51*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 5);
52*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 6);
53*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 7);
54*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 8);
55*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 9);
56*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 10);
57*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 11);
58*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 12);
59*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 13);
60*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 14);
61*1031c584SApple OSS Distributions OSMetaClassDefineReservedUnused(OSString, 15);
62*1031c584SApple OSS Distributions
63*1031c584SApple OSS Distributions bool
initWithString(const OSString * aString)64*1031c584SApple OSS Distributions OSString::initWithString(const OSString *aString)
65*1031c584SApple OSS Distributions {
66*1031c584SApple OSS Distributions return initWithCString(aString->string);
67*1031c584SApple OSS Distributions }
68*1031c584SApple OSS Distributions
69*1031c584SApple OSS Distributions bool
initWithCString(const char * cString)70*1031c584SApple OSS Distributions OSString::initWithCString(const char *cString)
71*1031c584SApple OSS Distributions {
72*1031c584SApple OSS Distributions unsigned int newLength;
73*1031c584SApple OSS Distributions char * newString;
74*1031c584SApple OSS Distributions
75*1031c584SApple OSS Distributions if (!cString || !super::init()) {
76*1031c584SApple OSS Distributions return false;
77*1031c584SApple OSS Distributions }
78*1031c584SApple OSS Distributions
79*1031c584SApple OSS Distributions newLength = (unsigned int) strnlen(cString, kMaxStringLength);
80*1031c584SApple OSS Distributions if (newLength >= kMaxStringLength) {
81*1031c584SApple OSS Distributions return false;
82*1031c584SApple OSS Distributions }
83*1031c584SApple OSS Distributions
84*1031c584SApple OSS Distributions newLength++;
85*1031c584SApple OSS Distributions newString = (char *)kalloc_data(newLength,
86*1031c584SApple OSS Distributions Z_VM_TAG_BT(Z_WAITOK, VM_KERN_MEMORY_LIBKERN));
87*1031c584SApple OSS Distributions if (!newString) {
88*1031c584SApple OSS Distributions return false;
89*1031c584SApple OSS Distributions }
90*1031c584SApple OSS Distributions
91*1031c584SApple OSS Distributions bcopy(cString, newString, newLength);
92*1031c584SApple OSS Distributions
93*1031c584SApple OSS Distributions if (!(flags & kOSStringNoCopy) && string) {
94*1031c584SApple OSS Distributions kfree_data(string, length);
95*1031c584SApple OSS Distributions OSCONTAINER_ACCUMSIZE(-((size_t)length));
96*1031c584SApple OSS Distributions }
97*1031c584SApple OSS Distributions string = newString;
98*1031c584SApple OSS Distributions length = newLength;
99*1031c584SApple OSS Distributions flags &= ~kOSStringNoCopy;
100*1031c584SApple OSS Distributions
101*1031c584SApple OSS Distributions OSCONTAINER_ACCUMSIZE(length);
102*1031c584SApple OSS Distributions
103*1031c584SApple OSS Distributions return true;
104*1031c584SApple OSS Distributions }
105*1031c584SApple OSS Distributions
106*1031c584SApple OSS Distributions bool
initWithStringOfLength(const char * cString,size_t inlength)107*1031c584SApple OSS Distributions OSString::initWithStringOfLength(const char *cString, size_t inlength)
108*1031c584SApple OSS Distributions {
109*1031c584SApple OSS Distributions unsigned int newLength;
110*1031c584SApple OSS Distributions unsigned int cStringLength;
111*1031c584SApple OSS Distributions char * newString;
112*1031c584SApple OSS Distributions
113*1031c584SApple OSS Distributions if (!cString || !super::init()) {
114*1031c584SApple OSS Distributions return false;
115*1031c584SApple OSS Distributions }
116*1031c584SApple OSS Distributions
117*1031c584SApple OSS Distributions if (inlength >= kMaxStringLength) {
118*1031c584SApple OSS Distributions return false;
119*1031c584SApple OSS Distributions }
120*1031c584SApple OSS Distributions
121*1031c584SApple OSS Distributions cStringLength = (unsigned int)strnlen(cString, inlength);
122*1031c584SApple OSS Distributions
123*1031c584SApple OSS Distributions if (cStringLength < inlength) {
124*1031c584SApple OSS Distributions inlength = cStringLength;
125*1031c584SApple OSS Distributions }
126*1031c584SApple OSS Distributions
127*1031c584SApple OSS Distributions newLength = (unsigned int) (inlength + 1);
128*1031c584SApple OSS Distributions newString = (char *)kalloc_data(newLength,
129*1031c584SApple OSS Distributions Z_VM_TAG_BT(Z_WAITOK, VM_KERN_MEMORY_LIBKERN));
130*1031c584SApple OSS Distributions if (!newString) {
131*1031c584SApple OSS Distributions return false;
132*1031c584SApple OSS Distributions }
133*1031c584SApple OSS Distributions
134*1031c584SApple OSS Distributions bcopy(cString, newString, inlength);
135*1031c584SApple OSS Distributions newString[inlength] = 0;
136*1031c584SApple OSS Distributions
137*1031c584SApple OSS Distributions if (!(flags & kOSStringNoCopy) && string) {
138*1031c584SApple OSS Distributions kfree_data(string, length);
139*1031c584SApple OSS Distributions OSCONTAINER_ACCUMSIZE(-((size_t)length));
140*1031c584SApple OSS Distributions }
141*1031c584SApple OSS Distributions
142*1031c584SApple OSS Distributions string = newString;
143*1031c584SApple OSS Distributions length = newLength;
144*1031c584SApple OSS Distributions flags &= ~kOSStringNoCopy;
145*1031c584SApple OSS Distributions
146*1031c584SApple OSS Distributions OSCONTAINER_ACCUMSIZE(length);
147*1031c584SApple OSS Distributions
148*1031c584SApple OSS Distributions return true;
149*1031c584SApple OSS Distributions }
150*1031c584SApple OSS Distributions
151*1031c584SApple OSS Distributions bool
initWithCStringNoCopy(const char * cString)152*1031c584SApple OSS Distributions OSString::initWithCStringNoCopy(const char *cString)
153*1031c584SApple OSS Distributions {
154*1031c584SApple OSS Distributions if (!cString || !super::init()) {
155*1031c584SApple OSS Distributions return false;
156*1031c584SApple OSS Distributions }
157*1031c584SApple OSS Distributions
158*1031c584SApple OSS Distributions length = (unsigned int) strnlen(cString, kMaxStringLength);
159*1031c584SApple OSS Distributions if (length >= kMaxStringLength) {
160*1031c584SApple OSS Distributions return false;
161*1031c584SApple OSS Distributions }
162*1031c584SApple OSS Distributions
163*1031c584SApple OSS Distributions length++;
164*1031c584SApple OSS Distributions flags |= kOSStringNoCopy;
165*1031c584SApple OSS Distributions string = const_cast<char *>(cString);
166*1031c584SApple OSS Distributions
167*1031c584SApple OSS Distributions return true;
168*1031c584SApple OSS Distributions }
169*1031c584SApple OSS Distributions
170*1031c584SApple OSS Distributions OSSharedPtr<OSString>
withString(const OSString * aString)171*1031c584SApple OSS Distributions OSString::withString(const OSString *aString)
172*1031c584SApple OSS Distributions {
173*1031c584SApple OSS Distributions OSSharedPtr<OSString> me = OSMakeShared<OSString>();
174*1031c584SApple OSS Distributions
175*1031c584SApple OSS Distributions if (me && !me->initWithString(aString)) {
176*1031c584SApple OSS Distributions return nullptr;
177*1031c584SApple OSS Distributions }
178*1031c584SApple OSS Distributions
179*1031c584SApple OSS Distributions return me;
180*1031c584SApple OSS Distributions }
181*1031c584SApple OSS Distributions
182*1031c584SApple OSS Distributions OSSharedPtr<OSString>
withCString(const char * cString)183*1031c584SApple OSS Distributions OSString::withCString(const char *cString)
184*1031c584SApple OSS Distributions {
185*1031c584SApple OSS Distributions OSSharedPtr<OSString> me = OSMakeShared<OSString>();
186*1031c584SApple OSS Distributions
187*1031c584SApple OSS Distributions if (me && !me->initWithCString(cString)) {
188*1031c584SApple OSS Distributions return nullptr;
189*1031c584SApple OSS Distributions }
190*1031c584SApple OSS Distributions
191*1031c584SApple OSS Distributions return me;
192*1031c584SApple OSS Distributions }
193*1031c584SApple OSS Distributions
194*1031c584SApple OSS Distributions OSSharedPtr<OSString>
withCStringNoCopy(const char * cString)195*1031c584SApple OSS Distributions OSString::withCStringNoCopy(const char *cString)
196*1031c584SApple OSS Distributions {
197*1031c584SApple OSS Distributions OSSharedPtr<OSString> me = OSMakeShared<OSString>();
198*1031c584SApple OSS Distributions
199*1031c584SApple OSS Distributions if (me && !me->initWithCStringNoCopy(cString)) {
200*1031c584SApple OSS Distributions return nullptr;
201*1031c584SApple OSS Distributions }
202*1031c584SApple OSS Distributions
203*1031c584SApple OSS Distributions return me;
204*1031c584SApple OSS Distributions }
205*1031c584SApple OSS Distributions
206*1031c584SApple OSS Distributions OSSharedPtr<OSString>
withCString(const char * cString,size_t length)207*1031c584SApple OSS Distributions OSString::withCString(const char *cString, size_t length)
208*1031c584SApple OSS Distributions {
209*1031c584SApple OSS Distributions OSSharedPtr<OSString> me = OSMakeShared<OSString>();
210*1031c584SApple OSS Distributions
211*1031c584SApple OSS Distributions if (me && !me->initWithStringOfLength(cString, length)) {
212*1031c584SApple OSS Distributions return nullptr;
213*1031c584SApple OSS Distributions }
214*1031c584SApple OSS Distributions
215*1031c584SApple OSS Distributions return me;
216*1031c584SApple OSS Distributions }
217*1031c584SApple OSS Distributions
218*1031c584SApple OSS Distributions
219*1031c584SApple OSS Distributions
220*1031c584SApple OSS Distributions /* @@@ gvdl */
221*1031c584SApple OSS Distributions #if 0
222*1031c584SApple OSS Distributions OSString *
223*1031c584SApple OSS Distributions OSString::stringWithFormat(const char *format, ...)
224*1031c584SApple OSS Distributions {
225*1031c584SApple OSS Distributions #ifndef KERNEL // mach3xxx
226*1031c584SApple OSS Distributions OSString *me;
227*1031c584SApple OSS Distributions va_list argList;
228*1031c584SApple OSS Distributions
229*1031c584SApple OSS Distributions if (!format) {
230*1031c584SApple OSS Distributions return 0;
231*1031c584SApple OSS Distributions }
232*1031c584SApple OSS Distributions
233*1031c584SApple OSS Distributions va_start(argList, format);
234*1031c584SApple OSS Distributions me = stringWithCapacity(256);
235*1031c584SApple OSS Distributions me->length = vsnprintf(me->string, 256, format, argList);
236*1031c584SApple OSS Distributions me->length++; // we include the null in the length
237*1031c584SApple OSS Distributions if (me->Length > 256) {
238*1031c584SApple OSS Distributions me->Length = 256;
239*1031c584SApple OSS Distributions }
240*1031c584SApple OSS Distributions va_end(argList);
241*1031c584SApple OSS Distributions
242*1031c584SApple OSS Distributions return me;
243*1031c584SApple OSS Distributions #else
244*1031c584SApple OSS Distributions return 0;
245*1031c584SApple OSS Distributions #endif
246*1031c584SApple OSS Distributions }
247*1031c584SApple OSS Distributions #endif /* 0 */
248*1031c584SApple OSS Distributions
249*1031c584SApple OSS Distributions void
free()250*1031c584SApple OSS Distributions OSString::free()
251*1031c584SApple OSS Distributions {
252*1031c584SApple OSS Distributions if (!(flags & kOSStringNoCopy) && string) {
253*1031c584SApple OSS Distributions kfree_data(string, length);
254*1031c584SApple OSS Distributions OSCONTAINER_ACCUMSIZE(-((size_t)length));
255*1031c584SApple OSS Distributions }
256*1031c584SApple OSS Distributions
257*1031c584SApple OSS Distributions super::free();
258*1031c584SApple OSS Distributions }
259*1031c584SApple OSS Distributions
260*1031c584SApple OSS Distributions unsigned int
getLength() const261*1031c584SApple OSS Distributions OSString::getLength() const
262*1031c584SApple OSS Distributions {
263*1031c584SApple OSS Distributions return length - 1;
264*1031c584SApple OSS Distributions }
265*1031c584SApple OSS Distributions
266*1031c584SApple OSS Distributions const char *
getCStringNoCopy() const267*1031c584SApple OSS Distributions OSString::getCStringNoCopy() const
268*1031c584SApple OSS Distributions {
269*1031c584SApple OSS Distributions return string;
270*1031c584SApple OSS Distributions }
271*1031c584SApple OSS Distributions
272*1031c584SApple OSS Distributions bool
setChar(char aChar,unsigned int index)273*1031c584SApple OSS Distributions OSString::setChar(char aChar, unsigned int index)
274*1031c584SApple OSS Distributions {
275*1031c584SApple OSS Distributions if (!(flags & kOSStringNoCopy) && index < length - 1) {
276*1031c584SApple OSS Distributions string[index] = aChar;
277*1031c584SApple OSS Distributions
278*1031c584SApple OSS Distributions return true;
279*1031c584SApple OSS Distributions } else {
280*1031c584SApple OSS Distributions return false;
281*1031c584SApple OSS Distributions }
282*1031c584SApple OSS Distributions }
283*1031c584SApple OSS Distributions
284*1031c584SApple OSS Distributions char
getChar(unsigned int index) const285*1031c584SApple OSS Distributions OSString::getChar(unsigned int index) const
286*1031c584SApple OSS Distributions {
287*1031c584SApple OSS Distributions if (index < length) {
288*1031c584SApple OSS Distributions return string[index];
289*1031c584SApple OSS Distributions } else {
290*1031c584SApple OSS Distributions return '\0';
291*1031c584SApple OSS Distributions }
292*1031c584SApple OSS Distributions }
293*1031c584SApple OSS Distributions
294*1031c584SApple OSS Distributions
295*1031c584SApple OSS Distributions bool
isEqualTo(const OSString * aString) const296*1031c584SApple OSS Distributions OSString::isEqualTo(const OSString *aString) const
297*1031c584SApple OSS Distributions {
298*1031c584SApple OSS Distributions if (length != aString->length) {
299*1031c584SApple OSS Distributions return false;
300*1031c584SApple OSS Distributions } else {
301*1031c584SApple OSS Distributions return isEqualTo((const char *) aString->string);
302*1031c584SApple OSS Distributions }
303*1031c584SApple OSS Distributions }
304*1031c584SApple OSS Distributions
305*1031c584SApple OSS Distributions bool
isEqualTo(const char * aCString) const306*1031c584SApple OSS Distributions OSString::isEqualTo(const char *aCString) const
307*1031c584SApple OSS Distributions {
308*1031c584SApple OSS Distributions return strncmp(string, aCString, length) == 0;
309*1031c584SApple OSS Distributions }
310*1031c584SApple OSS Distributions
311*1031c584SApple OSS Distributions bool
isEqualTo(const OSMetaClassBase * obj) const312*1031c584SApple OSS Distributions OSString::isEqualTo(const OSMetaClassBase *obj) const
313*1031c584SApple OSS Distributions {
314*1031c584SApple OSS Distributions OSString * str;
315*1031c584SApple OSS Distributions OSData * data;
316*1031c584SApple OSS Distributions
317*1031c584SApple OSS Distributions if ((str = OSDynamicCast(OSString, obj))) {
318*1031c584SApple OSS Distributions return isEqualTo(str);
319*1031c584SApple OSS Distributions } else if ((data = OSDynamicCast(OSData, obj))) {
320*1031c584SApple OSS Distributions return isEqualTo(data);
321*1031c584SApple OSS Distributions } else {
322*1031c584SApple OSS Distributions return false;
323*1031c584SApple OSS Distributions }
324*1031c584SApple OSS Distributions }
325*1031c584SApple OSS Distributions
326*1031c584SApple OSS Distributions bool
isEqualTo(const OSData * obj) const327*1031c584SApple OSS Distributions OSString::isEqualTo(const OSData *obj) const
328*1031c584SApple OSS Distributions {
329*1031c584SApple OSS Distributions if (NULL == obj) {
330*1031c584SApple OSS Distributions return false;
331*1031c584SApple OSS Distributions }
332*1031c584SApple OSS Distributions
333*1031c584SApple OSS Distributions unsigned int dataLen = obj->getLength();
334*1031c584SApple OSS Distributions const char * dataPtr = (const char *) obj->getBytesNoCopy();
335*1031c584SApple OSS Distributions
336*1031c584SApple OSS Distributions if (dataLen != length) {
337*1031c584SApple OSS Distributions // check for the fact that OSData may be a buffer that
338*1031c584SApple OSS Distributions // that includes a termination byte and will thus have
339*1031c584SApple OSS Distributions // a length of the actual string length PLUS 1. In this
340*1031c584SApple OSS Distributions // case we verify that the additional byte is a terminator
341*1031c584SApple OSS Distributions // and if so count the two lengths as being the same.
342*1031c584SApple OSS Distributions
343*1031c584SApple OSS Distributions if ((dataLen - length) == 1) {
344*1031c584SApple OSS Distributions if (dataPtr[dataLen - 1] != 0) {
345*1031c584SApple OSS Distributions return false;
346*1031c584SApple OSS Distributions }
347*1031c584SApple OSS Distributions dataLen--;
348*1031c584SApple OSS Distributions } else {
349*1031c584SApple OSS Distributions return false;
350*1031c584SApple OSS Distributions }
351*1031c584SApple OSS Distributions }
352*1031c584SApple OSS Distributions
353*1031c584SApple OSS Distributions for (unsigned int i = 0; i < dataLen; i++) {
354*1031c584SApple OSS Distributions if (*dataPtr++ != string[i]) {
355*1031c584SApple OSS Distributions return false;
356*1031c584SApple OSS Distributions }
357*1031c584SApple OSS Distributions }
358*1031c584SApple OSS Distributions
359*1031c584SApple OSS Distributions return true;
360*1031c584SApple OSS Distributions }
361*1031c584SApple OSS Distributions
362*1031c584SApple OSS Distributions bool
serialize(OSSerialize * s) const363*1031c584SApple OSS Distributions OSString::serialize(OSSerialize *s) const
364*1031c584SApple OSS Distributions {
365*1031c584SApple OSS Distributions char *c = string;
366*1031c584SApple OSS Distributions
367*1031c584SApple OSS Distributions if (s->previouslySerialized(this)) {
368*1031c584SApple OSS Distributions return true;
369*1031c584SApple OSS Distributions }
370*1031c584SApple OSS Distributions
371*1031c584SApple OSS Distributions if (!s->addXMLStartTag(this, "string")) {
372*1031c584SApple OSS Distributions return false;
373*1031c584SApple OSS Distributions }
374*1031c584SApple OSS Distributions while (*c) {
375*1031c584SApple OSS Distributions if (*c == '<') {
376*1031c584SApple OSS Distributions if (!s->addString("<")) {
377*1031c584SApple OSS Distributions return false;
378*1031c584SApple OSS Distributions }
379*1031c584SApple OSS Distributions } else if (*c == '>') {
380*1031c584SApple OSS Distributions if (!s->addString(">")) {
381*1031c584SApple OSS Distributions return false;
382*1031c584SApple OSS Distributions }
383*1031c584SApple OSS Distributions } else if (*c == '&') {
384*1031c584SApple OSS Distributions if (!s->addString("&")) {
385*1031c584SApple OSS Distributions return false;
386*1031c584SApple OSS Distributions }
387*1031c584SApple OSS Distributions } else {
388*1031c584SApple OSS Distributions if (!s->addChar(*c)) {
389*1031c584SApple OSS Distributions return false;
390*1031c584SApple OSS Distributions }
391*1031c584SApple OSS Distributions }
392*1031c584SApple OSS Distributions c++;
393*1031c584SApple OSS Distributions }
394*1031c584SApple OSS Distributions
395*1031c584SApple OSS Distributions return s->addXMLEndTag("string");
396*1031c584SApple OSS Distributions }
397