[project @ 2004-08-14 12:57:00 by joty]

Using more stddef.h types.

svn path=/import/netsurf/; revision=1230
This commit is contained in:
John Tytgat 2004-08-14 12:57:02 +00:00
parent 44c418dc73
commit 7d3a242132
14 changed files with 91 additions and 81 deletions

View File

@ -28,7 +28,8 @@ static void font_close(struct font_data *data);
* functions * functions
*/ */
unsigned long nsfont_width(struct font_data *font, const char * text, unsigned int length) unsigned long nsfont_width(struct font_data *font, const char * text,
size_t length)
{ {
int width; int width;
@ -41,7 +42,7 @@ unsigned long nsfont_width(struct font_data *font, const char * text, unsigned i
} }
void nsfont_position_in_string(struct font_data* font, const char* text, void nsfont_position_in_string(struct font_data* font, const char* text,
unsigned int length, unsigned long x, int* char_offset, int* pixel_offset) size_t length, unsigned long x, int* char_offset, int* pixel_offset)
{ {
assert(font != 0 && text != 0); assert(font != 0 && text != 0);
@ -137,8 +138,8 @@ void font_close(struct font_data *data)
} }
char *nsfont_split(struct font_data *data, const char * text, unsigned int length, char *nsfont_split(struct font_data *data, const char * text,
unsigned int width, unsigned int *used_width) size_t length, unsigned int width, unsigned int *used_width)
{ {
int i = width / 10; int i = width / 10;
@ -155,7 +156,7 @@ char *nsfont_split(struct font_data *data, const char * text, unsigned int lengt
void nsfont_paint(struct font_data *data, const char *text, void nsfont_paint(struct font_data *data, const char *text,
int xpos, int ypos, void *trfm, int length) size_t length, int xpos, int ypos, void *trfm)
{ {
assert(data != NULL); assert(data != NULL);
assert(text != NULL); assert(text != NULL);

View File

@ -383,7 +383,7 @@ void browser_window_update(struct browser_window *bw,
if (bw->current_content->title != NULL if (bw->current_content->title != NULL
&& (title_local_enc = cnv_str_local_enc(bw->current_content->title)) != NULL) { && (title_local_enc = cnv_str_local_enc(bw->current_content->title)) != NULL) {
gui_window_set_title(bw->window, title_local_enc); gui_window_set_title(bw->window, title_local_enc);
free(title_local_enc); free((void *)title_local_enc);
} else } else
gui_window_set_title(bw->window, bw->current_content->url); gui_window_set_title(bw->window, bw->current_content->url);
@ -936,6 +936,7 @@ void browser_window_textarea_callback(struct browser_window *bw,
struct box *text_box = textarea->gadget->caret_text_box; struct box *text_box = textarea->gadget->caret_text_box;
struct box *new_br, *new_text, *t; struct box *new_br, *new_text, *t;
struct box *prev; struct box *prev;
/** \todo: consider changing the following 2 types in size_t */
int char_offset = textarea->gadget->caret_box_offset; int char_offset = textarea->gadget->caret_box_offset;
int pixel_offset = textarea->gadget->caret_pixel_offset; int pixel_offset = textarea->gadget->caret_pixel_offset;
int dy; int dy;
@ -1154,7 +1155,7 @@ void browser_window_textarea_callback(struct browser_window *bw,
textarea->height = height; textarea->height = height;
} }
if (text_box->length < (unsigned int)char_offset) { if (text_box->length < (size_t)char_offset) {
/* the text box has been split and the caret is in the /* the text box has been split and the caret is in the
* second part */ * second part */
char_offset -= (text_box->length + 1); /* +1 for the space */ char_offset -= (text_box->length + 1); /* +1 for the space */
@ -1327,8 +1328,8 @@ void browser_window_input_callback(struct browser_window *bw,
box_offset += utf8keySize; box_offset += utf8keySize;
free((void *)utf8key); free((void *)utf8key);
text_box->width = nsfont_width(text_box->font, text_box->text, text_box->width = nsfont_width(text_box->font,
(unsigned int)text_box->length); text_box->text, text_box->length);
changed = true; changed = true;
} else if (key == 8 || key == 127) { } else if (key == 8 || key == 127) {
@ -1362,8 +1363,8 @@ void browser_window_input_callback(struct browser_window *bw,
text_box->length -= prev_offset - box_offset; text_box->length -= prev_offset - box_offset;
text_box->text[text_box->length] = 0; text_box->text[text_box->length] = 0;
text_box->width = nsfont_width(text_box->font, text_box->text, text_box->width = nsfont_width(text_box->font,
(unsigned int)text_box->length); text_box->text, text_box->length);
changed = true; changed = true;
@ -1462,7 +1463,7 @@ void browser_window_input_callback(struct browser_window *bw,
} }
pixel_offset = nsfont_width(text_box->font, text_box->text, pixel_offset = nsfont_width(text_box->font, text_box->text,
(unsigned int)box_offset); box_offset);
dx = text_box->x; dx = text_box->x;
text_box->x = 0; text_box->x = 0;
if (input->width < text_box->width && input->width / 2 < pixel_offset) { if (input->width < text_box->width && input->width / 2 < pixel_offset) {

View File

@ -70,7 +70,7 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
data->id = fontdesc; data->id = fontdesc;
data->size = size; data->size = size;
data->space_width = nsfont_width(data, " ", 1); data->space_width = nsfont_width(data, " ", sizeof(" ")-1);
return data; return data;
} }
@ -82,7 +82,7 @@ void nsfont_free_set(struct font_set *set)
unsigned long nsfont_width(struct font_data *font, const char *text, unsigned long nsfont_width(struct font_data *font, const char *text,
unsigned int length) size_t length)
{ {
int width; int width;
PangoContext *context; PangoContext *context;
@ -108,7 +108,7 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
void nsfont_position_in_string(struct font_data *font, const char *text, void nsfont_position_in_string(struct font_data *font, const char *text,
unsigned int length, unsigned long x, int *char_offset, size_t length, unsigned long x, int *char_offset,
int *pixel_offset) int *pixel_offset)
{ {
int index; int index;
@ -134,8 +134,8 @@ void nsfont_position_in_string(struct font_data *font, const char *text,
} }
char *nsfont_split(struct font_data *font, const char *text, unsigned int length, char *nsfont_split(struct font_data *font, const char *text,
unsigned int width, unsigned int *used_width) size_t length, unsigned int width, unsigned int *used_width)
{ {
int index = length; int index = length;
int x_pos; int x_pos;

View File

@ -195,46 +195,51 @@ void box_add_child(struct box * parent, struct box * child)
*/ */
struct box * box_create(struct css_style * style, struct box * box_create(struct css_style * style,
char *href, char *title, char *id, pool box_pool) const char *href, const char *title, const char *id,
pool box_pool)
{ {
unsigned int i; unsigned int i;
struct box *box = pool_alloc(box_pool, sizeof (struct box)); struct box *box;
assert(box);
if ((box = pool_alloc(box_pool, sizeof (struct box))) == NULL)
return NULL;
box->type = BOX_INLINE; box->type = BOX_INLINE;
box->style = style; box->style = style;
box->x = box->y = 0;
box->width = UNKNOWN_WIDTH; box->width = UNKNOWN_WIDTH;
box->height = 0;
box->descendant_x0 = box->descendant_y0 = 0;
box->descendant_x1 = box->descendant_y1 = 0;
for (i = 0; i != 4; i++)
box->margin[i] = box->padding[i] = box->border[i] = 0;
box->min_width = 0;
box->max_width = UNKNOWN_MAX_WIDTH; box->max_width = UNKNOWN_MAX_WIDTH;
box->href = href ? xstrdup(href) : 0; box->text = NULL;
box->title = title ? xstrdup(title) : 0; box->length = 0;
box->columns = 1;
box->rows = 1;
box->text = 0;
box->space = 0; box->space = 0;
box->clone = 0; box->clone = 0;
box->style_clone = 0; box->style_clone = 0;
box->length = 0; box->href = href ? xstrdup(href) : NULL;
box->title = title ? xstrdup(title) : NULL;
box->columns = 1;
box->rows = 1;
box->start_column = 0; box->start_column = 0;
box->next = 0; box->next = NULL;
box->prev = 0; box->prev = NULL;
box->children = 0; box->children = NULL;
box->last = 0; box->last = NULL;
box->parent = 0; box->parent = NULL;
box->float_children = 0; box->float_children = NULL;
box->next_float = 0; box->next_float = NULL;
box->col = 0; box->col = NULL;
box->font = 0; box->font = NULL;
box->gadget = 0; box->gadget = NULL;
box->usemap = 0; box->usemap = NULL;
box->id = id ? xstrdup(id) : 0; box->id = id ? xstrdup(id) : NULL;
box->background = 0; box->background = NULL;
box->object = 0; box->object = NULL;
box->object_params = 0; box->object_params = NULL;
box->x = box->y = 0;
box->height = 0;
for (i = 0; i != 4; i++)
box->margin[i] = box->padding[i] = box->border[i] = 0;
box->descendant_x0 = box->descendant_y0 = 0;
box->descendant_x1 = box->descendant_y1 = 0;
return box; return box;
} }

View File

@ -159,8 +159,8 @@ struct box {
int min_width; int min_width;
int max_width; /**< Width that would be taken with no line breaks. */ int max_width; /**< Width that would be taken with no line breaks. */
char *text; /**< Text, or 0 if none. Unterminated. */ char *text; /**< Text, or 0 if none. Unterminated. */
unsigned int length; /**< Length of text. */ size_t length; /**< Length of text. */
/** Text is followed by a space. */ /** Text is followed by a space. */
unsigned int space : 1; unsigned int space : 1;
@ -234,7 +234,8 @@ struct column {
void xml_to_box(xmlNode *n, struct content *c); void xml_to_box(xmlNode *n, struct content *c);
void box_dump(struct box * box, unsigned int depth); void box_dump(struct box * box, unsigned int depth);
struct box * box_create(struct css_style * style, struct box * box_create(struct css_style * style,
char *href, char *title, char *id, pool box_pool); 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_insert_sibling(struct box *box, struct box *new_box);
void box_free(struct box *box); void box_free(struct box *box);

View File

@ -10,6 +10,7 @@
#ifndef _NETSURF_RENDER_FONT_H_ #ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_ #define _NETSURF_RENDER_FONT_H_
#include <stddef.h>
#include "netsurf/css/css.h" #include "netsurf/css/css.h"
typedef enum { typedef enum {
@ -31,21 +32,21 @@ struct font_set *nsfont_new_set(void);
struct font_data *nsfont_open(struct font_set *set, struct css_style *style); struct font_data *nsfont_open(struct font_set *set, struct css_style *style);
void nsfont_free_set(struct font_set *set); void nsfont_free_set(struct font_set *set);
unsigned long nsfont_width(struct font_data *font, const char *text, unsigned long nsfont_width(struct font_data *font, const char *text,
unsigned int length); size_t length);
void nsfont_position_in_string(struct font_data *font, const char *text, void nsfont_position_in_string(struct font_data *font, const char *text,
unsigned int length, unsigned long x, int *char_offset, size_t length, unsigned long x, int *char_offset,
int *pixel_offset); int *pixel_offset);
char *nsfont_split(struct font_data *font, const char *text, char *nsfont_split(struct font_data *font, const char *text,
unsigned int length, size_t length,
unsigned int width, unsigned int *used_width); unsigned int width, unsigned int *used_width);
void nsfont_paint(struct font_data *font, const char *str, void nsfont_paint(struct font_data *font, const char *str,
int xpos, int ypos, void *trfm, int length); size_t length, int xpos, int ypos, void *trfm);
void nsfont_txtenum(struct font_data *font, const char *text, void nsfont_txtenum(struct font_data *font, const char *text,
unsigned int length, size_t length,
unsigned int *width, unsigned int *width,
const char **rofontname, const char **rofontname,
const char **rotext, const char **rotext,
unsigned int *rolength, size_t *rolength,
unsigned int *consumed); size_t *consumed);
#endif #endif

View File

@ -90,11 +90,11 @@ bool html_create(struct content *c, const char *params[])
html->getenc = false; html->getenc = false;
} else { } else {
LOG(("xmlSwitchToEncoding failed for <%s>\n", encStr)); LOG(("xmlSwitchToEncoding failed for <%s>\n", encStr));
free(encStr); free((void *)encStr);
} }
} else { } else {
LOG(("xmlFindCharEncodingHandler() failed for <%s>\n", encStr)); LOG(("xmlFindCharEncodingHandler() failed for <%s>\n", encStr));
free(encStr); free((void *)encStr);
} }
} }
html->base_url = xstrdup(c->url); html->base_url = xstrdup(c->url);

View File

@ -36,7 +36,7 @@ struct imagemap;
struct content_html_data { struct content_html_data {
htmlParserCtxt *parser; /**< HTML parser context. */ htmlParserCtxt *parser; /**< HTML parser context. */
xmlChar *encoding; /**< Encoding of source. */ const char *encoding; /**< Encoding of source. */
bool getenc; /**< Need to get the encoding from the document, as it bool getenc; /**< Need to get the encoding from the document, as it
* wasn't specified in the Content-Type header. */ * wasn't specified in the Content-Type header. */

View File

@ -749,7 +749,8 @@ bool layout_line(struct box *first, int width, int *y,
if (b->text) { if (b->text) {
if (b->width == UNKNOWN_WIDTH) if (b->width == UNKNOWN_WIDTH)
b->width = nsfont_width(b->font, b->text, b->width = nsfont_width(b->font,
b->text,
b->length); b->length);
x += b->width + b->space ? x += b->width + b->space ?
b->font->space_width : 0; b->font->space_width : 0;
@ -998,7 +999,8 @@ bool layout_line(struct box *first, int width, int *y,
} else { } else {
/* fit as many words as possible */ /* fit as many words as possible */
assert(space != 0); assert(space != 0);
space = nsfont_split(split_box->font, split_box->text, space = nsfont_split(split_box->font,
split_box->text,
split_box->length, split_box->length,
x1 - x0 - x - space_before, &w) x1 - x0 - x - space_before, &w)
- split_box->text; - split_box->text;

View File

@ -414,7 +414,7 @@ void nsfont_free_set(struct font_set *set)
* \return width of text in pixels * \return width of text in pixels
*/ */
unsigned long nsfont_width(struct font_data *font, const char *text, unsigned long nsfont_width(struct font_data *font, const char *text,
unsigned int length) size_t length)
{ {
int width; int width;
os_error *error; os_error *error;
@ -487,7 +487,7 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
* \param pixel_offset updated to give the coordinate of the character in pixels * \param pixel_offset updated to give the coordinate of the character in pixels
*/ */
void nsfont_position_in_string(struct font_data *font, const char *text, void nsfont_position_in_string(struct font_data *font, const char *text,
unsigned int length, unsigned long x, size_t length, unsigned long x,
int *char_offset, int *pixel_offset) int *char_offset, int *pixel_offset)
{ {
os_error *error; os_error *error;
@ -568,8 +568,7 @@ void nsfont_position_in_string(struct font_data *font, const char *text,
* \return pointer to character which does not fit * \return pointer to character which does not fit
*/ */
char *nsfont_split(struct font_data *font, const char *text, char *nsfont_split(struct font_data *font, const char *text,
unsigned int length, size_t length, unsigned int width, unsigned int *used_width)
unsigned int width, unsigned int *used_width)
{ {
os_error *error; os_error *error;
font_scan_block block; font_scan_block block;
@ -645,7 +644,7 @@ char *nsfont_split(struct font_data *font, const char *text,
void nsfont_paint(struct font_data *data, const char *text, void nsfont_paint(struct font_data *data, const char *text,
int xpos, int ypos, void *trfm, int length) size_t length, int xpos, int ypos, void *trfm)
{ {
os_error *error; os_error *error;
unsigned int flags; unsigned int flags;
@ -679,7 +678,7 @@ void nsfont_paint(struct font_data *data, const char *text,
xos_read_vdu_variables((const os_vdu_var_list *)&var_input, (int *)&var_output); xos_read_vdu_variables((const os_vdu_var_list *)&var_input, (int *)&var_output);
xpos += var_output[0]; xpos += var_output[0];
ypos += var_output[1]; ypos += var_output[1];
switch (data->ftype) { switch (data->ftype) {
case FONTTYPE_UFONT: case FONTTYPE_UFONT:
@ -728,12 +727,12 @@ void nsfont_paint(struct font_data *data, const char *text,
* \param consumed number of bytes of the given text which can be set with one RISC OS font. If 0, then error happened or initial text length was 0. * \param consumed number of bytes of the given text which can be set with one RISC OS font. If 0, then error happened or initial text length was 0.
*/ */
void nsfont_txtenum(struct font_data *font, const char *text, void nsfont_txtenum(struct font_data *font, const char *text,
unsigned int length, size_t length,
unsigned int *width, unsigned int *width,
const char **rofontname, const char **rofontname,
const char **rotext, const char **rotext,
unsigned int *rolength, size_t *rolength,
unsigned int *consumed) size_t *consumed)
{ {
assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL); assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL);

View File

@ -11,6 +11,7 @@
#define _NETSURF_RISCOS_GUI_H_ #define _NETSURF_RISCOS_GUI_H_
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include "oslib/osspriteop.h" #include "oslib/osspriteop.h"
#include "oslib/wimp.h" #include "oslib/wimp.h"
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"

View File

@ -530,13 +530,13 @@ bool html_redraw_box(struct box *box,
} }
if (scale == 1) if (scale == 1)
nsfont_paint(box->font, box->text, nsfont_paint(box->font, box->text, box->length,
x, y - (int) (box->height * 1.5), x, y - (int) (box->height * 1.5),
NULL, (int) box->length); NULL);
else else
nsfont_paint(box->font, box->text, nsfont_paint(box->font, box->text, box->length,
x, y - (int) (box->height * 1.5 * scale), x, y - (int) (box->height * 1.5 * scale),
&trfm, (int) box->length); &trfm);
} else { } else {
@ -832,7 +832,7 @@ bool html_redraw_file(int x, int y, int width, int height,
int text_width; int text_width;
const char *text; const char *text;
const char *sprite; const char *sprite;
int length; size_t length;
if (box->gadget->value) { if (box->gadget->value) {
text = box->gadget->value; text = box->gadget->value;
@ -849,8 +849,7 @@ bool html_redraw_file(int x, int y, int width, int height,
else else
x = x + 4; x = x + 4;
nsfont_paint(box->font, text, nsfont_paint(box->font, text, length, x, y - height * 0.75, &trfm);
x, y - height * 0.75, &trfm, length);
/* xwimpspriteop_put_sprite_user_coords(sprite, x + 4, */ /* xwimpspriteop_put_sprite_user_coords(sprite, x + 4, */
/* y - height / 2 - 17, os_ACTION_OVERWRITE); */ /* y - height / 2 - 17, os_ACTION_OVERWRITE); */

View File

@ -700,8 +700,8 @@ bool print_find_fonts(struct box *box, struct print_font **print_fonts, int *num
{ {
struct box *a; struct box *a;
const char *txt; const char *txt;
int txt_len; size_t txt_len;
unsigned int width, rolength, consumed; size_t width, rolength, consumed;
const char *rofontname, *rotext; const char *rofontname, *rotext;
int i; int i;

View File

@ -1021,7 +1021,7 @@ static bool add_text(struct box *box, os_colour cbc, os_colour fc,
size_t txt_len = box->length; size_t txt_len = box->length;
while (txt_len != 0) { while (txt_len != 0) {
unsigned int width, rolength, consumed; size_t width, rolength, consumed;
const char *rofontname, *rotext; const char *rofontname, *rotext;
byte fontIndex; byte fontIndex;
drawfile_object *dro; drawfile_object *dro;