diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c
index d00d1cef..9afc4c0a 100644
--- a/src/document/html/parser/general.c
+++ b/src/document/html/parser/general.c
@@ -41,10 +41,6 @@
/* Unsafe macros */
#include "document/html/internal.h"
-#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
-#include "ecmascript/ecmascript.h"
-#endif
-
void
html_span(struct html_context *html_context, char *a,
char *xxx3, char *xxx4, char **xxx5)
diff --git a/src/document/html/parser/stack.c b/src/document/html/parser/stack.c
index df99f99c..bcbd773b 100644
--- a/src/document/html/parser/stack.c
+++ b/src/document/html/parser/stack.c
@@ -27,10 +27,6 @@
/* Unsafe macros */
#include "document/html/internal.h"
-#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
-#include "ecmascript/ecmascript.h"
-#endif
-
#if 0 //def CONFIG_XML
#include
#endif
diff --git a/src/ecmascript/ecmascript.cpp b/src/ecmascript/ecmascript.cpp
index 19701e00..e320f3db 100644
--- a/src/ecmascript/ecmascript.cpp
+++ b/src/ecmascript/ecmascript.cpp
@@ -110,50 +110,6 @@ char *local_storage_filename;
int local_storage_ready;
-struct string *
-add_to_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list,
- const char *source, int length, int element_offset)
-{
- struct ecmascript_string_list_item *item;
- struct string *string;
-
- assertm(list && source, "[add_to_string_list]");
- if_assert_failed return NULL;
-
- item = (struct ecmascript_string_list_item *)mem_alloc(sizeof(*item));
- if (!item) return NULL;
-
- string = &item->string;
- if (length < 0) length = strlen(source);
-
- if (!init_string(string)
- || !add_bytes_to_string(string, source, length)) {
- done_string(string);
- mem_free(item);
- return NULL;
- }
-
- item->element_offset = element_offset;
-
- add_to_list_end(*list, item);
- return string;
-}
-
-void
-free_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list)
-{
- assertm(list != NULL, "[free_string_list]");
- if_assert_failed return;
-
- while (!list_empty(*list)) {
- struct ecmascript_string_list_item *item = (struct ecmascript_string_list_item *)list->next;
-
- del_from_list(item);
- done_string(&item->string);
- mem_free(item);
- }
-}
-
static int
is_prefix(char *prefix, char *url, int dl)
{
diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h
index c8832e6e..d6edefd9 100644
--- a/src/ecmascript/ecmascript.h
+++ b/src/ecmascript/ecmascript.h
@@ -27,6 +27,7 @@
#include "main/module.h"
#include "main/timer.h"
+#include "util/string.h"
#include "util/time.h"
//#define ECMASCRIPT_DEBUG 1
@@ -47,12 +48,6 @@ struct terminal;
struct uri;
struct view_state;
-struct ecmascript_string_list_item {
- LIST_HEAD(struct ecmascript_string_list_item);
- struct string string;
- int element_offset;
-};
-
struct ecmascript_interpreter {
struct view_state *vs;
void *backend_data;
@@ -202,10 +197,6 @@ void free_document(void *doc);
void location_goto(struct document_view *doc_view, char *url);
void location_goto_const(struct document_view *doc_view, const char *url);
-struct string *add_to_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list, const char *string, int length, int element_offset);
-
-void free_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list);
-
extern char *console_error_filename;
extern char *console_log_filename;
diff --git a/src/util/string.c b/src/util/string.c
index 584fa43b..77d3db21 100644
--- a/src/util/string.c
+++ b/src/util/string.c
@@ -654,3 +654,47 @@ free_string_list(LIST_OF(struct string_list_item) *list)
mem_free(item);
}
}
+
+struct string *
+add_to_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list,
+ const char *source, int length, int element_offset)
+{
+ struct ecmascript_string_list_item *item;
+ struct string *string;
+
+ assertm(list && source, "[add_to_string_list]");
+ if_assert_failed return NULL;
+
+ item = (struct ecmascript_string_list_item *)mem_alloc(sizeof(*item));
+ if (!item) return NULL;
+
+ string = &item->string;
+ if (length < 0) length = strlen(source);
+
+ if (!init_string(string)
+ || !add_bytes_to_string(string, source, length)) {
+ done_string(string);
+ mem_free(item);
+ return NULL;
+ }
+
+ item->element_offset = element_offset;
+
+ add_to_list_end(*list, item);
+ return string;
+}
+
+void
+free_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list)
+{
+ assertm(list != NULL, "[free_string_list]");
+ if_assert_failed return;
+
+ while (!list_empty(*list)) {
+ struct ecmascript_string_list_item *item = (struct ecmascript_string_list_item *)list->next;
+
+ del_from_list(item);
+ done_string(&item->string);
+ mem_free(item);
+ }
+}
diff --git a/src/util/string.h b/src/util/string.h
index 34940bbe..e083aa20 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -308,6 +308,15 @@ add_to_string_list(LIST_OF(struct string_list_item) *list,
void free_string_list(LIST_OF(struct string_list_item) *list);
+struct ecmascript_string_list_item {
+ LIST_HEAD(struct ecmascript_string_list_item);
+ struct string string;
+ int element_offset;
+};
+struct string *add_to_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list, const char *string, int length, int element_offset);
+
+void free_ecmascript_string_list(LIST_OF(struct ecmascript_string_list_item) *list);
+
void string_replace(struct string *res, struct string *inp, struct string *what, struct string *repl);