summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-02-25 17:58:00 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-02-25 17:58:00 +0000
commit1cf46a6792a9e243edb857e131e44338bcbbd341 (patch)
tree9d145155307f4bc19746e486c7cd49ef897a49a1
parent674591f63df9c9b1e8e02aef4992a24b39cda0fc (diff)
downloadnetsurf-1cf46a6792a9e243edb857e131e44338bcbbd341.tar.gz
netsurf-1cf46a6792a9e243edb857e131e44338bcbbd341.tar.bz2
SignednessWarnings.squash()
Aside from a number of instances of const being cast away (mostly relating to the urldb, which is correct to only export const data) this now builds warning-free with GCC 4 on x86, which is nice. svn path=/trunk/netsurf/; revision=3868
-rw-r--r--desktop/browser.c42
-rw-r--r--desktop/options.c38
-rw-r--r--desktop/textinput.c33
-rw-r--r--image/bmp.c2
-rw-r--r--image/bmpread.c9
-rw-r--r--image/gif.c2
-rw-r--r--image/gifread.c5
-rw-r--r--image/ico.c2
-rw-r--r--image/jpeg.c4
-rw-r--r--render/box_construct.c77
-rw-r--r--render/html.c48
-rw-r--r--render/imagemap.c16
-rw-r--r--render/textplain.c2
-rw-r--r--utils/utf8.c3
14 files changed, 158 insertions, 125 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 3cfcd0352..27fcd6ad1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1422,7 +1422,7 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1431,7 +1431,8 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel)) {
bw->drag_type = DRAGGING_SELECTION;
@@ -1456,9 +1457,10 @@ void browser_window_mouse_action_html(struct browser_window *bw,
}
else if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2))
+ if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2))
selection_init(bw->sel, gadget_box);
nsfont_position_in_string(text_box->style,
@@ -1468,7 +1470,8 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel))
bw->drag_type = DRAGGING_SELECTION;
@@ -1546,7 +1549,7 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1555,14 +1558,18 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- if (selection_click(bw->sel, mouse, text_box->byte_offset + idx)) {
- /* key presses must be directed at the main browser
- * window, paste text operations ignored */
+ if (selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx)) {
+ /* key presses must be directed at the
+ * main browser window, paste text
+ * operations ignored */
browser_window_remove_caret(bw);
if (selection_dragging(bw->sel)) {
- bw->drag_type = DRAGGING_SELECTION;
- status = messages_get("Selecting");
+ bw->drag_type =
+ DRAGGING_SELECTION;
+ status =
+ messages_get("Selecting");
} else
status = c->status_message;
@@ -1805,7 +1812,7 @@ void browser_window_mouse_track_html(struct browser_window *bw,
&dx, &dy, dir);
if (box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(box->style,
box->text,
@@ -1814,7 +1821,8 @@ void browser_window_mouse_track_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_track(bw->sel, mouse, box->byte_offset + idx);
+ selection_track(bw->sel, mouse,
+ box->byte_offset + idx);
}
}
break;
@@ -1877,7 +1885,7 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
if (c) {
bool found = true;
int dir = -1;
- int idx;
+ size_t idx;
if (selection_dragging_start(bw->sel)) dir = 1;
@@ -1889,7 +1897,8 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
box = browser_window_pick_text_box(bw, mouse, x, y,
&dx, &dy, dir);
if (box) {
- nsfont_position_in_string(box->style,
+ nsfont_position_in_string(
+ box->style,
box->text,
box->length,
dx,
@@ -1897,7 +1906,8 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
&pixel_offset);
idx += box->byte_offset;
- selection_track(bw->sel, mouse, idx);
+ selection_track(bw->sel, mouse,
+ idx);
}
else
found = false;
diff --git a/desktop/options.c b/desktop/options.c
index d3eba4c8e..33a6932f5 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -428,11 +428,11 @@ void options_load_tree_directory(xmlNode *ul, struct node *directory) {
if (n->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(n->name, "li") == 0) {
+ if (strcmp((const char *) n->name, "li") == 0) {
/* entry */
options_load_tree_entry(n, directory);
- } else if (strcmp(n->name, "h4") == 0) {
+ } else if (strcmp((const char *) n->name, "h4") == 0) {
/* directory */
title = (char *) xmlNodeGetContent(n);
if (!title) {
@@ -445,7 +445,7 @@ void options_load_tree_directory(xmlNode *ul, struct node *directory) {
n && n->type != XML_ELEMENT_NODE;
n = n->next)
;
- if (!n || strcmp(n->name, "ul") != 0) {
+ if (!n || strcmp((const char *) n->name, "ul") != 0) {
/* next element isn't expected ul */
free(title);
warn_user("HotlistLoadError", "(Expected "
@@ -478,7 +478,7 @@ void options_load_tree_entry(xmlNode *li, struct node *directory) {
for (n = li->children; n; n = n->next) {
/* The li must contain an "a" element */
if (n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, "a") == 0) {
+ strcmp((const char *) n->name, "a") == 0) {
url = (char *) xmlGetProp(n, (const xmlChar *) "href");
title = (char *) xmlNodeGetContent(n);
}
@@ -526,7 +526,7 @@ xmlNode *options_find_tree_element(xmlNode *node, const char *name) {
return 0;
for (n = node->children;
n && !(n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, name) == 0);
+ strcmp((const char *) n->name, name) == 0);
n = n->next)
;
return n;
@@ -545,14 +545,15 @@ bool options_save_tree(struct tree *tree, const char *filename, const char *page
/* Unfortunately the Browse Hotlist format is invalid HTML,
* so this is a lie. */
- doc = htmlNewDoc("http://www.w3.org/TR/html4/strict.dtd",
- "-//W3C//DTD HTML 4.01//EN");
+ doc = htmlNewDoc(
+ (const xmlChar *) "http://www.w3.org/TR/html4/strict.dtd",
+ (const xmlChar *) "-//W3C//DTD HTML 4.01//EN");
if (!doc) {
warn_user("NoMemory", 0);
return false;
}
- html = xmlNewNode(NULL, "html");
+ html = xmlNewNode(NULL, (const xmlChar *) "html");
if (!html) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -560,21 +561,22 @@ bool options_save_tree(struct tree *tree, const char *filename, const char *page
}
xmlDocSetRootElement(doc, html);
- head = xmlNewChild(html, NULL, "head", NULL);
+ head = xmlNewChild(html, NULL, (const xmlChar *) "head", NULL);
if (!head) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- title = xmlNewTextChild(head, NULL, "title", page_title);
+ title = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
+ (const xmlChar *) page_title);
if (!title) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- body = xmlNewChild(html, NULL, "body", NULL);
+ body = xmlNewChild(html, NULL, (const xmlChar *) "body", NULL);
if (!body) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -611,7 +613,7 @@ bool options_save_tree_directory(struct node *directory, xmlNode *node) {
struct node *child;
xmlNode *ul, *h4;
- ul = xmlNewChild(node, NULL, "ul", NULL);
+ ul = xmlNewChild(node, NULL, (const xmlChar *) "ul", NULL);
if (!ul)
return false;
@@ -623,7 +625,9 @@ bool options_save_tree_directory(struct node *directory, xmlNode *node) {
} else {
/* directory */
/* invalid HTML */
- h4 = xmlNewTextChild(ul, NULL, "h4", child->data.text);
+ h4 = xmlNewTextChild(ul, NULL,
+ (const xmlChar *) "h4",
+ (const xmlChar *) child->data.text);
if (!h4)
return false;
@@ -649,18 +653,20 @@ bool options_save_tree_entry(struct node *entry, xmlNode *node) {
xmlAttr *href;
struct node_element *element;
- li = xmlNewChild(node, NULL, "li", NULL);
+ li = xmlNewChild(node, NULL, (const xmlChar *) "li", NULL);
if (!li)
return false;
- a = xmlNewTextChild(li, NULL, "a", entry->data.text);
+ a = xmlNewTextChild(li, NULL, (const xmlChar *) "a",
+ (const xmlChar *) entry->data.text);
if (!a)
return false;
element = tree_find_element(entry, TREE_ELEMENT_URL);
if (!element)
return false;
- href = xmlNewProp(a, "href", element->text);
+ href = xmlNewProp(a, (const xmlChar *) "href",
+ (const xmlChar *) element->text);
if (!href)
return false;
return true;
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 34006dbaf..2a7f4d553 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -84,8 +84,9 @@ static bool textarea_cut(struct browser_window *bw,
struct box *end_box, unsigned end_idx);
static void textarea_reflow(struct browser_window *bw, struct box *textarea,
struct box *inline_container);
-static bool word_left(const char *text, int *poffset, int *pchars);
-static bool word_right(const char *text, int len, int *poffset, int *pchars);
+static bool word_left(const char *text, size_t *poffset, size_t *pchars);
+static bool word_right(const char *text, size_t len, size_t *poffset,
+ size_t *pchars);
static bool ensure_caret_visible(struct box *textarea);
/**
@@ -179,7 +180,7 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
nsfont_position_in_string(text_box->style, text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset, ppixel_offset);
} else {
/* find the relevant text box */
y -= inline_container->y;
@@ -202,7 +203,8 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
text_box->text,
text_box->length,
textarea->width,
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
} else {
/* in a text box */
if (text_box->type == BOX_BR)
@@ -221,7 +223,8 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
}
}
@@ -1023,7 +1026,7 @@ bool browser_window_input_callback(struct browser_window *bw,
break;
case KEY_WORD_LEFT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_left(input->gadget->value, &form_offset, &nchars)) {
/* Gadget */
@@ -1037,7 +1040,7 @@ bool browser_window_input_callback(struct browser_window *bw,
break;
case KEY_WORD_RIGHT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_right(input->gadget->value, input->gadget->length,
&form_offset, &nchars)) {
@@ -1513,7 +1516,7 @@ void input_update_display(struct browser_window *bw, struct box *input,
box_coords(input, &box_x, &box_y);
nsfont_width(text_box->style, text_box->text, box_offset,
- &pixel_offset);
+ (int *) &pixel_offset);
dx = text_box->x;
text_box->x = 0;
if (input->width < text_box->width &&
@@ -1901,11 +1904,11 @@ void textarea_reflow(struct browser_window *bw, struct box *textarea,
* \return true iff the start of a word was found before/at the string start
*/
-bool word_left(const char *text, int *poffset, int *pchars)
+bool word_left(const char *text, size_t *poffset, size_t *pchars)
{
- int offset = *poffset;
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset > 0) {
offset = utf8_prev(text, offset);
@@ -1914,7 +1917,7 @@ bool word_left(const char *text, int *poffset, int *pchars)
}
while (offset > 0) {
- int prev = utf8_prev(text, offset);
+ size_t prev = utf8_prev(text, offset);
success = true;
if (isspace(text[prev]))
break;
@@ -1939,11 +1942,11 @@ bool word_left(const char *text, int *poffset, int *pchars)
* \return true iff the start of a word was found before the string end
*/
-bool word_right(const char *text, int len, int *poffset, int *pchars)
+bool word_right(const char *text, size_t len, size_t *poffset, size_t *pchars)
{
- int offset = *poffset;
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset < len) {
if (isspace(text[offset])) break;
diff --git a/image/bmp.c b/image/bmp.c
index 4e1c5f762..ed1ea6c02 100644
--- a/image/bmp.c
+++ b/image/bmp.c
@@ -52,7 +52,7 @@ bool nsbmp_convert(struct content *c, int iwidth, int iheight) {
/* set our source data */
bmp = c->data.bmp.bmp;
- bmp->bmp_data = c->source_data;
+ bmp->bmp_data = (unsigned char *) c->source_data;
bmp->buffer_size = c->source_size;
/* analyse the BMP */
diff --git a/image/bmpread.c b/image/bmpread.c
index c89db98b7..f8ae53cc0 100644
--- a/image/bmpread.c
+++ b/image/bmpread.c
@@ -50,7 +50,7 @@ void bmp_invalidate(struct bitmap *bitmap, void *private_word);
* \return BMP_OK on success
*/
bmp_result bmp_analyse(struct bmp_image *bmp) {
- char *data = bmp->bmp_data;
+ char *data = (char *) bmp->bmp_data;
/* ensure we aren't already initialised */
if (bmp->bitmap)
@@ -87,7 +87,7 @@ bmp_result bmp_analyse(struct bmp_image *bmp) {
* \return BMP_OK on success
*/
bmp_result ico_analyse(struct ico_collection *ico) {
- char *data = ico->ico_data;
+ char *data = (char *) ico->ico_data;
unsigned int count, i;
bmp_result result;
struct ico_image *image;
@@ -126,7 +126,8 @@ bmp_result ico_analyse(struct ico_collection *ico) {
image->bmp.bmp_data = ico->ico_data + READ_INT(data, 12);
image->bmp.ico = true;
data += 16;
- result = bmp_analyse_header(&image->bmp, image->bmp.bmp_data);
+ result = bmp_analyse_header(&image->bmp,
+ (char *) image->bmp.bmp_data);
if (result != BMP_OK)
return result;
area = image->bmp.width * image->bmp.height;
@@ -370,7 +371,7 @@ bmp_result bmp_decode(struct bmp_image *bmp) {
assert(bmp->bitmap);
- data = bmp->bmp_data + bmp->bitmap_offset;
+ data = (char *) bmp->bmp_data + bmp->bitmap_offset;
bytes = bmp->buffer_size - bmp->bitmap_offset;
switch (bmp->encoding) {
diff --git a/image/gif.c b/image/gif.c
index fb6c559db..657f1a666 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -73,7 +73,7 @@ bool nsgif_convert(struct content *c, int iwidth, int iheight) {
/* Create our animation
*/
gif = c->data.gif.gif;
- gif->gif_data = c->source_data;
+ gif->gif_data = (unsigned char *) c->source_data;
gif->buffer_size = c->source_size;
gif->buffer_position = 0;
diff --git a/image/gifread.c b/image/gifread.c
index ce826b006..30fd19e0f 100644
--- a/image/gifread.c
+++ b/image/gifread.c
@@ -149,7 +149,7 @@ int gif_initialise(struct gif_animation *gif) {
/* Check we are a GIF
*/
- if (strncmp(gif_data, "GIF", 3) != 0)
+ if (strncmp((const char *) gif_data, "GIF", 3) != 0)
return GIF_DATA_ERROR;
gif_data += 3;
@@ -410,7 +410,8 @@ int gif_initialise_frame(struct gif_animation *gif) {
*/
} else if ((gif_data[1] == 0xff) &&
(gif_data[2] == 0x0b) &&
- (strncmp(gif_data + 3, "NETSCAPE2.0", 11) == 0) &&
+ (strncmp((const char *) gif_data + 3,
+ "NETSCAPE2.0", 11) == 0) &&
(gif_data[14] == 0x03) &&
(gif_data[15] == 0x01)) {
gif->loop_count = gif_data[16] | (gif_data[17] << 8);
diff --git a/image/ico.c b/image/ico.c
index 50c69c4e3..45d445000 100644
--- a/image/ico.c
+++ b/image/ico.c
@@ -53,7 +53,7 @@ bool nsico_convert(struct content *c, int iwidth, int iheight) {
/* set our source data */
ico = c->data.ico.ico;
- ico->ico_data = c->source_data;
+ ico->ico_data = (unsigned char *) c->source_data;
ico->buffer_size = c->source_size;
/* analyse the BMP */
diff --git a/image/jpeg.c b/image/jpeg.c
index 11f591b5f..523a52fce 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -95,7 +95,7 @@ bool nsjpeg_convert(struct content *c, int w, int h)
return false;
}
jpeg_create_decompress(&cinfo);
- source_mgr.next_input_byte = c->source_data;
+ source_mgr.next_input_byte = (unsigned char *) c->source_data;
source_mgr.bytes_in_buffer = c->source_size;
cinfo.src = &source_mgr;
jpeg_read_header(&cinfo, TRUE);
@@ -180,7 +180,7 @@ void nsjpeg_init_source(j_decompress_ptr cinfo)
}
-static char nsjpeg_eoi[] = { 0xff, JPEG_EOI };
+static unsigned char nsjpeg_eoi[] = { 0xff, JPEG_EOI };
/**
* JPEG data source manager: fill the input buffer.
diff --git a/render/box_construct.c b/render/box_construct.c
index b5c04be3b..741816ac8 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -355,7 +355,7 @@ bool box_construct_element(xmlNode *n, struct content *content,
/* extract title attribute, if present */
if ((title0 = xmlGetProp(n, (const xmlChar *) "title"))) {
- char *title1 = squash_whitespace(title0);
+ char *title1 = squash_whitespace((char *) title0);
xmlFree(title0);
if (!title1)
return false;
@@ -638,7 +638,7 @@ bool box_construct_text(xmlNode *n, struct content *content,
if (parent_style->white_space == CSS_WHITE_SPACE_NORMAL ||
parent_style->white_space == CSS_WHITE_SPACE_NOWRAP) {
- char *text = squash_whitespace(n->content);
+ char *text = squash_whitespace((char *) n->content);
if (!text)
return false;
@@ -719,7 +719,7 @@ bool box_construct_text(xmlNode *n, struct content *content,
} else {
/* white-space: pre */
- char *text = cnv_space2nbsp(n->content);
+ char *text = cnv_space2nbsp((char *) n->content);
char *current;
/* note: pre-wrap/pre-line are unimplemented */
assert(parent_style->white_space == CSS_WHITE_SPACE_PRE ||
@@ -823,14 +823,14 @@ struct css_style * box_get_style(struct content *c,
colour border_color = 0x888888; /* mid-grey default for tables */
/* if not in a table, switch off cellpadding and cell borders */
- if (strcmp(n->name, "thead") != 0 &&
- strcmp(n->name, "tbody") != 0 &&
- strcmp(n->name, "tfoot") != 0 &&
- strcmp(n->name, "tr") != 0 &&
- strcmp(n->name, "td") != 0 &&
- strcmp(n->name, "th") != 0 &&
- strcmp(n->name, "col") != 0 &&
- strcmp(n->name, "colgroup") != 0) {
+ if (strcmp((const char *) n->name, "thead") != 0 &&
+ strcmp((const char *) n->name, "tbody") != 0 &&
+ strcmp((const char *) n->name, "tfoot") != 0 &&
+ strcmp((const char *) n->name, "tr") != 0 &&
+ strcmp((const char *) n->name, "td") != 0 &&
+ strcmp((const char *) n->name, "th") != 0 &&
+ strcmp((const char *) n->name, "col") != 0 &&
+ strcmp((const char *) n->name, "colgroup") != 0) {
markup_track->cell_border = false;
markup_track->cell_padding = false;
}
@@ -1205,17 +1205,17 @@ struct css_style * box_get_style(struct content *c,
* text-align for the current block can be handled in the default
* CSS file.
*/
- if (strcmp(n->name, "center") == 0)
+ if (strcmp((const char *) n->name, "center") == 0)
markup_track->align = ALIGN_CENTER;
- else if (strcmp(n->name, "div") == 0 ||
- strcmp(n->name, "col") == 0 ||
- strcmp(n->name, "colgroup") == 0 ||
- strcmp(n->name, "tbody") == 0 ||
- strcmp(n->name, "td") == 0 ||
- strcmp(n->name, "tfoot") == 0 ||
- strcmp(n->name, "th") == 0 ||
- strcmp(n->name, "thead") == 0 ||
- strcmp(n->name, "tr") == 0) {
+ else if (strcmp((const char *) n->name, "div") == 0 ||
+ strcmp((const char *) n->name, "col") == 0 ||
+ strcmp((const char *) n->name, "colgroup") == 0 ||
+ strcmp((const char *) n->name, "tbody") == 0 ||
+ strcmp((const char *) n->name, "td") == 0 ||
+ strcmp((const char *) n->name, "tfoot") == 0 ||
+ strcmp((const char *) n->name, "th") == 0 ||
+ strcmp((const char *) n->name, "thead") == 0 ||
+ strcmp((const char *) n->name, "tr") == 0) {
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "align"))) {
if (strcasecmp(s, "center") == 0)
@@ -1229,13 +1229,13 @@ struct css_style * box_get_style(struct content *c,
}
/* Table cells without an align value have a default implied
* alignment */
- if (strcmp(n->name, "td") == 0) {
+ if (strcmp((const char *) n->name, "td") == 0) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_LEFT;
else
xmlFree(s);
}
- if (strcmp(n->name, "th") == 0) {
+ if (strcmp((const char *) n->name, "th") == 0) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_CENTER;
else
@@ -1336,19 +1336,20 @@ void box_text_transform(char *s, unsigned int len,
switch (tt) {
case CSS_TEXT_TRANSFORM_UPPERCASE:
for (i = 0; i < len; ++i)
- if (s[i] < 0x80)
+ if ((unsigned char) s[i] < 0x80)
s[i] = toupper(s[i]);
break;
case CSS_TEXT_TRANSFORM_LOWERCASE:
for (i = 0; i < len; ++i)
- if (s[i] < 0x80)
+ if ((unsigned char) s[i] < 0x80)
s[i] = tolower(s[i]);
break;
case CSS_TEXT_TRANSFORM_CAPITALIZE:
- if (s[0] < 0x80)
+ if ((unsigned char) s[0] < 0x80)
s[0] = toupper(s[0]);
for (i = 1; i < len; ++i)
- if (s[i] < 0x80 && isspace(s[i - 1]))
+ if ((unsigned char) s[i] < 0x80 &&
+ isspace(s[i - 1]))
s[i] = toupper(s[i]);
break;
default:
@@ -1437,19 +1438,19 @@ bool box_a(BOX_SPECIAL_PARAMS)
/* target frame [16.3] */
if ((s = xmlGetProp(n, (const xmlChar *) "target"))) {
- if (!strcasecmp(s, "_blank"))
+ if (!strcasecmp((const char *) s, "_blank"))
box->target = TARGET_BLANK;
- else if (!strcasecmp(s, "_top"))
+ else if (!strcasecmp((const char *) s, "_top"))
box->target = TARGET_TOP;
- else if (!strcasecmp(s, "_parent"))
+ else if (!strcasecmp((const char *) s, "_parent"))
box->target = TARGET_PARENT;
- else if (!strcasecmp(s, "_self"))
+ else if (!strcasecmp((const char *) s, "_self"))
/* the default may have been overridden by a
* <base target=...>, so this is different to 0 */
box->target = TARGET_SELF;
else if (('a' <= s[0] && s[0] <= 'z') ||
('A' <= s[0] && s[0] <= 'Z')) { /* [6.16] */
- box->target = talloc_strdup(content, s);
+ box->target = talloc_strdup(content, (const char *) s);
if (!box->target) {
xmlFree(s);
return false;
@@ -1477,7 +1478,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
/* handle alt text */
if ((alt = xmlGetProp(n, (const xmlChar *) "alt"))) {
- s = squash_whitespace(alt);
+ s = squash_whitespace((const char *) alt);
xmlFree(alt);
if (!s)
return false;
@@ -2589,12 +2590,12 @@ bool box_select_add_option(struct form_control *control, xmlNode *n)
char *text_nowrap = 0;
bool selected;
xmlChar *content;
- xmlChar *s;
+ char *s;
content = xmlNodeGetContent(n);
if (!content)
goto no_memory;
- text = squash_whitespace(content);
+ text = squash_whitespace((const char *) content);
xmlFree(content);
if (!text)
goto no_memory;
@@ -2703,8 +2704,8 @@ bool box_textarea(BOX_SPECIAL_PARAMS)
while (1) {
/* BOX_TEXT */
- len = strcspn(current, "\r\n");
- s = talloc_strndup(content, current, len);
+ len = strcspn((const char *) current, "\r\n");
+ s = talloc_strndup(content, (const char *) current, len);
if (!s) {
xmlFree(string);
xmlBufferFree(buf);
@@ -2849,7 +2850,7 @@ bool box_get_attribute(xmlNode *n, const char *attribute,
xmlChar *s = xmlGetProp(n, (const xmlChar *) attribute);
if (!s)
return true;
- *value = talloc_strdup(context, s);
+ *value = talloc_strdup(context, (const char *) s);
xmlFree(s);
if (!*value)
return false;
diff --git a/render/html.c b/render/html.c
index c54f23ea8..0c55bd805 100644
--- a/render/html.c
+++ b/render/html.c
@@ -203,16 +203,19 @@ bool html_process_data(struct content *c, char *data, unsigned int size)
/* However, if that encoding is non-ASCII-compatible,
* ignore it, as it can't possibly be correct */
- if (strncasecmp(c->data.html.parser->input->encoding,
+ if (strncasecmp((const char *) c->data.html.parser->
+ input->encoding,
"UTF-16", 6) == 0 || /* UTF-16(LE|BE)? */
- strncasecmp(c->data.html.parser->input->encoding,
+ strncasecmp((const char *) c->data.html.parser->
+ input->encoding,
"UTF-32", 6) == 0) { /* UTF-32(LE|BE)? */
c->data.html.encoding = talloc_strdup(c, "ISO-8859-1");
c->data.html.encoding_source =
ENCODING_SOURCE_DETECTED;
} else {
c->data.html.encoding = talloc_strdup(c,
- c->data.html.parser->input->encoding);
+ (const char *) c->data.html.parser->
+ input->encoding);
c->data.html.encoding_source = ENCODING_SOURCE_META;
}
@@ -523,11 +526,12 @@ bool html_head(struct content *c, xmlNode *head)
continue;
LOG(("Node: %s", node->name));
- if (!c->title && strcmp(node->name, "title") == 0) {
+ if (!c->title && strcmp((const char *) node->name,
+ "title") == 0) {
xmlChar *title = xmlNodeGetContent(node);
if (!title)
return false;
- char *title2 = squash_whitespace(title);
+ char *title2 = squash_whitespace((const char *) title);
xmlFree(title);
if (!title2)
return false;
@@ -536,7 +540,7 @@ bool html_head(struct content *c, xmlNode *head)
if (!c->title)
return false;
- } else if (strcmp(node->name, "base") == 0) {
+ } else if (strcmp((const char *) node->name, "base") == 0) {
char *href = (char *) xmlGetProp(node,
(const xmlChar *) "href");
if (href) {
@@ -552,12 +556,18 @@ bool html_head(struct content *c, xmlNode *head)
}
/* don't use the central values to ease freeing later on */
if ((s = xmlGetProp(node, (const xmlChar *) "target"))) {
- if ((!strcasecmp(s, "_blank")) || (!strcasecmp(s, "_top")) ||
- (!strcasecmp(s, "_parent")) ||
- (!strcasecmp(s, "_self")) ||
+ if ((!strcasecmp((const char *) s, "_blank")) ||
+ (!strcasecmp((const char *) s,
+ "_top")) ||
+ (!strcasecmp((const char *) s,
+ "_parent")) ||
+ (!strcasecmp((const char *) s,
+ "_self")) ||
('a' <= s[0] && s[0] <= 'z') ||
('A' <= s[0] && s[0] <= 'Z')) { /* [6.16] */
- c->data.html.base_target = talloc_strdup(c, s);
+ c->data.html.base_target =
+ talloc_strdup(c,
+ (const char *) s);
if (!c->data.html.base_target) {
xmlFree(s);
return false;
@@ -594,7 +604,7 @@ bool html_meta_refresh(struct content *c, xmlNode *head)
continue;
/* Recurse into noscript elements */
- if (strcmp((const char *)n->name, "noscript") == 0) {
+ if (strcmp((const char *) n->name, "noscript") == 0) {
if (!html_meta_refresh(c, n)) {
/* Some error occurred */
return false;
@@ -604,26 +614,26 @@ bool html_meta_refresh(struct content *c, xmlNode *head)
}
}
- if (strcmp((const char *)n->name, "meta")) {
+ if (strcmp((const char *) n->name, "meta")) {
continue;
}
- equiv = xmlGetProp(n, (const xmlChar *)"http-equiv");
+ equiv = xmlGetProp(n, (const xmlChar *) "http-equiv");
if (!equiv)
continue;
- if (strcasecmp((const char *)equiv, "refresh")) {
+ if (strcasecmp((const char *) equiv, "refresh")) {
xmlFree(equiv);
continue;
}
xmlFree(equiv);
- content = xmlGetProp(n, (const xmlChar *)"content");
+ content = xmlGetProp(n, (const xmlChar *) "content");
if (!content)
continue;
- end = (char *)content + strlen(content);
+ end = (char *) content + strlen((const char *) content);
msg_data.delay = (int)strtol((char *) content, &url, 10);
/* a very small delay and self-referencing URL can cause a loop
@@ -776,7 +786,7 @@ bool html_find_stylesheets(struct content *c, xmlNode *html,
if (node->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(node->name, "link") != 0)
+ if (strcmp((const char *) node->name, "link") != 0)
continue;
/* rel=<space separated list, including 'stylesheet'> */
@@ -949,7 +959,7 @@ bool html_find_inline_stylesheets(struct content *c, xmlNode *html)
if (node->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(node->name, "style") != 0)
+ if (strcmp((const char *) node->name, "style") != 0)
continue;
if (!html_process_style_element(c, node))
@@ -1012,7 +1022,7 @@ bool html_process_style_element(struct content *c, xmlNode *style)
* give the content of comments which may be used to 'hide'
* the content */
for (child = style->children; child != 0; child = child->next) {
- data = xmlNodeGetContent(child);
+ data = (char *) xmlNodeGetContent(child);
if (!content_process_data(c->data.html.
stylesheet_content[STYLESHEET_STYLE],
data, strlen(data))) {
diff --git a/render/imagemap.c b/render/imagemap.c
index 399cd6225..852af6213 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -247,11 +247,11 @@ bool imagemap_extract(xmlNode *node, struct content *c)
assert(c != NULL);
if (node->type == XML_ELEMENT_NODE) {
- if (strcmp(node->name, "map") == 0) {
- if ((name = (char *)xmlGetProp(node,
- (const xmlChar *)"id")) == NULL) {
- if ((name = (char *)xmlGetProp(node,
- (const xmlChar *)"name")) ==
+ if (strcmp((const char *) node->name, "map") == 0) {
+ if ((name = (char *) xmlGetProp(node,
+ (const xmlChar *) "id")) == NULL) {
+ if ((name = (char *) xmlGetProp(node,
+ (const xmlChar *) "name")) ==
NULL)
return true;
}
@@ -306,8 +306,8 @@ bool imagemap_extract_map(xmlNode *node, struct content *c,
/** \todo ignore <area> elements if there are other
* block-level elements present in map
*/
- if (strcmp(node->name, "area") == 0 ||
- strcmp(node->name, "a") == 0) {
+ if (strcmp((const char *) node->name, "area") == 0 ||
+ strcmp((const char *) node->name, "a") == 0) {
return imagemap_addtolist(node,
c->data.html.base_url, entry);
}
@@ -341,7 +341,7 @@ bool imagemap_addtolist(xmlNode *n, char *base_url, struct mapentry **entry)
assert(base_url != NULL);
assert(entry != NULL);
- if (strcmp(n->name, "area") == 0) {
+ if (strcmp((const char *) n->name, "area") == 0) {
/* nohref attribute present - ignore this entry */
if (xmlGetProp(n, (const xmlChar*)"nohref") != 0) {
return true;
diff --git a/render/textplain.c b/render/textplain.c
index c096c97a2..63610ba17 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -503,7 +503,7 @@ size_t textplain_offset_from_coords(struct content *c, int x, int y, int dir)
if (x <= width) {
int pixel_offset;
- int char_offset;
+ size_t char_offset;
nsfont_position_in_string(&textplain_style,
text, next_offset, x,
diff --git a/utils/utf8.c b/utils/utf8.c
index 3b83c95e3..e734cfad6 100644
--- a/utils/utf8.c
+++ b/utils/utf8.c
@@ -44,9 +44,10 @@ static utf8_convert_ret utf8_convert(const char *string, size_t len,
* \param l Length of sequence
* \return UCS4 character
*/
-size_t utf8_to_ucs4(const char *s, size_t l)
+size_t utf8_to_ucs4(const char *s_in, size_t l)
{
size_t c = 0;
+ const unsigned char *s = (const unsigned char *) s_in;
if (!s)
assert(0);