Overview
Comment: | Work around a bug in gcc 4.0.1 (or is it Apple gcc only?). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
95992fdc0e87d7527a6d121cf37dca6c |
User & Date: | js on 2009-01-04 02:46:22 |
Other Links: | manifest | tags |
Context
2009-01-05
| ||
00:56 | Initial OFAutoreleasePool - still needs a *lot* of testing. check-in: b412845664 user: js tags: trunk | |
2009-01-04
| ||
02:46 | Work around a bug in gcc 4.0.1 (or is it Apple gcc only?). check-in: 95992fdc0e user: js tags: trunk | |
01:40 | Clean up exceptions. check-in: bb1fe89478 user: js tags: trunk | |
Changes
Modified src/OFXMLFactory.h from [3e158df444] to [49fd5f9573].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * Copyright (c) 2008 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" /** * The OFXMLFactory class provides an easy way to create XML stanzas. */ @interface OFXMLFactory: OFObject {} | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * Copyright (c) 2008 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import <stdarg.h> #import <stdio.h> #import "OFObject.h" /** * The OFXMLFactory class provides an easy way to create XML stanzas. */ @interface OFXMLFactory: OFObject {} |
︙ | ︙ |
Modified src/OFXMLFactory.m from [0c4e28e6ff] to [84c8f6247c].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #import <stdarg.h> #import <stdlib.h> #import <string.h> #import <limits.h> #import "OFXMLFactory.h" #import "OFExceptions.h" #import "OFMacros.h" | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #import <stdarg.h> #import <stdio.h> #import <stdlib.h> #import <string.h> #import <limits.h> #import "OFXMLFactory.h" #import "OFExceptions.h" #import "OFMacros.h" |
︙ | ︙ | |||
105 106 107 108 109 110 111 | return ret; } + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close andData: (const char*)data, ... { | | > | > > > > > | > | | | < < < < < | < < | | | > > > > > > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | return ret; } + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close andData: (const char*)data, ... { char *arg, *val, *xml, *esc_val; size_t i, len; va_list args; /* Start of tag */ len = strlen(name); if (SIZE_MAX - len < 3) @throw [OFOutOfRangeException newWithClass: self]; len += 3; if ((xml = malloc(len)) == NULL) @throw [OFNoMemException newWithClass: self andSize: len]; i = 0; xml[i++] = '<'; memcpy(xml + i, name, strlen(name)); i += strlen(name); /* * Arguments * * va_start / va_end need to be INSIDE the @try block due to a bug in * gcc 4.0.1. (Only in Apple gcc?) */ @try { va_start(args, data); while ((arg = va_arg(args, char*)) != NULL && (val = va_arg(args, char*)) != NULL) { esc_val = NULL; /* Needed for our @catch */ esc_val = [OFXMLFactory escapeCString: val]; xf_resize_chars(&xml, &len, 1 + strlen(arg) + 2 + strlen(esc_val) + 1, self); xml[i++] = ' '; memcpy(xml + i, arg, strlen(arg)); i += strlen(arg); xml[i++] = '='; xml[i++] = '\''; memcpy(xml + i, esc_val, strlen(esc_val)); i += strlen(esc_val); xml[i++] = '\''; free(esc_val); } va_end(args); } @catch (OFException *e) { if (esc_val != NULL) free(esc_val); if (xml != NULL) free(xml); @throw e; } /* End of tag */ if (close) { if (data == NULL) { xf_resize_chars(&xml, &len, 2 - 1, self); xml[i++] = '/'; |
︙ | ︙ |