Changeset 235627 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Sep 4, 2018, 12:48:39 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r235450 r235627 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 * Copyright (C) 2004-201 7Apple Inc. All rights reserved.3 * Copyright (C) 2004-2018 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2006 Bjoern Graf ([email protected]) 5 5 * … … 1015 1015 } 1016 1016 1017 static CString cStringFromViewWithString(ExecState* exec, ThrowScope& scope, StringViewWithUnderlyingString& viewWithString) 1018 { 1019 Expected<CString, UTF8ConversionError> expectedString = viewWithString.view.tryGetUtf8(); 1020 if (expectedString) 1021 return expectedString.value(); 1022 switch (expectedString.error()) { 1023 case UTF8ConversionError::OutOfMemory: 1024 throwOutOfMemoryError(exec, scope); 1025 break; 1026 case UTF8ConversionError::IllegalSource: 1027 scope.throwException(exec, createError(exec, "Illegal source encountered during UTF8 conversion")); 1028 break; 1029 case UTF8ConversionError::SourceExhausted: 1030 scope.throwException(exec, createError(exec, "Source exhausted during UTF8 conversion")); 1031 break; 1032 default: 1033 RELEASE_ASSERT_NOT_REACHED(); 1034 } 1035 return { }; 1036 } 1037 1017 1038 static EncodedJSValue printInternal(ExecState* exec, FILE* out) 1018 1039 { … … 1035 1056 auto viewWithString = exec->uncheckedArgument(i).toString(exec)->viewWithUnderlyingString(exec); 1036 1057 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 1037 if (fprintf(out, "%s", viewWithString.view.utf8().data()) < 0) 1058 auto string = cStringFromViewWithString(exec, scope, viewWithString); 1059 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 1060 if (fprintf(out, "%s", string.data()) < 0) 1038 1061 goto fail; 1039 1062 } … … 1054 1077 auto viewWithString = exec->argument(0).toString(exec)->viewWithUnderlyingString(exec); 1055 1078 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 1056 fprintf(stderr, "--> %s\n", viewWithString.view.utf8().data()); 1079 auto string = cStringFromViewWithString(exec, scope, viewWithString); 1080 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 1081 fprintf(stderr, "--> %s\n", string.data()); 1057 1082 return JSValue::encode(jsUndefined()); 1058 1083 }
Note:
See TracChangeset
for help on using the changeset viewer.