Here is my current diff.
It's mostly moving back variable decl before statements as gcc2 wasn't
c99, and BeOS can't use gcc4 without great hackery, and g++ crashes
miserably on the C code.
The css font size is due to g++ not liking it inlined in the union.
Still needs cleanup though, like strtod stuff.
Haiku should soon be usable so we can move to it, and it can use gcc4,
but I'd like to at least have some revisions that build under BeOS
without patch before moving along.
François.
Index: render/form.c
===================================================================
--- render/form.c (révision 4724)
+++ render/form.c (copie de travail)
@@ -343,12 +343,13 @@
case GADGET_IMAGE: {
/* image */
+ const size_t len;
if (control != submit_button)
/* only the activated submit button
* is successful */
continue;
- const size_t len = strlen(control->name) + 3;
+ len = strlen(control->name) + 3;
/* x */
success_new = malloc(sizeof(*success_new));
Index: render/html.c
===================================================================
--- render/html.c (révision 4724)
+++ render/html.c (copie de travail)
@@ -534,10 +534,11 @@
LOG(("Node: %s", node->name));
if (!c->title && strcmp((const char *) node->name,
"title") == 0) {
+ char *title2;
xmlChar *title = xmlNodeGetContent(node);
if (!title)
return false;
- char *title2 = squash_whitespace((const char *) title);
+ title2 = squash_whitespace((const char *) title);
xmlFree(title);
if (!title2)
return false;
Index: render/textplain.c
===================================================================
--- render/textplain.c (révision 4724)
+++ render/textplain.c (copie de travail)
@@ -24,7 +24,9 @@
#include <assert.h>
#include <errno.h>
#include <stddef.h>
+#ifndef __BEOS__
#define LIBICONV_PLUG
+#endif
#include <iconv.h>
#include "content/content.h"
#include "css/css.h"
Index: render/html_redraw.c
===================================================================
--- render/html_redraw.c (révision 4724)
+++ render/html_redraw.c (copie de travail)
@@ -778,7 +778,8 @@
!box->text) {
int padding_height = (box->padding[TOP] + box->height +
box->padding[BOTTOM]) * scale;
- for (struct box *c = box; c; c = c->next) {
+ struct box *c;
+ for (c = box; c; c = c->next) {
int x = (x_parent + c->x) * scale;
int y = y_parent + c->y;
int padding_width = c->width;
@@ -792,6 +793,7 @@
y *= scale;
padding_width *= scale;
}
+{//XXX
int p[20] = {
x, y,
x - left, y - top,
@@ -830,6 +832,7 @@
box->border[RIGHT] * scale);
if (!box->inline_end || c == box->inline_end)
break;
+}//XXX
}
} else {
int x = (x_parent + box->x) * scale;
@@ -846,7 +849,8 @@
x, y,
x - left, y - top
};
- for (unsigned int i = 0; i != 4; i++) {
+ unsigned int i;
+ for (i = 0; i != 4; i++) {
if (box->border[i] == 0)
continue;
if (!html_redraw_border_plot(i, p,
@@ -1446,7 +1450,8 @@
bool html_redraw_text_decoration_inline(struct box *box, int x, int y,
float scale, colour colour, float ratio)
{
- for (struct box *c = box->next;
+ struct box *c;
+ for (c = box->next;
c && c != box->inline_end;
c = c->next) {
if (!plot.line((x + c->x) * scale,
@@ -1475,8 +1480,9 @@
bool html_redraw_text_decoration_block(struct box *box, int x, int y,
float scale, colour colour, float ratio)
{
+ struct box *c;
/* draw through text descendants */
- for (struct box *c = box->children; c; c = c->next) {
+ for (c = box->children; c; c = c->next) {
if (c->type == BOX_TEXT) {
if (!plot.line((x + c->x) * scale,
(y + c->y + c->height * ratio) * scale,
Index: render/layout.c
===================================================================
--- render/layout.c (révision 4724)
+++ render/layout.c (copie de travail)
@@ -848,11 +848,11 @@
box->gadget->type == GADGET_PASSWORD ||
box->gadget->type == GADGET_FILE ||
box->gadget->type == GADGET_TEXTAREA)) {
+ struct css_length size;
/* Give sensible dimensions to gadgets, with auto width/height,
* that don't shrink to fit contained text. */
assert(box->style);
- struct css_length size;
size.unit = CSS_UNIT_EM;
if (box->gadget->type == GADGET_TEXTBOX ||
box->gadget->type == GADGET_PASSWORD ||
Index: render/imagemap.c
===================================================================
--- render/imagemap.c (révision 4724)
+++ render/imagemap.c (copie de travail)
@@ -449,6 +449,8 @@
}
if (new_map->type != IMAGEMAP_DEFAULT) {
+ int x, y;
+ float *xcoords, *ycoords;
/* coordinates are a comma-separated list of values */
val = strtok(coords, ",");
num = 1;
@@ -518,8 +520,6 @@
xmlFree(coords);
return false;
}
- int x, y;
- float *xcoords, *ycoords;
while (val) {
x = atoi(val);
val = strtok('\0', ",");
Index: render/box_construct.c
===================================================================
--- render/box_construct.c (révision 4724)
+++ render/box_construct.c (copie de travail)
@@ -957,10 +957,11 @@
"maxlength"))) {
int maxlength = isdigit(s[0]) ? atoi(s): -1;
if (0 < maxlength && size == -1 && maxlength < 10) {
+ char *type;
/* Bump up really small widths */
maxlength = maxlength < 5 ? maxlength + 1 :
maxlength;
- char *type = (char *) xmlGetProp(n,
+ type = (char *) xmlGetProp(n,
(const xmlChar *) "type");
style->width.width = CSS_WIDTH_LENGTH;
if (!type || strcasecmp(type, "text") == 0 ||
@@ -1052,7 +1053,8 @@
int border_width = atoi(s);
/* precentage border width not implemented */
if (!strrchr(s, '%') && 0 < border_width) {
- for (unsigned int i = 0; i != 4; i++) {
+ unsigned int i;
+ for (i = 0; i != 4; i++) {
if (!author->border_color[i])
style->border[i].color =
border_color;
@@ -1077,7 +1079,8 @@
strcmp((const char *) n->name, "th") == 0) {
/* set any cellborders stipulated by associated table */
if (markup_track->cell_border) {
- for (unsigned int i = 0; i != 4; i++) {
+ unsigned int i;
+ for (i = 0; i != 4; i++) {
if (!author->border_color[i])
style->border[i].color = markup_track->
border_color;
@@ -1095,7 +1098,8 @@
}
/* set any cellpadding stipulated by associated table */
if (markup_track->cell_padding) {
- for (unsigned int i = 0; i != 4; i++) {
+ unsigned int i;
+ for (i = 0; i != 4; i++) {
if (!author->padding[i]) {
style->padding[i].padding =
CSS_PADDING_LENGTH;
@@ -1285,8 +1289,8 @@
}
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "border"))) {
+ int border_width = atoi(s);
markup_track->border_color = border_color;
- int border_width = atoi(s);
/* percentage border width not implemented */
if (!strrchr(s, '%') && 0 < border_width) {
markup_track->cell_border = true;
@@ -2977,7 +2981,12 @@
for (i = 0; i != n; i++) {
while (isspace(*s))
s++;
+#if defined(__HAIKU__) || defined(__BEOS__)
+#warning FIXME
+ length[i].value = (float)strtod(s, &end);
+#else
length[i].value = strtof(s, &end);
+#endif
if (length[i].value <= 0)
length[i].value = 1;
s = end;
Index: image/jpeg.c
===================================================================
--- image/jpeg.c (révision 4724)
+++ image/jpeg.c (copie de travail)
@@ -122,6 +122,7 @@
rowstride = bitmap_get_rowstride(bitmap);
do {
+ int i;
JSAMPROW scanlines[1];
scanlines[0] = (JSAMPROW) (pixels +
rowstride * cinfo.output_scanline);
@@ -129,7 +130,7 @@
#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4
/* expand to RGBA */
- for (int i = width - 1; 0 <= i; i--) {
+ for (i = width - 1; 0 <= i; i--) {
int r = scanlines[0][i * RGB_PIXELSIZE + RGB_RED];
int g = scanlines[0][i * RGB_PIXELSIZE + RGB_GREEN];
int b = scanlines[0][i * RGB_PIXELSIZE + RGB_BLUE];
Index: css/ruleset.c
===================================================================
--- css/ruleset.c (révision 4724)
+++ css/ruleset.c (copie de travail)
@@ -681,6 +681,7 @@
colour named_colour(const char *name)
{
struct css_colour_entry *col;
+ int length;
col = bsearch(name, css_colour_table,
sizeof css_colour_table / sizeof css_colour_table[0],
@@ -693,7 +694,7 @@
* start of a colour specified in #rrggbb or #rgb format.
* This attempts to detect and recover from this.
*/
- int length = strlen(name);
+ length = strlen(name);
if ((length == 3) || (length == 6))
return hex_colour(name, length);
return CSS_COLOR_NONE;
Index: css/css.c
===================================================================
--- css/css.c (révision 4724)
+++ css/css.c (copie de travail)
@@ -2461,6 +2461,7 @@
* Set all members to false
*/
void css_importance_reset(struct css_importance *i) {
+ int j;
i->background_color = false;
i->background_image = false;
i->border_spacing = false;
@@ -2469,7 +2470,7 @@
i->width = false;
/**< top, right, bottom, left */
- for (int j = 0; j < 4; j++) {
+ for (j = 0; j < 4; j++) {
i->border_color[j] = false;
i->border_style[j] = false;
i->border_width[j] = false;
Index: css/css.h
===================================================================
--- css/css.h (révision 4724)
+++ css/css.h (copie de travail)
@@ -152,6 +152,15 @@
CSS_VERTICAL_ALIGN_NOT_SET
} css_vertical_align_type;
+typedef enum {
+ CSS_FONT_SIZE_INHERIT,
+ CSS_FONT_SIZE_ABSOLUTE,
+ CSS_FONT_SIZE_LENGTH,
+ CSS_FONT_SIZE_PERCENT,
+ CSS_FONT_SIZE_NOT_SET
+} css_font_size_type;
+
+
struct css_counter_control {
char *name;
int value;
@@ -255,11 +264,7 @@
/* font properties */
css_font_family font_family;
struct {
- enum { CSS_FONT_SIZE_INHERIT,
- CSS_FONT_SIZE_ABSOLUTE,
- CSS_FONT_SIZE_LENGTH,
- CSS_FONT_SIZE_PERCENT,
- CSS_FONT_SIZE_NOT_SET } size;
+ css_font_size_type size;
union {
struct css_length length;
float absolute;
Index: utils/utils.c
===================================================================
--- utils/utils.c (révision 4724)
+++ utils/utils.c (copie de travail)
@@ -172,8 +172,10 @@
static char buffer2[BYTESIZE_BUFFER_SIZE];
static char buffer3[BYTESIZE_BUFFER_SIZE];
static char *curbuffer = buffer3;
+ enum {bytes, kilobytes, megabytes, gigabytes} unit = bytes;
+ static char units[][7] = {"Bytes", "kBytes", "MBytes", "GBytes"};
- float bytesize = (float)bsize;
+ float bytesize = (float)bsize;
if (curbuffer == buffer1)
curbuffer = buffer2;
@@ -182,9 +184,6 @@
else
curbuffer = buffer1;
- enum {bytes, kilobytes, megabytes, gigabytes} unit = bytes;
- static char units[][7] = {"Bytes", "kBytes", "MBytes", "GBytes"};
-
if (bytesize > 1024) {
bytesize /= 1024;
unit = kilobytes;
Index: utils/utils.h
===================================================================
--- utils/utils.h (révision 4724)
+++ utils/utils.h (copie de travail)
@@ -39,6 +39,14 @@
#ifndef max
#define max(x,y) (((x)>(y))?(x):(y))
#endif
+#ifndef PRIxPTR
+#define PRIxPTR "x"
+#endif
+/*
+#if defined(__HAIKU__) || defined(__BEOS__)
+#define strtof(s,p) ((float)(strtod((s),(p)))
+#endif
+*/
/**
* Calculate length of constant C string.
Index: utils/config.h
===================================================================
--- utils/config.h (révision 4724)
+++ utils/config.h (copie de travail)
@@ -24,11 +24,12 @@
/* Try to detect which features the target OS supports */
#define HAVE_STRNDUP
-#if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun))
+#if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun)) ||
defined(__HAIKU__) || defined(__BEOS__)
/* FreeBSD and Solaris do not have this function, so
* we implement it ourselves in util.c
*/
#undef HAVE_STRNDUP
+#include <size_t.h>
char *strndup(const char *s, size_t n);
#endif
@@ -72,6 +73,17 @@
#define WITH_PRINT
/* Theme auto-install */
#define WITH_THEME_INSTALL
+#elif defined(__HAIKU__) || defined(__BEOS__)
+ /* for intptr_t */
+ #include <inttypes.h>
+ #if defined(__HAIKU__)
+ /*not yet: #define WITH_MMAP*/
+ #endif
+ //#define WITH_NS_SVG /* internal SVG renderer */
+ // XXX: temp
+ //#undef WITH_JPEG
+ //#undef WITH_MNG
+ //#define WITH_RSVG
#else
/* We're likely to have a working mmap() */
#define WITH_MMAP
Index: utils/talloc.c
===================================================================
--- utils/talloc.c (révision 4724)
+++ utils/talloc.c (copie de travail)
@@ -55,10 +55,12 @@
#include "replace.h"
#else
#include <stdarg.h>
+#ifndef __BEOS__
/* Assume we've got va_copy */
#define HAVE_VA_COPY
#include <string.h>
#endif
+#endif
#include "talloc.h"
#endif /* not _TALLOC_SAMBA3 */
Index: utils/filename.c
===================================================================
--- utils/filename.c (révision 4724)
+++ utils/filename.c (copie de travail)
@@ -433,7 +433,7 @@
TEMP_FILENAME_PREFIX);
last_1 = filename_directory + strlen(TEMP_FILENAME_PREFIX) + 1;
last_2 = new_dir->prefix;
- for (int i = 0; i < 3 && *last_2; i++) {
+ for (index = 0; index < 3 && *last_2; index++) {
*last_1++ = *last_2++;
while (*last_2 && *last_2 != '/')
*last_1++ = *last_2++;
Index: utils/utf8.c
===================================================================
--- utils/utf8.c (révision 4724)
+++ utils/utf8.c (copie de travail)
@@ -25,7 +25,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#ifndef __BEOS__
#define LIBICONV_PLUG
+#endif
#include <iconv.h>
#include "utils/log.h"
Index: desktop/textinput.c
===================================================================
--- desktop/textinput.c (révision 4724)
+++ desktop/textinput.c (copie de travail)
@@ -618,11 +618,12 @@
case KEY_WORD_LEFT:
{
+ bool start_of_word;
/* if there is a selection, caret should stay at beginning */
if (selection_exists)
break;
- bool start_of_word = (char_offset <= 0 ||
+ start_of_word = (char_offset <= 0 ||
isspace(text_box->text[char_offset - 1]));
while (!word_left(text_box->text, &char_offset, NULL)) {
@@ -652,13 +653,14 @@
case KEY_WORD_RIGHT:
{
+ bool in_word;
/* if there is a selection, caret should move to the end */
if (selection_exists) {
text_box = selection_get_end(bw->sel, &char_offset);
break;
}
- bool in_word = (char_offset < text_box->length &&
+ in_word = (char_offset < text_box->length &&
!isspace(text_box->text[char_offset]));
while (!word_right(text_box->text, text_box->length,
@@ -1818,13 +1820,13 @@
void delete_selection(struct selection *s)
{
- assert(s->defined);
size_t start_offset, end_offset;
struct box *text_box = selection_get_start(s, &start_offset);
struct box *end_box = selection_get_end(s, &end_offset);
struct box *next;
size_t sel_len = s->end_idx - s->start_idx;
int beginning = 0;
+ assert(s->defined);
/* Clear selection so that deletion from textboxes proceeds */
selection_clear(s, true);
Index: desktop/browser.c
===================================================================
--- desktop/browser.c (révision 4724)
+++ desktop/browser.c (copie de travail)
@@ -2248,13 +2248,14 @@
void browser_window_form_select(struct browser_window *bw,
struct form_control *control, int item)
{
+ struct box *inline_box;
struct form_option *o;
int count;
assert(bw);
assert(control);
- struct box *inline_box = control->box->children->children;
+ inline_box = control->box->children->children;
for (count = 0, o = control->data.select.items;
o != NULL;
Index: desktop/selection.c
===================================================================
--- desktop/selection.c (révision 4724)
+++ desktop/selection.c (copie de travail)
@@ -547,6 +547,8 @@
struct content *c;
save_text_whitespace before = WHITESPACE_NONE;
bool first = true;
+ const char *text;
+ size_t length;
if (!selection_defined(s))
return true; /* easy case, nothing to do */
@@ -559,8 +561,7 @@
c = s->bw->current_content;
if (!c) return true;
- size_t length;
- const char *text = textplain_get_raw_data(c, s->start_idx,
+ text = textplain_get_raw_data(c, s->start_idx,
s->end_idx, &length);
if (text && !handler(text, length, NULL, handle, NULL, 0))
Index: desktop/options.c
===================================================================
--- desktop/options.c (révision 4724)
+++ desktop/options.c (copie de travail)
@@ -44,6 +44,8 @@
#include "riscos/options.h"
#elif defined(nsgtk)
#include "gtk/options.h"
+#elif defined(nsbeos)
+#include "beos/options.h"
#else
#define EXTRA_OPTION_DEFINE
#define EXTRA_OPTION_TABLE
Index: content/fetchers/fetch_curl.c
===================================================================
--- content/fetchers/fetch_curl.c (révision 4724)
+++ content/fetchers/fetch_curl.c (copie de travail)
@@ -252,9 +252,9 @@
curl_fetchers_registered--;
LOG(("Finalise cURL fetcher %s", scheme));
if (curl_fetchers_registered == 0) {
+ CURLMcode codem;
/* All the fetchers have been finalised. */
LOG(("All cURL fetchers finalised, closing down cURL"));
- CURLMcode codem;
curl_easy_cleanup(fetch_blank_curl);
Index: content/urldb.c
===================================================================
--- content/urldb.c (révision 4724)
+++ content/urldb.c (copie de travail)
@@ -2340,6 +2340,7 @@
char *scheme;
time_t now;
url_func_result res;
+ int i;
assert(url);
@@ -2552,7 +2553,7 @@
ret_used = strlen(ret) + 1;
}
- for (int i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
if (!urldb_concat_cookie(matched_cookies[i], version,
&ret_used, &ret_alloc, &ret)) {
free(path);
@@ -3490,6 +3491,7 @@
int version, domain_specified, path_specified,
secure, no_destroy, value_quoted;
time_t expires, last_used;
+ struct cookie_internal_data *c;
if(s[0] == 0 || s[0] == '#')
/* Skip blank lines or comments */
@@ -3548,8 +3550,7 @@
assert(p <= end);
/* Now create cookie */
- struct cookie_internal_data *c =
- malloc(sizeof(struct cookie_internal_data));
+ c = malloc(sizeof(struct cookie_internal_data));
if (!c)
break;
@@ -3602,11 +3603,12 @@
void urldb_delete_cookie_hosts(const char *domain, const char *path,
const char *name, struct host_part *parent)
{
+ struct host_part *h;
assert(parent);
urldb_delete_cookie_paths(domain, path, name, &parent->paths);
- for (struct host_part *h = parent->children; h; h = h->next)
+ for (h = parent->children; h; h = h->next)
urldb_delete_cookie_hosts(domain, path, name, h);
}
@@ -3614,6 +3616,7 @@
const char *name, struct path_data *parent)
{
struct cookie_internal_data *c;
+ struct path_data *p;
assert(parent);
@@ -3635,7 +3638,7 @@
}
}
- for (struct path_data *p = parent->children; p; p = p->next)
+ for (p = parent->children; p; p = p->next)
urldb_delete_cookie_paths(domain, path, name, p);
}
@@ -3684,11 +3687,12 @@
*/
void urldb_save_cookie_hosts(FILE *fp, struct host_part *parent)
{
+ struct host_part *h;
assert(fp && parent);
urldb_save_cookie_paths(fp, &parent->paths);
- for (struct host_part *h = parent->children; h; h = h->next)
+ for (h = parent->children; h; h = h->next)
urldb_save_cookie_hosts(fp, h);
}
@@ -3700,12 +3704,14 @@
*/
void urldb_save_cookie_paths(FILE *fp, struct path_data *parent)
{
+ struct path_data *p;
time_t now = time(NULL);
assert(fp && parent);
if (parent->cookies) {
- for (struct cookie_internal_data *c = parent->cookies; c;
+ struct cookie_internal_data *c;
+ for (c = parent->cookies; c;
c = c->next) {
if (c->expires < now)
/* Skip expired cookies */
@@ -3726,7 +3732,7 @@
}
}
- for (struct path_data *p = parent->children; p; p = p->next)
+ for (p = parent->children; p; p = p->next)
urldb_save_cookie_paths(fp, p);
}
@@ -3737,9 +3743,10 @@
void urldb_destroy(void)
{
struct host_part *a, *b;
+ int i;
/* Clean up search trees */
- for (int i = 0; i < NUM_SEARCH_TREES; i++) {
+ for (i = 0; i < NUM_SEARCH_TREES; i++) {
if (search_trees[i] != &empty)
urldb_destroy_search_tree(search_trees[i]);
}
@@ -3809,11 +3816,12 @@
void urldb_destroy_path_node_content(struct path_data *node)
{
struct cookie_internal_data *a, *b;
+ unsigned int i;
free(node->url);
free(node->scheme);
free(node->segment);
- for (unsigned int i = 0; i < node->frag_cnt; i++)
+ for (i = 0; i < node->frag_cnt; i++)
free(node->fragment[i]);
free(node->fragment);
Index: content/fetch.c
===================================================================
--- content/fetch.c (révision 4724)
+++ content/fetch.c (copie de travail)
@@ -352,6 +352,8 @@
void fetch_dispatch_jobs(void)
{
int all_active, all_queued;
+ struct fetch *q;
+ struct fetch *f;
if (!queue_ring)
return; /* Nothing to do, the queue is empty */
@@ -362,7 +364,7 @@
LOG(("queue_ring %i, fetch_ring %i", all_queued, all_active));
#endif
- struct fetch *q = queue_ring;
+ q = queue_ring;
if (q) {
do {
#ifdef DEBUG_FETCH_VERBOSE
@@ -371,7 +373,7 @@
q = q->r_next;
} while (q != queue_ring);
}
- struct fetch *f = fetch_ring;
+ f = fetch_ring;
if (f) {
do {
#ifdef DEBUG_FETCH_VERBOSE
Index: content/fetchcache.c
===================================================================
--- content/fetchcache.c (révision 4724)
+++ content/fetchcache.c (copie de travail)
@@ -574,6 +574,7 @@
r = regexec(&re_content_type, s, 2 + MAX_ATTRS * 3, pmatch, 0);
if (r) {
+ char *semi;
LOG(("failed to parse content-type '%s'", s));
/* The mime type must be first, so only copy up to the
* first semicolon in the string. This allows us to have
@@ -581,7 +582,7 @@
* Content-Type headers. Obviously, any truly broken
* Content-Type headers will be unaffected by this heuristic
*/
- char *semi = strchr(s, ';');
+ semi = strchr(s, ';');
if (semi)
type = strndup(s, semi - s);
else