libhubbub: branch master updated. release/0.2.0-2-gd509919
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libhubbub.git/shortlog/d509919a3bc507f3898...
...commit http://git.netsurf-browser.org/libhubbub.git/commit/d509919a3bc507f3898e2...
...tree http://git.netsurf-browser.org/libhubbub.git/tree/d509919a3bc507f3898e216...
The branch, master has been updated
via d509919a3bc507f3898e2166978462badbaab599 (commit)
from ff31fd617c976832422206a9d36ecd395f45cbaf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libhubbub.git/commit/?id=d509919a3bc507f38...
commit d509919a3bc507f3898e2166978462badbaab599
Author: Craig Barnes <craigbarnes85(a)gmail.com>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Correct various warnings in the test suite
diff --git a/test/csdetect.c b/test/csdetect.c
index 3f24792..aa1b192 100644
--- a/test/csdetect.c
+++ b/test/csdetect.c
@@ -108,7 +108,7 @@ void run_test(const uint8_t *data, size_t len, char *expected)
static int testnum;
assert(hubbub_charset_extract(data, len,
- &mibenum, &source) == HUBBUB_OK);
+ &mibenum, &source) == PARSERUTILS_OK);
assert(mibenum != 0);
diff --git a/test/parser.c b/test/parser.c
index 0670ebf..93bdad2 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -24,7 +24,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser *parser;
hubbub_parser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
@@ -46,7 +46,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
diff --git a/test/tokeniser.c b/test/tokeniser.c
index e71cdcd..717e34e 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
hubbub_tokeniser *tok;
hubbub_tokeniser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
#define CHUNK_SIZE (4096)
uint8_t buf[CHUNK_SIZE];
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
break;
assert(parserutils_inputstream_append(stream,
- buf, bytes_read) == HUBBUB_OK);
+ buf, bytes_read) == PARSERUTILS_OK);
len -= bytes_read;
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index 780c646..443b71d 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -149,7 +149,7 @@ void run_test(context *ctx)
ctx->last_start_tag);
assert(parserutils_inputstream_append(stream,
- buf, len - 1) == HUBBUB_OK);
+ buf, len - 1) == PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
@@ -196,10 +196,10 @@ void run_test(context *ctx)
¶ms) == HUBBUB_OK);
assert(parserutils_inputstream_append(stream,
- ctx->input, ctx->input_len) == HUBBUB_OK);
+ ctx->input, ctx->input_len) == PARSERUTILS_OK);
assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
printf("Input: '%.*s' (%d)\n", (int) ctx->input_len,
(const char *) ctx->input,
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index c74c9aa..9f0f84e 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -147,7 +147,7 @@ void run_test(context *ctx)
ctx->last_start_tag);
assert(parserutils_inputstream_append(stream,
- buf, len - 1) == HUBBUB_OK);
+ buf, len - 1) == PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
@@ -200,13 +200,13 @@ void run_test(context *ctx)
for (j = 0; j < ctx->input_len; j++) {
assert(parserutils_inputstream_append(stream,
ctx->input + j, 1) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
}
assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
diff --git a/test/tree.c b/test/tree.c
index d8319e6..9896df8 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -90,7 +90,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser *parser;
hubbub_parser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
@@ -125,7 +125,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
-----------------------------------------------------------------------
Summary of changes:
test/csdetect.c | 2 +-
test/parser.c | 4 ++--
test/tokeniser.c | 6 +++---
test/tokeniser2.c | 6 +++---
test/tokeniser3.c | 6 +++---
test/tree.c | 4 ++--
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/test/csdetect.c b/test/csdetect.c
index 3f24792..aa1b192 100644
--- a/test/csdetect.c
+++ b/test/csdetect.c
@@ -108,7 +108,7 @@ void run_test(const uint8_t *data, size_t len, char *expected)
static int testnum;
assert(hubbub_charset_extract(data, len,
- &mibenum, &source) == HUBBUB_OK);
+ &mibenum, &source) == PARSERUTILS_OK);
assert(mibenum != 0);
diff --git a/test/parser.c b/test/parser.c
index 0670ebf..93bdad2 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -24,7 +24,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser *parser;
hubbub_parser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
@@ -46,7 +46,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
diff --git a/test/tokeniser.c b/test/tokeniser.c
index e71cdcd..717e34e 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
hubbub_tokeniser *tok;
hubbub_tokeniser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
#define CHUNK_SIZE (4096)
uint8_t buf[CHUNK_SIZE];
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
break;
assert(parserutils_inputstream_append(stream,
- buf, bytes_read) == HUBBUB_OK);
+ buf, bytes_read) == PARSERUTILS_OK);
len -= bytes_read;
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index 780c646..443b71d 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -149,7 +149,7 @@ void run_test(context *ctx)
ctx->last_start_tag);
assert(parserutils_inputstream_append(stream,
- buf, len - 1) == HUBBUB_OK);
+ buf, len - 1) == PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
@@ -196,10 +196,10 @@ void run_test(context *ctx)
¶ms) == HUBBUB_OK);
assert(parserutils_inputstream_append(stream,
- ctx->input, ctx->input_len) == HUBBUB_OK);
+ ctx->input, ctx->input_len) == PARSERUTILS_OK);
assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
printf("Input: '%.*s' (%d)\n", (int) ctx->input_len,
(const char *) ctx->input,
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index c74c9aa..9f0f84e 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -147,7 +147,7 @@ void run_test(context *ctx)
ctx->last_start_tag);
assert(parserutils_inputstream_append(stream,
- buf, len - 1) == HUBBUB_OK);
+ buf, len - 1) == PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
@@ -200,13 +200,13 @@ void run_test(context *ctx)
for (j = 0; j < ctx->input_len; j++) {
assert(parserutils_inputstream_append(stream,
ctx->input + j, 1) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
}
assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ PARSERUTILS_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
diff --git a/test/tree.c b/test/tree.c
index d8319e6..9896df8 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -90,7 +90,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser *parser;
hubbub_parser_optparams params;
FILE *fp;
- size_t len, origlen;
+ size_t len;
uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
@@ -125,7 +125,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
}
fseek(fp, 0, SEEK_END);
- origlen = len = ftell(fp);
+ len = ftell(fp);
fseek(fp, 0, SEEK_SET);
while (len > 0) {
--
HTML5 parser library
10 years
netsurf: branch master updated. release/3.0-30-g52c5ccc
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/52c5cccdeb15db5f996a6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/52c5cccdeb15db5f996a661...
...tree http://git.netsurf-browser.org/netsurf.git/tree/52c5cccdeb15db5f996a66165...
The branch, master has been updated
via 52c5cccdeb15db5f996a661657d5eb195f930b00 (commit)
via 926be456b4316012e12c05a82f56637ce920397b (commit)
via 848f3d13ca50d156a20131829b3df29210097ba4 (commit)
via 560faaa7be1d2befcc4f51becf68c844b4110b12 (commit)
from 5c57a30047b4c9330110e5de9f5f406571f9baf1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=52c5cccdeb15db5f996...
commit 52c5cccdeb15db5f996a661657d5eb195f930b00
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
cleanup tree_create_leaf_node text ownership
diff --git a/desktop/cookies.c b/desktop/cookies.c
index 539be3e..197b3fb 100644
--- a/desktop/cookies.c
+++ b/desktop/cookies.c
@@ -264,19 +264,12 @@ static struct node *cookies_create_cookie_node(struct node *parent,
const struct cookie_data *data)
{
struct node *node;
- char *name;
- name = strdup(data->name);
- if (name == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- node = tree_create_leaf_node(cookies_tree, NULL, name,
+ node = tree_create_leaf_node(cookies_tree,
+ NULL,
+ data->name,
false, false, false);
if (node == NULL) {
- free(name);
return NULL;
}
diff --git a/desktop/sslcert.c b/desktop/sslcert.c
index b7a4244..2b4d726 100644
--- a/desktop/sslcert.c
+++ b/desktop/sslcert.c
@@ -119,19 +119,22 @@ static node_callback_resp sslcert_node_callback(void *user_data,
static struct node *sslcert_create_node(const struct ssl_cert_info *cert)
{
- struct node *node;
+ struct node *node = NULL;
struct node_element *element;
char *text;
text = messages_get_buff("SSL_Certificate_Subject", cert->subject);
- if (text == NULL)
- return NULL;
-
- node = tree_create_leaf_node(NULL, NULL, text, false, false, false);
- if (node == NULL) {
+ if (text != NULL) {
+ node = tree_create_leaf_node(NULL,
+ NULL,
+ text,
+ false, false, false);
free(text);
+ }
+ if (node == NULL) {
return NULL;
}
+
tree_set_node_user_callback(node, sslcert_node_callback, NULL);
/* add issuer node */
diff --git a/desktop/tree.c b/desktop/tree.c
index e72ef60..c62793e 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -117,7 +117,7 @@ struct node_element {
struct node *parent; /**< Parent node */
node_element_type type; /**< Element type */
struct node_element_box box; /**< Element bounding box */
- const char *text; /**< Text for the element */
+ char *text; /**< Text for the element */
void *bitmap; /**< Bitmap for the element */
struct node_element *next; /**< Next node element */
unsigned int flag; /**< Client specified flag for data
@@ -578,25 +578,14 @@ struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
node->previous = NULL;
tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL)
+ if (parent != NULL) {
tree_link_node(tree, parent, node, false);
+ }
return node;
}
-
-/**
- * Creates a leaf node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title (not copied, used directly)
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node.
- */
+/* exported interface documented in desktop/tree.h */
struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted)
@@ -607,8 +596,12 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node = calloc(sizeof(struct node), 1);
if (node == NULL) {
- LOG(("calloc failed"));
- warn_user("NoMemory", 0);
+ return NULL;
+ }
+
+ node->data.text = strdup(title);
+ if (node->data.text == NULL) {
+ free(node);
return NULL;
}
@@ -617,7 +610,6 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node->deleted = deleted;
node->data.parent = node;
node->data.type = NODE_ELEMENT_TEXT;
- node->data.text = title;
node->data.flag = TREE_ELEMENT_TITLE;
node->data.editable = editable;
node->sort = NULL;
@@ -625,8 +617,9 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node->previous = NULL;
tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL)
+ if (parent != NULL) {
tree_link_node(tree, parent, node, false);
+ }
return node;
}
@@ -1488,18 +1481,20 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
assert(element != NULL);
- if (tree != NULL && element == tree->editing)
+ if ((tree != NULL) && (element == tree->editing)) {
tree_stop_edit(tree, false);
+ }
- if (text != NULL && (element->type == NODE_ELEMENT_TEXT ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
+ if ((text != NULL) &&
+ (element->type == NODE_ELEMENT_TEXT ||
+ element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
if (element->text != NULL) {
- if(strcmp(element->text, text) == 0) text_changed = true;
-
+ if (strcmp(element->text, text) == 0) {
+ text_changed = true;
+ }
response = NODE_CALLBACK_NOT_HANDLED;
- if (!element->editable &&
- element->parent->user_callback !=
- NULL) {
+ if ((!element->editable) &&
+ (element->parent->user_callback != NULL)) {
msg_data.msg = NODE_DELETE_ELEMENT_TXT;
msg_data.flag = element->flag;
msg_data.node = element->parent;
@@ -1508,14 +1503,16 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
element->parent->callback_data,
&msg_data);
}
- if (response != NODE_CALLBACK_HANDLED)
- free((void *)element->text);
+ if (response != NODE_CALLBACK_HANDLED) {
+ free(element->text);
+ }
}
- element->text = text;
+ element->text = (char *)text;
}
- if (bitmap != NULL && (element->type == NODE_ELEMENT_BITMAP ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
+ if ((bitmap != NULL) &&
+ ((element->type == NODE_ELEMENT_BITMAP) ||
+ (element->type == NODE_ELEMENT_TEXT_PLUS_ICON))) {
if (element->bitmap != NULL) {
response = NODE_CALLBACK_NOT_HANDLED;
if (element->parent->user_callback != NULL) {
@@ -1527,10 +1524,11 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
element->parent->callback_data,
&msg_data);
}
- if (response != NODE_CALLBACK_HANDLED)
+
+ if (response != NODE_CALLBACK_HANDLED) {
free(element->bitmap);
- }
- else {
+ }
+ } else {
/* Increase the box width to accomodate the new icon */
element->box.width += NODE_INSTEP;
}
diff --git a/desktop/tree.h b/desktop/tree.h
index b881087..00ac999 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -153,9 +153,23 @@ struct tree *tree_create(unsigned int flags,
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
+
+/**
+ * Creates a leaf node with the specified title, and optionally links it into
+ * the tree.
+ *
+ * \param tree the owner tree of 'parent', may be NULL
+ * \param parent the parent node, or NULL not to link
+ * \param title the node title.
+ * \param editable if true, the node title will be editable
+ * \param retain_in_memory if true, the node will stay in memory after deletion
+ * \param deleted if true, the node is created with the deleted flag
+ * \return the newly created node or NULL on error.
+ */
struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
+
struct node_element *tree_create_node_element(struct node *parent,
node_element_type type, unsigned int flag, bool editable);
void tree_link_node(struct tree *tree, struct node *link, struct node *node,
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 7646048..938cd1d 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -126,35 +126,41 @@ void tree_url_node_cleanup()
* \param parent the node to link to
* \param url the URL (copied)
* \param data the URL data to use
- * \param title the custom title to use
+ * \param title custom title to use or NULL to use url
* \return the node created, or NULL for failure
*/
struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
nsurl *url, const char *title,
tree_node_user_callback user_callback, void *callback_data)
{
- struct node *node;
+ struct node *node = NULL;
struct node_element *element;
- char *text_cp, *squashed;
- squashed = squash_whitespace(title ? title : nsurl_access(url));
- text_cp = strdup(squashed);
- if (text_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
+ if (title == NULL) {
+ node = tree_create_leaf_node(tree,
+ parent,
+ nsurl_access(url),
+ true, false, false);
+ } else {
+ char *squashed;
+
+ squashed = squash_whitespace(title);
+ if (squashed != NULL) {
+ node = tree_create_leaf_node(tree,
+ parent,
+ squashed,
+ true, false, false);
+ free(squashed);
+ }
}
- free(squashed);
- node = tree_create_leaf_node(tree, parent, text_cp, true, false,
- false);
if (node == NULL) {
- free(text_cp);
return NULL;
}
- if (user_callback != NULL)
+ if (user_callback != NULL) {
tree_set_node_user_callback(node, user_callback,
callback_data);
+ }
tree_create_node_element(node, NODE_ELEMENT_BITMAP,
TREE_ELEMENT_THUMBNAIL, false);
@@ -165,7 +171,7 @@ struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
TREE_ELEMENT_URL, true);
if (element != NULL) {
- text_cp = strdup(nsurl_access(url));
+ char *text_cp = strdup(nsurl_access(url));
if (text_cp == NULL) {
tree_delete_node(tree, node, false);
LOG(("malloc failed"));
@@ -194,22 +200,18 @@ struct node *tree_create_URL_node_readonly(struct tree *tree,
{
struct node *node;
struct node_element *element;
- char *title;
+ const char *title;
assert(url && data);
if (data->title != NULL) {
- title = strdup(data->title);
+ title = data->title;
} else {
- title = strdup(nsurl_access(url));
+ title = nsurl_access(url);
}
- if (title == NULL)
- return NULL;
-
node = tree_create_leaf_node(tree, parent, title, false, false, false);
if (node == NULL) {
- free(title);
return NULL;
}
diff --git a/utils/utils.c b/utils/utils.c
index 3398a7d..8155f4a 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -98,26 +98,34 @@ char *remove_underscores(const char *s, bool replacespace)
/**
* Replace consecutive whitespace with a single space.
*
+ * @todo determine if squash_whitespace utf-8 safe and that it needs to be
+ *
* \param s source string
- * \return heap allocated result, or 0 on memory exhaustion
+ * \return heap allocated result, or NULL on memory exhaustion
*/
-char * squash_whitespace(const char *s)
+char *squash_whitespace(const char *s)
{
- char *c = malloc(strlen(s) + 1);
+ char *c;
int i = 0, j = 0;
- if (!c)
- return 0;
- do {
- if (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' ||
- s[i] == '\t') {
- c[j++] = ' ';
- while (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' ||
- s[i] == '\t')
- i++;
- }
- c[j++] = s[i++];
- } while (s[i - 1] != 0);
+
+ c = malloc(strlen(s) + 1);
+ if (c != NULL) {
+ do {
+ if (s[i] == ' ' ||
+ s[i] == '\n' ||
+ s[i] == '\r' ||
+ s[i] == '\t') {
+ c[j++] = ' ';
+ while (s[i] == ' ' ||
+ s[i] == '\n' ||
+ s[i] == '\r' ||
+ s[i] == '\t')
+ i++;
+ }
+ c[j++] = s[i++];
+ } while (s[i - 1] != 0);
+ }
return c;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=926be456b4316012e12...
commit 926be456b4316012e12c05a82f56637ce920397b
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
check the return codes from css increment and reset
diff --git a/css/dump.c b/css/dump.c
index 1fe8874..1b4d126 100644
--- a/css/dump.c
+++ b/css/dump.c
@@ -576,7 +576,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
/* counter-increment */
val = css_computed_counter_increment(style, &counter);
- if (counter == NULL) {
+ if ((val == CSS_COUNTER_INCREMENT_NONE) || (counter == NULL)) {
fprintf(stream, "counter-increment: none ");
} else {
fprintf(stream, "counter-increment:");
@@ -596,7 +596,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
/* counter-reset */
val = css_computed_counter_reset(style, &counter);
- if (counter == NULL) {
+ if ((val = CSS_COUNTER_RESET_NONE) || (counter == NULL)) {
fprintf(stream, "counter-reset: none ");
} else {
fprintf(stream, "counter-reset:");
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=848f3d13ca50d156a20...
commit 848f3d13ca50d156a20131829b3df29210097ba4
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
ensure parameter contract is met
diff --git a/content/llcache.c b/content/llcache.c
index 171ae15..938f1e8 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1185,6 +1185,7 @@ static nserror llcache_object_add_user(llcache_object *object,
{
assert(user->next == NULL);
assert(user->prev == NULL);
+ assert(user->handle != NULL);
user->handle->object = object;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=560faaa7be1d2befcc4...
commit 560faaa7be1d2befcc4f51becf68c844b4110b12
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
free memory on error condition
diff --git a/content/content.c b/content/content.c
index 9482fb9..941e189 100644
--- a/content/content.c
+++ b/content/content.c
@@ -1338,6 +1338,7 @@ nserror content__clone(const struct content *c, struct content *nc)
error = llcache_handle_clone(c->llcache, &(nc->llcache));
if (error != NSERROR_OK) {
+ free(user_sentinel);
return error;
}
-----------------------------------------------------------------------
Summary of changes:
content/content.c | 1 +
content/llcache.c | 1 +
css/dump.c | 4 +-
desktop/cookies.c | 13 ++-------
desktop/sslcert.c | 15 ++++++----
desktop/tree.c | 68 ++++++++++++++++++++++------------------------
desktop/tree.h | 14 +++++++++
desktop/tree_url_node.c | 46 ++++++++++++++++---------------
utils/utils.c | 38 ++++++++++++++++----------
9 files changed, 110 insertions(+), 90 deletions(-)
diff --git a/content/content.c b/content/content.c
index 9482fb9..941e189 100644
--- a/content/content.c
+++ b/content/content.c
@@ -1338,6 +1338,7 @@ nserror content__clone(const struct content *c, struct content *nc)
error = llcache_handle_clone(c->llcache, &(nc->llcache));
if (error != NSERROR_OK) {
+ free(user_sentinel);
return error;
}
diff --git a/content/llcache.c b/content/llcache.c
index 171ae15..938f1e8 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1185,6 +1185,7 @@ static nserror llcache_object_add_user(llcache_object *object,
{
assert(user->next == NULL);
assert(user->prev == NULL);
+ assert(user->handle != NULL);
user->handle->object = object;
diff --git a/css/dump.c b/css/dump.c
index 1fe8874..1b4d126 100644
--- a/css/dump.c
+++ b/css/dump.c
@@ -576,7 +576,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
/* counter-increment */
val = css_computed_counter_increment(style, &counter);
- if (counter == NULL) {
+ if ((val == CSS_COUNTER_INCREMENT_NONE) || (counter == NULL)) {
fprintf(stream, "counter-increment: none ");
} else {
fprintf(stream, "counter-increment:");
@@ -596,7 +596,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
/* counter-reset */
val = css_computed_counter_reset(style, &counter);
- if (counter == NULL) {
+ if ((val = CSS_COUNTER_RESET_NONE) || (counter == NULL)) {
fprintf(stream, "counter-reset: none ");
} else {
fprintf(stream, "counter-reset:");
diff --git a/desktop/cookies.c b/desktop/cookies.c
index 539be3e..197b3fb 100644
--- a/desktop/cookies.c
+++ b/desktop/cookies.c
@@ -264,19 +264,12 @@ static struct node *cookies_create_cookie_node(struct node *parent,
const struct cookie_data *data)
{
struct node *node;
- char *name;
- name = strdup(data->name);
- if (name == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- node = tree_create_leaf_node(cookies_tree, NULL, name,
+ node = tree_create_leaf_node(cookies_tree,
+ NULL,
+ data->name,
false, false, false);
if (node == NULL) {
- free(name);
return NULL;
}
diff --git a/desktop/sslcert.c b/desktop/sslcert.c
index b7a4244..2b4d726 100644
--- a/desktop/sslcert.c
+++ b/desktop/sslcert.c
@@ -119,19 +119,22 @@ static node_callback_resp sslcert_node_callback(void *user_data,
static struct node *sslcert_create_node(const struct ssl_cert_info *cert)
{
- struct node *node;
+ struct node *node = NULL;
struct node_element *element;
char *text;
text = messages_get_buff("SSL_Certificate_Subject", cert->subject);
- if (text == NULL)
- return NULL;
-
- node = tree_create_leaf_node(NULL, NULL, text, false, false, false);
- if (node == NULL) {
+ if (text != NULL) {
+ node = tree_create_leaf_node(NULL,
+ NULL,
+ text,
+ false, false, false);
free(text);
+ }
+ if (node == NULL) {
return NULL;
}
+
tree_set_node_user_callback(node, sslcert_node_callback, NULL);
/* add issuer node */
diff --git a/desktop/tree.c b/desktop/tree.c
index e72ef60..c62793e 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -117,7 +117,7 @@ struct node_element {
struct node *parent; /**< Parent node */
node_element_type type; /**< Element type */
struct node_element_box box; /**< Element bounding box */
- const char *text; /**< Text for the element */
+ char *text; /**< Text for the element */
void *bitmap; /**< Bitmap for the element */
struct node_element *next; /**< Next node element */
unsigned int flag; /**< Client specified flag for data
@@ -578,25 +578,14 @@ struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
node->previous = NULL;
tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL)
+ if (parent != NULL) {
tree_link_node(tree, parent, node, false);
+ }
return node;
}
-
-/**
- * Creates a leaf node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title (not copied, used directly)
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node.
- */
+/* exported interface documented in desktop/tree.h */
struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted)
@@ -607,8 +596,12 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node = calloc(sizeof(struct node), 1);
if (node == NULL) {
- LOG(("calloc failed"));
- warn_user("NoMemory", 0);
+ return NULL;
+ }
+
+ node->data.text = strdup(title);
+ if (node->data.text == NULL) {
+ free(node);
return NULL;
}
@@ -617,7 +610,6 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node->deleted = deleted;
node->data.parent = node;
node->data.type = NODE_ELEMENT_TEXT;
- node->data.text = title;
node->data.flag = TREE_ELEMENT_TITLE;
node->data.editable = editable;
node->sort = NULL;
@@ -625,8 +617,9 @@ struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
node->previous = NULL;
tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL)
+ if (parent != NULL) {
tree_link_node(tree, parent, node, false);
+ }
return node;
}
@@ -1488,18 +1481,20 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
assert(element != NULL);
- if (tree != NULL && element == tree->editing)
+ if ((tree != NULL) && (element == tree->editing)) {
tree_stop_edit(tree, false);
+ }
- if (text != NULL && (element->type == NODE_ELEMENT_TEXT ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
+ if ((text != NULL) &&
+ (element->type == NODE_ELEMENT_TEXT ||
+ element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
if (element->text != NULL) {
- if(strcmp(element->text, text) == 0) text_changed = true;
-
+ if (strcmp(element->text, text) == 0) {
+ text_changed = true;
+ }
response = NODE_CALLBACK_NOT_HANDLED;
- if (!element->editable &&
- element->parent->user_callback !=
- NULL) {
+ if ((!element->editable) &&
+ (element->parent->user_callback != NULL)) {
msg_data.msg = NODE_DELETE_ELEMENT_TXT;
msg_data.flag = element->flag;
msg_data.node = element->parent;
@@ -1508,14 +1503,16 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
element->parent->callback_data,
&msg_data);
}
- if (response != NODE_CALLBACK_HANDLED)
- free((void *)element->text);
+ if (response != NODE_CALLBACK_HANDLED) {
+ free(element->text);
+ }
}
- element->text = text;
+ element->text = (char *)text;
}
- if (bitmap != NULL && (element->type == NODE_ELEMENT_BITMAP ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
+ if ((bitmap != NULL) &&
+ ((element->type == NODE_ELEMENT_BITMAP) ||
+ (element->type == NODE_ELEMENT_TEXT_PLUS_ICON))) {
if (element->bitmap != NULL) {
response = NODE_CALLBACK_NOT_HANDLED;
if (element->parent->user_callback != NULL) {
@@ -1527,10 +1524,11 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
element->parent->callback_data,
&msg_data);
}
- if (response != NODE_CALLBACK_HANDLED)
+
+ if (response != NODE_CALLBACK_HANDLED) {
free(element->bitmap);
- }
- else {
+ }
+ } else {
/* Increase the box width to accomodate the new icon */
element->box.width += NODE_INSTEP;
}
diff --git a/desktop/tree.h b/desktop/tree.h
index b881087..00ac999 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -153,9 +153,23 @@ struct tree *tree_create(unsigned int flags,
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
+
+/**
+ * Creates a leaf node with the specified title, and optionally links it into
+ * the tree.
+ *
+ * \param tree the owner tree of 'parent', may be NULL
+ * \param parent the parent node, or NULL not to link
+ * \param title the node title.
+ * \param editable if true, the node title will be editable
+ * \param retain_in_memory if true, the node will stay in memory after deletion
+ * \param deleted if true, the node is created with the deleted flag
+ * \return the newly created node or NULL on error.
+ */
struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
+
struct node_element *tree_create_node_element(struct node *parent,
node_element_type type, unsigned int flag, bool editable);
void tree_link_node(struct tree *tree, struct node *link, struct node *node,
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 7646048..938cd1d 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -126,35 +126,41 @@ void tree_url_node_cleanup()
* \param parent the node to link to
* \param url the URL (copied)
* \param data the URL data to use
- * \param title the custom title to use
+ * \param title custom title to use or NULL to use url
* \return the node created, or NULL for failure
*/
struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
nsurl *url, const char *title,
tree_node_user_callback user_callback, void *callback_data)
{
- struct node *node;
+ struct node *node = NULL;
struct node_element *element;
- char *text_cp, *squashed;
- squashed = squash_whitespace(title ? title : nsurl_access(url));
- text_cp = strdup(squashed);
- if (text_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
+ if (title == NULL) {
+ node = tree_create_leaf_node(tree,
+ parent,
+ nsurl_access(url),
+ true, false, false);
+ } else {
+ char *squashed;
+
+ squashed = squash_whitespace(title);
+ if (squashed != NULL) {
+ node = tree_create_leaf_node(tree,
+ parent,
+ squashed,
+ true, false, false);
+ free(squashed);
+ }
}
- free(squashed);
- node = tree_create_leaf_node(tree, parent, text_cp, true, false,
- false);
if (node == NULL) {
- free(text_cp);
return NULL;
}
- if (user_callback != NULL)
+ if (user_callback != NULL) {
tree_set_node_user_callback(node, user_callback,
callback_data);
+ }
tree_create_node_element(node, NODE_ELEMENT_BITMAP,
TREE_ELEMENT_THUMBNAIL, false);
@@ -165,7 +171,7 @@ struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
TREE_ELEMENT_URL, true);
if (element != NULL) {
- text_cp = strdup(nsurl_access(url));
+ char *text_cp = strdup(nsurl_access(url));
if (text_cp == NULL) {
tree_delete_node(tree, node, false);
LOG(("malloc failed"));
@@ -194,22 +200,18 @@ struct node *tree_create_URL_node_readonly(struct tree *tree,
{
struct node *node;
struct node_element *element;
- char *title;
+ const char *title;
assert(url && data);
if (data->title != NULL) {
- title = strdup(data->title);
+ title = data->title;
} else {
- title = strdup(nsurl_access(url));
+ title = nsurl_access(url);
}
- if (title == NULL)
- return NULL;
-
node = tree_create_leaf_node(tree, parent, title, false, false, false);
if (node == NULL) {
- free(title);
return NULL;
}
diff --git a/utils/utils.c b/utils/utils.c
index 3398a7d..8155f4a 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -98,26 +98,34 @@ char *remove_underscores(const char *s, bool replacespace)
/**
* Replace consecutive whitespace with a single space.
*
+ * @todo determine if squash_whitespace utf-8 safe and that it needs to be
+ *
* \param s source string
- * \return heap allocated result, or 0 on memory exhaustion
+ * \return heap allocated result, or NULL on memory exhaustion
*/
-char * squash_whitespace(const char *s)
+char *squash_whitespace(const char *s)
{
- char *c = malloc(strlen(s) + 1);
+ char *c;
int i = 0, j = 0;
- if (!c)
- return 0;
- do {
- if (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' ||
- s[i] == '\t') {
- c[j++] = ' ';
- while (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' ||
- s[i] == '\t')
- i++;
- }
- c[j++] = s[i++];
- } while (s[i - 1] != 0);
+
+ c = malloc(strlen(s) + 1);
+ if (c != NULL) {
+ do {
+ if (s[i] == ' ' ||
+ s[i] == '\n' ||
+ s[i] == '\r' ||
+ s[i] == '\t') {
+ c[j++] = ' ';
+ while (s[i] == ' ' ||
+ s[i] == '\n' ||
+ s[i] == '\r' ||
+ s[i] == '\t')
+ i++;
+ }
+ c[j++] = s[i++];
+ } while (s[i - 1] != 0);
+ }
return c;
}
--
NetSurf Browser
10 years
netsurf: branch master updated. release/3.0-26-g5c57a30
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5c57a30047b4c9330110e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5c57a30047b4c9330110e5d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5c57a30047b4c9330110e5de9...
The branch, master has been updated
via 5c57a30047b4c9330110e5de9f5f406571f9baf1 (commit)
from 6c7ca26bdc88ac95feb53b647c1c3b33f602f04c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5c57a30047b4c933011...
commit 5c57a30047b4c9330110e5de9f5f406571f9baf1
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
cleanup title string ownership madness in the tree_create_folder_node() API
diff --git a/desktop/cookies.c b/desktop/cookies.c
index 581e1cc..539be3e 100644
--- a/desktop/cookies.c
+++ b/desktop/cookies.c
@@ -329,44 +329,33 @@ static void cookies_schedule_callback(const void *scheduled_data)
const struct cookie_data *data = scheduled_data;
struct node *node = NULL;
struct node *cookie_node = NULL;
- char *domain_cp;
assert(data != NULL);
node = cookies_find(cookies_tree_root, data->domain);
if (node == NULL) {
- domain_cp = strdup(data->domain);
- if (domain_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
- /* ownership of domain_cp passed to tree, if node creation
- * does not fail */
node = tree_create_folder_node(cookies_tree,
- cookies_tree_root, domain_cp,
+ cookies_tree_root,
+ data->domain,
false, false, false);
if (node != NULL) {
- tree_set_node_user_callback(node, cookies_node_callback,
+ tree_set_node_user_callback(node,
+ cookies_node_callback,
NULL);
tree_set_node_icon(cookies_tree, node, folder_icon);
-
- } else {
- free(domain_cp);
}
}
- if (node == NULL)
- return;
-
- cookie_node = cookies_find(node, data->name);
- if (cookie_node == NULL)
- cookies_create_cookie_node(node, data);
- else
- cookies_update_cookie_node(cookie_node, data);
+ if (node != NULL) {
+ cookie_node = cookies_find(node, data->name);
+ if (cookie_node == NULL) {
+ cookies_create_cookie_node(node, data);
+ } else {
+ cookies_update_cookie_node(cookie_node, data);
+ }
- return;
+ }
}
/**
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index 3222dc7..2a941e0 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -175,33 +175,24 @@ static bool history_global_initialise_node(const char *title,
time_t base, int days_back)
{
struct tm *full_time;
- char *buffer;
struct node *node;
base += days_back * 60 * 60 * 24;
if (title == NULL) {
full_time = localtime(&base);
- buffer = strdup(messages_get(weekday_msg_name[full_time->tm_wday]));
- } else {
- buffer = strdup(title);
+ title = messages_get(weekday_msg_name[full_time->tm_wday]);
}
- if (buffer == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return false;
- }
-
- node = tree_create_folder_node(NULL, NULL, buffer,
- false, true, true);
+ node = tree_create_folder_node(NULL, NULL, title, false, true, true);
if (node == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- free(buffer);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return false;
}
- if (folder_icon != NULL)
+
+ if (folder_icon != NULL) {
tree_set_node_icon(global_history_tree, node, folder_icon);
+ }
+
tree_set_node_user_callback(node, history_global_node_callback, NULL);
global_history_base_node[global_history_base_node_count] = node;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index e2386fc..20cc8ea 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -121,7 +121,6 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
{
struct node *node;
const struct url_data *url_data;
- char *name;
int hlst_loop;
/* Either load or create a hotlist */
@@ -143,18 +142,15 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
return true;
}
-
/* failed to load hotlist file, use default list */
- name = strdup("NetSurf");
- if (name == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return false;
- }
- node = tree_create_folder_node(hotlist_tree, hotlist_tree_root,
- name, true, false, false);
+ node = tree_create_folder_node(hotlist_tree,
+ hotlist_tree_root,
+ messages_get("NetSurf"),
+ true,
+ false,
+ false);
if (node == NULL) {
- free(name);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return false;
}
@@ -373,14 +369,7 @@ void hotlist_collapse_addresses(void)
void hotlist_add_folder(bool selected)
{
struct node *node, *parent = NULL;
- struct node_element *element;
- char *title = strdup("Untitled");
- if (title == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
creating_node = true;
if (selected == true) {
@@ -394,16 +383,21 @@ void hotlist_add_folder(bool selected)
parent = tree_get_default_folder_node(hotlist_tree);
}
- node = tree_create_folder_node(hotlist_tree, parent, title,
- true, false, false);
+ node = tree_create_folder_node(hotlist_tree,
+ parent,
+ messages_get("Untitled"),
+ true,
+ false,
+ false);
if (node == NULL) {
- free(title);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return;
}
+
tree_set_node_user_callback(node, hotlist_node_callback, NULL);
tree_set_node_icon(hotlist_tree, node, folder_icon);
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(hotlist_tree, element);
+ tree_start_edit(hotlist_tree,
+ tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL));
}
/**
diff --git a/desktop/tree.c b/desktop/tree.c
index af64be8..e72ef60 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -233,26 +233,19 @@ struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks, void *client_data)
{
struct tree *tree;
- char *title;
tree = calloc(sizeof(struct tree), 1);
if (tree == NULL) {
LOG(("calloc failed"));
- warn_user("NoMemory", 0);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return NULL;
}
- title = strdup("Root");
- if (title == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- free(tree);
- return NULL;
- }
- tree->root = tree_create_folder_node(NULL, NULL, title,
+ tree->root = tree_create_folder_node(NULL,
+ NULL,
+ messages_get("Root"),
false, false, false);
if (tree->root == NULL) {
- free(title);
free(tree);
return NULL;
}
@@ -553,18 +546,7 @@ static void tree_recalculate_node_sizes(struct tree *tree, struct node *node,
}
-/**
- * Creates a folder node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title (not copied, used directly)
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node.
- */
+/* exported interface documented in desktop/tree.h */
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted)
@@ -575,16 +557,20 @@ struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
node = calloc(sizeof(struct node), 1);
if (node == NULL) {
- LOG(("calloc failed"));
- warn_user("NoMemory", 0);
return NULL;
}
+
+ node->data.text = strdup(title);
+ if (node->data.text == NULL) {
+ free(node);
+ return NULL;
+ }
+
node->folder = true;
node->retain_in_memory = retain_in_memory;
node->deleted = deleted;
node->data.parent = node;
node->data.type = NODE_ELEMENT_TEXT;
- node->data.text = title;
node->data.flag = TREE_ELEMENT_TITLE;
node->data.editable = editable;
node->sort = NULL;
diff --git a/desktop/tree.h b/desktop/tree.h
index 8ac5057..b881087 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -137,6 +137,19 @@ void tree_setup_colours(void);
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks,
void *client_data);
+
+/**
+ * Creates a folder node with the specified title, and optionally links it into
+ * the tree.
+ *
+ * \param tree the owner tree of 'parent', may be NULL
+ * \param parent the parent node, or NULL not to link
+ * \param title the node title
+ * \param editable if true, the node title will be editable
+ * \param retain_in_memory if true, the node will stay in memory after deletion
+ * \param deleted if true, the node is created with the deleted flag
+ * \return the newly created node or NULL on error.
+ */
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 76bc8a4..7646048 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -683,6 +683,7 @@ static bool tree_url_load_directory_cb(dom_node *node, void *ctx)
dir = tree_create_folder_node(tctx->tree, tctx->directory,
title, true, false, false);
+ free(title);
if (dir == NULL) {
dom_string_unref(name);
return false;
-----------------------------------------------------------------------
Summary of changes:
desktop/cookies.c | 35 ++++++++++++-----------------------
desktop/history_global_core.c | 23 +++++++----------------
desktop/hotlist.c | 40 +++++++++++++++++-----------------------
desktop/tree.c | 38 ++++++++++++--------------------------
desktop/tree.h | 13 +++++++++++++
desktop/tree_url_node.c | 1 +
6 files changed, 62 insertions(+), 88 deletions(-)
diff --git a/desktop/cookies.c b/desktop/cookies.c
index 581e1cc..539be3e 100644
--- a/desktop/cookies.c
+++ b/desktop/cookies.c
@@ -329,44 +329,33 @@ static void cookies_schedule_callback(const void *scheduled_data)
const struct cookie_data *data = scheduled_data;
struct node *node = NULL;
struct node *cookie_node = NULL;
- char *domain_cp;
assert(data != NULL);
node = cookies_find(cookies_tree_root, data->domain);
if (node == NULL) {
- domain_cp = strdup(data->domain);
- if (domain_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
- /* ownership of domain_cp passed to tree, if node creation
- * does not fail */
node = tree_create_folder_node(cookies_tree,
- cookies_tree_root, domain_cp,
+ cookies_tree_root,
+ data->domain,
false, false, false);
if (node != NULL) {
- tree_set_node_user_callback(node, cookies_node_callback,
+ tree_set_node_user_callback(node,
+ cookies_node_callback,
NULL);
tree_set_node_icon(cookies_tree, node, folder_icon);
-
- } else {
- free(domain_cp);
}
}
- if (node == NULL)
- return;
-
- cookie_node = cookies_find(node, data->name);
- if (cookie_node == NULL)
- cookies_create_cookie_node(node, data);
- else
- cookies_update_cookie_node(cookie_node, data);
+ if (node != NULL) {
+ cookie_node = cookies_find(node, data->name);
+ if (cookie_node == NULL) {
+ cookies_create_cookie_node(node, data);
+ } else {
+ cookies_update_cookie_node(cookie_node, data);
+ }
- return;
+ }
}
/**
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index 3222dc7..2a941e0 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -175,33 +175,24 @@ static bool history_global_initialise_node(const char *title,
time_t base, int days_back)
{
struct tm *full_time;
- char *buffer;
struct node *node;
base += days_back * 60 * 60 * 24;
if (title == NULL) {
full_time = localtime(&base);
- buffer = strdup(messages_get(weekday_msg_name[full_time->tm_wday]));
- } else {
- buffer = strdup(title);
+ title = messages_get(weekday_msg_name[full_time->tm_wday]);
}
- if (buffer == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return false;
- }
-
- node = tree_create_folder_node(NULL, NULL, buffer,
- false, true, true);
+ node = tree_create_folder_node(NULL, NULL, title, false, true, true);
if (node == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- free(buffer);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return false;
}
- if (folder_icon != NULL)
+
+ if (folder_icon != NULL) {
tree_set_node_icon(global_history_tree, node, folder_icon);
+ }
+
tree_set_node_user_callback(node, history_global_node_callback, NULL);
global_history_base_node[global_history_base_node_count] = node;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index e2386fc..20cc8ea 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -121,7 +121,6 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
{
struct node *node;
const struct url_data *url_data;
- char *name;
int hlst_loop;
/* Either load or create a hotlist */
@@ -143,18 +142,15 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
return true;
}
-
/* failed to load hotlist file, use default list */
- name = strdup("NetSurf");
- if (name == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return false;
- }
- node = tree_create_folder_node(hotlist_tree, hotlist_tree_root,
- name, true, false, false);
+ node = tree_create_folder_node(hotlist_tree,
+ hotlist_tree_root,
+ messages_get("NetSurf"),
+ true,
+ false,
+ false);
if (node == NULL) {
- free(name);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return false;
}
@@ -373,14 +369,7 @@ void hotlist_collapse_addresses(void)
void hotlist_add_folder(bool selected)
{
struct node *node, *parent = NULL;
- struct node_element *element;
- char *title = strdup("Untitled");
- if (title == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
creating_node = true;
if (selected == true) {
@@ -394,16 +383,21 @@ void hotlist_add_folder(bool selected)
parent = tree_get_default_folder_node(hotlist_tree);
}
- node = tree_create_folder_node(hotlist_tree, parent, title,
- true, false, false);
+ node = tree_create_folder_node(hotlist_tree,
+ parent,
+ messages_get("Untitled"),
+ true,
+ false,
+ false);
if (node == NULL) {
- free(title);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return;
}
+
tree_set_node_user_callback(node, hotlist_node_callback, NULL);
tree_set_node_icon(hotlist_tree, node, folder_icon);
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(hotlist_tree, element);
+ tree_start_edit(hotlist_tree,
+ tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL));
}
/**
diff --git a/desktop/tree.c b/desktop/tree.c
index af64be8..e72ef60 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -233,26 +233,19 @@ struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks, void *client_data)
{
struct tree *tree;
- char *title;
tree = calloc(sizeof(struct tree), 1);
if (tree == NULL) {
LOG(("calloc failed"));
- warn_user("NoMemory", 0);
+ warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
return NULL;
}
- title = strdup("Root");
- if (title == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- free(tree);
- return NULL;
- }
- tree->root = tree_create_folder_node(NULL, NULL, title,
+ tree->root = tree_create_folder_node(NULL,
+ NULL,
+ messages_get("Root"),
false, false, false);
if (tree->root == NULL) {
- free(title);
free(tree);
return NULL;
}
@@ -553,18 +546,7 @@ static void tree_recalculate_node_sizes(struct tree *tree, struct node *node,
}
-/**
- * Creates a folder node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title (not copied, used directly)
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node.
- */
+/* exported interface documented in desktop/tree.h */
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted)
@@ -575,16 +557,20 @@ struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
node = calloc(sizeof(struct node), 1);
if (node == NULL) {
- LOG(("calloc failed"));
- warn_user("NoMemory", 0);
return NULL;
}
+
+ node->data.text = strdup(title);
+ if (node->data.text == NULL) {
+ free(node);
+ return NULL;
+ }
+
node->folder = true;
node->retain_in_memory = retain_in_memory;
node->deleted = deleted;
node->data.parent = node;
node->data.type = NODE_ELEMENT_TEXT;
- node->data.text = title;
node->data.flag = TREE_ELEMENT_TITLE;
node->data.editable = editable;
node->sort = NULL;
diff --git a/desktop/tree.h b/desktop/tree.h
index 8ac5057..b881087 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -137,6 +137,19 @@ void tree_setup_colours(void);
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks,
void *client_data);
+
+/**
+ * Creates a folder node with the specified title, and optionally links it into
+ * the tree.
+ *
+ * \param tree the owner tree of 'parent', may be NULL
+ * \param parent the parent node, or NULL not to link
+ * \param title the node title
+ * \param editable if true, the node title will be editable
+ * \param retain_in_memory if true, the node will stay in memory after deletion
+ * \param deleted if true, the node is created with the deleted flag
+ * \return the newly created node or NULL on error.
+ */
struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
const char *title, bool editable, bool retain_in_memory,
bool deleted);
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 76bc8a4..7646048 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -683,6 +683,7 @@ static bool tree_url_load_directory_cb(dom_node *node, void *ctx)
dir = tree_create_folder_node(tctx->tree, tctx->directory,
title, true, false, false);
+ free(title);
if (dir == NULL) {
dom_string_unref(name);
return false;
--
NetSurf Browser
10 years
netsurf: branch master updated. release/3.0-25-g6c7ca26
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6c7ca26bdc88ac95feb53...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6c7ca26bdc88ac95feb53b6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6c7ca26bdc88ac95feb53b647...
The branch, master has been updated
via 6c7ca26bdc88ac95feb53b647c1c3b33f602f04c (commit)
via f889f0ccbf354792e355ec8fc3fe7654552f2864 (commit)
from 4c4dff3384ef87a537cb57dd893c9b7a1d3a441d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6c7ca26bdc88ac95feb...
commit 6c7ca26bdc88ac95feb53b647c1c3b33f602f04c
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
FatMessages had strings in latin1 encoding now converted to utf-8
diff --git a/resources/FatMessages b/resources/FatMessages
index 32acda8..82c64ce 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2334,7 +2334,7 @@ nl.all.SSLCerts:SSL certificates
en.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
de.all.SSLError:NetSurf konnte ein SSL Zertifikat nicht prüfen. Bitte die Details unten beachten.
fr.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
-it.all.SSLError:NetSurf non � stato in grado di verificare l'autenticit� di questo certificato SSL, per favore verifica i dettagli presenti di seguito
+it.all.SSLError:NetSurf non è stato in grado di verificare l'autenticità di questo certificato SSL, per favore verifica i dettagli presenti di seguito
nl.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
en.all.SSL_Certificate_Subject:Subject: %s
de.all.SSL_Certificate_Subject:Subject: %s
@@ -2744,7 +2744,7 @@ nl.all.HotlistSaveError:The hotlist was unable to be correctly saved.
en.all.TreeLoadError:The tree was unable to be correctly loaded.
de.all.TreeLoadError:The tree was unable to be correctly loaded.
fr.all.TreeLoadError:The tree was unable to be correctly loaded.
-it.all.TreeLoadError:L'albero non � stato caricato correttamente.
+it.all.TreeLoadError:L'albero non è stato caricato correttamente.
nl.all.TreeLoadError:The tree was unable to be correctly loaded.
en.all.NoDirError:%s is not a directory
de.all.NoDirError:%s ist kein Verzeichnis.
@@ -5011,7 +5011,7 @@ nl.ro.HelpInterfaceConfig13:\Ssave these settings and close the \w.|M\Asave thes
en.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
de.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
fr.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
-it.ro.HelpInterfaceConfig16:This indicates whether NetSurf�will�use�an�external�hotlist�client�if�available,�in�preference�to�the�internal�hotlist.
+it.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
nl.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
en.ro.HelpInterfaceConfig18:\Tthe path to a hotlist application which will be used to display the hotlist.
de.ro.HelpInterfaceConfig18:\Tthe path to a hotlist application which will be used to display the hotlist.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f889f0ccbf354792e35...
commit f889f0ccbf354792e355ec8fc3fe7654552f2864
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fix leak in error path
diff --git a/content/content.c b/content/content.c
index 3533d94..9482fb9 100644
--- a/content/content.c
+++ b/content/content.c
@@ -92,6 +92,7 @@ nserror content__init(struct content *c, const content_handler *handler,
if (fallback_charset != NULL) {
c->fallback_charset = strdup(fallback_charset);
if (c->fallback_charset == NULL) {
+ free(user_sentinel);
return NSERROR_NOMEM;
}
}
-----------------------------------------------------------------------
Summary of changes:
content/content.c | 1 +
resources/FatMessages | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/content/content.c b/content/content.c
index 3533d94..9482fb9 100644
--- a/content/content.c
+++ b/content/content.c
@@ -92,6 +92,7 @@ nserror content__init(struct content *c, const content_handler *handler,
if (fallback_charset != NULL) {
c->fallback_charset = strdup(fallback_charset);
if (c->fallback_charset == NULL) {
+ free(user_sentinel);
return NSERROR_NOMEM;
}
}
diff --git a/resources/FatMessages b/resources/FatMessages
index 32acda8..82c64ce 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2334,7 +2334,7 @@ nl.all.SSLCerts:SSL certificates
en.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
de.all.SSLError:NetSurf konnte ein SSL Zertifikat nicht prüfen. Bitte die Details unten beachten.
fr.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
-it.all.SSLError:NetSurf non � stato in grado di verificare l'autenticit� di questo certificato SSL, per favore verifica i dettagli presenti di seguito
+it.all.SSLError:NetSurf non è stato in grado di verificare l'autenticità di questo certificato SSL, per favore verifica i dettagli presenti di seguito
nl.all.SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below.
en.all.SSL_Certificate_Subject:Subject: %s
de.all.SSL_Certificate_Subject:Subject: %s
@@ -2744,7 +2744,7 @@ nl.all.HotlistSaveError:The hotlist was unable to be correctly saved.
en.all.TreeLoadError:The tree was unable to be correctly loaded.
de.all.TreeLoadError:The tree was unable to be correctly loaded.
fr.all.TreeLoadError:The tree was unable to be correctly loaded.
-it.all.TreeLoadError:L'albero non � stato caricato correttamente.
+it.all.TreeLoadError:L'albero non è stato caricato correttamente.
nl.all.TreeLoadError:The tree was unable to be correctly loaded.
en.all.NoDirError:%s is not a directory
de.all.NoDirError:%s ist kein Verzeichnis.
@@ -5011,7 +5011,7 @@ nl.ro.HelpInterfaceConfig13:\Ssave these settings and close the \w.|M\Asave thes
en.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
de.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
fr.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
-it.ro.HelpInterfaceConfig16:This indicates whether NetSurf�will�use�an�external�hotlist�client�if�available,�in�preference�to�the�internal�hotlist.
+it.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
nl.ro.HelpInterfaceConfig16:This indicates whether NetSurf will use an external hotlist client if available, in preference to the internal hotlist.
en.ro.HelpInterfaceConfig18:\Tthe path to a hotlist application which will be used to display the hotlist.
de.ro.HelpInterfaceConfig18:\Tthe path to a hotlist application which will be used to display the hotlist.
--
NetSurf Browser
10 years
nsgenjsbind: branch master updated. release/0.0.1-1-g51bd180
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/51bd18034c510a6d4...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/51bd18034c510a6d471...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/51bd18034c510a6d47118...
The branch, master has been updated
via 51bd18034c510a6d4711823e08b69af2f7aa063e (commit)
from 4fae88dac6f26991335a66948ad29f480f7f148f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commit/?id=51bd18034c510a6...
commit 51bd18034c510a6d4711823e08b69af2f7aa063e
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fix building teh lexers with bison versions at and after 2.6
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index b257c83..8189a72 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -19,6 +19,16 @@
yylloc->first_column = yylloc->last_column + 1; \
yylloc->last_column += yyleng;
+
+/* Ensure compatability with bison 2.6 and later */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED && defined NSGENBIND_STYPE_IS_DECLARED
+#define YYSTYPE NSGENBIND_STYPE
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED && defined NSGENBIND_LTYPE_IS_DECLARED
+#define YYLTYPE NSGENBIND_LTYPE
+#endif
+
%}
/* lexer options */
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 5369d99..74b9bb8 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -27,6 +27,15 @@
yylloc->first_column = yylloc->last_column + 1; \
yylloc->last_column += yyleng;
+/* Ensure compatability with bison 2.6 and later */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED && defined WEBIDL_STYPE_IS_DECLARED
+#define YYSTYPE WEBIDL_STYPE
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED && defined WEBIDL_LTYPE_IS_DECLARED
+#define YYLTYPE WEBIDL_LTYPE
+#endif
+
%}
-----------------------------------------------------------------------
Summary of changes:
src/nsgenbind-lexer.l | 10 ++++++++++
src/webidl-lexer.l | 9 +++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index b257c83..8189a72 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -19,6 +19,16 @@
yylloc->first_column = yylloc->last_column + 1; \
yylloc->last_column += yyleng;
+
+/* Ensure compatability with bison 2.6 and later */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED && defined NSGENBIND_STYPE_IS_DECLARED
+#define YYSTYPE NSGENBIND_STYPE
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED && defined NSGENBIND_LTYPE_IS_DECLARED
+#define YYLTYPE NSGENBIND_LTYPE
+#endif
+
%}
/* lexer options */
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 5369d99..74b9bb8 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -27,6 +27,15 @@
yylloc->first_column = yylloc->last_column + 1; \
yylloc->last_column += yyleng;
+/* Ensure compatability with bison 2.6 and later */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED && defined WEBIDL_STYPE_IS_DECLARED
+#define YYSTYPE WEBIDL_STYPE
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED && defined WEBIDL_LTYPE_IS_DECLARED
+#define YYLTYPE WEBIDL_LTYPE
+#endif
+
%}
--
NetSurf Generator for JavaScript bindings
10 years
netsurf: branch master updated. release/3.0-23-g4c4dff3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4c4dff3384ef87a537cb5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4c4dff3384ef87a537cb57d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4c4dff3384ef87a537cb57dd8...
The branch, master has been updated
via 4c4dff3384ef87a537cb57dd893c9b7a1d3a441d (commit)
from 98369b74e21fb5cf769fcfdf0e717cf6592736c1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4c4dff3384ef87a537c...
commit 4c4dff3384ef87a537cb57dd893c9b7a1d3a441d
Author: Vivek Dasmohapatra <vivek(a)collabora.co.uk>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Improvements to generated output
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 08d8822..45e5539 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -49,7 +49,7 @@ my %opt = qw( plat any format messages );
sub input_stream ();
sub output_stream ();
sub formatter ();
-sub header ();
+sub static_section($);
sub usage ();
sub main ()
@@ -58,6 +58,7 @@ sub main ()
my $output;
my $format;
my $header;
+ my $footer;
my $opt_ok;
# option parsing:
@@ -74,7 +75,8 @@ sub main ()
$input = input_stream();
$output = output_stream();
$format = formatter();
- $header = header();
+ $header = static_section('header');
+ $footer = static_section('footer');
}
# double check the options are sane (and we weren't asked for the help)
@@ -100,7 +102,7 @@ sub main ()
$opt{plat} eq $plat ||
'all' eq $plat )
{
- print( $output $format->( $key, $val ), "\n" );
+ print( $output $format->( $key, $val ) );
}
}
else
@@ -108,6 +110,8 @@ sub main ()
warn( "Malformed entry: $_" );
}
}
+
+ print( $output $footer );
}
main();
@@ -169,10 +173,11 @@ sub formatter ()
return $func || die( "No handler found for format '$name'\n" );
}
-sub header ()
+sub static_section ($)
{
my $name = $opt{format};
- my $func = "msgfmt::$name"->UNIVERSAL::can("header");
+ my $sect = shift();
+ my $func = "msgfmt::$name"->UNIVERSAL::can( $sect );
return $func ? $func->() : "";
}
@@ -181,17 +186,15 @@ sub header ()
{
package msgfmt::java;
- # escape characters spec says ' should be escaped here but
- # transifex does not recognise it. hence [\\:] and not [\\:']
- sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
- sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+ sub escape { $_[0] =~ s/([:'\\])/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
}
{
- package msgfmt::messages;
+ package msgfmt::messages; # native netsurf format
- sub format { return join( ":", @_ ) }
+ sub format { return join( ":", @_ ) . "\n" }
sub header
{
my $in = $opt{input} || '-stdin-';
@@ -202,6 +205,19 @@ TXT
}
}
+{
+ package msgfmt::transifex;
+ use base 'msgfmt::java';
+
+ # transifex has the following quirks:
+ # \ processing is buggy - they re-process every \\ as a \
+ # so \\n, instead or producing literal '\n', is interpreted as \ ^J
+ # Additionally, although the java properties format specifies
+ # that ' should be \ escaped, transifex does not allow/support this:
+ sub escape { $_[0] =~ s/(:|\\(?![abfnrtv]))/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
+}
+
########### YAML ###########
#{
# package msgfmt::yaml;
@@ -209,18 +225,15 @@ TXT
# print Dump %data;
#}
-######## android properties ########
-#{
-# package msgfmt::android;
-# use HTML::Entities;
-# print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
-# foreach my $lang (sort keys %data) {
-# foreach my $plat (sort keys %{$data{$lang}}) {
-# foreach my $key (sort keys %{$data{$lang}{$plat}}) {
-# my $val = $data{$lang}{$plat}{$key};
-# print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
-# }
-# }
-# }
-# print "</resources>";
-#}
+{
+ package msgfmt::android;
+
+ sub header { qq|<?xml version="1.0" encoding="utf-8"?>\n<resources>\n| }
+ sub footer { qq|</resources>| }
+ sub format
+ {
+ use HTML::Entities qw(encode_entities);
+ my $escaped = encode_entities( $_[1], '<>&"' );
+ qq| <string name="$_[0]">$escaped</string>\n|;
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
utils/split-messages.pl | 65 ++++++++++++++++++++++++++++------------------
1 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 08d8822..45e5539 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -49,7 +49,7 @@ my %opt = qw( plat any format messages );
sub input_stream ();
sub output_stream ();
sub formatter ();
-sub header ();
+sub static_section($);
sub usage ();
sub main ()
@@ -58,6 +58,7 @@ sub main ()
my $output;
my $format;
my $header;
+ my $footer;
my $opt_ok;
# option parsing:
@@ -74,7 +75,8 @@ sub main ()
$input = input_stream();
$output = output_stream();
$format = formatter();
- $header = header();
+ $header = static_section('header');
+ $footer = static_section('footer');
}
# double check the options are sane (and we weren't asked for the help)
@@ -100,7 +102,7 @@ sub main ()
$opt{plat} eq $plat ||
'all' eq $plat )
{
- print( $output $format->( $key, $val ), "\n" );
+ print( $output $format->( $key, $val ) );
}
}
else
@@ -108,6 +110,8 @@ sub main ()
warn( "Malformed entry: $_" );
}
}
+
+ print( $output $footer );
}
main();
@@ -169,10 +173,11 @@ sub formatter ()
return $func || die( "No handler found for format '$name'\n" );
}
-sub header ()
+sub static_section ($)
{
my $name = $opt{format};
- my $func = "msgfmt::$name"->UNIVERSAL::can("header");
+ my $sect = shift();
+ my $func = "msgfmt::$name"->UNIVERSAL::can( $sect );
return $func ? $func->() : "";
}
@@ -181,17 +186,15 @@ sub header ()
{
package msgfmt::java;
- # escape characters spec says ' should be escaped here but
- # transifex does not recognise it. hence [\\:] and not [\\:']
- sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
- sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+ sub escape { $_[0] =~ s/([:'\\])/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
}
{
- package msgfmt::messages;
+ package msgfmt::messages; # native netsurf format
- sub format { return join( ":", @_ ) }
+ sub format { return join( ":", @_ ) . "\n" }
sub header
{
my $in = $opt{input} || '-stdin-';
@@ -202,6 +205,19 @@ TXT
}
}
+{
+ package msgfmt::transifex;
+ use base 'msgfmt::java';
+
+ # transifex has the following quirks:
+ # \ processing is buggy - they re-process every \\ as a \
+ # so \\n, instead or producing literal '\n', is interpreted as \ ^J
+ # Additionally, although the java properties format specifies
+ # that ' should be \ escaped, transifex does not allow/support this:
+ sub escape { $_[0] =~ s/(:|\\(?![abfnrtv]))/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
+}
+
########### YAML ###########
#{
# package msgfmt::yaml;
@@ -209,18 +225,15 @@ TXT
# print Dump %data;
#}
-######## android properties ########
-#{
-# package msgfmt::android;
-# use HTML::Entities;
-# print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
-# foreach my $lang (sort keys %data) {
-# foreach my $plat (sort keys %{$data{$lang}}) {
-# foreach my $key (sort keys %{$data{$lang}{$plat}}) {
-# my $val = $data{$lang}{$plat}{$key};
-# print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
-# }
-# }
-# }
-# print "</resources>";
-#}
+{
+ package msgfmt::android;
+
+ sub header { qq|<?xml version="1.0" encoding="utf-8"?>\n<resources>\n| }
+ sub footer { qq|</resources>| }
+ sub format
+ {
+ use HTML::Entities qw(encode_entities);
+ my $escaped = encode_entities( $_[1], '<>&"' );
+ qq| <string name="$_[0]">$escaped</string>\n|;
+ }
+}
--
NetSurf Browser
10 years
netsurf: branch master updated. release/3.0-22-g98369b7
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/98369b74e21fb5cf769fc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/98369b74e21fb5cf769fcfd...
...tree http://git.netsurf-browser.org/netsurf.git/tree/98369b74e21fb5cf769fcfdf0...
The branch, master has been updated
via 98369b74e21fb5cf769fcfdf0e717cf6592736c1 (commit)
from 2f03a0bfaf10f3bba7c041d7d5189f764735d5fd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=98369b74e21fb5cf769...
commit 98369b74e21fb5cf769fcfdf0e717cf6592736c1
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fixup message splitting with updated tool
diff --git a/Makefile b/Makefile
index e57800b..88cb9bb 100644
--- a/Makefile
+++ b/Makefile
@@ -137,6 +137,7 @@ PERL=perl
MKDIR=mkdir
TOUCH=touch
STRIP=strip
+SPLIT_MESSAGES=$(PERL) utils/split-messages.pl
# Override this only if the host compiler is called something different
HOST_CC := gcc
@@ -744,7 +745,7 @@ FAT_LANGUAGES=de en fr it nl
define split_install_messages
$(foreach LANG, $(FAT_LANGUAGES), @echo MSGSPLIT: $(1)/$(LANG) to $(2)
$(Q)mkdir -p $(2)/$(LANG)$(3)
- $(Q)$(PERL) utils/split-messages.pl -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
+ $(Q)$(SPLIT_MESSAGES) -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
)
endef
diff --git a/amiga/pkg/makepackage b/amiga/pkg/makepackage
index dcc130a..4f5eb84 100755
--- a/amiga/pkg/makepackage
+++ b/amiga/pkg/makepackage
@@ -27,8 +27,8 @@ makedir ram:NetSurf/SObjs
copy sobjs:libjpeg.so.8 sobjs:libcurl.so.7 sobjs:librtmp.so.0 sobjs:libsvgtiny.so.0 sobjs:libssl.so.1.0.0 sobjs:libcrypto.so.1.0.0 sobjs:libcss.so.0 sobjs:libwapcaplet.so.0 sobjs:libpng12.so sobjs:libdom.so.0 sobjs:libhubbub.so.0 ram:NetSurf/SObjs clone
;sobjs:libhpdf-2.2.0.so.0.0
echo "Splitting Messages file"
-perl utils/split-messages.pl de ami < resources/FatMessages >RAM:NetSurf/Resources/de/Messages
-perl utils/split-messages.pl en ami < resources/FatMessages >RAM:NetSurf/Resources/en/Messages
-perl utils/split-messages.pl fr ami < resources/FatMessages >RAM:NetSurf/Resources/fr/Messages
-perl utils/split-messages.pl it ami < resources/FatMessages >RAM:NetSurf/Resources/it/Messages
-perl utils/split-messages.pl nl ami < resources/FatMessages >RAM:NetSurf/Resources/nl/Messages
+perl utils/split-messages.pl -l de -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/de/Messages
+perl utils/split-messages.pl -l en -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/en/Messages
+perl utils/split-messages.pl -l fr -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/fr/Messages
+perl utils/split-messages.pl -l it -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/it/Messages
+perl utils/split-messages.pl -l nl -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/nl/Messages
diff --git a/atari/Makefile.target b/atari/Makefile.target
index d339292..95d675f 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -191,9 +191,8 @@ endif
$(Q)cp \!NetSurf/Resources/internal.css,f79 $(ATARI_TARGET_DIR)res/internal.css
$(Q)cp \!NetSurf/Resources/SearchEngines $(ATARI_TARGET_DIR)res/search
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
-# $(Q)cp resources/FatMessages $(ATARI_TARGET_DIR)res/messages
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
- $(Q)$(PERL) utils/split-messages.pl en all < resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
$(Q)cp \!NetSurf/Resources/en/welcome.html,faf $(ATARI_TARGET_DIR)res/welcome.html
$(Q)cp \!NetSurf/Resources/en/licence.html,faf $(ATARI_TARGET_DIR)res/licence.html
$(Q)cp \!NetSurf/Resources/en/credits.html,faf $(ATARI_TARGET_DIR)res/credits.html
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 2da4c5b..7e2c198 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -168,7 +168,7 @@ $$(OBJROOT)/$(1).lproj: $(2)
$(VQ)echo Bundling language $(1)
$(Q)mkdir -p $$@
$(Q)cp -pLR $(2) $$@
- $(Q)$(PERL) utils/split-messages.pl $(1) cocoa < resources/FatMessages > $$@/Messages
+ $(Q)$(SPLIT_MESSAGES) -l $(1) -p cocoa -f messages resources/FatMessages > $$@/Messages
endef
# compile_xib (xib) (lang)
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index 8ab8804..1441710 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -171,7 +171,7 @@ install-framebuffer:
$(Q)mkdir -p $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)
$(Q)cp -v $(EXETARGET) $(DESTDIR)/$(NETSURF_FRAMEBUFFER_BIN)netsurf$(SUBTARGET)
$(Q)for F in $(NETSURF_FRAMEBUFFER_RESOURCE_LIST); do cp -vL framebuffer/res/$$F $(DESTDIR)/$(NETSURF_FRAMEBUFFER_RESOURCES); done
- $(Q)$(PERL) utils/split-messages.pl en all < resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
# ----------------------------------------------------------------------------
# Package target
diff --git a/windows/Makefile.target b/windows/Makefile.target
index 33a9492..defb765 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -92,7 +92,7 @@ WIN_RES_OBJ := installer.nsi NetSurf.ico netsurf.png welcome.html default.css
WIN_RES_INS_OBJ := $(addprefix windows/res/,$(WIN_RES_OBJ)) $(OBJROOT)/messages
$(OBJROOT)/messages: resources/FatMessages
- $(PERL) utils/split-messages.pl en all < resources/FatMessages > $@
+ $(Q)$(SPLIT_MESSAGES) -l en -p win -f messages resources/FatMessages > $@
netsurf-installer.exe: $(EXETARGET) $(WIN_RES_INS_OBJ)
makensis -V4 -NOCD windows/res/installer.nsi
-----------------------------------------------------------------------
Summary of changes:
Makefile | 3 ++-
amiga/pkg/makepackage | 10 +++++-----
atari/Makefile.target | 3 +--
cocoa/Makefile.target | 2 +-
framebuffer/Makefile.target | 2 +-
windows/Makefile.target | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index e57800b..88cb9bb 100644
--- a/Makefile
+++ b/Makefile
@@ -137,6 +137,7 @@ PERL=perl
MKDIR=mkdir
TOUCH=touch
STRIP=strip
+SPLIT_MESSAGES=$(PERL) utils/split-messages.pl
# Override this only if the host compiler is called something different
HOST_CC := gcc
@@ -744,7 +745,7 @@ FAT_LANGUAGES=de en fr it nl
define split_install_messages
$(foreach LANG, $(FAT_LANGUAGES), @echo MSGSPLIT: $(1)/$(LANG) to $(2)
$(Q)mkdir -p $(2)/$(LANG)$(3)
- $(Q)$(PERL) utils/split-messages.pl -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
+ $(Q)$(SPLIT_MESSAGES) -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
)
endef
diff --git a/amiga/pkg/makepackage b/amiga/pkg/makepackage
index dcc130a..4f5eb84 100755
--- a/amiga/pkg/makepackage
+++ b/amiga/pkg/makepackage
@@ -27,8 +27,8 @@ makedir ram:NetSurf/SObjs
copy sobjs:libjpeg.so.8 sobjs:libcurl.so.7 sobjs:librtmp.so.0 sobjs:libsvgtiny.so.0 sobjs:libssl.so.1.0.0 sobjs:libcrypto.so.1.0.0 sobjs:libcss.so.0 sobjs:libwapcaplet.so.0 sobjs:libpng12.so sobjs:libdom.so.0 sobjs:libhubbub.so.0 ram:NetSurf/SObjs clone
;sobjs:libhpdf-2.2.0.so.0.0
echo "Splitting Messages file"
-perl utils/split-messages.pl de ami < resources/FatMessages >RAM:NetSurf/Resources/de/Messages
-perl utils/split-messages.pl en ami < resources/FatMessages >RAM:NetSurf/Resources/en/Messages
-perl utils/split-messages.pl fr ami < resources/FatMessages >RAM:NetSurf/Resources/fr/Messages
-perl utils/split-messages.pl it ami < resources/FatMessages >RAM:NetSurf/Resources/it/Messages
-perl utils/split-messages.pl nl ami < resources/FatMessages >RAM:NetSurf/Resources/nl/Messages
+perl utils/split-messages.pl -l de -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/de/Messages
+perl utils/split-messages.pl -l en -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/en/Messages
+perl utils/split-messages.pl -l fr -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/fr/Messages
+perl utils/split-messages.pl -l it -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/it/Messages
+perl utils/split-messages.pl -l nl -p ami -f messages resources/FatMessages >RAM:NetSurf/Resources/nl/Messages
diff --git a/atari/Makefile.target b/atari/Makefile.target
index d339292..95d675f 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -191,9 +191,8 @@ endif
$(Q)cp \!NetSurf/Resources/internal.css,f79 $(ATARI_TARGET_DIR)res/internal.css
$(Q)cp \!NetSurf/Resources/SearchEngines $(ATARI_TARGET_DIR)res/search
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
-# $(Q)cp resources/FatMessages $(ATARI_TARGET_DIR)res/messages
$(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle
- $(Q)$(PERL) utils/split-messages.pl en all < resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages resources/FatMessages > $(ATARI_TARGET_DIR)res/messages
$(Q)cp \!NetSurf/Resources/en/welcome.html,faf $(ATARI_TARGET_DIR)res/welcome.html
$(Q)cp \!NetSurf/Resources/en/licence.html,faf $(ATARI_TARGET_DIR)res/licence.html
$(Q)cp \!NetSurf/Resources/en/credits.html,faf $(ATARI_TARGET_DIR)res/credits.html
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 2da4c5b..7e2c198 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -168,7 +168,7 @@ $$(OBJROOT)/$(1).lproj: $(2)
$(VQ)echo Bundling language $(1)
$(Q)mkdir -p $$@
$(Q)cp -pLR $(2) $$@
- $(Q)$(PERL) utils/split-messages.pl $(1) cocoa < resources/FatMessages > $$@/Messages
+ $(Q)$(SPLIT_MESSAGES) -l $(1) -p cocoa -f messages resources/FatMessages > $$@/Messages
endef
# compile_xib (xib) (lang)
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index 8ab8804..1441710 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -171,7 +171,7 @@ install-framebuffer:
$(Q)mkdir -p $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)
$(Q)cp -v $(EXETARGET) $(DESTDIR)/$(NETSURF_FRAMEBUFFER_BIN)netsurf$(SUBTARGET)
$(Q)for F in $(NETSURF_FRAMEBUFFER_RESOURCE_LIST); do cp -vL framebuffer/res/$$F $(DESTDIR)/$(NETSURF_FRAMEBUFFER_RESOURCES); done
- $(Q)$(PERL) utils/split-messages.pl en all < resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
+ $(Q)$(SPLIT_MESSAGES) -l en -p fb -f messages resources/FatMessages | gzip -9n > $(DESTDIR)$(NETSURF_FRAMEBUFFER_RESOURCES)messages
# ----------------------------------------------------------------------------
# Package target
diff --git a/windows/Makefile.target b/windows/Makefile.target
index 33a9492..defb765 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -92,7 +92,7 @@ WIN_RES_OBJ := installer.nsi NetSurf.ico netsurf.png welcome.html default.css
WIN_RES_INS_OBJ := $(addprefix windows/res/,$(WIN_RES_OBJ)) $(OBJROOT)/messages
$(OBJROOT)/messages: resources/FatMessages
- $(PERL) utils/split-messages.pl en all < resources/FatMessages > $@
+ $(Q)$(SPLIT_MESSAGES) -l en -p win -f messages resources/FatMessages > $@
netsurf-installer.exe: $(EXETARGET) $(WIN_RES_INS_OBJ)
makensis -V4 -NOCD windows/res/installer.nsi
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. release/3.0-21-g2f03a0b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2f03a0bfaf10f3bba7c04...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2f03a0bfaf10f3bba7c041d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2f03a0bfaf10f3bba7c041d7d...
The branch, master has been updated
via 2f03a0bfaf10f3bba7c041d7d5189f764735d5fd (commit)
via 82e2fc57d7ded7e917ae399ca99fa8953f137b2d (commit)
via 25e6563e6133c849814b621ce4c34a6419eace56 (commit)
from 820767e417fb63355a904f0ce0761be17f3a03fa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2f03a0bfaf10f3bba7c...
commit 2f03a0bfaf10f3bba7c041d7d5189f764735d5fd
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fix use after free on error path
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index f411dac..76bc8a4 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -565,12 +565,12 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
error = nsurl_create(url2, &url);
- free(url2);
-
if (error != NSERROR_OK) {
LOG(("Failed normalising '%s'", url2));
- warn_user("NoMemory", NULL);
+ free(url2);
+
+ warn_user(messages_get_errorcode(error), NULL);
free(title);
dom_node_unref(a);
@@ -578,6 +578,8 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
return;
}
+ free(url2);
+
data = urldb_get_url_data(url);
if (data == NULL) {
/* No entry in database, so add one */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=82e2fc57d7ded7e917a...
commit 82e2fc57d7ded7e917ae399ca99fa8953f137b2d
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
free memory on error path
diff --git a/content/llcache.c b/content/llcache.c
index 8996aca..171ae15 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -539,8 +539,11 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
/* extract ETag header */
free(object->cache.etag);
object->cache.etag = strdup(*value);
- if (object->cache.etag == NULL)
+ if (object->cache.etag == NULL) {
+ free(*name);
+ free(*value);
return NSERROR_NOMEM;
+ }
} else if (14 < len && strcasecmp(*name, "Last-Modified") == 0) {
/* extract Last-Modified header */
object->cache.last_modified = curl_getdate(*value, NULL);
@@ -613,8 +616,9 @@ static nserror llcache_fetch_process_header(llcache_object *object,
}
error = llcache_fetch_parse_header(object, data, len, &name, &value);
- if (error != NSERROR_OK)
+ if (error != NSERROR_OK) {
return error;
+ }
/* Append header data to the object's headers array */
temp = realloc(object->headers, (object->num_headers + 1) *
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=25e6563e6133c849814...
commit 25e6563e6133c849814b621ce4c34a6419eace56
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
remove dead store
diff --git a/render/table.c b/render/table.c
index 4cc213d..5eba544 100644
--- a/render/table.c
+++ b/render/table.c
@@ -687,7 +687,6 @@ void table_used_bottom_border_for_cell(struct box *cell)
if (table_border_is_more_eyecatching(&a, a_src, &b, b_src)) {
a = b;
- a_src = b_src;
}
}
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 8 ++++++--
desktop/tree_url_node.c | 8 +++++---
render/table.c | 1 -
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 8996aca..171ae15 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -539,8 +539,11 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
/* extract ETag header */
free(object->cache.etag);
object->cache.etag = strdup(*value);
- if (object->cache.etag == NULL)
+ if (object->cache.etag == NULL) {
+ free(*name);
+ free(*value);
return NSERROR_NOMEM;
+ }
} else if (14 < len && strcasecmp(*name, "Last-Modified") == 0) {
/* extract Last-Modified header */
object->cache.last_modified = curl_getdate(*value, NULL);
@@ -613,8 +616,9 @@ static nserror llcache_fetch_process_header(llcache_object *object,
}
error = llcache_fetch_parse_header(object, data, len, &name, &value);
- if (error != NSERROR_OK)
+ if (error != NSERROR_OK) {
return error;
+ }
/* Append header data to the object's headers array */
temp = realloc(object->headers, (object->num_headers + 1) *
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index f411dac..76bc8a4 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -565,12 +565,12 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
error = nsurl_create(url2, &url);
- free(url2);
-
if (error != NSERROR_OK) {
LOG(("Failed normalising '%s'", url2));
- warn_user("NoMemory", NULL);
+ free(url2);
+
+ warn_user(messages_get_errorcode(error), NULL);
free(title);
dom_node_unref(a);
@@ -578,6 +578,8 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
return;
}
+ free(url2);
+
data = urldb_get_url_data(url);
if (data == NULL) {
/* No entry in database, so add one */
diff --git a/render/table.c b/render/table.c
index 4cc213d..5eba544 100644
--- a/render/table.c
+++ b/render/table.c
@@ -687,7 +687,6 @@ void table_used_bottom_border_for_cell(struct box *cell)
if (table_border_is_more_eyecatching(&a, a_src, &b, b_src)) {
a = b;
- a_src = b_src;
}
}
--
NetSurf Browser
10 years, 1 month
netsurf: branch master updated. release/3.0-18-g820767e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/820767e417fb63355a904...
...commit http://git.netsurf-browser.org/netsurf.git/commit/820767e417fb63355a904f0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/820767e417fb63355a904f0ce...
The branch, master has been updated
via 820767e417fb63355a904f0ce0761be17f3a03fa (commit)
from 32eaf611b49ce60012d3af9a75a51e111bed7966 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=820767e417fb63355a9...
commit 820767e417fb63355a904f0ce0761be17f3a03fa
Author: Vivek Dasmohapatra <vivek(a)collabora.co.uk>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Improve the message split script to allow alternate output formats
diff --git a/Makefile b/Makefile
index 0ae5b4a..e57800b 100644
--- a/Makefile
+++ b/Makefile
@@ -605,7 +605,7 @@ clean-builddir:
CLEANS += clean-builddir
all-program: $(EXETARGET) post-exe
- $(call split_install_messages, '[^\.]+', !NetSurf/Resources)
+ $(call split_install_messages, any, !NetSurf/Resources)
.PHONY: testament
testament utils/testament.h:
@@ -744,7 +744,7 @@ FAT_LANGUAGES=de en fr it nl
define split_install_messages
$(foreach LANG, $(FAT_LANGUAGES), @echo MSGSPLIT: $(1)/$(LANG) to $(2)
$(Q)mkdir -p $(2)/$(LANG)$(3)
- $(Q)$(PERL) utils/split-messages.pl $(LANG) $(1) < resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
+ $(Q)$(PERL) utils/split-messages.pl -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
)
endef
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
old mode 100755
new mode 100644
index 2bbe79a..08d8822
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -1,23 +1,226 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+#
+# Copyright 2013 Vivek Dasmohapatra <vivek(a)collabora.co.uk>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# * The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+=head1
+
+Filter the NetSurf combined messages (i10n) file according to language
+and platform and generate output in a selection of formats for use
+both internally within netsurf and externally for translation
+services.
+
+=cut
use strict;
-die "usage: split-messages <langname> <platname> < FatMessages > ThinMessages" if ($#ARGV != 1);
+use Getopt::Long ();
+use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY );
+
+use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling );
+use constant GETOPT_SPEC =>
+ qw( output|o=s
+ input|i=s
+ lang|l=s
+ plat|platform|p=s
+ format|fmt|f=s
+ help|h|? );
+
+# default option values:
+my %opt = qw( plat any format messages );
+
+sub input_stream ();
+sub output_stream ();
+sub formatter ();
+sub header ();
+sub usage ();
+
+sub main ()
+{
+ my $input;
+ my $output;
+ my $format;
+ my $header;
+ my $opt_ok;
+
+ # option parsing:
+ Getopt::Long::Configure( GETOPT_OPTS );
+ $opt_ok = Getopt::Long::GetOptions( \%opt, GETOPT_SPEC );
+
+ # allow input and output to be specified as non-option arguments:
+ if( @ARGV ) { $opt{input } ||= shift( @ARGV ) }
+ if( @ARGV ) { $opt{output} ||= shift( @ARGV ) }
+
+ # open the appropriate streams and get the formatter and headers:
+ if( $opt_ok )
+ {
+ $input = input_stream();
+ $output = output_stream();
+ $format = formatter();
+ $header = header();
+ }
+
+ # double check the options are sane (and we weren't asked for the help)
+ if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}$/ )
+ {
+ usage();
+ }
+
+ # we are good to go:
+ print( $output $header );
+
+ while (<$input>)
+ {
+ /^#/ && next;
+ /^\s*$/ && next;
+ # only parsing thinsg that look like message lines:
+ if( /^([a-z]{2}).([^.]+).([^:]+):(.*)/ )
+ {
+ my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 );
+
+ if( $lang ne $opt{lang} ) { next };
+ if( $opt{plat} eq 'any' ||
+ $opt{plat} eq $plat ||
+ 'all' eq $plat )
+ {
+ print( $output $format->( $key, $val ), "\n" );
+ }
+ }
+ else
+ {
+ warn( "Malformed entry: $_" );
+ }
+ }
+}
+
+main();
+
+sub usage ()
+{
+ my @fmt = map { s/::$//; $_ } keys(%{$::{'msgfmt::'}});
+ print(STDERR <<TXT );
+usage:
+ $0 -l lang-code \
+ [-o output-file] [-i input-file] [-p platform] [-f format]
+
+ $0 -l lang-code ... [input-file [output-file]]
+
+ lang-code : en fr ko ... (no default)
+ platform : any gtk ami (default 'any')
+ format : @fmt (default 'messages')
+ input-file : defaults to standard input
+ output-file: defaults to standard output
+TXT
+ exit(1);
+}
+
+sub input_stream ()
+{
+ if( $opt{input} )
+ {
+ my $ifh;
+
+ sysopen( $ifh, $opt{input}, O_RDONLY ) ||
+ die( "$0: Failed to open input file $opt{input}: $!\n" );
+
+ return $ifh;
+ }
+
+ return \*STDIN;
+}
+
+sub output_stream ()
+{
+ if( $opt{output} )
+ {
+ my $ofh;
+
+ sysopen( $ofh, $opt{output}, O_CREAT|O_EXCL|O_APPEND|O_WRONLY ) ||
+ die( "$0: Failed to open output file $opt{output}: $!\n" );
+
+ return $ofh;
+ }
-my $langname = $ARGV[0];
-my $platname = $ARGV[1];
+ return \*STDOUT;
+}
+
+sub formatter ()
+{
+ my $name = $opt{format};
+ my $func = "msgfmt::$name"->UNIVERSAL::can("format");
+
+ return $func || die( "No handler found for format '$name'\n" );
+}
+
+sub header ()
+{
+ my $name = $opt{format};
+ my $func = "msgfmt::$name"->UNIVERSAL::can("header");
-my $allprefix = $langname . ".all.";
-my $platprefix = $langname . "." . $platname . ".";
+ return $func ? $func->() : "";
+}
-print "# This messages file is automatically generated from FatMessages\n";
-print "# at build-time. Please go and edit that instead of this.\n\n";
+# format implementations:
+{
+ package msgfmt::java;
-foreach (<STDIN>) {
- if (not /^#/ and not /^\s*$/) {
- if (/^$allprefix/ or /^$platprefix/) {
- s/^$langname\.(all|$platname)\.//;
- print "$_";
- }
+ # escape characters spec says ' should be escaped here but
+ # transifex does not recognise it. hence [\\:] and not [\\:']
+ sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+ sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
+}
+
+{
+ package msgfmt::messages;
+
+ sub format { return join( ":", @_ ) }
+ sub header
+ {
+ my $in = $opt{input} || '-stdin-';
+ return <<TXT;
+# This messages file is automatically generated from $in
+# at build-time. Please go and edit that instead of this.\n
+TXT
}
}
+
+########### YAML ###########
+#{
+# package msgfmt::yaml;
+# use YAML qw(Dump Bless);
+# print Dump %data;
+#}
+
+######## android properties ########
+#{
+# package msgfmt::android;
+# use HTML::Entities;
+# print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
+# foreach my $lang (sort keys %data) {
+# foreach my $plat (sort keys %{$data{$lang}}) {
+# foreach my $key (sort keys %{$data{$lang}{$plat}}) {
+# my $val = $data{$lang}{$plat}{$key};
+# print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
+# }
+# }
+# }
+# print "</resources>";
+#}
-----------------------------------------------------------------------
Summary of changes:
Makefile | 4 +-
utils/split-messages.pl | 231 ++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 219 insertions(+), 16 deletions(-)
mode change 100755 => 100644 utils/split-messages.pl
diff --git a/Makefile b/Makefile
index 0ae5b4a..e57800b 100644
--- a/Makefile
+++ b/Makefile
@@ -605,7 +605,7 @@ clean-builddir:
CLEANS += clean-builddir
all-program: $(EXETARGET) post-exe
- $(call split_install_messages, '[^\.]+', !NetSurf/Resources)
+ $(call split_install_messages, any, !NetSurf/Resources)
.PHONY: testament
testament utils/testament.h:
@@ -744,7 +744,7 @@ FAT_LANGUAGES=de en fr it nl
define split_install_messages
$(foreach LANG, $(FAT_LANGUAGES), @echo MSGSPLIT: $(1)/$(LANG) to $(2)
$(Q)mkdir -p $(2)/$(LANG)$(3)
- $(Q)$(PERL) utils/split-messages.pl $(LANG) $(1) < resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
+ $(Q)$(PERL) utils/split-messages.pl -l $(LANG) -p $(1) -f messages resources/FatMessages | gzip -9n > $(2)$(3)/$(LANG)/Messages
)
endef
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
old mode 100755
new mode 100644
index 2bbe79a..08d8822
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -1,23 +1,226 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+#
+# Copyright 2013 Vivek Dasmohapatra <vivek(a)collabora.co.uk>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# * The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+=head1
+
+Filter the NetSurf combined messages (i10n) file according to language
+and platform and generate output in a selection of formats for use
+both internally within netsurf and externally for translation
+services.
+
+=cut
use strict;
-die "usage: split-messages <langname> <platname> < FatMessages > ThinMessages" if ($#ARGV != 1);
+use Getopt::Long ();
+use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY );
+
+use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling );
+use constant GETOPT_SPEC =>
+ qw( output|o=s
+ input|i=s
+ lang|l=s
+ plat|platform|p=s
+ format|fmt|f=s
+ help|h|? );
+
+# default option values:
+my %opt = qw( plat any format messages );
+
+sub input_stream ();
+sub output_stream ();
+sub formatter ();
+sub header ();
+sub usage ();
+
+sub main ()
+{
+ my $input;
+ my $output;
+ my $format;
+ my $header;
+ my $opt_ok;
+
+ # option parsing:
+ Getopt::Long::Configure( GETOPT_OPTS );
+ $opt_ok = Getopt::Long::GetOptions( \%opt, GETOPT_SPEC );
+
+ # allow input and output to be specified as non-option arguments:
+ if( @ARGV ) { $opt{input } ||= shift( @ARGV ) }
+ if( @ARGV ) { $opt{output} ||= shift( @ARGV ) }
+
+ # open the appropriate streams and get the formatter and headers:
+ if( $opt_ok )
+ {
+ $input = input_stream();
+ $output = output_stream();
+ $format = formatter();
+ $header = header();
+ }
+
+ # double check the options are sane (and we weren't asked for the help)
+ if( !$opt_ok || $opt{help} || $opt{lang} !~ /^[a-z]{2}$/ )
+ {
+ usage();
+ }
+
+ # we are good to go:
+ print( $output $header );
+
+ while (<$input>)
+ {
+ /^#/ && next;
+ /^\s*$/ && next;
+ # only parsing thinsg that look like message lines:
+ if( /^([a-z]{2}).([^.]+).([^:]+):(.*)/ )
+ {
+ my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 );
+
+ if( $lang ne $opt{lang} ) { next };
+ if( $opt{plat} eq 'any' ||
+ $opt{plat} eq $plat ||
+ 'all' eq $plat )
+ {
+ print( $output $format->( $key, $val ), "\n" );
+ }
+ }
+ else
+ {
+ warn( "Malformed entry: $_" );
+ }
+ }
+}
+
+main();
+
+sub usage ()
+{
+ my @fmt = map { s/::$//; $_ } keys(%{$::{'msgfmt::'}});
+ print(STDERR <<TXT );
+usage:
+ $0 -l lang-code \
+ [-o output-file] [-i input-file] [-p platform] [-f format]
+
+ $0 -l lang-code ... [input-file [output-file]]
+
+ lang-code : en fr ko ... (no default)
+ platform : any gtk ami (default 'any')
+ format : @fmt (default 'messages')
+ input-file : defaults to standard input
+ output-file: defaults to standard output
+TXT
+ exit(1);
+}
+
+sub input_stream ()
+{
+ if( $opt{input} )
+ {
+ my $ifh;
+
+ sysopen( $ifh, $opt{input}, O_RDONLY ) ||
+ die( "$0: Failed to open input file $opt{input}: $!\n" );
+
+ return $ifh;
+ }
+
+ return \*STDIN;
+}
+
+sub output_stream ()
+{
+ if( $opt{output} )
+ {
+ my $ofh;
+
+ sysopen( $ofh, $opt{output}, O_CREAT|O_EXCL|O_APPEND|O_WRONLY ) ||
+ die( "$0: Failed to open output file $opt{output}: $!\n" );
+
+ return $ofh;
+ }
-my $langname = $ARGV[0];
-my $platname = $ARGV[1];
+ return \*STDOUT;
+}
+
+sub formatter ()
+{
+ my $name = $opt{format};
+ my $func = "msgfmt::$name"->UNIVERSAL::can("format");
+
+ return $func || die( "No handler found for format '$name'\n" );
+}
+
+sub header ()
+{
+ my $name = $opt{format};
+ my $func = "msgfmt::$name"->UNIVERSAL::can("header");
-my $allprefix = $langname . ".all.";
-my $platprefix = $langname . "." . $platname . ".";
+ return $func ? $func->() : "";
+}
-print "# This messages file is automatically generated from FatMessages\n";
-print "# at build-time. Please go and edit that instead of this.\n\n";
+# format implementations:
+{
+ package msgfmt::java;
-foreach (<STDIN>) {
- if (not /^#/ and not /^\s*$/) {
- if (/^$allprefix/ or /^$platprefix/) {
- s/^$langname\.(all|$platname)\.//;
- print "$_";
- }
+ # escape characters spec says ' should be escaped here but
+ # transifex does not recognise it. hence [\\:] and not [\\:']
+ sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
+ sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+ sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
+}
+
+{
+ package msgfmt::messages;
+
+ sub format { return join( ":", @_ ) }
+ sub header
+ {
+ my $in = $opt{input} || '-stdin-';
+ return <<TXT;
+# This messages file is automatically generated from $in
+# at build-time. Please go and edit that instead of this.\n
+TXT
}
}
+
+########### YAML ###########
+#{
+# package msgfmt::yaml;
+# use YAML qw(Dump Bless);
+# print Dump %data;
+#}
+
+######## android properties ########
+#{
+# package msgfmt::android;
+# use HTML::Entities;
+# print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
+# foreach my $lang (sort keys %data) {
+# foreach my $plat (sort keys %{$data{$lang}}) {
+# foreach my $key (sort keys %{$data{$lang}{$plat}}) {
+# my $val = $data{$lang}{$plat}{$key};
+# print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
+# }
+# }
+# }
+# print "</resources>";
+#}
--
NetSurf Browser
10 years, 1 month