mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-06 23:44:43 -04:00
[ecmascript] Moved add_to_ecmascript_string_list to util/string.h
This commit is contained in:
parent
f2fa1d40e2
commit
2f6cac0243
@ -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)
|
||||
|
@ -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 <libxml++/libxml++.h>
|
||||
#endif
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user