summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/fetch.c2
-rw-r--r--content/fetchcache.c14
-rw-r--r--css/css.c8
-rw-r--r--desktop/browser.c2
-rw-r--r--desktop/imagemap.c9
-rw-r--r--render/box.c727
-rw-r--r--render/box.h8
-rw-r--r--render/html.c12
-rw-r--r--riscos/buffer.c32
-rw-r--r--riscos/gui.c18
-rw-r--r--riscos/help.c16
11 files changed, 413 insertions, 435 deletions
diff --git a/content/fetch.c b/content/fetch.c
index cb1353f98..1ea20a8a0 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -384,7 +384,7 @@ CURLcode fetch_set_options(struct fetch *f)
SETOPT(CURLOPT_COOKIEFILE, 0);
SETOPT(CURLOPT_COOKIEJAR, 0);
}
- if ((li = login_list_get(f->url))) {
+ if ((li = login_list_get(f->url)) != NULL) {
SETOPT(CURLOPT_HTTPAUTH, CURLAUTH_ANY);
SETOPT(CURLOPT_USERPWD, li->logindetails);
} else {
diff --git a/content/fetchcache.c b/content/fetchcache.c
index 02ce109b1..54fd7e1c8 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -72,19 +72,17 @@ struct content * fetchcache(const char *url,
char *url1;
char *hash;
- url1 = strdup(url);
- if (!url1)
- return 0;
+ if ((url1 = strdup(url)) == NULL)
+ return NULL;
/* strip fragment identifier */
- if ((hash = strchr(url1, '#')))
- *hash = 0;
+ if ((hash = strchr(url1, '#')) != NULL)
+ *hash = NULL;
LOG(("url %s", url1));
if (!post_urlenc && !post_multipart) {
- c = content_get(url1);
- if (c) {
+ if ((c = content_get(url1)) != NULL) {
free(url1);
content_add_user(c, callback, p1, p2);
return c;
@@ -94,7 +92,7 @@ struct content * fetchcache(const char *url,
c = content_create(url1);
free(url1);
if (!c)
- return 0;
+ return NULL;
content_add_user(c, callback, p1, p2);
if (!post_urlenc && !post_multipart)
diff --git a/css/css.c b/css/css.c
index 1446f9640..97779e62b 100644
--- a/css/css.c
+++ b/css/css.c
@@ -395,8 +395,8 @@ bool css_convert(struct content *c, int width, int height)
current = source_data;
end = source_data + c->source_size;
- while (current < end && (token = css_tokenise(&current, end + 10,
- &token_text))) {
+ while (current < end
+ && (token = css_tokenise(&current, end + 10, &token_text)) != NULL) {
token_data.text = token_text;
token_data.length = current - token_text;
css_parser_(parser, token, token_data, &param);
@@ -1207,8 +1207,8 @@ void css_parse_property_list(struct content *c, struct css_style * style,
current = source_data;
end = source_data + strlen(str);
- while (current < end && (token = css_tokenise(&current, end + 10,
- &token_text))) {
+ while (current < end
+ && (token = css_tokenise(&current, end + 10, &token_text)) != NULL) {
token_data.text = token_text;
token_data.length = current - token_text;
css_parser_(parser, token, token_data, &param);
diff --git a/desktop/browser.c b/desktop/browser.c
index 65ba0b050..fac897822 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -605,7 +605,7 @@ void browser_window_mouse_click_html(struct browser_window *bw,
url_func_result res;
/* search the box tree for a link, imagemap, or form control */
- while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
+ while ((box = box_at_point(box, x, y, &box_x, &box_y, &content)) != NULL) {
if (box->style &&
box->style->visibility == CSS_VISIBILITY_HIDDEN)
continue;
diff --git a/desktop/imagemap.c b/desktop/imagemap.c
index f5ab1ad06..b223bcf3f 100644
--- a/desktop/imagemap.c
+++ b/desktop/imagemap.c
@@ -201,8 +201,7 @@ void imagemap_extract(xmlNode *node, struct content *c) {
if (node->type == XML_ELEMENT_NODE) {
if (strcmp(node->name, "map") == 0) {
- if (!(name = (char*)xmlGetProp(node,
- (const xmlChar*)"name")))
+ if ((name = (char*)xmlGetProp(node, (const xmlChar*)"name")) == NULL)
return;
entry = imagemap_extract_map(node, c, entry);
imagemap_add(c, name, entry);
@@ -254,16 +253,16 @@ struct mapentry *imagemap_addtolist(xmlNode *n, struct mapentry *entry) {
}
}
/* no href -> ignore */
- if (!(href = (char*)xmlGetProp(n, (const xmlChar*)"href"))) {
+ if ((href = (char*)xmlGetProp(n, (const xmlChar*)"href")) == NULL) {
return entry;
}
/* no shape -> shape is a rectangle */
- if (!(shape = (char*)xmlGetProp(n, (const xmlChar*)"shape"))) {
+ if ((shape = (char*)xmlGetProp(n, (const xmlChar*)"shape")) == NULL) {
shape = (char*)xmlMemStrdup("rect");
}
if (strcasecmp(shape, "default") != 0) {
/* no coords -> ignore */
- if (!(coords = (char*)xmlGetProp(n, (const xmlChar*)"coords"))) {
+ if ((coords = (char*)xmlGetProp(n, (const xmlChar*)"coords")) == NULL) {
xmlFree(href);
xmlFree(shape);
return entry;
diff --git a/render/box.c b/render/box.c
index f248f3d62..03f0117bf 100644
--- a/render/box.c
+++ b/render/box.c
@@ -92,8 +92,9 @@ static struct box * convert_xml_to_box(xmlNode * n, struct content *content,
struct box * parent, struct box *inline_container,
struct box_status status);
static struct css_style * box_get_style(struct content *c,
- struct content ** stylesheet,
- unsigned int stylesheet_count, struct css_style * parent_style,
+ struct content ** stylesheet,
+ unsigned int stylesheet_count,
+ struct css_style * parent_style,
xmlNode * n);
static void box_text_transform(char *s, unsigned int len,
css_text_transform tt);
@@ -119,7 +120,8 @@ static struct box_result box_button(xmlNode *n, struct box_status *status,
struct css_style *style);
static struct box_result box_frameset(xmlNode *n, struct box_status *status,
struct css_style *style);
-static void add_option(xmlNode* n, struct form_control* current_select, const char *text);
+static void add_option(xmlNode* n, struct form_control* current_select,
+ const char *text);
static void box_normalise_block(struct box *block, pool box_pool);
static void box_normalise_table(struct box *table, pool box_pool);
void box_normalise_table_row_group(struct box *row_group,
@@ -139,7 +141,7 @@ static struct box_result box_applet(xmlNode *n, struct box_status *status,
static struct box_result box_iframe(xmlNode *n, struct box_status *status,
struct css_style *style);
static bool plugin_decode(struct content* content, char* url, struct box* box,
- struct object_params* po);
+ struct object_params* po);
static struct box_multi_length *box_parse_multi_lengths(const char *s,
unsigned int *count);
@@ -308,7 +310,7 @@ void xml_to_box(xmlNode *n, struct content *c)
/* mapping from CSS display to box type
* this table must be in sync with css/css_enums */
-static box_type box_map[] = {
+static const box_type box_map[] = {
0, /*CSS_DISPLAY_INHERIT,*/
BOX_INLINE, /*CSS_DISPLAY_INLINE,*/
BOX_BLOCK, /*CSS_DISPLAY_BLOCK,*/
@@ -369,13 +371,13 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
style->display = CSS_DISPLAY_BLOCK;
/* extract title attribute, if present */
- if ((title0 = xmlGetProp(n, (const xmlChar *) "title"))) {
+ if ((title0 = xmlGetProp(n, (const xmlChar *) "title")) != NULL) {
status.title = title = squash_whitespace(title0);
xmlFree(title0);
}
/* extract id attribute, if present */
- if ((title0 = xmlGetProp(n, (const xmlChar *) "id"))) {
+ if ((title0 = xmlGetProp(n, (const xmlChar *) "id")) != NULL) {
status.id = id = squash_whitespace(title0);
xmlFree(title0);
}
@@ -590,13 +592,13 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
/* new inline container unless this is a float */
inline_container = 0;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "colspan"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "colspan")) != NULL) {
int colspan = atoi(s);
if (1 <= colspan && colspan <= 100)
box->columns = colspan;
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rowspan"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rowspan")) != NULL) {
if ((box->rows = strtol(s, 0, 10)) == 0)
box->rows = 1;
xmlFree(s);
@@ -636,7 +638,7 @@ end:
*/
struct css_style * box_get_style(struct content *c,
- struct content ** stylesheet,
+ struct content ** stylesheet,
unsigned int stylesheet_count, struct css_style * parent_style,
xmlNode * n)
{
@@ -660,7 +662,7 @@ struct css_style * box_get_style(struct content *c,
the spec. Many browsers seem to allow it on other elements too,
so let's be generic ;)
*/
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "background"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "background")) != NULL) {
style->background_image.type = CSS_BACKGROUND_IMAGE_URI;
/**\todo This will leak memory. */
res = url_join(s, c->data.html.base_url, &style->background_image.uri);
@@ -674,7 +676,7 @@ struct css_style * box_get_style(struct content *c,
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "bgcolor"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "bgcolor")) != NULL) {
unsigned int r, g, b;
if (s[0] == '#' && sscanf(s + 1, "%2x%2x%2x", &r, &g, &b) == 3)
style->background_color = (b << 16) | (g << 8) | r;
@@ -683,7 +685,7 @@ struct css_style * box_get_style(struct content *c,
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "color"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "color")) != NULL) {
unsigned int r, g, b;
if (s[0] == '#' && sscanf(s + 1, "%2x%2x%2x", &r, &g, &b) == 3)
style->color = (b << 16) | (g << 8) | r;
@@ -692,14 +694,14 @@ struct css_style * box_get_style(struct content *c,
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "height"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "height")) != NULL) {
float value = atof(s);
if (value < 0 || strlen(s) == 0) {
/* ignore negative values and height="" */
} else if (strrchr(s, '%')) {
- /*the specification doesn't make clear what
- * percentage heights mean, so ignore them */
- } else {
+ /*the specification doesn't make clear what
+ * percentage heights mean, so ignore them */
+ } else {
style->height.height = CSS_HEIGHT_LENGTH;
style->height.length.unit = CSS_UNIT_PX;
style->height.length.value = value;
@@ -708,7 +710,7 @@ struct css_style * box_get_style(struct content *c,
}
if (strcmp((const char *) n->name, "input") == 0) {
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "size"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "size")) != NULL) {
int size = atoi(s);
if (0 < size) {
char *type = (char *) xmlGetProp(n, (const xmlChar *) "type");
@@ -729,7 +731,7 @@ struct css_style * box_get_style(struct content *c,
}
if (strcmp((const char *) n->name, "body") == 0) {
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "text"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "text")) != NULL) {
unsigned int r, g, b;
if (s[0] == '#' && sscanf(s + 1, "%2x%2x%2x", &r, &g, &b) == 3)
style->color = (b << 16) | (g << 8) | r;
@@ -739,7 +741,7 @@ struct css_style * box_get_style(struct content *c,
}
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "width"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "width")) != NULL) {
float value = atof(s);
if (value < 0 || strlen(s) == 0) {
/* ignore negative values and width="" */
@@ -755,7 +757,7 @@ struct css_style * box_get_style(struct content *c,
}
if (strcmp((const char *) n->name, "textarea") == 0) {
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rows"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rows")) != NULL) {
int value = atoi(s);
if (0 < value) {
style->height.height = CSS_HEIGHT_LENGTH;
@@ -764,7 +766,7 @@ struct css_style * box_get_style(struct content *c,
}
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "cols"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "cols")) != NULL) {
int value = atoi(s);
if (0 < value) {
style->width.width = CSS_WIDTH_LENGTH;
@@ -775,7 +777,7 @@ struct css_style * box_get_style(struct content *c,
}
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "style"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "style")) != NULL) {
struct css_style astyle;
memcpy(&astyle, &css_empty_style, sizeof(struct css_style));
css_parse_property_list(c, &astyle, s);
@@ -847,11 +849,11 @@ struct box_result box_a(xmlNode *n, struct box_status *status,
char *s, *s1;
char *id = status->id;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "href")))
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "href")) != NULL)
status->href = s;
/* name and id share the same namespace */
- if ((s1 = (char *) xmlGetProp(n, (const xmlChar *) "name"))) {
+ if ((s1 = (char *) xmlGetProp(n, (const xmlChar *) "name")) != NULL) {
if (status->id && strcmp(status->id, s1) == 0) {
/* both specified and they match => ok */
id = status->id;
@@ -880,7 +882,7 @@ struct box_result box_body(xmlNode *n, struct box_status *status,
{
struct box *box;
status->content->data.html.background_colour = style->background_color;
- box = box_create(style, status->href, status->title, status->id,
+ box = box_create(style, status->href, status->title, status->id,
status->content->data.html.box_pool);
return (struct box_result) {box, true, false};
@@ -908,7 +910,7 @@ struct box_result box_image(xmlNode *n, struct box_status *status,
status->content->data.html.box_pool);
/* handle alt text */
- if ((s2 = xmlGetProp(n, (const xmlChar *) "alt"))) {
+ if ((s2 = xmlGetProp(n, (const xmlChar *) "alt")) != NULL) {
box->text = squash_whitespace(s2);
box->length = strlen(box->text);
box->font = nsfont_open(status->content->data.html.fonts, style);
@@ -916,11 +918,11 @@ struct box_result box_image(xmlNode *n, struct box_status *status,
}
/* img without src is an error */
- if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "src")))
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src")) == NULL)
return (struct box_result) {box, false, false};
/* imagemap associated with this image */
- if ((map = xmlGetProp(n, (const xmlChar *) "usemap"))) {
+ if ((map = xmlGetProp(n, (const xmlChar *) "usemap")) != NULL) {
if (map[0] == '#') {
box->usemap = xstrdup(map+1);
}
@@ -963,8 +965,7 @@ struct box_result box_form(xmlNode *n, struct box_status *status,
box = box_create(style, status->href, status->title, status->id,
status->content->data.html.box_pool);
- s = (char *) xmlGetProp(n, (const xmlChar *) "action");
- if (!s) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "action")) == NULL) {
/* the action attribute is required */
return (struct box_result) {box, true, false};
}
@@ -973,10 +974,10 @@ struct box_result box_form(xmlNode *n, struct box_status *status,
form->action = s;
form->method = method_GET;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "method"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "method")) != NULL) {
if (strcasecmp(s, "post") == 0) {
form->method = method_POST_URLENC;
- if ((s2 = (char *) xmlGetProp(n, (const xmlChar *) "enctype"))) {
+ if ((s2 = (char *) xmlGetProp(n, (const xmlChar *) "enctype")) != NULL) {
if (strcasecmp(s2, "multipart/form-data") == 0)
form->method = method_POST_MULTIPART;
xmlFree(s2);
@@ -1018,7 +1019,7 @@ struct box_result box_textarea(xmlNode *n, struct box_status *status,
else
box->gadget->form = 0;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name")) != NULL) {
box->gadget->name = strdup(s);
xmlFree(s);
if (!box->gadget->name) {
@@ -1095,7 +1096,7 @@ struct box_result box_select(xmlNode *n, struct box_status *status,
gadget->form = 0;
gadget->data.select.multiple = false;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "multiple"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "multiple")) != NULL) {
gadget->data.select.multiple = true;
xmlFree(s);
}
@@ -1129,7 +1130,7 @@ struct box_result box_select(xmlNode *n, struct box_status *status,
return (struct box_result) {0, false, false};
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name")) != NULL) {
gadget->name = strdup(s);
xmlFree(s);
if (!gadget->name) {
@@ -1193,7 +1194,7 @@ void add_option(xmlNode* n, struct form_control* current_select, const char *tex
current_select->data.select.last_item->next = option;
current_select->data.select.last_item = option;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
option->value = xstrdup(s);
xmlFree(s);
} else {
@@ -1212,7 +1213,7 @@ void add_option(xmlNode* n, struct form_control* current_select, const char *tex
option->selected = option->initial_selected = false;
option->text = text;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "selected"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "selected")) != NULL) {
xmlFree(s);
if (current_select->data.select.num_selected == 0 ||
current_select->data.select.multiple) {
@@ -1260,7 +1261,7 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
return (struct box_result) {0, false, true};
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
gadget->value = strdup(s);
xmlFree(s);
if (!gadget->value) {
@@ -1283,12 +1284,12 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
}
gadget->box = box;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "checked"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "checked")) != NULL) {
gadget->selected = true;
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
gadget->value = strdup(s);
xmlFree(s);
if (!gadget->value) {
@@ -1330,7 +1331,7 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
box_add_child(box, inline_container);
} else if (type && strcasecmp(type, "button") == 0) {
- struct box_result result = box_button(n, status, style);
+ struct box_result result = box_button(n, status, style);
struct box *inline_container, *inline_box;
box = result.box;
inline_container = box_create(0, 0, 0, 0,
@@ -1340,11 +1341,11 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
status->content->data.html.box_pool);
inline_box->type = BOX_INLINE;
inline_box->style_clone = 1;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
- inline_box->text = s;
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
+ inline_box->text = s;
}
else {
- inline_box->text = xstrdup("Button");
+ inline_box->text = xstrdup("Button");
}
inline_box->length = strlen(inline_box->text);
inline_box->font = nsfont_open(status->content->data.html.fonts, style);
@@ -1352,9 +1353,9 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
box_add_child(box, inline_container);
} else if (type && strcasecmp(type, "image") == 0) {
- box = box_create(style, NULL, 0, status->id,
+ box = box_create(style, NULL, 0, status->id,
status->content->data.html.box_pool);
- box->gadget = gadget = form_new_control(GADGET_IMAGE);
+ box->gadget = gadget = form_new_control(GADGET_IMAGE);
if (!gadget) {
box_free_box(box);
xmlFree(type);
@@ -1362,7 +1363,7 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
}
gadget->box = box;
gadget->type = GADGET_IMAGE;
- if ((s = (char *) xmlGetProp(n, (const xmlChar*) "src"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar*) "src")) != NULL) {
res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
@@ -1419,7 +1420,7 @@ struct box *box_input_text(xmlNode *n, struct box_status *status,
box->gadget->box = box;
box->gadget->maxlength = 100;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "maxlength"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "maxlength")) != NULL) {
box->gadget->maxlength = atoi(s);
xmlFree(s);
}
@@ -1491,7 +1492,7 @@ struct box_result box_button(xmlNode *n, struct box_status *status,
else
box->gadget->form = 0;
box->gadget->box = box;
- if ((s = xmlGetProp(n, (const xmlChar *) "name"))) {
+ if ((s = xmlGetProp(n, (const xmlChar *) "name")) != NULL) {
box->gadget->name = strdup((char *) s);
xmlFree(s);
if (!box->gadget->name) {
@@ -1499,7 +1500,7 @@ struct box_result box_button(xmlNode *n, struct box_status *status,
return (struct box_result) {0, false, true};
}
}
- if ((s = xmlGetProp(n, (const xmlChar *) "value"))) {
+ if ((s = xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
box->gadget->value = strdup((char *) s);
xmlFree(s);
if (!box->gadget->value) {
@@ -1538,11 +1539,11 @@ void box_dump(struct box * box, unsigned int depth)
case BOX_INLINE: fprintf(stderr, "INLINE "); break;
case BOX_INLINE_BLOCK: fprintf(stderr, "INLINE_BLOCK "); break;
case BOX_TABLE: fprintf(stderr, "TABLE [columns %i] ",
- box->columns); break;
+ box->columns); break;
case BOX_TABLE_ROW: fprintf(stderr, "TABLE_ROW "); break;
case BOX_TABLE_CELL: fprintf(stderr, "TABLE_CELL [columns %i, "
- "start %i, rows %i] ", box->columns,
- box->start_column, box->rows); break;
+ "start %i, rows %i] ", box->columns,
+ box->start_column, box->rows); break;
case BOX_TABLE_ROW_GROUP: fprintf(stderr, "TABLE_ROW_GROUP "); break;
case BOX_FLOAT_LEFT: fprintf(stderr, "FLOAT_LEFT "); break;
case BOX_FLOAT_RIGHT: fprintf(stderr, "FLOAT_RIGHT "); break;
@@ -1552,7 +1553,7 @@ void box_dump(struct box * box, unsigned int depth)
if (box->text)
fprintf(stderr, "'%.*s' ", (int) box->length, box->text);
if (box->space)
- fprintf(stderr, "space ");
+ fprintf(stderr, "space ");
if (box->object)
fprintf(stderr, "(object '%s') ", box->object->url);
if (box->style)
@@ -2062,18 +2063,18 @@ struct box_result box_object(xmlNode *n, struct box_status *status,
box = box_create(style, status->href, 0, status->id,
status->content->data.html.box_pool);
- po = xcalloc(1, sizeof(*po));
-
- /* initialise po struct */
- po->data = 0;
- po->type = 0;
- po->codetype = 0;
- po->codebase = 0;
- po->classid = 0;
- po->params = 0;
+ po = xcalloc(1, sizeof(*po));
- /* object data */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "data"))) {
+ /* initialise po struct */
+ po->data = 0;
+ po->type = 0;
+ po->codetype = 0;
+ po->codebase = 0;
+ po->classid = 0;
+ po->params = 0;
+
+ /* object data */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "data")) != NULL) {
res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
@@ -2090,95 +2091,84 @@ struct box_result box_object(xmlNode *n, struct box_status *status,
}
/* imagemap associated with this object */
- if ((map = xmlGetProp(n, (const xmlChar *) "usemap"))) {
- if (map[0] == '#') {
- box->usemap = xstrdup(map+1);
- }
- else {
- box->usemap = xstrdup(map);
- }
- xmlFree(map);
- }
-
- /* object type */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "type"))) {
-
- po->type = strdup(s);
- LOG(("type: %s", s));
- xmlFree(s);
- }
-
- /* object codetype */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codetype"))) {
-
- po->codetype = strdup(s);
- LOG(("codetype: %s", s));
- xmlFree(s);
- }
-
- /* object codebase */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codebase"))) {
-
- po->codebase = strdup(s);
- LOG(("codebase: %s", s));
- xmlFree(s);
- }
-
- /* object classid */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "classid"))) {
-
- po->classid = strdup(s);
- LOG(("classid: %s", s));
- xmlFree(s);
- }
-
- /* parameters
- * parameter data is stored in a singly linked list.
- * po->params points to the head of the list.
- * new parameters are added to the head of the list.
- */
- for (c = n->children; c != 0; c = c->next) {
- if (strcmp((const char *) c->name, "param") == 0) {
-
- pp = xcalloc(1, sizeof(*pp));
-
- /* initialise pp struct */
- pp->name = 0;
- pp->value = 0;
- pp->valuetype = 0;
- pp->type = 0;
- pp->next = 0;
-
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "name"))) {
- pp->name = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "value"))) {
- pp->value = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "type"))) {
- pp->type = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "valuetype"))) {
- pp->valuetype = strdup(s);
- xmlFree(s);
- }
- else {
-
- pp->valuetype = strdup("data");
- }
-
- pp->next = po->params;
- po->params = pp;
- }
- else {
- /* The first non-param child is the start of the
- * alt html. Therefore, we should break out of this loop.
- */
- continue;
- }
+ if ((map = xmlGetProp(n, (const xmlChar *) "usemap")) != NULL) {
+ box->usemap = (map[0] == '#') ? xstrdup(map+1) : xstrdup(map);
+ xmlFree(map);
+ }
+
+ /* object type */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "type")) != NULL) {
+ po->type = strdup(s);
+ LOG(("type: %s", s));
+ xmlFree(s);
+ }
+
+ /* object codetype */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codetype")) != NULL) {
+ po->codetype = strdup(s);
+ LOG(("codetype: %s", s));
+ xmlFree(s);
+ }
+
+ /* object codebase */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codebase")) != NULL) {
+ po->codebase = strdup(s);
+ LOG(("codebase: %s", s));
+ xmlFree(s);
+ }
+
+ /* object classid */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "classid")) != NULL) {
+ po->classid = strdup(s);
+ LOG(("classid: %s", s));
+ xmlFree(s);
+ }
+
+ /* parameters
+ * parameter data is stored in a singly linked list.
+ * po->params points to the head of the list.
+ * new parameters are added to the head of the list.
+ */
+ for (c = n->children; c != NULL; c = c->next) {
+ if (strcmp((const char *) c->name, "param") == 0) {
+ pp = xcalloc(1, sizeof(*pp));
+
+ /* initialise pp struct */
+ pp->name = 0;
+ pp->value = 0;
+ pp->valuetype = 0;
+ pp->type = 0;
+ pp->next = 0;
+
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "name")) != NULL) {
+ pp->name = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "value")) != NULL) {
+ pp->value = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "type")) != NULL) {
+ pp->type = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "valuetype")) != NULL) {
+ pp->valuetype = strdup(s);
+ xmlFree(s);
+ } else {
+ pp->valuetype = strdup("data");
+ }
+
+ pp->next = po->params;
+ po->params = pp;
+ } else {
+ /* The first non-param child is the start
+ * of the alt html. Therefore, we should
+ * break out of this loop.
+ */
+ /** \todo: following statement is *not* breaking the loop ?! Is comment or code wrong here ? */
+ continue;
+ }
}
box->object_params = po;
@@ -2210,15 +2200,15 @@ struct box_result box_embed(xmlNode *n, struct box_status *status,
po = xcalloc(1, sizeof(*po));
/* initialise po struct */
- po->data = 0;
- po->type = 0;
- po->codetype = 0;
- po->codebase = 0;
- po->classid = 0;
- po->params = 0;
+ po->data = 0;
+ po->type = 0;
+ po->codetype = 0;
+ po->codebase = 0;
+ po->classid = 0;
+ po->params = 0;
/* embed src */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src")) != NULL) {
res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
@@ -2230,37 +2220,35 @@ struct box_result box_embed(xmlNode *n, struct box_status *status,
return (struct box_result) {box, false, true};
}
LOG(("embed '%s'", url));
- po->data = strdup(s);
- xmlFree(s);
- }
-
- /**
- * we munge all other attributes into a plugin_parameter structure
- */
- for(a=n->properties; a!=0; a=a->next) {
-
- pp = xcalloc(1, sizeof(*pp));
-
- /* initialise pp struct */
- pp->name = 0;
- pp->value = 0;
- pp->valuetype = 0;
- pp->type = 0;
- pp->next = 0;
-
- if(strcasecmp((const char*)a->name, "src") != 0) {
- pp->name = strdup((const char*)a->name);
- pp->value = strdup((char*)a->children->content);
- pp->valuetype = strdup("data");
-
- pp->next = po->params;
- po->params = pp;
- }
- }
+ po->data = strdup(s);
+ xmlFree(s);
+ }
+
+ /**
+ * we munge all other attributes into a plugin_parameter structure
+ */
+ for (a=n->properties; a != NULL; a=a->next) {
+ pp = xcalloc(1, sizeof(*pp));
+
+ /* initialise pp struct */
+ pp->name = 0;
+ pp->value = 0;
+ pp->valuetype = 0;
+ pp->type = 0;
+ pp->next = 0;
+
+ if (strcasecmp((const char*)a->name, "src") != 0) {
+ pp->name = strdup((const char*)a->name);
+ pp->value = strdup((char*)a->children->content);
+ pp->valuetype = strdup("data");
+ pp->next = po->params;
+ po->params = pp;
+ }
+ }
box->object_params = po;
- /* start fetch */
+ /* start fetch */
plugin_decode(status->content, url, box, po);
return (struct box_result) {box, false, false};
@@ -2286,15 +2274,15 @@ struct box_result box_applet(xmlNode *n, struct box_status *status,
po = xcalloc(1, sizeof(*po));
/* initialise po struct */
- po->data = 0;
- po->type = 0;
- po->codetype = 0;
- po->codebase = 0;
- po->classid = 0;
- po->params = 0;
+ po->data = 0;
+ po->type = 0;
+ po->codetype = 0;
+ po->codebase = 0;
+ po->classid = 0;
+ po->params = 0;
/* code */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "code"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "code")) != NULL) {
res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
@@ -2310,70 +2298,67 @@ struct box_result box_applet(xmlNode *n, struct box_status *status,
xmlFree(s);
}
- /* object codebase */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codebase"))) {
-
- po->codebase = strdup(s);
- LOG(("codebase: %s", s));
- xmlFree(s);
- }
-
- /* parameters
- * parameter data is stored in a singly linked list.
- * po->params points to the head of the list.
- * new parameters are added to the head of the list.
- */
- for (c = n->children; c != 0; c = c->next) {
- if (strcmp((const char *) c->name, "param") == 0) {
-
- pp = xcalloc(1, sizeof(*pp));
-
- /* initialise pp struct */
- pp->name = 0;
- pp->value = 0;
- pp->valuetype = 0;
- pp->type = 0;
- pp->next = 0;
-
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "name"))) {
- pp->name = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "value"))) {
- pp->value = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "type"))) {
- pp->type = strdup(s);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "valuetype"))) {
- pp->valuetype = strdup(s);
- xmlFree(s);
- }
- else {
-
- pp->valuetype = strdup("data");
- }
-
- pp->next = po->params;
- po->params = pp;
- }
- else {
- /* The first non-param child is the start of the
- * alt html. Therefore, we should break out of this loop.
- */
- continue;
- }
- }
-
- box->object_params = po;
+ /* object codebase */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codebase")) != NULL) {
+ po->codebase = strdup(s);
+ LOG(("codebase: %s", s));
+ xmlFree(s);
+ }
+
+ /* parameters
+ * parameter data is stored in a singly linked list.
+ * po->params points to the head of the list.
+ * new parameters are added to the head of the list.
+ */
+ for (c = n->children; c != 0; c = c->next) {
+ if (strcmp((const char *) c->name, "param") == 0) {
+ pp = xcalloc(1, sizeof(*pp));
+
+ /* initialise pp struct */
+ pp->name = 0;
+ pp->value = 0;
+ pp->valuetype = 0;
+ pp->type = 0;
+ pp->next = 0;
+
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "name")) != NULL) {
+ pp->name = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "value")) != NULL) {
+ pp->value = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "type")) != NULL) {
+ pp->type = strdup(s);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "valuetype")) != NULL) {
+ pp->valuetype = strdup(s);
+ xmlFree(s);
+ } else {
+ pp->valuetype = strdup("data");
+ }
+
+ pp->next = po->params;
+ po->params = pp;
+ } else {
+ /* The first non-param child is the start
+ * of the alt html. Therefore, we should
+ * break out of this loop.
+ */
+ /** \todo: following statement is *not* breaking the loop ?! Is comment or code wrong here ? */
+ continue;
+ }
+ }
+
+ box->object_params = po;
/* start fetch */
- if(plugin_decode(status->content, url, box, po))
- return (struct box_result) {box, false, false};
+ if (plugin_decode(status->content, url, box, po))
+ return (struct box_result) {box, false, false};
- return (struct box_result) {box, true, false};
+ return (struct box_result) {box, true, false};
}
/**
@@ -2384,7 +2369,7 @@ struct box_result box_applet(xmlNode *n, struct box_status *status,
struct box_result box_iframe(xmlNode *n, struct box_status *status,
struct css_style *style)
{
- struct box *box;
+ struct box *box;
struct object_params *po;
char *s, *url = NULL;
url_func_result res;
@@ -2395,15 +2380,15 @@ struct box_result box_iframe(xmlNode *n, struct box_status *status,
po = xcalloc(1, sizeof(*po));
/* initialise po struct */
- po->data = 0;
- po->type = 0;
- po->codetype = 0;
- po->codebase = 0;
- po->classid = 0;
- po->params = 0;
+ po->data = 0;
+ po->type = 0;
+ po->codetype = 0;
+ po->codebase = 0;
+ po->classid = 0;
+ po->params = 0;
/* iframe src */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src")) != NULL) {
res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
@@ -2421,7 +2406,7 @@ struct box_result box_iframe(xmlNode *n, struct box_status *status,
box->object_params = po;
- /* start fetch */
+ /* start fetch */
plugin_decode(status->content, url, box, po);
return (struct box_result) {box, false, false};
@@ -2436,103 +2421,99 @@ struct box_result box_iframe(xmlNode *n, struct box_status *status,
*
* Returns false if the object could not be handled.
*
- * TODO: reformat, plug failure leaks
+ * TODO: plug failure leaks
*/
bool plugin_decode(struct content* content, char* url, struct box* box,
- struct object_params* po)
+ struct object_params* po)
{
- struct plugin_params * pp;
- url_func_result res;
-
- /* Check if the codebase attribute is defined.
- * If it is not, set it to the codebase of the current document.
- */
- if(po->codebase == 0)
- res = url_join("./", content->data.html.base_url, &po->codebase);
- else
- res = url_join(po->codebase, content->data.html.base_url, &po->codebase);
-
- if (res != URL_FUNC_OK)
- return false;
-
- /* Set basehref */
- po->basehref = strdup(content->data.html.base_url);
-
- /* Check that we have some data specified.
- * First, check the data attribute.
- * Second, check the classid attribute.
- * The data attribute takes precedence.
- * If neither are specified or if classid begins "clsid:",
- * we can't handle this object.
- */
- if(po->data == 0 && po->classid == 0) {
- return false;
- }
- if(po->data == 0 && po->classid != 0) {
- if(strncasecmp(po->classid, "clsid:", 6) == 0) {
- /* Flash */
- if(strcasecmp(po->classid, "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000") == 0) {
- for(pp = po->params; pp != 0 &&
- (strcasecmp(pp->name, "movie") != 0);
- pp = pp->next);
- if(pp == 0)
- return false;
- res = url_join(pp->value, po->basehref, &url);
- if (res != URL_FUNC_OK)
- return false;
- /* munge the codebase */
- res = url_join("./",
- content->data.html.base_url,
- &po->codebase);
- if (res != URL_FUNC_OK)
- return false;
- }
- else {
- LOG(("ActiveX object - n0"));
- return false;
- }
- }
- else {
- res = url_join(po->classid, po->codebase, &url);
- if (res != URL_FUNC_OK)
- return false;
-
- /* The java plugin doesn't need the .class extension
- * so we strip it.
- */
- if(strcasecmp((&po->classid[strlen(po->classid)-6]),
- ".class") == 0)
- po->classid[strlen(po->classid)-6] = 0;
- }
- }
- else {
- res = url_join(po->data, po->codebase, &url);
- if (res != URL_FUNC_OK)
- return false;
- }
-
- /* Check if the declared mime type is understandable.
- * Checks type and codetype attributes.
- */
- if(po->type != 0) {
- if (content_lookup(po->type) == CONTENT_OTHER)
- return false;
- }
- if(po->codetype != 0) {
- if (content_lookup(po->codetype) == CONTENT_OTHER)
- return false;
- }
-
- /* If we've got to here, the object declaration has provided us with
- * enough data to enable us to have a go at downloading and displaying it.
- *
- * We may still find that the object has a MIME type that we can't handle
- * when we fetch it (if the type was not specified or is different to that
- * given in the attributes).
- */
- html_fetch_object(content, url, box, 0, 1000, 1000, false);
-
- return true;
+ struct plugin_params * pp;
+ url_func_result res;
+
+ /* Check if the codebase attribute is defined.
+ * If it is not, set it to the codebase of the current document.
+ */
+ if (po->codebase == 0)
+ res = url_join("./", content->data.html.base_url, &po->codebase);
+ else
+ res = url_join(po->codebase, content->data.html.base_url, &po->codebase);
+
+ if (res != URL_FUNC_OK)
+ return false;
+
+ /* Set basehref */
+ po->basehref = strdup(content->data.html.base_url);
+
+ /* Check that we have some data specified.
+ * First, check the data attribute.
+ * Second, check the classid attribute.
+ * The data attribute takes precedence.
+ * If neither are specified or if classid begins "clsid:",
+ * we can't handle this object.
+ */
+ if (po->data == 0 && po->classid == 0)
+ return false;
+
+ if (po->data == 0 && po->classid != 0) {
+ if (strncasecmp(po->classid, "clsid:", 6) == 0) {
+ /* Flash */
+ if (strcasecmp(po->classid, "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000") == 0) {
+ for (pp = po->params;
+ pp != 0 && strcasecmp(pp->name, "movie") != 0;
+ pp = pp->next)
+ /* no body */;
+ if (pp == 0)
+ return false;
+ res = url_join(pp->value, po->basehref, &url);
+ if (res != URL_FUNC_OK)
+ return false;
+ /* munge the codebase */
+ res = url_join("./",
+ content->data.html.base_url,
+ &po->codebase);
+ if (res != URL_FUNC_OK)
+ return false;
+ }
+ else {
+ LOG(("ActiveX object - n0"));
+ return false;
+ }
+ } else {
+ res = url_join(po->classid, po->codebase, &url);
+ if (res != URL_FUNC_OK)
+ return false;
+
+ /* The java plugin doesn't need the .class extension
+ * so we strip it.
+ */
+ if (strcasecmp(&po->classid[strlen(po->classid)-6],
+ ".class") == 0)
+ po->classid[strlen(po->classid)-6] = 0;
+ }
+ } else {
+ res = url_join(po->data, po->codebase, &url);
+ if (res != URL_FUNC_OK)
+ return false;
+ }
+
+ /* Check if the declared mime type is understandable.
+ * Checks type and codetype attributes.
+ */
+ if (po->type != 0 && content_lookup(po->type) == CONTENT_OTHER)
+ return false;
+ if (po->codetype != 0 && content_lookup(po->codetype) == CONTENT_OTHER)
+ return false;
+
+ /* If we've got to here, the object declaration has provided us with
+ * enough data to enable us to have a go at downloading and
+ * displaying it.
+ *
+ * We may still find that the object has a MIME type that we can't
+ * handle when we fetch it (if the type was not specified or is
+ * different to that given in the attributes).
+ */
+ html_fetch_object(content, url, box, 0, 1000, 1000, false);
+
+ return true;
}
@@ -2558,7 +2539,7 @@ struct box_result box_frameset(xmlNode *n, struct box_status *status,
box->type = BOX_TABLE;
/* parse rows and columns */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rows"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rows")) != NULL) {
row_height = box_parse_multi_lengths(s, &rows);
xmlFree(s);
if (!row_height) {
@@ -2567,7 +2548,7 @@ struct box_result box_frameset(xmlNode *n, struct box_status *status,
}
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "cols"))) {
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "cols")) != NULL) {
col_width = box_parse_multi_lengths(s, &cols);
xmlFree(s);
if (!col_width) {
@@ -2684,8 +2665,7 @@ struct box_result box_frameset(xmlNode *n, struct box_status *status,
object_box->style_clone = 1;
box_add_child(cell_box, object_box);
- if (!(s = (char *) xmlGetProp(c,
- (const xmlChar *) "src"))) {
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *) "src")) == NULL) {
c = c->next;
continue;
}
@@ -2734,16 +2714,15 @@ struct box_multi_length *box_parse_multi_lengths(const char *s,
unsigned int *count)
{
char *end;
- unsigned int i, n = 1;
+ unsigned int i, n;
struct box_multi_length *length;
- for (i = 0; s[i]; i++)
+ for (i = 0, n = 1; s[i]; i++)
if (s[i] == ',')
n++;
- length = malloc(sizeof *length * n);
- if (!length)
- return 0;
+ if ((length = malloc(sizeof *length * n)) == NULL)
+ return NULL;
for (i = 0; i != n; i++) {
while (isspace(*s))
@@ -2797,7 +2776,7 @@ void box_coords(struct box *box, int *x, int *y)
* Find the boxes at a point.
*
* \param box box to search children of
- * \param x point to find, in global document coordinates
+ * \param x point to find, in global document coordinates
* \param y point to find, in global document coordinates
* \param box_x position of box, in global document coordinates, updated
* to position of returned box, if any
@@ -2934,7 +2913,7 @@ struct box *box_object_at_point(struct content *c, int x, int y)
assert(c->type == CONTENT_HTML);
- while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
+ while ((box = box_at_point(box, x, y, &box_x, &box_y, &content)) != NULL) {
if (box->style &&
box->style->visibility == CSS_VISIBILITY_HIDDEN)
continue;
@@ -2953,7 +2932,7 @@ struct box *box_object_at_point(struct content *c, int x, int y)
* \param id id to look for
* \return the box or 0 if not found
*/
-struct box *box_find_by_id(struct box *box, char *id)
+struct box *box_find_by_id(struct box *box, const char *id)
{
struct box *a, *b;
@@ -2965,5 +2944,5 @@ struct box *box_find_by_id(struct box *box, char *id)
return b;
}
- return 0;
+ return NULL;
}
diff --git a/render/box.h b/render/box.h
index 5b6427bc6..8014b9856 100644
--- a/render/box.h
+++ b/render/box.h
@@ -232,11 +232,11 @@ struct column {
void xml_to_box(xmlNode *n, struct content *c);
-void box_dump(struct box * box, unsigned int depth);
-struct box * box_create(struct css_style * style,
+void box_dump(struct box *box, unsigned int depth);
+struct box * box_create(struct css_style *style,
const char *href, const char *title,
const char *id, pool box_pool);
-void box_add_child(struct box * parent, struct box * child);
+void box_add_child(struct box * parent, struct box *child);
void box_insert_sibling(struct box *box, struct box *new_box);
void box_free(struct box *box);
void box_coords(struct box *box, int *x, int *y);
@@ -244,6 +244,6 @@ struct box *box_at_point(struct box *box, int x, int y,
int *box_x, int *box_y,
struct content **content);
struct box *box_object_at_point(struct content *c, int x, int y);
-struct box *box_find_by_id(struct box *box, char *id);
+struct box *box_find_by_id(struct box *box, const char *id);
#endif
diff --git a/render/html.c b/render/html.c
index f71182079..d3e359f85 100644
--- a/render/html.c
+++ b/render/html.c
@@ -386,7 +386,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
if (strcmp(node->name, "link") == 0) {
/* rel='stylesheet' */
- if (!(rel = (char *) xmlGetProp(node, (const xmlChar *) "rel")))
+ if ((rel = (char *) xmlGetProp(node, (const xmlChar *) "rel")) == NULL)
continue;
if (strcasecmp(rel, "stylesheet") != 0) {
xmlFree(rel);
@@ -395,7 +395,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
xmlFree(rel);
/* type='text/css' or not present */
- if ((type = (char *) xmlGetProp(node, (const xmlChar *) "type"))) {
+ if ((type = (char *) xmlGetProp(node, (const xmlChar *) "type")) != NULL) {
if (strcmp(type, "text/css") != 0) {
xmlFree(type);
continue;
@@ -404,7 +404,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
}
/* media contains 'screen' or 'all' or not present */
- if ((media = (char *) xmlGetProp(node, (const xmlChar *) "media"))) {
+ if ((media = (char *) xmlGetProp(node, (const xmlChar *) "media")) != NULL) {
if (strstr(media, "screen") == 0 &&
strstr(media, "all") == 0) {
xmlFree(media);
@@ -414,7 +414,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
}
/* href='...' */
- if (!(href = (char *) xmlGetProp(node, (const xmlChar *) "href")))
+ if ((href = (char *) xmlGetProp(node, (const xmlChar *) "href")) == NULL)
continue;
/* TODO: only the first preferred stylesheets (ie. those with a
@@ -447,7 +447,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
} else if (strcmp(node->name, "style") == 0) {
/* type='text/css', or not present (invalid but common) */
- if ((type = (char *) xmlGetProp(node, (const xmlChar *) "type"))) {
+ if ((type = (char *) xmlGetProp(node, (const xmlChar *) "type")) != NULL) {
if (strcmp(type, "text/css") != 0) {
xmlFree(type);
continue;
@@ -456,7 +456,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
}
/* media contains 'screen' or 'all' or not present */
- if ((media = (char *) xmlGetProp(node, (const xmlChar *) "media"))) {
+ if ((media = (char *) xmlGetProp(node, (const xmlChar *) "media")) != NULL) {
if (strstr(media, "screen") == 0 &&
strstr(media, "all") == 0) {
xmlFree(media);
diff --git a/riscos/buffer.c b/riscos/buffer.c
index b77d6957a..b791afb35 100644
--- a/riscos/buffer.c
+++ b/riscos/buffer.c
@@ -18,18 +18,18 @@
/* SCREEN BUFFERING
================
-
+
Because RISC OS provides no native way for windows to be buffered (ie
the contents is only updated when the task has finished doing any
drawing) certain situation cause the window contents to flicker in an
undesirable manner. Examples of this are GIF and MNG animations, and
web pages with fixed backgrounds.
-
+
To overcome this, a very simple, transparent, interface is provided here
to allow for output to be buffered. It should be noted that screen
buffering can lower the perceived client response time as the user is
unable to see that the application is doing anything.
-
+
[rjw] - Mon 19th July 2004
*/
@@ -104,13 +104,14 @@ void ro_gui_buffer_open(wimp_draw *redraw) {
buffer->sprite_count = 0;
buffer->first = 16;
buffer->used = 16;
-
+
/* Fill in the sprite header details
*/
sprintf(name, "buffer");
- if ((error = xosspriteop_get_sprite_user_coords(osspriteop_NAME, buffer,
- name, palette,
- clipping.x0, clipping.y0, clipping.x1, clipping.y1))) {
+ if ((error = xosspriteop_get_sprite_user_coords(osspriteop_NAME,
+ buffer, name, palette,
+ clipping.x0, clipping.y0,
+ clipping.x1, clipping.y1)) != NULL) {
// LOG(("Grab error '%s'", error->errmess));
free(buffer);
buffer = NULL;
@@ -119,14 +120,14 @@ void ro_gui_buffer_open(wimp_draw *redraw) {
/* Allocate OS_SpriteOp save area
*/
- if ((error = xosspriteop_read_save_area_size(osspriteop_NAME, buffer,
- (osspriteop_id)name, &size))) {
+ if ((error = xosspriteop_read_save_area_size(osspriteop_NAME,
+ buffer, (osspriteop_id)name, &size)) != NULL) {
// LOG(("Save area error '%s'", error->errmess));
free(buffer);
buffer = NULL;
return;
}
- if (!(save_area = malloc((unsigned)size))) {
+ if ((save_area = malloc((size_t)size)) == NULL) {
free(buffer);
buffer = NULL;
return;
@@ -135,9 +136,10 @@ void ro_gui_buffer_open(wimp_draw *redraw) {
/* Switch output to sprite
*/
- if ((error = xosspriteop_switch_output_to_sprite(osspriteop_NAME, buffer,
- (osspriteop_id)name, save_area,
- 0, (int *)&context1, (int *)&context2, (int *)&context3))) {
+ if ((error = xosspriteop_switch_output_to_sprite(osspriteop_NAME,
+ buffer, (osspriteop_id)name, save_area, 0,
+ (int *)&context1, (int *)&context2,
+ (int *)&context3)) != NULL) {
// LOG(("Switching error '%s'", error->errmess));
free(save_area);
free(buffer);
@@ -161,7 +163,7 @@ void ro_gui_buffer_open(wimp_draw *redraw) {
* Closes any open buffer and flushes the contents to screen
*/
void ro_gui_buffer_close(void) {
-
+
/* Check we have an open buffer
*/
if (!buffer) return;
@@ -178,7 +180,7 @@ void ro_gui_buffer_close(void) {
xosspriteop_put_sprite_user_coords(osspriteop_NAME,
buffer, (osspriteop_id)name,
clipping.x0, clipping.y0, (os_action)0);
-
+
/* Free our memory
*/
free(buffer);
diff --git a/riscos/gui.c b/riscos/gui.c
index 82cc07f49..43c06ede6 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -692,7 +692,7 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
ro_gui_hotlist_redraw(redraw);
else if (redraw->w == dialog_debug)
ro_gui_debugwin_redraw(redraw);
- else if ((g = ro_gui_window_lookup(redraw->w)))
+ else if ((g = ro_gui_window_lookup(redraw->w)) != NULL)
ro_gui_window_redraw(g, redraw);
else {
error = xwimp_redraw_window(redraw, &more);
@@ -760,9 +760,9 @@ void ro_gui_close_window_request(wimp_close *close)
if (close->w == dialog_debug)
ro_gui_debugwin_close();
- else if ((g = ro_gui_window_lookup(close->w)))
+ else if ((g = ro_gui_window_lookup(close->w)) != NULL)
browser_window_destroy(g->bw);
- else if ((dw = ro_gui_download_window_lookup(close->w)))
+ else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL)
ro_gui_download_window_destroy(dw);
else
ro_gui_dialog_close(close->w);
@@ -823,13 +823,13 @@ void ro_gui_mouse_click(wimp_pointer *pointer)
else if (hotlist_toolbar &&
hotlist_toolbar->toolbar_handle == pointer->w)
ro_gui_hotlist_toolbar_click(pointer);
- else if ((g = ro_gui_window_lookup(pointer->w)))
+ else if ((g = ro_gui_window_lookup(pointer->w)) != NULL)
ro_gui_window_click(g, pointer);
- else if ((g = ro_gui_toolbar_lookup(pointer->w)))
+ else if ((g = ro_gui_toolbar_lookup(pointer->w)) != NULL)
ro_gui_toolbar_click(g, pointer);
- else if ((g = ro_gui_status_lookup(pointer->w)))
+ else if ((g = ro_gui_status_lookup(pointer->w)) != NULL)
ro_gui_status_click(g, pointer);
- else if ((dw = ro_gui_download_window_lookup(pointer->w)))
+ else if ((dw = ro_gui_download_window_lookup(pointer->w)) != NULL)
ro_gui_download_window_click(dw, pointer);
else
ro_gui_dialog_click(pointer);
@@ -915,9 +915,9 @@ void ro_gui_keypress(wimp_key *key)
if (key->w == hotlist_window)
handled = ro_gui_hotlist_keypress(key->c);
- else if ((g = ro_gui_window_lookup(key->w)))
+ else if ((g = ro_gui_window_lookup(key->w)) != NULL)
handled = ro_gui_window_keypress(g, key->c, false);
- else if ((g = ro_gui_toolbar_lookup(key->w)))
+ else if ((g = ro_gui_toolbar_lookup(key->w)) != NULL)
handled = ro_gui_window_keypress(g, key->c, true);
else
handled = ro_gui_dialog_keypress(key);
diff --git a/riscos/help.c b/riscos/help.c
index 1ba514f95..6a7f7a696 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -51,7 +51,7 @@
of numbers representing the menu structure (eg 'HelpBrowserMenu3-1-2').
If '<key><identifier>' is not available, then simply '<key>' is then used. For example
if 'HelpToolbar7' is not available then 'HelpToolbar' is then tried.
-
+
If an item is greyed out then a suffix of 'g' is added (eg 'HelpToolbar7g'). For this to
work, windows must have bit 4 of the window flag byte set and the user must be running
RISC OS 5.03 or greater.
@@ -126,11 +126,11 @@ void ro_gui_interactive_help_request(wimp_message *message) {
} else if (hotlist_toolbar &&
window == hotlist_toolbar->toolbar_handle) {
sprintf(message_token, "HelpHotToolbar%i", (int)icon);
- } else if ((g = ro_gui_window_lookup(window))) {
+ } else if ((g = ro_gui_window_lookup(window)) != NULL) {
sprintf(message_token, "HelpBrowser%i", (int)icon);
- } else if ((g = ro_gui_toolbar_lookup(window))) {
+ } else if ((g = ro_gui_toolbar_lookup(window)) != NULL) {
sprintf(message_token, "HelpToolbar%i", (int)icon);
- } else if ((g = ro_gui_status_lookup(window))) {
+ } else if ((g = ro_gui_status_lookup(window)) != NULL) {
sprintf(message_token, "HelpStatus%i", (int)icon);
}
@@ -142,7 +142,7 @@ void ro_gui_interactive_help_request(wimp_message *message) {
if ((icon >= 0) && (ro_gui_get_icon_shaded_state(window, icon))) {
strcat(message_token, "g");
}
-
+
/* Broadcast out message
*/
ro_gui_interactive_help_broadcast(message, &message_token[0]);
@@ -183,7 +183,7 @@ void ro_gui_interactive_help_request(wimp_message *message) {
*/
greyed |= test_menu->entries[menu_tree.items[index]].icon_flags & wimp_ICON_SHADED;
test_menu = test_menu->entries[menu_tree.items[index]].sub_menu;
-
+
/* Continue adding the entries
*/
if (index == 0) {
@@ -230,7 +230,7 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token
base_token = token;
while (base_token[0] != 0x00) {
if ((base_token[0] == '-') ||
- ((base_token[0] >= '0') && (base_token[0] <= '9'))) {
+ ((base_token[0] >= '0') && (base_token[0] <= '9'))) {
base_token[0] = 0x00;
} else {
++base_token;
@@ -242,7 +242,7 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token
translated_token = messages_get(token);
}
}
-
+
/* Copy our message string
*/