1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-14 23:32:27 +00:00

Merge branch 'elinks-0.12' into elinks-0.13

Conflicts:
	NEWS
	configure.in
	doc/man/man1/elinks.1.in (regenerated)
	doc/man/man5/elinks.conf.5 (regenerated)
	doc/man/man5/elinkskeys.5 (regenerated)
	po/af.po (kept 0.13.GIT)
	po/be.po (kept 0.13.GIT)
	po/bg.po (kept 0.13.GIT)
	po/ca.po (kept 0.13.GIT)
	po/cs.po (kept 0.13.GIT)
	po/da.po (kept 0.13.GIT)
	po/de.po (kept 0.13.GIT)
	po/el.po (kept 0.13.GIT)
	po/es.po (kept 0.13.GIT)
	po/et.po (kept 0.13.GIT)
	po/fi.po (kept 0.13.GIT)
	po/fr.po (kept 0.13.GIT)
	po/gl.po (kept 0.13.GIT)
	po/hr.po (kept 0.13.GIT)
	po/hu.po (kept 0.13.GIT)
	po/id.po (kept 0.13.GIT)
	po/is.po (kept 0.13.GIT)
	po/it.po (kept 0.13.GIT)
	po/lt.po (kept 0.13.GIT)
	po/nb.po (kept 0.13.GIT)
	po/nl.po (kept 0.13.GIT)
	po/pl.po (kept 0.13.GIT)
	po/pt.po (kept 0.13.GIT)
	po/pt_BR.po (kept 0.13.GIT)
	po/ro.po (kept 0.13.GIT)
	po/ru.po (kept 0.13.GIT)
	po/sk.po (kept 0.13.GIT)
	po/sr.po (kept 0.13.GIT)
	po/sv.po (kept 0.13.GIT)
	po/tr.po (kept 0.13.GIT)
	po/uk.po (kept 0.13.GIT)
	src/ecmascript/ecmascript.c
This commit is contained in:
Kalle Olavi Niemitalo 2009-07-11 16:47:33 +03:00 committed by Kalle Olavi Niemitalo
commit 7bb51e7139
17 changed files with 286 additions and 652 deletions

View File

@ -632,6 +632,10 @@ Yevgeny Gromov <yevgeny@tut.by>
Yurii Rashkovskii <yrashk@univer.kharkov.ua>
Updated Russian localization
Yuriy M. Kaminskiy <yumkam@gmail.com>
"I'm perfectly fine with GPL v2-or-later (or, considering amount of added code ;-), any other OSL-approved license too)."
Fixes failure to search for more than one double-width character.
<zimon@niksula.hut.fi>
RPM spec file in contrib/
RedHat compilation fixes

13
COPYING
View File

@ -50,11 +50,6 @@ include their complete licence notices in COPYING:
* test/color.html: possibly derived from rgb.txt of X11?
* test/optgroup.html: GNU free documentation licence; see
test/GFDL-1.2.
* test/GFDL-1.2: Changing the text of GFDLv1.2 is not allowed.
The following files or their derivatives are installed by "make
install" or might otherwise be useful to include in binary packages,
so their full licence terms should be included here in COPYING:
@ -94,6 +89,14 @@ so their full licence terms should be included here in COPYING:
below. These files were downloaded from directories under
<http://www.unicode.org/Public/> and then modified for ELinks.
The following file has been removed, but because it was included in
some earlier releases without proper licence notices, it is listed
here to clarify the permissions.
* test/optgroup.html (added in 0.10pre0; documented in 0.11.6 and
0.12pre3; removed after 0.12pre5): GNU free documentation licence;
the author did not specify a version.
-----------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE

15
NEWS
View File

@ -78,16 +78,17 @@ have already been considered.
(mostly reverted)
//////////////////////////////////////////////////////////////////////
ELinks 0.12pre4.GIT now:
------------------------
ELinks 0.12pre5:
----------------
To be released as 0.12pre5, 0.12rc1, or even 0.12.0. This branch also
includes the changes listed under ``ELinks 0.11.6.GIT now'' below.
Released on 2009-07-08.
* bug 1080: Support ``--dump-color-mode'' with ``--dump-charset UTF-8''.
* Debian bug 534835: Check the return values of some SpiderMonkey
functions, to avoid crashes if out of memory.
* minor bug 1017: To work around HTTP server bugs, disable
protocol.http.compression by default, until ELinks can report
decompression errors or automatically retry the connection.
* enhancement: The French translation was updated.
Bugs that should be removed from NEWS before the 0.12.0 release:
@ -95,6 +96,10 @@ Bugs that should be removed from NEWS before the 0.12.0 release:
regfree() in TRE and in the system libc, link with TRE before any
other libraries. ELinks 0.12pre4 was the first release that had
this bug.
* Searching for more than one fullwidth (e.g. Japanese) character now
works.
* bug 1080: Support ``--dump-color-mode'' with ``--dump-charset UTF-8''.
Neither of those worked before ELinks 0.12pre1.
ELinks 0.12pre4:
----------------

View File

@ -1,11 +1,11 @@
.\" Title: elinks
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: 05/31/2009
.\" Date: 07/11/2009
.\" Manual: The Elinks text-browser
.\" Source: ELinks 0.13.GIT
.\"
.TH "ELINKS" "1" "05/31/2009" "ELinks 0\&.13\&.GIT" "The Elinks text\-browser"
.TH "ELINKS" "1" "07/11/2009" "ELinks 0\&.13\&.GIT" "The Elinks text\-browser"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)

View File

@ -1,11 +1,11 @@
.\" Title: elinks.conf
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: 05/31/2009
.\" Date: 07/11/2009
.\" Manual: ELinks configuration file
.\" Source: ELinks 0.13.GIT
.\"
.TH "ELINKS\&.CONF" "5" "05/31/2009" "ELinks 0\&.13\&.GIT" "ELinks configuration file"
.TH "ELINKS\&.CONF" "5" "07/11/2009" "ELinks 0\&.13\&.GIT" "ELinks configuration file"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
@ -1416,7 +1416,7 @@ Request localised versions of documents from web\-servers (using the Accept\-Lan
ELinks\' user\-interface (this also affects navigator\&.language ECMAScript value available to scripts)\&. Note that some see this as a potential security risk because it tells web\-masters and the FBI sniffers about your language preference\&.
.RE
.PP
protocol\&.http\&.compression \fB[0|1]\fR (default: 1)
protocol\&.http\&.compression \fB[0|1]\fR (default: 0)
.RS 4
If enabled, the capability to receive compressed content (gzip and/or bzip2) is announced to the server, which usually sends the reply compressed, thus saving some bandwidth at slight CPU expense\&.
.sp

View File

@ -393,17 +393,23 @@ render_document(struct view_state *vs, struct document_view *doc_view,
&& vs->ecmascript->onload_snippets_cache_id
&& document->cache_id != vs->ecmascript->onload_snippets_cache_id))
ecmascript_reset_state(vs);
assert(vs->ecmascript);
vs->ecmascript->onload_snippets_cache_id = document->cache_id;
/* If ecmascript_reset_state cannot construct a new
* ECMAScript interpreter, it sets vs->ecmascript =
* NULL and vs->ecmascript_fragile = 1. */
if (vs->ecmascript) {
vs->ecmascript->onload_snippets_cache_id = document->cache_id;
/* Passing of the onload_snippets pointers gives *_snippets()
* some feeling of universality, shall we ever get any other
* snippets (?). */
add_snippets(vs->ecmascript,
&document->onload_snippets,
&vs->ecmascript->onload_snippets);
process_snippets(vs->ecmascript, &vs->ecmascript->onload_snippets,
&vs->ecmascript->current_onload_snippet);
/* Passing of the onload_snippets pointers
* gives *_snippets() some feeling of
* universality, shall we ever get any other
* snippets (?). */
add_snippets(vs->ecmascript,
&document->onload_snippets,
&vs->ecmascript->onload_snippets);
process_snippets(vs->ecmascript,
&vs->ecmascript->onload_snippets,
&vs->ecmascript->current_onload_snippet);
}
}
#endif

View File

@ -84,12 +84,21 @@ ecmascript_get_interpreter(struct view_state *vs)
interpreter->vs = vs;
interpreter->vs->ecmascript_fragile = 0;
init_list(interpreter->onload_snippets);
/* The following backend call reads interpreter->vs. */
if (
#ifdef CONFIG_ECMASCRIPT_SEE
see_get_interpreter(interpreter);
!see_get_interpreter(interpreter)
#else
spidermonkey_get_interpreter(interpreter);
!spidermonkey_get_interpreter(interpreter)
#endif
) {
/* Undo what was done above. */
interpreter->vs->ecmascript_fragile = 1;
mem_free(interpreter);
--interpreter_count;
return NULL;
}
init_string(&interpreter->code);
return interpreter;
}

View File

@ -175,57 +175,70 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
JS_SetErrorReporter(ctx, error_reporter);
window_obj = JS_NewObject(ctx, (JSClass *) &window_class, NULL, NULL);
if (!window_obj) {
spidermonkey_put_interpreter(interpreter);
return NULL;
}
JS_InitStandardClasses(ctx, window_obj);
JS_DefineProperties(ctx, window_obj, (JSPropertySpec *) window_props);
spidermonkey_DefineFunctions(ctx, window_obj, window_funcs);
JS_SetPrivate(ctx, window_obj, interpreter->vs); /* to @window_class */
if (!window_obj) goto release_and_fail;
if (!JS_InitStandardClasses(ctx, window_obj)) goto release_and_fail;
if (!JS_DefineProperties(ctx, window_obj, (JSPropertySpec *) window_props))
goto release_and_fail;
if (!spidermonkey_DefineFunctions(ctx, window_obj, window_funcs))
goto release_and_fail;
if (!JS_SetPrivate(ctx, window_obj, interpreter->vs)) /* to @window_class */
goto release_and_fail;
document_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
(JSClass *) &document_class, NULL, 0,
(JSPropertySpec *) document_props,
document_funcs,
NULL, NULL);
if (!document_obj) goto release_and_fail;
forms_obj = spidermonkey_InitClass(ctx, document_obj, NULL,
(JSClass *) &forms_class, NULL, 0,
(JSPropertySpec *) forms_props,
forms_funcs,
NULL, NULL);
if (!forms_obj) goto release_and_fail;
history_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
(JSClass *) &history_class, NULL, 0,
(JSPropertySpec *) NULL,
history_funcs,
NULL, NULL);
if (!history_obj) goto release_and_fail;
location_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
(JSClass *) &location_class, NULL, 0,
(JSPropertySpec *) location_props,
location_funcs,
NULL, NULL);
if (!location_obj) goto release_and_fail;
menubar_obj = JS_InitClass(ctx, window_obj, NULL,
(JSClass *) &menubar_class, NULL, 0,
(JSPropertySpec *) unibar_props, NULL,
NULL, NULL);
JS_SetPrivate(ctx, menubar_obj, "t"); /* to @menubar_class */
if (!menubar_obj) goto release_and_fail;
if (!JS_SetPrivate(ctx, menubar_obj, "t")) /* to @menubar_class */
goto release_and_fail;
statusbar_obj = JS_InitClass(ctx, window_obj, NULL,
(JSClass *) &statusbar_class, NULL, 0,
(JSPropertySpec *) unibar_props, NULL,
NULL, NULL);
JS_SetPrivate(ctx, statusbar_obj, "s"); /* to @statusbar_class */
if (!statusbar_obj) goto release_and_fail;
if (!JS_SetPrivate(ctx, statusbar_obj, "s")) /* to @statusbar_class */
goto release_and_fail;
navigator_obj = JS_InitClass(ctx, window_obj, NULL,
(JSClass *) &navigator_class, NULL, 0,
(JSPropertySpec *) navigator_props, NULL,
NULL, NULL);
if (!navigator_obj) goto release_and_fail;
return ctx;
release_and_fail:
spidermonkey_put_interpreter(interpreter);
return NULL;
}
void

View File

@ -134,16 +134,19 @@ smjs_get_elinks_object(void)
jsobj = spidermonkey_InitClass(smjs_ctx, smjs_global_object, NULL,
(JSClass *) &elinks_class, NULL, 0, NULL,
elinks_funcs, NULL, NULL);
if (!jsobj) return NULL;
JS_DefineProperty(smjs_ctx, jsobj, "location", JSVAL_NULL,
elinks_get_location, elinks_set_location,
JSPROP_ENUMERATE | JSPROP_PERMANENT);
if (!JS_DefineProperty(smjs_ctx, jsobj, "location", JSVAL_NULL,
elinks_get_location, elinks_set_location,
JSPROP_ENUMERATE | JSPROP_PERMANENT))
return NULL;
JS_DefineProperty(smjs_ctx, jsobj, "home", JSVAL_NULL,
elinks_get_home, JS_PropertyStub,
JSPROP_ENUMERATE
| JSPROP_PERMANENT
| JSPROP_READONLY);
if (!JS_DefineProperty(smjs_ctx, jsobj, "home", JSVAL_NULL,
elinks_get_home, JS_PropertyStub,
JSPROP_ENUMERATE
| JSPROP_PERMANENT
| JSPROP_READONLY))
return NULL;
return jsobj;
}
@ -151,7 +154,7 @@ smjs_get_elinks_object(void)
void
smjs_init_elinks_object(void)
{
smjs_elinks_object = smjs_get_elinks_object();
smjs_elinks_object = smjs_get_elinks_object(); /* TODO: check NULL */
smjs_init_action_interface();
smjs_init_bookmarks_interface();

View File

@ -14,8 +14,9 @@
* (The function names could be generated with the ## preprocessor
* operator, but that would make grepping more difficult.)
*
* At most one of the following macros may be defined:
* One of the following macros must be defined:
*
* - DUMP_COLOR_MODE_NONE
* - DUMP_COLOR_MODE_16
* - DUMP_COLOR_MODE_256
* - DUMP_COLOR_MODE_TRUE
@ -34,13 +35,12 @@
#endif /* CONFIG_UTF8 */
static int
DUMP_FUNCTION_COLOR(struct document *document, int fd,
unsigned char buf[D_BUF])
DUMP_FUNCTION_COLOR(struct document *document, struct dump_output *out)
{
#ifdef CONFIG_UTF8
if (is_cp_utf8(document->options.cp))
return DUMP_FUNCTION_UTF8(document, fd, buf);
return DUMP_FUNCTION_UTF8(document, out);
#endif /* CONFIG_UTF8 */
return DUMP_FUNCTION_UNIBYTE(document, fd, buf);
return DUMP_FUNCTION_UNIBYTE(document, out);
}

View File

@ -11,8 +11,9 @@
* - DUMP_FUNCTION_SPECIALIZED: The name of the function that this
* file should define.
*
* At most one of the following macros may be defined:
* One of the following macros must be defined:
*
* - DUMP_COLOR_MODE_NONE
* - DUMP_COLOR_MODE_16
* - DUMP_COLOR_MODE_256
* - DUMP_COLOR_MODE_TRUE
@ -23,11 +24,9 @@
*/
static int
DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd,
unsigned char buf[D_BUF])
DUMP_FUNCTION_SPECIALIZED(struct document *document, struct dump_output *out)
{
int y;
int bptr = 0;
#ifdef DUMP_COLOR_MODE_16
unsigned char color = 0;
const int width = get_opt_int("document.dump.width", NULL);
@ -43,17 +42,19 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd,
#endif /* DUMP_COLOR_MODE_TRUE */
for (y = 0; y < document->height; y++) {
#ifdef DUMP_COLOR_MODE_NONE
int white = 0;
#endif
int x;
#ifdef DUMP_COLOR_MODE_16
write_color_16(color, fd, buf, &bptr);
write_color_16(color, out);
#elif defined(DUMP_COLOR_MODE_256)
write_color_256("38", foreground, fd, buf, &bptr);
write_color_256("48", background, fd, buf, &bptr);
write_color_256("38", foreground, out);
write_color_256("48", background, out);
#elif defined(DUMP_COLOR_MODE_TRUE)
write_true_color("38", foreground, fd, buf, &bptr);
write_true_color("48", background, fd, buf, &bptr);
write_true_color("38", foreground, out);
write_true_color("48", background, out);
#endif /* DUMP_COLOR_MODE_TRUE */
for (x = 0; x < document->data[y].length; x++) {
@ -68,55 +69,74 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd,
#ifdef DUMP_COLOR_MODE_16
const unsigned char color1
= document->data[y].chars[x].color[0];
if (color != color1) {
color = color1;
if (write_color_16(color, fd, buf, &bptr))
return -1;
}
#elif defined(DUMP_COLOR_MODE_256)
const unsigned char color1
= document->data[y].chars[x].color[0];
const unsigned char color2
= document->data[y].chars[x].color[1];
if (foreground != color1) {
foreground = color1;
if (write_color_256("38", foreground, fd, buf, &bptr))
return -1;
}
if (background != color2) {
background = color2;
if (write_color_256("48", background, fd, buf, &bptr))
return -1;
}
#elif defined(DUMP_COLOR_MODE_TRUE)
const unsigned char *const new_foreground
= &document->data[y].chars[x].color[0];
const unsigned char *const new_background
= &document->data[y].chars[x].color[3];
#endif /* DUMP_COLOR_MODE_TRUE */
c = document->data[y].chars[x].data;
#ifdef DUMP_CHARSET_UTF8
if (c == UCS_NO_CHAR) {
/* This is the second cell of
* a double-cell character. */
continue;
}
#endif /* DUMP_CHARSET_UTF8 */
#ifdef DUMP_COLOR_MODE_16
if (color != color1) {
color = color1;
if (write_color_16(color, out))
return -1;
}
#elif defined(DUMP_COLOR_MODE_256)
if (foreground != color1) {
foreground = color1;
if (write_color_256("38", foreground, out))
return -1;
}
if (background != color2) {
background = color2;
if (write_color_256("48", background, out))
return -1;
}
#elif defined(DUMP_COLOR_MODE_TRUE)
if (memcmp(foreground, new_foreground, 3)) {
foreground = new_foreground;
if (write_true_color("38", foreground, fd, buf, &bptr))
if (write_true_color("38", foreground, out))
return -1;
}
if (memcmp(background, new_background, 3)) {
background = new_background;
if (write_true_color("48", background, fd, buf, &bptr))
if (write_true_color("48", background, out))
return -1;
}
#endif /* DUMP_COLOR_MODE_TRUE */
c = document->data[y].chars[x].data;
if ((attr & SCREEN_ATTR_FRAME)
&& c >= 176 && c < 224)
c = frame_dumb[c - 176];
if (c <= ' ') {
#ifdef DUMP_CHARSET_UTF8
if (!isscreensafe_ucs(c)) c = ' ';
#else
if (!isscreensafe(c)) c = ' ';
#endif
#ifdef DUMP_COLOR_MODE_NONE
if (c == ' ') {
/* Count spaces. */
white++;
continue;
@ -124,39 +144,38 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd,
/* Print spaces if any. */
while (white) {
if (write_char(' ', fd, buf, &bptr))
if (write_char(' ', out))
return -1;
white--;
}
#endif /* DUMP_COLOR_MODE_NONE */
/* Print normal char. */
#ifdef DUMP_CHARSET_UTF8
utf8_buf = encode_utf8(c);
while (*utf8_buf) {
if (write_char(*utf8_buf++,
fd, buf, &bptr)) return -1;
if (write_char(*utf8_buf++, out)) return -1;
}
x += unicode_to_cell(c) - 1;
#else /* !DUMP_CHARSET_UTF8 */
if (write_char(c, fd, buf, &bptr))
if (write_char(c, out))
return -1;
#endif /* !DUMP_CHARSET_UTF8 */
}
#if defined(DUMP_COLOR_MODE_16) || defined(DUMP_COLOR_MODE_256) || defined(DUMP_COLOR_MODE_TRUE)
#ifndef DUMP_COLOR_MODE_NONE
for (;x < width; x++) {
if (write_char(' ', fd, buf, &bptr))
if (write_char(' ', out))
return -1;
}
#endif /* DUMP_COLOR_MODE_16 || DUMP_COLOR_MODE_256 || DUMP_COLOR_MODE_TRUE */
#endif /* !DUMP_COLOR_MODE_NONE */
/* Print end of line. */
if (write_char('\n', fd, buf, &bptr))
if (write_char('\n', out))
return -1;
}
if (hard_write(fd, buf, bptr) != bptr)
if (dump_output_flush(out))
return -1;
return 0;

View File

@ -53,21 +53,94 @@ static int dump_redir_count = 0;
#define D_BUF 65536
static int
write_char(unsigned char c, int fd, unsigned char *buf, int *bptr)
/** A place where dumping functions write their output. The data
* first goes to the buffer in this structure. When the buffer is
* full enough, it is flushed to a file descriptor or to a string. */
struct dump_output {
/** How many bytes are in #buf already. */
size_t bufpos;
/** A string to which the buffer should eventually be flushed,
* or NULL. */
struct string *string;
/** A file descriptor to which the buffer should eventually be
* flushed, or -1. */
int fd;
/** Bytes waiting to be flushed. */
unsigned char buf[D_BUF];
};
/** Allocate and initialize a struct dump_output.
* The caller should eventually free the structure with mem_free().
*
* @param fd
* The file descriptor to which the output will be written.
* Use -1 if the output should go to a string instead.
*
* @param string
* The string to which the output will be appended.
* Use NULL if the output should go to a file descriptor instead.
*
* @return The new structure, or NULL on error.
*
* @relates dump_output */
static struct dump_output *
dump_output_alloc(int fd, struct string *string)
{
buf[(*bptr)++] = c;
if ((*bptr) >= D_BUF) {
if (hard_write(fd, buf, (*bptr)) != (*bptr))
struct dump_output *out;
assert((fd == -1) ^ (string == NULL));
if_assert_failed return NULL;
out = mem_alloc(sizeof(*out));
if (out) {
out->fd = fd;
out->string = string;
out->bufpos = 0;
}
return out;
}
/** Flush buffered output to the file or string.
*
* @return 0 on success, or -1 on error.
*
* @post If this succeeds, then out->bufpos == 0, so that the buffer
* has room for more data.
*
* @relates dump_output */
static int
dump_output_flush(struct dump_output *out)
{
if (out->string) {
if (!add_bytes_to_string(out->string, out->buf, out->bufpos))
return -1;
}
else {
if (hard_write(out->fd, out->buf, out->bufpos) != out->bufpos)
return -1;
(*bptr) = 0;
}
out->bufpos = 0;
return 0;
}
static int
write_color_16(unsigned char color, int fd, unsigned char *buf, int *bptr)
write_char(unsigned char c, struct dump_output *out)
{
if (out->bufpos >= D_BUF) {
if (dump_output_flush(out))
return -1;
}
out->buf[out->bufpos++] = c;
return 0;
}
static int
write_color_16(unsigned char color, struct dump_output *out)
{
unsigned char bufor[] = "\033[0;30;40m";
unsigned char *data = bufor;
@ -81,7 +154,7 @@ write_color_16(unsigned char color, int fd, unsigned char *buf, int *bptr)
bufor[7] = '\0';
}
while(*data) {
if (write_char(*data++, fd, buf, bptr)) return -1;
if (write_char(*data++, out)) return -1;
}
return 0;
}
@ -103,14 +176,14 @@ write_color_16(unsigned char color, int fd, unsigned char *buf, int *bptr)
static int
write_color_256(const unsigned char *str, unsigned char color,
int fd, unsigned char *buf, int *bptr)
struct dump_output *out)
{
unsigned char bufor[16];
unsigned char *data = bufor;
snprintf(bufor, 16, "\033[%s;5;%dm", str, color);
while(*data) {
if (write_char(*data++, fd, buf, bptr)) return -1;
if (write_char(*data++, out)) return -1;
}
return 0;
}
@ -131,14 +204,14 @@ write_color_256(const unsigned char *str, unsigned char color,
static int
write_true_color(const unsigned char *str, const unsigned char *color,
int fd, unsigned char *buf, int *bptr)
struct dump_output *out)
{
unsigned char bufor[24];
unsigned char *data = bufor;
snprintf(bufor, 24, "\033[%s;2;%d;%d;%dm", str, color[0], color[1], color[2]);
while(*data) {
if (write_char(*data++, fd, buf, bptr)) return -1;
if (write_char(*data++, out)) return -1;
}
return 0;
}
@ -155,10 +228,12 @@ write_true_color(const unsigned char *str, const unsigned char *color,
#endif /* CONFIG_TRUE_COLOR */
#define DUMP_COLOR_MODE_NONE
#define DUMP_FUNCTION_COLOR dump_nocolor
#define DUMP_FUNCTION_UTF8 dump_nocolor_utf8
#define DUMP_FUNCTION_UNIBYTE dump_nocolor_unibyte
#include "dump-color-mode.h"
#undef DUMP_COLOR_MODE_NONE
#undef DUMP_FUNCTION_COLOR
#undef DUMP_FUNCTION_UTF8
#undef DUMP_FUNCTION_UNIBYTE
@ -210,17 +285,17 @@ dump_references(struct document *document, int fd, unsigned char buf[D_BUF])
int
dump_to_file(struct document *document, int fd)
{
unsigned char *buf = mem_alloc(D_BUF);
int result;
struct dump_output *out = dump_output_alloc(fd, NULL);
int error;
if (!buf) return -1;
if (!out) return -1;
result = dump_nocolor(document, fd, buf);
if (!result)
result = dump_references(document, fd, buf);
error = dump_nocolor(document, out);
if (!error)
error = dump_references(document, fd, out->buf);
mem_free(buf);
return result;
mem_free(out);
return error;
}
/* This dumps the given @cached's formatted output onto @fd. */
@ -231,7 +306,7 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
struct document_view formatted;
struct view_state vs;
int width;
unsigned char *buf;
struct dump_output *out;
if (!cached) return;
@ -251,47 +326,47 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
render_document(&vs, &formatted, &o);
buf = mem_alloc(D_BUF);
if (buf) {
int result;
out = dump_output_alloc(fd, NULL);
if (out) {
int error;
switch (o.color_mode) {
case COLOR_MODE_DUMP:
case COLOR_MODE_MONO: /* FIXME: inversion */
result = dump_nocolor(formatted.document, fd, buf);
error = dump_nocolor(formatted.document, out);
break;
default:
/* If the desired color mode was not compiled in,
* use 16 colors. */
case COLOR_MODE_16:
result = dump_16color(formatted.document, fd, buf);
error = dump_16color(formatted.document, out);
break;
#ifdef CONFIG_88_COLORS
case COLOR_MODE_88:
result = dump_256color(formatted.document, fd, buf);
error = dump_256color(formatted.document, out);
break;
#endif
#ifdef CONFIG_256_COLORS
case COLOR_MODE_256:
result = dump_256color(formatted.document, fd, buf);
error = dump_256color(formatted.document, out);
break;
#endif
#ifdef CONFIG_TRUE_COLOR
case COLOR_MODE_TRUE_COLOR:
result = dump_truecolor(formatted.document, fd, buf);
error = dump_truecolor(formatted.document, out);
break;
#endif
}
if (!result)
dump_references(formatted.document, fd, buf);
if (!error)
dump_references(formatted.document, fd, out->buf);
mem_free(buf);
} /* if buf */
mem_free(out);
} /* if out */
detach_formatted(&formatted);
destroy_vs(&vs, 1);
@ -527,93 +602,20 @@ dump_next(LIST_OF(struct string_list_item) *url_list)
}
}
/* Using this function in dump_to_file() is unfortunately slightly slower than
* the current code. However having this here instead of in the scripting
* backends is better. */
struct string *
add_document_to_string(struct string *string, struct document *document)
{
int y;
struct dump_output *out;
int error;
assert(string && document);
if_assert_failed return NULL;
#ifdef CONFIG_UTF8
if (is_cp_utf8(document->options.cp))
goto utf8;
#endif /* CONFIG_UTF8 */
out = dump_output_alloc(-1, string);
if (!out) return NULL;
for (y = 0; y < document->height; y++) {
int white = 0;
int x;
error = dump_nocolor(document, out);
for (x = 0; x < document->data[y].length; x++) {
struct screen_char *pos = &document->data[y].chars[x];
unsigned char data = pos->data;
unsigned int frame = (pos->attr & SCREEN_ATTR_FRAME);
if (!isscreensafe(data)) {
white++;
continue;
} else {
if (frame && data >= 176 && data < 224)
data = frame_dumb[data - 176];
if (data <= ' ') {
/* Count spaces. */
white++;
} else {
/* Print spaces if any. */
if (white) {
add_xchar_to_string(string, ' ', white);
white = 0;
}
add_char_to_string(string, data);
}
}
}
add_char_to_string(string, '\n');
}
#ifdef CONFIG_UTF8
goto end;
utf8:
for (y = 0; y < document->height; y++) {
int white = 0;
int x;
for (x = 0; x < document->data[y].length; x++) {
struct screen_char *pos = &document->data[y].chars[x];
unicode_val_T data = pos->data;
unsigned int frame = (pos->attr & SCREEN_ATTR_FRAME);
if (!isscreensafe_ucs(data)) {
white++;
continue;
} else {
if (frame && data >= 176 && data < 224)
data = frame_dumb[data - 176];
if (data <= ' ') {
/* Count spaces. */
white++;
} else if (data == UCS_NO_CHAR) {
/* This is the second cell of
* a double-cell character. */
} else {
/* Print spaces if any. */
if (white) {
add_xchar_to_string(string, ' ', white);
white = 0;
}
add_to_string(string, encode_utf8(data));
}
}
}
add_char_to_string(string, '\n');
}
end:
#endif /* CONFIG_UTF8 */
return string;
mem_free(out);
return error ? NULL : string;
}

View File

@ -921,7 +921,15 @@ call_onsubmit_and_submit(struct session *ses, struct document_view *doc_view,
if (vs->ecmascript_fragile)
ecmascript_reset_state(vs);
interpreter = vs->ecmascript;
assert(interpreter);
/* If there is an onsubmit script and we want
* to run it, but the ECMAScript interpreter
* cannot be initialized, then don't submit. */
if (!interpreter) {
done_string(&code);
/* See the comment below for the
* return value. */
return 1;
}
add_to_string(&code, fc->form->onsubmit);
res = ecmascript_eval_boolback(interpreter, &code);

View File

@ -174,6 +174,12 @@ get_srch(struct document *document)
if (document->data[y].chars[x].attr & SCREEN_ATTR_UNSEARCHABLE)
continue;
#ifdef CONFIG_UTF8
/* skip double-width char placeholders */
if (c == UCS_NO_CHAR)
continue;
#endif
if (c > ' ') {
add_srch_chr(document, c, x, y, 1);
continue;

View File

@ -1,397 +0,0 @@
GNU Free Documentation License
Version 1.2, November 2002
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (c) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

View File

@ -5,7 +5,3 @@ occuring inside of these documents. No automated testsuite yet, though.
Possible meaningful content of the documents is completely irrelevant and you
should ignore it. Noone takes any responsibility for it :).
optgroup.html originates from <http://iccl.fi/>. Ari Sovijärvi kindly
granted us the "GNU free documentation licence" (included in the file
GFDL-1.2).

View File

@ -1,43 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>select optgroup test</title>
</head>
<body style="background: #cfcfcf">
<form action="read.cgi">
<select name="id" style="border: 3px solid #C0C0C0; background: #F0F0F0; font-family: arial;">
<optgroup label="Navigation">
<option value="mm">Main menu
<option value="ab">Archive
</optgroup>
<optgroup label="Part I - Piecing it together">
<option value="0">I - Genesis
<option value="3">II - The Borg
<option value="8">III - The coffee wars
<option value="13">IV - Not the XMAS spirit
<option value="19">V - Avoiding the issue
<option value="25">VI - Techs
<option value="30">VII - The upgrade
<option value="39">VIII - Listening to the conscience
<option value="50">IX - The myth of Deirdre
</optgroup>
<optgroup label="Part II - Against the odds">
<option value="62">X - All the bad things
<option value="74">XI - Going bye-bye
<option value="86">XII - Meet Mark
<option value="100">SPECIAL - ICCL 1 year
<option value="103">XIII - Taking the first steps
<option value="122">XIV - When it almost falls apart
<option value="135">XV - More human than before
<option value="148">XVI - Avoiding the issue, again
<option value="163">XVII - That's what friends are for
<option value="164">&nbsp;&nbsp;It's too quiet (2.15/04)
<option value="165">&nbsp;&nbsp;Friend on a bender (1.16/04)
<option selected value="166">&nbsp;&nbsp;Understanding girls (2.16/04)
</optgroup>
</select>
<input type="file" size="70">
</form>
</body>
</html>