Bug 1289050 - Part 9: Use Latin1 variant of JS_ReportErrorNumber after encoding in Latin1. r=jandem

This commit is contained in:
Tooru Fujisawa 2016-08-15 23:05:08 +09:00
parent cda82ac672
commit 8e53519144
18 changed files with 164 additions and 144 deletions

View File

@ -688,8 +688,9 @@ js::obj_create(JSContext* cx, unsigned argc, Value* vp)
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
bytes.get(), "not an object or null");
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
bytes.get(), "not an object or null");
return false;
}

View File

@ -141,8 +141,8 @@ ErrorWrongTypeArg(JSContext* cx, unsigned argIndex, Handle<TypeDescr*> typeDescr
if (!typeNameStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SIMD_NOT_A_VECTOR,
typeNameStr, charArgIndex);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_SIMD_NOT_A_VECTOR,
typeNameStr, charArgIndex);
JS_free(cx, typeNameStr);
return false;
}

View File

@ -170,7 +170,8 @@ WeakMap_set_impl(JSContext* cx, const CallArgs& args)
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, args.get(0), nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT,
bytes.get());
return false;
}
@ -358,7 +359,9 @@ WeakMap_construct(JSContext* cx, unsigned argc, Value* vp)
DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, keyVal, nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
JSMSG_NOT_NONNULL_OBJECT,
bytes.get());
return false;
}

View File

@ -130,7 +130,9 @@ WeakSetObject::construct(JSContext* cx, unsigned argc, Value* vp)
DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, keyVal, nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
JSMSG_NOT_NONNULL_OBJECT,
bytes.get());
return false;
}

View File

@ -1138,9 +1138,9 @@ ConvError(JSContext* cx, const char* expectedStr, HandleValue actual,
if (!arrStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARRAY,
valStr, indexStr, arrStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARRAY,
valStr, indexStr, arrStr);
break;
}
case TYPE_struct: {
@ -1170,9 +1170,9 @@ ConvError(JSContext* cx, const char* expectedStr, HandleValue actual,
posStr = "";
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_STRUCT,
valStr, nameStr, expectedStr, structStr, posStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_STRUCT,
valStr, nameStr, expectedStr, structStr, posStr);
break;
}
default:
@ -1195,9 +1195,9 @@ ConvError(JSContext* cx, const char* expectedStr, HandleValue actual,
if (!funStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARG,
valStr, indexStr, funStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARG,
valStr, indexStr, funStr);
break;
}
case ConversionType::Finalizer: {
@ -1210,8 +1210,8 @@ ConvError(JSContext* cx, const char* expectedStr, HandleValue actual,
if (!funStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_FIN, valStr, funStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_FIN, valStr, funStr);
break;
}
case ConversionType::Return: {
@ -1224,16 +1224,16 @@ ConvError(JSContext* cx, const char* expectedStr, HandleValue actual,
if (!funStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_RET, valStr, funStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_RET, valStr, funStr);
break;
}
case ConversionType::Setter:
case ConversionType::Construct:
MOZ_ASSERT(!funObj);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_SET, valStr, expectedStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_SET, valStr, expectedStr);
break;
}
@ -1271,8 +1271,8 @@ ArgumentConvError(JSContext* cx, HandleValue actual, const char* funStr,
char indexStr[16];
SprintfLiteral(indexStr, "%u", argIndex + 1);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARG, valStr, indexStr, funStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_CONV_ERROR_ARG, valStr, indexStr, funStr);
return false;
}
@ -1280,8 +1280,8 @@ static bool
ArgumentLengthError(JSContext* cx, const char* fun, const char* count,
const char* s)
{
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_WRONG_ARG_LENGTH, fun, count, s);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_WRONG_ARG_LENGTH, fun, count, s);
return false;
}
@ -1309,9 +1309,9 @@ ArrayLengthMismatch(JSContext* cx, unsigned expectedLength, HandleObject arrObj,
if (!arrStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARRAY_MISMATCH,
valStr, arrStr, expectedLengthStr, actualLengthStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARRAY_MISMATCH,
valStr, arrStr, expectedLengthStr, actualLengthStr);
return false;
}
@ -1339,9 +1339,9 @@ ArrayLengthOverflow(JSContext* cx, unsigned expectedLength, HandleObject arrObj,
if (!arrStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARRAY_OVERFLOW,
valStr, arrStr, expectedLengthStr, actualLengthStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARRAY_OVERFLOW,
valStr, arrStr, expectedLengthStr, actualLengthStr);
return false;
}
@ -1378,8 +1378,8 @@ DuplicateFieldError(JSContext* cx, Handle<JSFlatString*> name)
if (!nameStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_DUPLICATE_FIELD, nameStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_DUPLICATE_FIELD, nameStr);
return false;
}
@ -1407,8 +1407,8 @@ EmptyFinalizerError(JSContext* cx, ConversionType convType,
posStr = "";
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_EMPTY_FIN, posStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_EMPTY_FIN, posStr);
return false;
}
@ -1450,10 +1450,10 @@ FieldCountMismatch(JSContext* cx,
posStr = "";
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_MISMATCH,
valStr, structStr, expectedCountStr, actualCountStr,
posStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_MISMATCH,
valStr, structStr, expectedCountStr, actualCountStr,
posStr);
return false;
}
@ -1469,8 +1469,8 @@ FieldDescriptorCountError(JSContext* cx, Value val, size_t length)
char lengthStr[16];
SprintfLiteral(lengthStr, "%" PRIuSIZE, length);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_COUNT, valStr, lengthStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_COUNT, valStr, lengthStr);
return false;
}
@ -1483,8 +1483,8 @@ FieldDescriptorNameError(JSContext* cx, HandleId id)
if (!propStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_NAME, propStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_NAME, propStr);
return false;
}
@ -1503,8 +1503,8 @@ FieldDescriptorSizeError(JSContext* cx, HandleObject typeObj, HandleId id)
if (!propStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_SIZE, typeStr, propStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_SIZE, typeStr, propStr);
return false;
}
@ -1517,8 +1517,8 @@ FieldDescriptorNameTypeError(JSContext* cx, Value val)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_NAMETYPE, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_NAMETYPE, valStr);
return false;
}
@ -1536,8 +1536,8 @@ FieldDescriptorTypeError(JSContext* cx, HandleValue poroVal, HandleId id)
if (!propStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_TYPE, typeStr, propStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_DESC_TYPE, typeStr, propStr);
return false;
}
@ -1556,8 +1556,8 @@ FieldMissingError(JSContext* cx, JSObject* typeObj, JSFlatString* name_)
if (!nameStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_MISSING, typeStr, nameStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIELD_MISSING, typeStr, nameStr);
return false;
}
@ -1578,8 +1578,8 @@ FinalizerSizeError(JSContext* cx, HandleObject funObj, HandleValue actual)
if (!funStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIN_SIZE_ERROR, funStr, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_FIN_SIZE_ERROR, funStr, valStr);
return false;
}
@ -1608,9 +1608,10 @@ FunctionArgumentLengthMismatch(JSContext* cx,
const char* variadicStr = isVariadic ? " or more": "";
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARG_COUNT_MISMATCH,
funStr, expectedCountStr, variadicStr, actualCountStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARG_COUNT_MISMATCH,
funStr, expectedCountStr, variadicStr,
actualCountStr);
return false;
}
@ -1627,8 +1628,9 @@ FunctionArgumentTypeError(JSContext* cx,
char indexStr[16];
SprintfLiteral(indexStr, "%u", index + 1);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARG_TYPE_ERROR, indexStr, reason, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_ARG_TYPE_ERROR,
indexStr, reason, valStr);
return false;
}
@ -1641,8 +1643,8 @@ FunctionReturnTypeError(JSContext* cx, Value type, const char* reason)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_RET_TYPE_ERROR, reason, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_RET_TYPE_ERROR, reason, valStr);
return false;
}
@ -1655,8 +1657,8 @@ IncompatibleCallee(JSContext* cx, const char* funName, HandleObject actualObj)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_CALLEE, funName, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_CALLEE, funName, valStr);
return false;
}
@ -1664,9 +1666,9 @@ static bool
IncompatibleThisProto(JSContext* cx, const char* funName,
const char* actualType)
{
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS,
funName, actualType);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS,
funName, actualType);
return false;
}
@ -1678,9 +1680,9 @@ IncompatibleThisProto(JSContext* cx, const char* funName, HandleValue actualVal)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS_VAL,
funName, "incompatible object", valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS_VAL,
funName, "incompatible object", valStr);
return false;
}
@ -1702,9 +1704,9 @@ IncompatibleThisType(JSContext* cx, const char* funName, const char* actualType,
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS_VAL,
funName, actualType, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_INCOMPATIBLE_THIS_VAL,
funName, actualType, valStr);
return false;
}
@ -1716,8 +1718,8 @@ InvalidIndexError(JSContext* cx, HandleValue val)
if (!indexStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_INVALID_INDEX, indexStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_INVALID_INDEX, indexStr);
return false;
}
@ -1754,8 +1756,8 @@ NonPrimitiveError(JSContext* cx, HandleObject typeObj)
if (!typeStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_NON_PRIMITIVE, typeStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_NON_PRIMITIVE, typeStr);
return false;
}
@ -1767,8 +1769,8 @@ NonStringBaseError(JSContext* cx, HandleValue thisVal)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_NON_STRING_BASE, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_NON_STRING_BASE, valStr);
return false;
}
@ -1781,8 +1783,8 @@ NullPointerError(JSContext* cx, const char* action, HandleObject obj)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_NULL_POINTER, action, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_NULL_POINTER, action, valStr);
return false;
}
@ -1814,8 +1816,8 @@ PropNameNonStringError(JSContext* cx, HandleId id, HandleValue actual,
posStr = "";
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_PROP_NONSTRING, propStr, valStr, posStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_PROP_NONSTRING, propStr, valStr, posStr);
return false;
}
@ -1835,8 +1837,8 @@ TypeError(JSContext* cx, const char* expected, HandleValue actual)
if (!src)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_TYPE_ERROR, expected, src);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_TYPE_ERROR, expected, src);
return false;
}
@ -1848,8 +1850,8 @@ TypeOverflow(JSContext* cx, const char* expected, HandleValue actual)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_TYPE_OVERFLOW, valStr, expected);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_TYPE_OVERFLOW, valStr, expected);
return false;
}
@ -1864,8 +1866,8 @@ UndefinedSizeCastError(JSContext* cx, HandleObject targetTypeObj)
if (!targetTypeStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_UNDEFINED_SIZE_CAST, targetTypeStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_UNDEFINED_SIZE_CAST, targetTypeStr);
return false;
}
@ -1895,10 +1897,10 @@ SizeMismatchCastError(JSContext* cx,
SprintfLiteral(sourceSizeStr, "%" PRIuSIZE, sourceSize);
SprintfLiteral(targetSizeStr, "%" PRIuSIZE, targetSize);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_SIZE_MISMATCH_CAST,
targetTypeStr, sourceTypeStr,
targetSizeStr, sourceSizeStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_SIZE_MISMATCH_CAST,
targetTypeStr, sourceTypeStr,
targetSizeStr, sourceSizeStr);
return false;
}
@ -1911,8 +1913,8 @@ UndefinedSizePointerError(JSContext* cx, const char* action, HandleObject obj)
if (!valStr)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_UNDEFINED_SIZE, action, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_UNDEFINED_SIZE, action, valStr);
return false;
}
@ -1927,8 +1929,8 @@ VariadicArgumentTypeError(JSContext* cx, uint32_t index, HandleValue actual)
char indexStr[16];
SprintfLiteral(indexStr, "%u", index + 1);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
CTYPESMSG_VARG_TYPE_ERROR, indexStr, valStr);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
CTYPESMSG_VARG_TYPE_ERROR, indexStr, valStr);
return false;
}

View File

@ -1960,8 +1960,8 @@ Parser<FullParseHandler>::moduleBody(ModuleSharedContext* modulesc)
if (!str.encodeLatin1(context, name))
return null();
JS_ReportErrorNumber(context->asJSContext(), GetErrorMessage, nullptr,
JSMSG_MISSING_EXPORT, str.ptr());
JS_ReportErrorNumberLatin1(context->asJSContext(), GetErrorMessage, nullptr,
JSMSG_MISSING_EXPORT, str.ptr());
return null();
}

View File

@ -1627,9 +1627,9 @@ JS::GetFirstArgumentAsTypeHint(JSContext* cx, CallArgs args, JSType *result)
return false;
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
"Symbol.toPrimitive",
"\"string\", \"number\", or \"default\"", source);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
"Symbol.toPrimitive",
"\"string\", \"number\", or \"default\"", source);
return false;
}
@ -3738,8 +3738,12 @@ AutoFile::open(JSContext* cx, const char* filename)
} else {
fp_ = fopen(filename, "r");
if (!fp_) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_OPEN,
filename, "No such file or directory");
/*
* Use Latin1 variant here because the encoding of filename is
* platform dependent.
*/
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_CANT_OPEN,
filename, "No such file or directory");
return false;
}
}

View File

@ -808,8 +808,10 @@ bool
js::ReportIsNotDefined(JSContext* cx, HandleId id)
{
JSAutoByteString printable;
if (ValueToPrintable(cx, IdToValue(id), &printable))
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, printable.ptr());
if (ValueToPrintable(cx, IdToValue(id), &printable)) {
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED,
printable.ptr());
}
return false;
}
@ -865,9 +867,9 @@ js::ReportMissingArg(JSContext* cx, HandleValue v, unsigned arg)
if (!bytes)
return;
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
JSMSG_MISSING_FUN_ARG, argbuf,
bytes ? bytes.get() : "");
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
JSMSG_MISSING_FUN_ARG,
argbuf, bytes ? bytes.get() : "");
}
bool

View File

@ -568,8 +568,8 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
if (!fun->isInterpreted()) {
JSAutoByteString funNameBytes;
if (const char* name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
JSMSG_NOT_SCRIPTED_FUNCTION, name);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
JSMSG_NOT_SCRIPTED_FUNCTION, name);
}
return false;
}
@ -2281,8 +2281,8 @@ js::ReportIncompatibleMethod(JSContext* cx, const CallArgs& args, const Class* c
if (JSFunction* fun = ReportIfNotFunction(cx, args.calleev())) {
JSAutoByteString funNameBytes;
if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
clasp->name, funName, InformalValueTypeName(thisv));
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
clasp->name, funName, InformalValueTypeName(thisv));
}
}
}
@ -2293,8 +2293,8 @@ js::ReportIncompatible(JSContext* cx, const CallArgs& args)
if (JSFunction* fun = ReportIfNotFunction(cx, args.calleev())) {
JSAutoByteString funNameBytes;
if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
funName, "method", InformalValueTypeName(args.thisv()));
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
funName, "method", InformalValueTypeName(args.thisv()));
}
}
}

View File

@ -83,7 +83,8 @@ js::ReportNotObject(JSContext* cx, const Value& v)
RootedValue value(cx, v);
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, nullptr);
if (bytes)
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT,
bytes.get());
}
const char*
@ -201,8 +202,8 @@ js::GetFirstArgumentAsObject(JSContext* cx, const CallArgs& args, const char* me
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
bytes.get(), "not an object");
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
bytes.get(), "not an object");
return false;
}
@ -236,7 +237,7 @@ js::Throw(JSContext* cx, jsid id, unsigned errorNumber)
JSAutoByteString bytes(cx, idstr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, bytes.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, errorNumber, bytes.ptr());
return false;
}

View File

@ -225,7 +225,7 @@ GetPM(JSContext* cx, JS::HandleValue value, const char* fname)
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, nullptr);
if (!bytes)
return nullptr;
JS_ReportErrorNumber(cx, GetErrorMessage, 0, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, 0, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
return nullptr;
}
RootedObject obj(cx, &value.toObject());

View File

@ -158,7 +158,7 @@ GetProxyTrap(JSContext* cx, HandleObject handler, HandlePropertyName name, Mutab
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_TRAP, bytes.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_BAD_TRAP, bytes.ptr());
return false;
}

View File

@ -2180,14 +2180,15 @@ AssertEq(JSContext* cx, unsigned argc, Value* vp)
const char* actual = ToSource(cx, args[0], &bytes0);
const char* expected = ToSource(cx, args[1], &bytes1);
if (args.length() == 2) {
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_ASSERT_EQ_FAILED,
actual, expected);
JS_ReportErrorNumberLatin1(cx, my_GetErrorMessage, nullptr, JSSMSG_ASSERT_EQ_FAILED,
actual, expected);
} else {
JSAutoByteString bytes2(cx, args[2].toString());
if (!bytes2)
return false;
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_ASSERT_EQ_FAILED_MSG,
actual, expected, bytes2.ptr());
JS_ReportErrorNumberLatin1(cx, my_GetErrorMessage, nullptr,
JSSMSG_ASSERT_EQ_FAILED_MSG,
actual, expected, bytes2.ptr());
}
return false;
}
@ -2891,9 +2892,13 @@ DisassWithSrc(JSContext* cx, unsigned argc, Value* vp)
bupline = 0;
while (line1 < line2) {
if (!fgets(linebuf, lineBufLen, file)) {
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr,
JSSMSG_UNEXPECTED_EOF,
script->filename());
/*
* FIXME: script->filename() should become UTF-8
* (bug 987069).
*/
JS_ReportErrorNumberLatin1(cx, my_GetErrorMessage, nullptr,
JSSMSG_UNEXPECTED_EOF,
script->filename());
return false;
}
line1++;

View File

@ -1341,8 +1341,8 @@ ReportOptimizedOut(JSContext* cx, HandleId id)
{
JSAutoByteString printable;
if (ValueToPrintable(cx, IdToValue(id), &printable)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT,
printable.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT,
printable.ptr());
}
}
@ -3186,9 +3186,9 @@ ReportCannotDeclareGlobalBinding(JSContext* cx, HandlePropertyName name, const c
{
JSAutoByteString printable;
if (AtomToPrintableString(cx, name, &printable)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
JSMSG_CANT_DECLARE_GLOBAL_BINDING,
printable.ptr(), reason);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr,
JSMSG_CANT_DECLARE_GLOBAL_BINDING,
printable.ptr(), reason);
}
}

View File

@ -66,7 +66,7 @@ ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavio
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, iterable, nullptr);
if (!bytes)
return false;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes.get());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes.get());
return false;
}

View File

@ -4982,7 +4982,7 @@ js::ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber, HandleId id)
errorNumber == JSMSG_BAD_CONST_ASSIGN);
JSAutoByteString printable;
if (ValueToPrintable(cx, IdToValue(id), &printable))
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, printable.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, errorNumber, printable.ptr());
}
void
@ -5025,8 +5025,8 @@ js::ReportRuntimeRedeclaration(JSContext* cx, HandlePropertyName name, const cha
{
JSAutoByteString printable;
if (AtomToPrintableString(cx, name, &printable)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_REDECLARED_VAR,
redeclKind, printable.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_REDECLARED_VAR,
redeclKind, printable.ptr());
}
}
@ -5078,11 +5078,11 @@ js::ThrowUninitializedThis(JSContext* cx, AbstractFramePtr frame)
name = str.ptr();
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_THIS, name);
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_THIS, name);
return false;
}
MOZ_ASSERT(fun->isArrow());
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_THIS_ARROW);
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_THIS_ARROW);
return false;
}

View File

@ -336,8 +336,8 @@ ThrowErrorWithType(JSContext* cx, JSExnType type, const CallArgs& args)
return;
}
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber,
errorArgs[0].ptr(), errorArgs[1].ptr(), errorArgs[2].ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, errorNumber,
errorArgs[0].ptr(), errorArgs[1].ptr(), errorArgs[2].ptr());
}
static bool
@ -1793,8 +1793,8 @@ js::ReportIncompatibleSelfHostedMethod(JSContext* cx, const CallArgs& args)
if (!funName)
return false;
if (strcmp(funName, "IsTypedArrayEnsuringArrayBuffer") != 0) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
funName, "method", InformalValueTypeName(args.thisv()));
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
funName, "method", InformalValueTypeName(args.thisv()));
return false;
}
++iter;

View File

@ -1102,8 +1102,8 @@ ParseBreakdown(JSContext* cx, HandleValue breakdownValue)
if (!byBytes)
return nullptr;
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CENSUS_BREAKDOWN,
byBytes.ptr());
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CENSUS_BREAKDOWN,
byBytes.ptr());
return nullptr;
}