ObjFW  Check-in [4075c85e25]

Overview
Comment:of_asprintf: Work around Win32 breaking C99 standard length modifiers.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.5
Files: files | file ages | folders
SHA3-256: 4075c85e25353f08467b26b76b1d32ad16d6bd6a04e7572eb172586b32243f1a
User & Date: js on 2011-06-30 20:50:40
Other Links: branch diff | manifest | tags
Context
2011-06-30
20:50
of_asprintf: Work around Win32 breaking C99 standard length modifiers. check-in: 4075c85e25 user: js tags: 0.5
20:44
Don't use _NSGetEnviron or environ on iOS. check-in: 5af02ce36a user: js tags: 0.5
2011-06-26
00:45
Handle q length modifier in of_asprintf on iOS. check-in: 3092cda94b user: js tags: 0.5
Changes

Modified src/of_asprintf.m from [983a2f4cc6] to [379e3421b7].

165
166
167
168
169
170
171

172
173




174
175
176
177
178
179
180
181
182
183
184
185

186
187




188
189
190
191
192
193
194

			ctx->len_mod = LENGTH_MODIFIER_H;
		}

		break;
	case 'l': /* and also ll */
		if (ctx->fmt_len > ctx->i + 1 && ctx->fmt[ctx->i + 1] == 'l') {

			if (!append_subfmt(ctx, ctx->fmt + ctx->i, 2))
				return false;





			ctx->i++;
			ctx->len_mod = LENGTH_MODIFIER_LL;
		} else {
			if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
				return false;

			ctx->len_mod = LENGTH_MODIFIER_L;
		}

		break;
	case 'j':

		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;





		ctx->len_mod = LENGTH_MODIFIER_J;

		break;
	case 'z':
		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;







>


>
>
>
>












>


>
>
>
>







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

			ctx->len_mod = LENGTH_MODIFIER_H;
		}

		break;
	case 'l': /* and also ll */
		if (ctx->fmt_len > ctx->i + 1 && ctx->fmt[ctx->i + 1] == 'l') {
#ifndef _WIN32
			if (!append_subfmt(ctx, ctx->fmt + ctx->i, 2))
				return false;
#else
			if (!append_subfmt(ctx, "I64", 3))
				return false;
#endif

			ctx->i++;
			ctx->len_mod = LENGTH_MODIFIER_LL;
		} else {
			if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
				return false;

			ctx->len_mod = LENGTH_MODIFIER_L;
		}

		break;
	case 'j':
#ifndef _WIN32
		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;
#else
		if (!append_subfmt(ctx, "I64", 3))
			return false;
#endif

		ctx->len_mod = LENGTH_MODIFIER_J;

		break;
	case 'z':
		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;
206
207
208
209
210
211
212














213
214
215
216
217
218
219
	case 'L':
		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;

		ctx->len_mod = LENGTH_MODIFIER_CAPITAL_L;

		break;














	default:
		ctx->i--;

		break;
	}

	ctx->state = STATE_FORMAT_CONVERSION_SPECIFIER;







>
>
>
>
>
>
>
>
>
>
>
>
>
>







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
	case 'L':
		if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
			return false;

		ctx->len_mod = LENGTH_MODIFIER_CAPITAL_L;

		break;
#ifdef _WIN32
	case 'I': /* win32 strangeness (I64 instead of ll or j) */
		if (ctx->fmt_len > ctx->i + 2 && ctx->fmt[ctx->i + 1] == '6' &&
		    ctx->fmt[ctx->i + 2] == '4') {
			if (!append_subfmt(ctx, ctx->fmt + ctx->i, 3))
				return false;

			ctx->i += 2;
			ctx->len_mod = LENGTH_MODIFIER_LL;
		} else
			ctx->i--;

		break;
#endif
	default:
		ctx->i--;

		break;
	}

	ctx->state = STATE_FORMAT_CONVERSION_SPECIFIER;