From 6eea23f725054a2efc1a28704167d3433800e15e Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 30 Aug 2013 09:06:26 -0400 Subject: dpi.c: Minor typos and normalizations --- src/IO/dpi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/IO/dpi.c b/src/IO/dpi.c index 8e71f8ca..c99bb3f0 100644 --- a/src/IO/dpi.c +++ b/src/IO/dpi.c @@ -492,7 +492,7 @@ static int Dpi_check_dpid(int num_tries) } } - _MSG("Dpi_check_dpid:: %s\n", + _MSG("Dpi_check_dpid: %s\n", (ret == 0) ? "OK" : (ret == 1 ? "EAGAIN" : "ERROR")); return ret; } @@ -531,7 +531,7 @@ static int Dpi_get_server_port(const char *server_name) socklen_t sin_sz; dReturn_val_if_fail (server_name != NULL, dpi_port); - _MSG("Dpi_get_server_port:: server_name = [%s]\n", server_name); + _MSG("Dpi_get_server_port: server_name = [%s]\n", server_name); /* Read dpid's port from saved file */ if (Dpi_read_comm_keys(&dpid_port) != -1) { @@ -608,7 +608,7 @@ static int Dpi_connect_socket(const char *server_name) /* Query dpid for the port number for this server */ if ((dpi_port = Dpi_get_server_port(server_name)) == -1) { - _MSG("Dpi_connect_socket:: can't get port number for %s\n", server_name); + _MSG("Dpi_connect_socket: can't get port number for %s\n", server_name); return -1; } _MSG("Dpi_connect_socket: server=%s port=%d\n", server_name, dpi_port); @@ -620,9 +620,9 @@ static int Dpi_connect_socket(const char *server_name) sin.sin_port = htons(dpi_port); if ((sock_fd = Dpi_make_socket_fd()) == -1) { - perror("[dpi::socket]"); + MSG_ERR("[Dpi_connect_socket] %s\n", dStrerror(errno)); } else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) { - MSG("[dpi::connect] errno:%d %s\n", errno, dStrerror(errno)); + MSG_ERR("[Dpi_connect_socket] errno:%d %s\n", errno, dStrerror(errno)); /* send authentication Key (the server closes sock_fd on auth error) */ } else if (!(cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "auth", SharedKey))) { -- cgit v1.2.3 From 75ad99f0389fb9f7434cfbefa205b1636d4ee1f1 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Mon, 2 Sep 2013 11:31:37 -0400 Subject: Avoid Dpid children to become zombies This handler was long overdue... Patch: Jorge Arellano, J. Gaffney --- src/dillo.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index 5c1e7364..567d897f 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -21,8 +21,11 @@ #include #include #include +#include +#include #include #include +#include #include #include @@ -95,6 +98,63 @@ static const CLI_options Options[] = { {NULL, NULL, 0, DILLO_CLI_NONE, NULL} }; + +/* + * SIGCHLD handling ---------------------------------------------------------- + */ + +/* + * Avoid our children (Dpid) to become zombies. :-) + * Notes: + * . We let sigaction block SIGCHLD while in the handler. + * . Portability is not simple. e.g. + * http://www.faqs.org/faqs/unix-faq/faq/part3/section-13.html + * man sigaction, waitpid + */ +static void raw_sigchld2(int signum) +{ + pid_t pid; + int status; + + while (1) { + pid = waitpid(-1, &status, WNOHANG); + if (pid > 0) { + if (WIFEXITED(status)) /* normal exit */ + printf("[dpid]: terminated normally (%d)\n", WEXITSTATUS(status)); + else if (WIFSIGNALED(status)) /* terminated by signal */ + printf("[dpid]: terminated by signal %d\n", WTERMSIG(status)); + } else if (pid == 0 || errno == ECHILD) { + break; + } else { + if (errno == EINTR) + continue; + perror("waitpid"); + break; + } + } + ++signum; /* compiler happiness */ +} + +/* + * Establish SIGCHLD handler + */ +static void est_sigchld(void) +{ + struct sigaction sigact; + sigset_t set; + + (void) sigemptyset(&set); + sigact.sa_handler = raw_sigchld2; /* our custom handler */ + sigact.sa_mask = set; /* no aditional signal blocks */ + sigact.sa_flags = SA_NOCLDSTOP; /* ignore stop/resume states */ + if (sigaction(SIGCHLD, &sigact, NULL) == -1) { + perror("sigaction"); + exit(1); + } +} + +//---------------------------------------------------------------------------- + /* * Print help text generated from the options structure */ @@ -329,6 +389,8 @@ int main(int argc, char **argv) // Some OSes exit dillo without this (not GNU/Linux). signal(SIGPIPE, SIG_IGN); + // Establish our custom SIGCHLD handler + est_sigchld(); /* Handle command line options */ opt_argv = dNew0(char*, numOptions(Options) + 1); -- cgit v1.2.3 From 249ddc27f05bc334bc554a692e6b2d541053afb3 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:19:28 +0000 Subject: some html5 structural elements The spec also has some rules about how, for instance, a footer can't go inside a header, and that sort of thing, but that can wait until we have something more sophisticated than a collection of IN_* flags. --- src/css.hh | 6 +++++- src/html.cc | 8 ++++++++ src/styleengine.cc | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/css.hh b/src/css.hh index e81fde62..c29912b3 100644 --- a/src/css.hh +++ b/src/css.hh @@ -451,7 +451,11 @@ class CssStyleSheet { (true, true, 256) {}; }; - static const int ntags = 90; // \todo replace 90 + static const int ntags = 90 + 8; // \todo don't hardcode + /* 90 is the full number of html4 elements, including those which we have + * implemented. From html 5, let's add: article, header, footer, nav, + * section, aside, figure, figcaption. + */ RuleList elementTable[ntags], anyTable; RuleMap idTable, classTable; diff --git a/src/html.cc b/src/html.cc index 5e2c799b..03e46607 100644 --- a/src/html.cc +++ b/src/html.cc @@ -3209,6 +3209,8 @@ const TagInfo Tags[] = { {"address", B8(010110),'R',2,Html_tag_open_default, NULL, Html_tag_close_par}, {"area", B8(010001),'F',0, Html_tag_open_default, Html_tag_content_area, NULL}, + {"article", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"aside", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"b", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"base", B8(100001),'F',0, Html_tag_open_base, NULL, NULL}, /* basefont 010001 */ @@ -3236,7 +3238,10 @@ const TagInfo Tags[] = { {"dt", B8(010110),'O',1, Html_tag_open_dt, NULL, Html_tag_close_par}, {"em", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, /* fieldset */ + {"figcaption", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"figure", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"font", B8(010101),'R',2, Html_tag_open_font, NULL, NULL}, + {"footer", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"form", B8(011110),'R',2, Html_tag_open_form, NULL, Html_tag_close_form}, {"frame", B8(010010),'F',0, Html_tag_open_frame, Html_tag_content_frame, NULL}, @@ -3249,6 +3254,7 @@ const TagInfo Tags[] = { {"h5", B8(010110),'R',2, Html_tag_open_h, NULL, NULL}, {"h6", B8(010110),'R',2, Html_tag_open_h, NULL, NULL}, {"head", B8(101101),'O',1, Html_tag_open_head, NULL, Html_tag_close_head}, + {"header", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"hr", B8(010010),'F',0, Html_tag_open_hr, Html_tag_content_hr, NULL}, {"html", B8(001110),'O',1, Html_tag_open_html, NULL, Html_tag_close_html}, @@ -3270,6 +3276,7 @@ const TagInfo Tags[] = { /* menu 1010 -- TODO: not exactly 1010, it can contain LI and inline */ {"menu", B8(011010),'R',2, Html_tag_open_menu, NULL, Html_tag_close_par}, {"meta", B8(100001),'F',0, Html_tag_open_meta, NULL, NULL}, + {"nav", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, /* noframes 1011 */ /* noscript 1011 */ {"object", B8(111101),'R',2, Html_tag_open_object, NULL, NULL}, @@ -3284,6 +3291,7 @@ const TagInfo Tags[] = { {"s", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"samp", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"script", B8(111001),'R',2, Html_tag_open_script,NULL,Html_tag_close_script}, + {"section", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"select", B8(010101),'R',2, Html_tag_open_select,NULL,Html_tag_close_select}, {"small", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"span", B8(010101),'R',2, Html_tag_open_span, NULL, NULL}, diff --git a/src/styleengine.cc b/src/styleengine.cc index b3ea8b3b..50bd4cb7 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -830,7 +830,9 @@ void StyleEngine::buildUserAgentStyle () { ":link {color: blue; text-decoration: underline; cursor: pointer}" ":visited {color: #800080; text-decoration: underline; cursor: pointer}" "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}" - "address, center, div, h1, h2, h3, h4, h5, h6, ol, p, ul, pre {display: block}" + "address, article, aside, center, div, figure, figcaption, footer," + " h1, h2, h3, h4, h5, h6, header, nav, ol, p, pre, section, ul" + " {display: block}" "i, em, cite, address, var {font-style: italic}" ":link img, :visited img {border: 1px solid}" "frameset, ul, ol, dir {margin-left: 40px}" @@ -839,6 +841,7 @@ void StyleEngine::buildUserAgentStyle () { * look better like this. */ "p {margin: 0.5em 0}" + "figure {margin: 1em 40px}" "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}" "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}" "h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}" -- cgit v1.2.3 From d87db43c658228cf49acacf2f7650b797010b81c Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:33:07 +0000 Subject: html5, don't restrict A to inline ('phrasing') content. Its content model is 'transparent', meaning that it's supposed to use the content model of its parent. --- src/html.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/html.cc b/src/html.cc index 03e46607..d695d56e 100644 --- a/src/html.cc +++ b/src/html.cc @@ -3203,7 +3203,7 @@ static void Html_tag_close_par(DilloHtml *html) */ const TagInfo Tags[] = { - {"a", B8(010101),'R',2, Html_tag_open_a, NULL, Html_tag_close_a}, + {"a", B8(011101),'R',2, Html_tag_open_a, NULL, Html_tag_close_a}, {"abbr", B8(010101),'R',2, Html_tag_open_abbr, NULL, NULL}, /* acronym 010101 */ {"address", B8(010110),'R',2,Html_tag_open_default, NULL, Html_tag_close_par}, -- cgit v1.2.3 From d6f101c5cb2372965086ba5fc52fb324005d85e9 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:38:23 +0000 Subject: html5, don't complain about unknown input type ...now that there's tel, url, email, datetime, date, month, week, time, datetime-local, number, range, color (all of which I imagine we will continue to regard as 'text'). --- src/form.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/form.cc b/src/form.cc index 6da5567b..4279c0a4 100644 --- a/src/form.cc +++ b/src/form.cc @@ -530,8 +530,6 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } else { /* Text input, which also is the default */ inp_type = DILLO_HTML_INPUT_TEXT; - if (*type && dStrAsciiCasecmp(type, "text")) - BUG_MSG("Unknown input type: \"%s\"\n", type); attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); resource = factory->createEntryResource(size, false, NULL); -- cgit v1.2.3 From c04f95a9a48c42bf65e5a4f1d524d34fa65c36f2 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:44:45 +0000 Subject: html5, id/name values are less restricted --- src/html.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/html.cc b/src/html.cc index d695d56e..58c94f81 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1511,17 +1511,27 @@ int32_t a_Html_color_parse(DilloHtml *html, const char *str, static int Html_check_name_val(DilloHtml *html, const char *val, const char *attrname) { - int i; + if (html->DocType == DT_HTML && html->DocTypeVersion >= 5.0f) { + bool valid = *val && !strchr(val, ' '); - for (i = 0; val[i]; ++i) - if (!isascii(val[i]) || !(isalnum(val[i]) || strchr(":_.-", val[i]))) - break; + if (!valid) { + BUG_MSG("'%s' value must not be empty and must not contain spaces", + attrname); + } + return valid ? 1 : 0; + } else { + int i; - if (val[i] || !(isascii(val[0]) && isalpha(val[0]))) - BUG_MSG("'%s' value \"%s\" is not of the form " - "[A-Za-z][A-Za-z0-9:_.-]*\n", attrname, val); + for (i = 0; val[i]; ++i) + if (!isascii(val[i]) || !(isalnum(val[i]) || strchr(":_.-", val[i]))) + break; + + if (val[i] || !(isascii(val[0]) && isalpha(val[0]))) + BUG_MSG("'%s' value \"%s\" is not of the form " + "[A-Za-z][A-Za-z0-9:_.-]*\n", attrname, val); - return !(val[i]); + return !(val[i]); + } } /* -- cgit v1.2.3 From 560b9fb24cb4cbba17ce76830514eac34bfb552d Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:46:02 +0000 Subject: don't warn about html5 in bug msgs --- src/html.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/html.cc b/src/html.cc index 58c94f81..2fd9244f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1619,7 +1619,6 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) html->DocTypeVersion = 2.0f; } } else if (!dStrAsciiCasecmp(ntag, HTML5_sig)) { - BUG_MSG("Document follows HTML5 working draft; treating as HTML4.\n"); html->DocType = DT_HTML; html->DocTypeVersion = 5.0f; } -- cgit v1.2.3 From b6d6d06a451e5cc411b3d06cd30317ba66381d65 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 5 Sep 2013 19:48:03 +0000 Subject: don't require STYLE type attribute for html5 --- src/html.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/html.cc b/src/html.cc index 2fd9244f..99c14dbf 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1766,7 +1766,8 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize) html->loadCssFromStash = true; if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) { - BUG_MSG("type attribute is required for