mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 06:12:27 +00:00
Revert whitespace fixes to third_party (#501)
This commit is contained in:
parent
d4000bb8f7
commit
9de3d8f1e6
365 changed files with 39190 additions and 39211 deletions
84
third_party/quickjs/run-test262.c
vendored
84
third_party/quickjs/run-test262.c
vendored
|
@ -325,7 +325,7 @@ void namelist_load(namelist_t *lp, const char *filename)
|
|||
char *p = str_strip(buf);
|
||||
if (*p == '#' || *p == ';' || *p == '\0')
|
||||
continue; /* line comment */
|
||||
|
||||
|
||||
namelist_add(lp, base_name, p);
|
||||
}
|
||||
free(base_name);
|
||||
|
@ -467,11 +467,11 @@ static void *agent_start(void *arg)
|
|||
JSContext *ctx;
|
||||
JSValue ret_val;
|
||||
int ret;
|
||||
|
||||
|
||||
rt = JS_NewRuntime();
|
||||
if (rt == NULL) {
|
||||
fatal(1, "JS_NewRuntime failure");
|
||||
}
|
||||
}
|
||||
ctx = JS_NewContext(rt);
|
||||
if (ctx == NULL) {
|
||||
JS_FreeRuntime(rt);
|
||||
|
@ -480,7 +480,7 @@ static void *agent_start(void *arg)
|
|||
JS_SetContextOpaque(ctx, agent);
|
||||
JS_SetRuntimeInfo(rt, "agent");
|
||||
JS_SetCanBlock(rt, TRUE);
|
||||
|
||||
|
||||
add_helpers(ctx);
|
||||
ret_val = JS_Eval(ctx, agent->script, strlen(agent->script),
|
||||
"<evalScript>", JS_EVAL_TYPE_GLOBAL);
|
||||
|
@ -489,7 +489,7 @@ static void *agent_start(void *arg)
|
|||
if (JS_IsException(ret_val))
|
||||
js_std_dump_error(ctx);
|
||||
JS_FreeValue(ctx, ret_val);
|
||||
|
||||
|
||||
for(;;) {
|
||||
JSContext *ctx1;
|
||||
ret = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1);
|
||||
|
@ -501,12 +501,12 @@ static void *agent_start(void *arg)
|
|||
break;
|
||||
} else {
|
||||
JSValue args[2];
|
||||
|
||||
|
||||
pthread_mutex_lock(&agent_mutex);
|
||||
while (!agent->broadcast_pending) {
|
||||
pthread_cond_wait(&agent_cond, &agent_mutex);
|
||||
}
|
||||
|
||||
|
||||
agent->broadcast_pending = FALSE;
|
||||
pthread_cond_signal(&agent_cond);
|
||||
|
||||
|
@ -543,7 +543,7 @@ static JSValue js_agent_start(JSContext *ctx, JSValue this_val,
|
|||
|
||||
if (JS_GetContextOpaque(ctx) != NULL)
|
||||
return JS_ThrowTypeError(ctx, "cannot be called inside an agent");
|
||||
|
||||
|
||||
script = JS_ToCString(ctx, argv[0]);
|
||||
if (!script)
|
||||
return JS_EXCEPTION;
|
||||
|
@ -562,7 +562,7 @@ static void js_agent_free(JSContext *ctx)
|
|||
{
|
||||
struct list_head *el, *el1;
|
||||
Test262Agent *agent;
|
||||
|
||||
|
||||
list_for_each_safe(el, el1, &agent_list) {
|
||||
agent = list_entry(el, Test262Agent, link);
|
||||
pthread_join(agent->tid, NULL);
|
||||
|
@ -571,7 +571,7 @@ static void js_agent_free(JSContext *ctx)
|
|||
free(agent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static JSValue js_agent_leaving(JSContext *ctx, JSValue this_val,
|
||||
int argc, JSValue *argv)
|
||||
{
|
||||
|
@ -603,16 +603,16 @@ static JSValue js_agent_broadcast(JSContext *ctx, JSValue this_val,
|
|||
uint8_t *buf;
|
||||
size_t buf_size;
|
||||
int32_t val;
|
||||
|
||||
|
||||
if (JS_GetContextOpaque(ctx) != NULL)
|
||||
return JS_ThrowTypeError(ctx, "cannot be called inside an agent");
|
||||
|
||||
|
||||
buf = JS_GetArrayBuffer(ctx, &buf_size, sab);
|
||||
if (!buf)
|
||||
return JS_EXCEPTION;
|
||||
if (JS_ToInt32(ctx, &val, argv[1]))
|
||||
return JS_EXCEPTION;
|
||||
|
||||
|
||||
/* broadcast the values and wait until all agents have started
|
||||
calling their callbacks */
|
||||
pthread_mutex_lock(&agent_mutex);
|
||||
|
@ -700,7 +700,7 @@ static JSValue js_agent_report(JSContext *ctx, JSValue this_val,
|
|||
rep = malloc(sizeof(*rep));
|
||||
rep->str = strdup(str);
|
||||
JS_FreeCString(ctx, str);
|
||||
|
||||
|
||||
pthread_mutex_lock(&report_mutex);
|
||||
list_add_tail(&rep->link, &report_list);
|
||||
pthread_mutex_unlock(&report_mutex);
|
||||
|
@ -720,7 +720,7 @@ static const JSCFunctionListEntry js_agent_funcs[] = {
|
|||
JS_CFUNC_DEF("sleep", 1, js_agent_sleep ),
|
||||
JS_CFUNC_DEF("monotonicNow", 0, js_agent_monotonicNow ),
|
||||
};
|
||||
|
||||
|
||||
static JSValue js_new_agent(JSContext *ctx)
|
||||
{
|
||||
JSValue agent;
|
||||
|
@ -736,7 +736,7 @@ static JSValue js_createRealm(JSContext *ctx, JSValue this_val,
|
|||
{
|
||||
JSContext *ctx1;
|
||||
JSValue ret;
|
||||
|
||||
|
||||
ctx1 = JS_NewContext(JS_GetRuntime(ctx));
|
||||
if (!ctx1)
|
||||
return JS_ThrowOutOfMemory(ctx);
|
||||
|
@ -756,7 +756,7 @@ static JSValue add_helpers1(JSContext *ctx)
|
|||
{
|
||||
JSValue global_obj;
|
||||
JSValue obj262, obj;
|
||||
|
||||
|
||||
global_obj = JS_GetGlobalObject(ctx);
|
||||
|
||||
JS_SetPropertyStr(ctx, global_obj, "print",
|
||||
|
@ -787,7 +787,7 @@ static JSValue add_helpers1(JSContext *ctx)
|
|||
JS_SetPropertyStr(ctx, obj262, "IsHTMLDDA", obj);
|
||||
|
||||
JS_SetPropertyStr(ctx, global_obj, "$262", JS_DupValue(ctx, obj262));
|
||||
|
||||
|
||||
JS_FreeValue(ctx, global_obj);
|
||||
return obj262;
|
||||
}
|
||||
|
@ -816,14 +816,14 @@ static JSModuleDef *js_module_loader_test(JSContext *ctx,
|
|||
uint8_t *buf;
|
||||
JSModuleDef *m;
|
||||
JSValue func_val;
|
||||
|
||||
|
||||
buf = js_load_file(ctx, &buf_len, module_name);
|
||||
if (!buf) {
|
||||
JS_ThrowReferenceError(ctx, "could not load module filename '%s'",
|
||||
module_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* compile the module */
|
||||
func_val = JS_Eval(ctx, (char *)buf, buf_len, module_name,
|
||||
JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
|
||||
|
@ -933,14 +933,14 @@ void load_config(const char *filename)
|
|||
}
|
||||
/* base_name = get_basename(filename); */
|
||||
base_name = strdup("");
|
||||
|
||||
|
||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||
char *p, *q;
|
||||
lineno++;
|
||||
p = str_strip(buf);
|
||||
if (*p == '#' || *p == ';' || *p == '\0')
|
||||
continue; /* line comment */
|
||||
|
||||
|
||||
if (*p == "[]"[0]) {
|
||||
/* new section */
|
||||
p++;
|
||||
|
@ -1006,7 +1006,7 @@ void load_config(const char *filename)
|
|||
test_mode = TEST_STRICT;
|
||||
else if (str_equal(q, "all") || str_equal(q, "both"))
|
||||
test_mode = TEST_ALL;
|
||||
else
|
||||
else
|
||||
fatal(2, "unknown test mode: %s", q);
|
||||
continue;
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ int longest_match(const char *str, const char *find, int pos, int *ppos, int lin
|
|||
int len, maxlen;
|
||||
|
||||
maxlen = 0;
|
||||
|
||||
|
||||
if (*find) {
|
||||
const char *p;
|
||||
for (p = str + pos; *p; p++) {
|
||||
|
@ -1180,7 +1180,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len,
|
|||
int ret, error_line, pos, pos_line;
|
||||
BOOL is_error, has_error_line;
|
||||
const char *error_name;
|
||||
|
||||
|
||||
pos = skip_comments(buf, 1, &pos_line);
|
||||
error_line = pos_line;
|
||||
has_error_line = FALSE;
|
||||
|
@ -1224,7 +1224,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len,
|
|||
if (is_error) {
|
||||
JSValue name, stack;
|
||||
const char *stack_str;
|
||||
|
||||
|
||||
name = JS_GetPropertyStr(ctx, exception_val, "name");
|
||||
error_name = JS_ToCString(ctx, name);
|
||||
stack = JS_GetPropertyStr(ctx, exception_val, "stack");
|
||||
|
@ -1233,10 +1233,10 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len,
|
|||
if (stack_str) {
|
||||
const char *p;
|
||||
int len;
|
||||
|
||||
|
||||
if (outfile)
|
||||
fprintf(outfile, "%s", stack_str);
|
||||
|
||||
|
||||
len = strlen(filename);
|
||||
p = strstr(stack_str, filename);
|
||||
if (p != NULL && p[len] == ':') {
|
||||
|
@ -1254,7 +1254,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len,
|
|||
if (error_type) {
|
||||
char *error_class;
|
||||
const char *msg;
|
||||
|
||||
|
||||
msg = JS_ToCString(ctx, exception_val);
|
||||
error_class = strdup_len(msg, strcspn(msg, ":"));
|
||||
if (!str_equal(error_class, error_type))
|
||||
|
@ -1378,7 +1378,7 @@ char *extract_desc(const char *buf, char style)
|
|||
const char *p, *desc_start;
|
||||
char *desc;
|
||||
int len;
|
||||
|
||||
|
||||
p = buf;
|
||||
while (*p != '\0') {
|
||||
if (p[0] == '/' && p[1] == '*' && p[2] == style && p[3] != '/') {
|
||||
|
@ -1510,11 +1510,11 @@ int run_test_buf(const char *filename, char *harness, namelist_t *ip,
|
|||
JSRuntime *rt;
|
||||
JSContext *ctx;
|
||||
int i, ret;
|
||||
|
||||
|
||||
rt = JS_NewRuntime();
|
||||
if (rt == NULL) {
|
||||
fatal(1, "JS_NewRuntime failure");
|
||||
}
|
||||
}
|
||||
ctx = JS_NewContext(rt);
|
||||
if (ctx == NULL) {
|
||||
JS_FreeRuntime(rt);
|
||||
|
@ -1523,10 +1523,10 @@ int run_test_buf(const char *filename, char *harness, namelist_t *ip,
|
|||
JS_SetRuntimeInfo(rt, filename);
|
||||
|
||||
JS_SetCanBlock(rt, can_block);
|
||||
|
||||
|
||||
/* loader for ES6 modules */
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, NULL);
|
||||
|
||||
|
||||
add_helpers(ctx);
|
||||
|
||||
for (i = 0; i < ip->count; i++) {
|
||||
|
@ -1539,7 +1539,7 @@ int run_test_buf(const char *filename, char *harness, namelist_t *ip,
|
|||
ret = eval_buf(ctx, buf, buf_len, filename, TRUE, is_negative,
|
||||
error_type, outfile, eval_flags, is_async);
|
||||
ret = (ret != 0);
|
||||
|
||||
|
||||
if (dump_memory) {
|
||||
update_stats(rt, filename);
|
||||
}
|
||||
|
@ -1572,7 +1572,7 @@ int run_test(const char *filename, int index)
|
|||
BOOL is_negative, is_nostrict, is_onlystrict, is_async, is_module, skip;
|
||||
BOOL can_block;
|
||||
namelist_t include_list = { 0 }, *ip = &include_list;
|
||||
|
||||
|
||||
is_nostrict = is_onlystrict = is_negative = is_async = is_module = skip = FALSE;
|
||||
can_block = TRUE;
|
||||
error_type = NULL;
|
||||
|
@ -1806,13 +1806,13 @@ int run_test262_harness_test(const char *filename, BOOL is_module)
|
|||
int eval_flags, ret_code, ret;
|
||||
JSValue res_val;
|
||||
BOOL can_block;
|
||||
|
||||
|
||||
outfile = stdout; /* for js_print */
|
||||
|
||||
rt = JS_NewRuntime();
|
||||
if (rt == NULL) {
|
||||
fatal(1, "JS_NewRuntime failure");
|
||||
}
|
||||
}
|
||||
ctx = JS_NewContext(rt);
|
||||
if (ctx == NULL) {
|
||||
JS_FreeRuntime(rt);
|
||||
|
@ -1822,10 +1822,10 @@ int run_test262_harness_test(const char *filename, BOOL is_module)
|
|||
|
||||
can_block = TRUE;
|
||||
JS_SetCanBlock(rt, can_block);
|
||||
|
||||
|
||||
/* loader for ES6 modules */
|
||||
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader_test, NULL);
|
||||
|
||||
|
||||
add_helpers(ctx);
|
||||
|
||||
buf = load_file(filename, &buf_len);
|
||||
|
@ -2005,14 +2005,14 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (optind >= argc && !test_list.count)
|
||||
help();
|
||||
|
||||
if (is_test262_harness) {
|
||||
return run_test262_harness_test(argv[optind], is_module);
|
||||
}
|
||||
|
||||
|
||||
error_out = stdout;
|
||||
if (error_filename) {
|
||||
error_file = load_file(error_filename, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue