Differences From Artifact [0594cc40a6]:
- File
src/OFString+XMLEscaping.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 2437) [annotate] [blame] [check-ins using] [more...]
To Artifact [90c811c9d5]:
- File src/OFString+XMLEscaping.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 2414) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
29 30 31 32 33 34 35 | @implementation OFString (XMLEscaping) - (OFString*)stringByXMLEscaping { void *pool = objc_autoreleasePoolPush(); char *retCString; const char *string, *append; size_t length, retLength, appendLen; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | @implementation OFString (XMLEscaping) - (OFString*)stringByXMLEscaping { void *pool = objc_autoreleasePoolPush(); char *retCString; const char *string, *append; size_t length, retLength, appendLen; size_t j; OFString *ret; string = [self UTF8String]; length = [self UTF8StringLength]; j = 0; retLength = length; /* * We can't use allocMemoryWithSize: here as it might be a @"" literal */ if ((retCString = malloc(retLength)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: retLength]; for (size_t i = 0; i < length; i++) { switch (string[i]) { case '<': append = "<"; appendLen = 4; break; case '>': append = ">"; appendLen = 4; break; case '"': append = """; appendLen = 6; break; case '\'': append = "'"; appendLen = 6; break; case '&': append = "&"; appendLen = 5; break; case '\r': append = "
"; appendLen = 5; break; default: append = NULL; appendLen = 0; } if (append != NULL) { char *newRetCString; if ((newRetCString = realloc(retCString, retLength + appendLen)) == NULL) { |
︙ | ︙ |