1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Merge branch 'elinks-0.12'

Conflicts:

	src/document/dom/renderer.c
This commit is contained in:
Jonas Fonseca 2007-09-09 18:25:49 +02:00
commit 0240c469b7
14 changed files with 111 additions and 190 deletions

View File

@ -15,21 +15,7 @@
#include "dom/select.h"
#include "dom/sgml/parser.h"
#include "dom/stack.h"
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
#include "util/test.h"
int
main(int argc, char *argv[])
@ -51,41 +37,14 @@ main(int argc, char *argv[])
arg += 2;
if (!strncmp(arg, "uri", 3)) {
arg += 3;
if (*arg == '=') {
arg++;
set_dom_string(&uri, arg, strlen(arg));
} else {
i++;
if (i >= argc)
die("--uri expects a URI");
set_dom_string(&uri, argv[i], strlen(argv[i]));
}
if (get_test_opt(&arg, "uri", &i, argc, argv, "a URI")) {
set_dom_string(&uri, arg, strlen(arg));
} else if (!strncmp(arg, "src", 3)) {
arg += 3;
if (*arg == '=') {
arg++;
set_dom_string(&source, arg, strlen(arg));
} else {
i++;
if (i >= argc)
die("--src expects a string");
set_dom_string(&source, argv[i], strlen(argv[i]));
}
} else if (get_test_opt(&arg, "src", &i, argc, argv, "a string")) {
set_dom_string(&source, arg, strlen(arg));
} else if (!strncmp(arg, "selector", 3)) {
arg += 8;
if (*arg == '=') {
arg++;
set_dom_string(&selector, arg, strlen(arg));
} else {
i++;
if (i >= argc)
die("--selector expects a string");
set_dom_string(&selector, argv[i], strlen(argv[i]));
}
} else if (get_test_opt(&arg, "selector", &i, argc, argv, "a string")) {
set_dom_string(&selector, arg, strlen(arg));
} else if (!strcmp(arg, "help")) {
die(NULL);

View File

@ -16,6 +16,7 @@
#include "dom/sgml/dump.h"
#include "dom/sgml/parser.h"
#include "dom/stack.h"
#include "util/test.h"
unsigned int number_of_lines = 0;
@ -242,44 +243,6 @@ sgml_error_function(struct sgml_parser *parser, struct dom_string *string,
return DOM_CODE_OK;
}
static void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
static int
get_opt(char **argref, const char *name, int *argi, int argc, char *argv[],
const char *expect_msg)
{
char *arg = *argref;
int namelen = strlen(name);
if (strncmp(arg, name, namelen))
return 0;
arg += namelen;
if (*arg == '=') {
(*argref) = arg + 1;
} else {
(*argi)++;
if ((*argi) >= argc)
die("--%s expects %s", name, expect_msg);
(*argref) = argv[(*argi)];
}
return 1;
}
int
main(int argc, char *argv[])
{
@ -305,17 +268,17 @@ main(int argc, char *argv[])
arg += 2;
if (get_opt(&arg, "uri", &i, argc, argv, "a URI")) {
if (get_test_opt(&arg, "uri", &i, argc, argv, "a URI")) {
set_dom_string(&uri, arg, strlen(arg));
} else if (get_opt(&arg, "src", &i, argc, argv, "a string")) {
} else if (get_test_opt(&arg, "src", &i, argc, argv, "a string")) {
set_dom_string(&source, arg, strlen(arg));
} else if (get_opt(&arg, "stdin", &i, argc, argv, "a number")) {
} else if (get_test_opt(&arg, "stdin", &i, argc, argv, "a number")) {
read_stdin = atoi(arg);
flags |= SGML_PARSER_INCREMENTAL;
} else if (get_opt(&arg, "normalize", &i, argc, argv, "a string")) {
} else if (get_test_opt(&arg, "normalize", &i, argc, argv, "a string")) {
normalize = 1;
normalize_flags = parse_dom_config(arg, ',');
type = SGML_PARSER_TREE;

View File

@ -177,6 +177,7 @@ trigger_event(int id, ...)
va_start(ap, id);
trigger_event_va(id, ap);
va_end(ap);
}
void
@ -187,6 +188,7 @@ trigger_event_name(unsigned char *name, ...)
va_start(ap, name);
trigger_event_va(id, ap);
va_end(ap);
}
static inline void

View File

@ -678,6 +678,9 @@ struct module mailcap_mime_module = struct_module(
);
#ifdef TEST_MAILCAP
#include "util/test.h"
/* Some ugly shortcuts for getting defined symbols to work. */
int default_mime_backend,
install_signal_handler,
@ -685,20 +688,6 @@ int default_mime_backend,
program;
LIST_OF(struct terminal) terminals;
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(1);
}
int
main(int argc, char *argv[])
{
@ -714,44 +703,16 @@ main(int argc, char *argv[])
arg += 2;
if (!strncmp(arg, "path", 4)) {
arg += 4;
if (*arg == '=') {
arg++;
get_mailcap_path() = arg;
} else {
i++;
if (i >= argc)
die("--path expects a parameter");
get_mailcap_path() = argv[i];
}
if (get_test_opt(&arg, "path", &i, argc, argv, "a string")) {
get_mailcap_path() = arg;
done_mailcap(NULL);
} else if (!strncmp(arg, "format", 6)) {
arg += 6;
if (*arg == '=') {
arg++;
format = arg;
} else {
i++;
if (i >= argc)
die("--format expects a parameter");
format = argv[i];
}
} else if (get_test_opt(&arg, "format", &i, argc, argv, "a string")) {
format = arg;
} else if (!strncmp(arg, "get", 3)) {
} else if (get_test_opt(&arg, "get", &i, argc, argv, "a string")) {
struct mime_handler *handler;
arg += 3;
if (*arg == '=') {
arg++;
} else {
i++;
if (i >= argc)
die("--get expects a parameter");
arg = argv[i];
}
if (has_gotten)
printf("\n");
has_gotten = 1;

View File

@ -13,21 +13,7 @@
#include "osdep/stat.h"
#include "protocol/ftp/parse.h"
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
#include "util/test.h"
int
main(int argc, char *argv[])
@ -45,17 +31,8 @@ main(int argc, char *argv[])
arg += 2;
if (!strncmp(arg, "response", 8)) {
arg += 8;
if (*arg == '=') {
arg++;
response = arg;
} else {
i++;
if (i >= argc)
die("--response expects a string");
response = argv[i];
}
if (get_test_opt(&arg, "response", &i, argc, argv, "a string")) {
response = arg;
responselen = strlen(response);
} else {

View File

@ -1 +1 @@
uri-parser
uri-test

View File

@ -13,6 +13,7 @@
#include "main/module.h"
#include "protocol/user.h"
#include "session/session.h"
#include "util/test.h"
#define STUB_MODULE(name) \
struct module name = struct_module( \
@ -38,21 +39,6 @@ STUB_MODULE(smb_protocol_module);
STUB_MODULE(uri_rewrite_module);
STUB_MODULE(user_protocol_module);
static void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
static void
stub_called(const unsigned char *fun)
{

View File

@ -785,6 +785,11 @@ normalize_uri(struct uri *uri, unsigned char *uristring)
continue;
}
} else if (is_uri_dir_sep(uri, src[1]) &&
uri->protocol == PROTOCOL_FILE) {
/* // - ignore first '/'. */
src += 1;
continue;
}
/* We don't want to access memory past the NUL char. */

View File

@ -27,7 +27,8 @@
#include "util/string.h"
/* TODO: We must use termcap/terminfo if available! --pasky */
/* TODO: We must use termcap/terminfo if available! --pasky
* Please mention ELinks bug 96 in commit logs. --KON */
/** Mapping from (enum ::border_char - 0xB0) to ASCII characters. */
const unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ ";
@ -74,11 +75,11 @@ static const unsigned char frame_vt100_u[48] = {
* 0x8D U+250C 'l' ACS_ULCORNER
* 0x8E U+2514 'm' ACS_LLCORNER
* 0x8F U+253C 'n' ACS_PLUS
* 0x90 - 'o' ACS_S1
* 0x91 - 'p' ACS_S3
* 0x90 U+23BA 'o' ACS_S1
* 0x91 U+23BB 'p' ACS_S3
* 0x92 U+2500 'q' ACS_HLINE
* 0x93 - 'r' ACS_S7
* 0x94 - 's' ACS_S9
* 0x93 U+23BC 'r' ACS_S7
* 0x94 U+23BD 's' ACS_S9
* 0x95 U+251C 't' ACS_LTEE
* 0x96 U+2524 'u' ACS_RTEE
* 0x97 U+2534 'v' ACS_BTEE

View File

@ -47,8 +47,20 @@ struct window {
/** The terminal (and screen) that hosts the window */
struct terminal *term;
/** Used for tabs focus detection. */
/** For ::WINDOW_TAB, the position and size in the tab bar.
* Updated while the tab bar is being drawn, and read if the
* user clicks there with the mouse. */
int xpos, width;
/** The position of something that has focus in the window.
* Any popup menus are drawn near this position.
* In tab windows, during ::NAVIGATE_CURSOR_ROUTING, this is
* also the position of the cursor that the user can move;
* there is no separate cursor position for each frame.
* In dialog boxes, this is typically the top left corner of
* the focused widget, while the cursor is somewhere within
* the widget.
* @see set_window_ptr, get_parent_ptr, set_cursor */
int x, y;
/** For delayed tab resizing */

View File

@ -445,7 +445,6 @@ add_format_to_string(struct string *string, const unsigned char *format, ...)
int newlength;
int width;
va_list ap;
va_list ap2;
assertm(string && format, "[add_format_to_string]");
if_assert_failed { return NULL; }
@ -453,17 +452,16 @@ add_format_to_string(struct string *string, const unsigned char *format, ...)
check_string_magic(string);
va_start(ap, format);
VA_COPY(ap2, ap);
width = vsnprintf(NULL, 0, format, ap2);
width = vsnprintf(NULL, 0, format, ap);
va_end(ap);
if (width <= 0) return NULL;
newlength = string->length + width;
if (!realloc_string(string, newlength))
return NULL;
va_start(ap, format);
vsnprintf(&string->source[string->length], width + 1, format, ap);
va_end(ap);
string->length = newlength;

50
src/util/test.h Normal file
View File

@ -0,0 +1,50 @@
/* Test library */
#ifndef EL__UTIL_TEST_H
#define EL__UTIL_TEST_H
#include <stdlib.h>
static inline void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(EXIT_FAILURE);
}
static inline int
get_test_opt(char **argref, const char *name, int *argi, int argc, char *argv[],
const char *expect_msg)
{
char *arg = *argref;
int namelen = strlen(name);
if (strncmp(arg, name, namelen))
return 0;
arg += namelen;
if (*arg == '=') {
(*argref) = arg + 1;
} else if (!*arg) {
(*argi)++;
if ((*argi) >= argc)
die("--%s expects %s", name, expect_msg);
(*argref) = argv[(*argi)];
} else {
return 0;
}
return 1;
}
#endif

View File

@ -1078,6 +1078,11 @@ enter(struct session *ses, struct document_view *doc_view, int do_reload)
return activate_link(ses, doc_view, link, do_reload);
}
/** Get the link at the coordinates @a x and @a y, or NULL if none.
* The coordinates are relative to the document view; not to the
* terminal, nor to the document. So (0, 0) means whatever part of
* the document has been scrolled to the top left corner of the
* document view. */
struct link *
get_link_at_coordinates(struct document_view *doc_view, int x, int y)
{

View File

@ -28,6 +28,8 @@ struct view_state {
* should never be negative. */
int y;
/** The index of the focused link in the document.links array,
* or -1 of none. */
int current_link;
int old_current_link;