mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[smjs document replace] struct string init and done
This commit is contained in:
parent
99ed5e56f5
commit
550baf1baf
@ -480,6 +480,8 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
|||||||
|
|
||||||
struct string code;
|
struct string code;
|
||||||
|
|
||||||
|
init_string(&code);
|
||||||
|
|
||||||
if (argc >= 1)
|
if (argc >= 1)
|
||||||
{
|
{
|
||||||
for (int i=0;i<argc;++i)
|
for (int i=0;i<argc;++i)
|
||||||
@ -527,6 +529,7 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
|||||||
set_led_value(interpreter->vs->doc_view->session->status.ecmascript_led, 'J');
|
set_led_value(interpreter->vs->doc_view->session->status.ecmascript_led, 'J');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
done_string(&code);
|
||||||
args.rval().setBoolean(false);
|
args.rval().setBoolean(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -559,10 +562,9 @@ string_replace(struct string *res, struct string *inp, struct string *what, stru
|
|||||||
|
|
||||||
init_string(&tmp);
|
init_string(&tmp);
|
||||||
init_string(&tmp2);
|
init_string(&tmp2);
|
||||||
init_string(res);
|
|
||||||
add_to_string(&tmp,inp->source);
|
add_to_string(&tmp,inp->source);
|
||||||
|
|
||||||
|
|
||||||
head = tmp.source;
|
head = tmp.source;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
ins = head;
|
ins = head;
|
||||||
@ -598,6 +600,10 @@ string_replace(struct string *res, struct string *inp, struct string *what, stru
|
|||||||
head = tmp.source;
|
head = tmp.source;
|
||||||
}
|
}
|
||||||
add_to_string(res,tmp.source);
|
add_to_string(res,tmp.source);
|
||||||
|
|
||||||
|
done_string(&tmp);
|
||||||
|
done_string(&tmp2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @document_funcs{"replace"} */
|
/* @document_funcs{"replace"} */
|
||||||
@ -623,6 +629,9 @@ document_replace(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
struct string needle;
|
struct string needle;
|
||||||
struct string heystack;
|
struct string heystack;
|
||||||
|
|
||||||
|
init_string(&needle);
|
||||||
|
init_string(&heystack);
|
||||||
|
|
||||||
jshandle_value_to_char_string(&needle, ctx, &args[0]);
|
jshandle_value_to_char_string(&needle, ctx, &args[0]);
|
||||||
jshandle_value_to_char_string(&heystack, ctx, &args[1]);
|
jshandle_value_to_char_string(&heystack, ctx, &args[1]);
|
||||||
|
|
||||||
@ -643,6 +652,7 @@ document_replace(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
add_to_string(&f_data,f->data);
|
add_to_string(&f_data,f->data);
|
||||||
|
|
||||||
struct string nu_str;
|
struct string nu_str;
|
||||||
|
init_string(&nu_str);
|
||||||
string_replace(&nu_str,&f_data,&needle,&heystack);
|
string_replace(&nu_str,&f_data,&needle,&heystack);
|
||||||
nu_len=nu_str.length;
|
nu_len=nu_str.length;
|
||||||
delete_entry_content(cached);
|
delete_entry_content(cached);
|
||||||
@ -657,6 +667,9 @@ document_replace(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
//DBG("doc replace %s %s\n", needle.source, heystack.source);
|
//DBG("doc replace %s %s\n", needle.source, heystack.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done_string(&needle);
|
||||||
|
done_string(&heystack);
|
||||||
|
|
||||||
args.rval().setBoolean(true);
|
args.rval().setBoolean(true);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -173,11 +173,12 @@ localstorage_getitem(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
static bool
|
static bool
|
||||||
localstorage_setitem(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
localstorage_setitem(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
{
|
{
|
||||||
//unsigned char *key;
|
|
||||||
struct string key;
|
struct string key;
|
||||||
//unsigned char *val;
|
|
||||||
struct string val;
|
struct string val;
|
||||||
|
|
||||||
|
init_string(&key);
|
||||||
|
init_string(&val);
|
||||||
|
|
||||||
JSCompartment *comp = js::GetContextCompartment(ctx);
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
if (!comp)
|
if (!comp)
|
||||||
@ -206,5 +207,8 @@ localstorage_setitem(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
#endif
|
#endif
|
||||||
args.rval().setBoolean(true);
|
args.rval().setBoolean(true);
|
||||||
|
|
||||||
|
done_string(&key);
|
||||||
|
done_string(&val);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user