mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
DEBUG-only code to catch format arg count vs. arg specifier mismatch (346773, r=dbaron).
This commit is contained in:
parent
5a3c477471
commit
9b38470bd3
@ -1,5 +1,5 @@
|
|||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
* vim: set ts=8 sw=4 et tw=80:
|
* vim: set ts=8 sw=4 et tw=78:
|
||||||
*
|
*
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
@ -652,19 +652,36 @@ JS_NewRuntime(uint32 maxbytes)
|
|||||||
JSRuntime *rt;
|
JSRuntime *rt;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
JS_BEGIN_MACRO
|
static JSBool didFirstChecks;
|
||||||
/*
|
|
||||||
* This code asserts that the numbers associated with the error names in
|
if (!didFirstChecks) {
|
||||||
* jsmsg.def are monotonically increasing. It uses values for the error
|
/*
|
||||||
* names enumerated in jscntxt.c. It's not a compiletime check, but it's
|
* This code asserts that the numbers associated with the error names
|
||||||
* better than nothing.
|
* in jsmsg.def are monotonically increasing. It uses values for the
|
||||||
*/
|
* error names enumerated in jscntxt.c. It's not a compile-time check
|
||||||
int errorNumber = 0;
|
* but it's better than nothing.
|
||||||
#define MSG_DEF(name, number, count, exception, format) \
|
*/
|
||||||
|
int errorNumber = 0;
|
||||||
|
#define MSG_DEF(name, number, count, exception, format) \
|
||||||
JS_ASSERT(name == errorNumber++);
|
JS_ASSERT(name == errorNumber++);
|
||||||
#include "js.msg"
|
#include "js.msg"
|
||||||
#undef MSG_DEF
|
#undef MSG_DEF
|
||||||
|
|
||||||
|
#define MSG_DEF(name, number, count, exception, format) \
|
||||||
|
JS_BEGIN_MACRO \
|
||||||
|
uintN numfmtspecs = 0; \
|
||||||
|
const char *fmt; \
|
||||||
|
for (fmt = format; *fmt != '\0'; fmt++) { \
|
||||||
|
if (*fmt == '{' && isdigit(fmt[1])) \
|
||||||
|
++numfmtspecs; \
|
||||||
|
} \
|
||||||
|
JS_ASSERT(count == numfmtspecs); \
|
||||||
JS_END_MACRO;
|
JS_END_MACRO;
|
||||||
|
#include "js.msg"
|
||||||
|
#undef MSG_DEF
|
||||||
|
|
||||||
|
didFirstChecks = JS_TRUE;
|
||||||
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
rt = (JSRuntime *) malloc(sizeof(JSRuntime));
|
rt = (JSRuntime *) malloc(sizeof(JSRuntime));
|
||||||
|
Loading…
Reference in New Issue
Block a user