File gcc14.patch of Package mlterm
diff --git a/baselib/src/bl_path.c b/baselib/src/bl_path.c
index 0d07df98fc1e..9dd53d569262 100644
--- a/baselib/src/bl_path.c
+++ b/baselib/src/bl_path.c
@@ -21,10 +21,8 @@
/* --- global functions --- */
-#if !defined(HAVE_BASENAME) || defined(USE_WIN32API) || defined(BL_DEBUG)
-
-char* __bl_basename(char *path) {
- char *p;
+const char* __bl_basename(const char *path) {
+ const char *p;
if (path == NULL || *path == '\0') {
return ".";
@@ -39,7 +37,7 @@ char* __bl_basename(char *path) {
|| (*p == '\\' && (p - 1 == path || !IsDBCSLeadByte(*(p - 1))))
#endif
) {
- *(p--) = '\0';
+ continue;
} else {
break;
}
@@ -62,8 +60,6 @@ char* __bl_basename(char *path) {
}
}
-#endif
-
#ifndef REMOVE_FUNCS_MLTERM_UNUSE
int bl_path_cleanname(char *cleaned_path, size_t size, const char *path) {
@@ -475,7 +471,7 @@ static void TEST_bl_basename(void) {
char path4[] = "/foo/\x95\x5c bar";
#endif
- assert(strcmp(__bl_basename(path1), "bar") == 0);
+ assert(strcmp(__bl_basename(path1), "bar/") == 0);
assert(strcmp(__bl_basename(path2), "bar") == 0);
assert(strcmp(__bl_basename(path3), " b a r") == 0);
#ifdef USE_WIN32API
diff --git a/baselib/src/bl_path.h b/baselib/src/bl_path.h
index 5abc957318da..e2dc1e581175 100644
--- a/baselib/src/bl_path.h
+++ b/baselib/src/bl_path.h
@@ -33,20 +33,10 @@
#endif
#endif
-/* XXX win32 basename() works strangely if cp932 characters are pssed. */
-#if defined(HAVE_BASENAME) && !defined(USE_WIN32API)
-
-#include <libgen.h>
-
-#define bl_basename(path) basename(path)
-
-#else
-
+/* Always implement basename so it can work on constant string */
#define bl_basename(path) __bl_basename(path)
-char *__bl_basename(char *path);
-
-#endif
+const char *__bl_basename(const char *path);
#ifndef REMOVE_FUNCS_MLTERM_UNUSE
diff --git a/baselib/src/bl_utmp_sysv.c b/baselib/src/bl_utmp_sysv.c
index c15f61d5cfbf..e78db4cc0597 100644
--- a/baselib/src/bl_utmp_sysv.c
+++ b/baselib/src/bl_utmp_sysv.c
@@ -62,7 +62,7 @@ bl_utmp_t bl_utmp_new(const char *tty, const char *host, int pty_fd) {
#endif
bl_utmp_t utmp;
const char *pw_name;
- char *tty_num;
+ const char *tty_num;
struct timeval timenow;
gettimeofday(&timenow, NULL);
diff --git a/inputmethod/fcitx/im_fcitx.c b/inputmethod/fcitx/im_fcitx.c
index f82941f3807b..e7510a832b93 100644
--- a/inputmethod/fcitx/im_fcitx.c
+++ b/inputmethod/fcitx/im_fcitx.c
@@ -448,7 +448,7 @@ static void commit_string(FcitxClient *client, char *str, void *data) {
if ((len = strlen(str)) == 0) {
/* do nothing */
} else {
- (*fcitx->im.listener->write_to_term)(fcitx->im.listener->self, str, len,
+ (*fcitx->im.listener->write_to_term)(fcitx->im.listener->self, (u_char *)str, len,
fcitx->term_encoding == VT_UTF8 ? NULL : parser_utf8);
}
@@ -481,7 +481,7 @@ static void forward_key(FcitxClient *client, guint keyval, guint state, gint typ
) {
fcitx->prev_key.state |= FcitxKeyState_IgnoredMask;
#ifdef USE_XLIB
- XPutBackEvent(fcitx->prev_key.display, &fcitx->prev_key);
+ XPutBackEvent(fcitx->prev_key.display, (XEvent *)&fcitx->prev_key);
#endif
memset(&fcitx->prev_key, 0, sizeof(XKeyEvent));
}
@@ -529,7 +529,7 @@ static void update_formatted_preedit(FcitxClient *client, GPtrArray *list, int c
}
(*parser_utf8->init)(parser_utf8);
- (*parser_utf8->set_str)(parser_utf8, item->string, str_len);
+ (*parser_utf8->set_str)(parser_utf8, (u_char *)item->string, str_len);
while ((*parser_utf8->next_char)(parser_utf8, &ch)) {
num_chars++;
@@ -548,7 +548,7 @@ static void update_formatted_preedit(FcitxClient *client, GPtrArray *list, int c
item = g_ptr_array_index(list, count);
(*parser_utf8->init)(parser_utf8);
- (*parser_utf8->set_str)(parser_utf8, item->string, strlen(item->string));
+ (*parser_utf8->set_str)(parser_utf8, (u_char *)item->string, strlen(item->string));
while ((*parser_utf8->next_char)(parser_utf8, &ch)) {
int is_fullwidth = 0;
diff --git a/inputmethod/ibus/im_ibus.c b/inputmethod/ibus/im_ibus.c
index 6bcca42531dd..0aaf99cf7bf6 100644
--- a/inputmethod/ibus/im_ibus.c
+++ b/inputmethod/ibus/im_ibus.c
@@ -151,7 +151,7 @@ static void update_preedit_text(IBusInputContext *context, IBusText *text, gint
ibus->im.preedit.filled_len = 0;
(*parser_utf8->init)(parser_utf8);
- (*parser_utf8->set_str)(parser_utf8, text->text, strlen(text->text));
+ (*parser_utf8->set_str)(parser_utf8, (u_char *)text->text, strlen(text->text));
index = 0;
while ((*parser_utf8->next_char)(parser_utf8, &ch)) {
@@ -159,14 +159,12 @@ static void update_preedit_text(IBusInputContext *context, IBusText *text, gint
IBusAttribute *attr;
int is_fullwidth = 0;
int is_comb = 0;
- int is_underlined = 0;
vt_color_t fg_color = VT_FG_COLOR;
vt_color_t bg_color = VT_BG_COLOR;
for (count = 0; (attr = ibus_attr_list_get(text->attrs, count)); count++) {
if (attr->start_index <= index && index < attr->end_index) {
if (attr->type == IBUS_ATTR_TYPE_UNDERLINE) {
- is_underlined = (attr->value != IBUS_ATTR_UNDERLINE_NONE);
}
#if 0
else if (attr->type == IBUS_ATTR_TYPE_FOREGROUND) {
@@ -281,7 +279,7 @@ static void commit_text(IBusInputContext *context, IBusText *text, gpointer data
if (ibus_text_get_length(text) == 0) {
/* do nothing */
} else {
- (*ibus->im.listener->write_to_term)(ibus->im.listener->self, text->text, strlen(text->text),
+ (*ibus->im.listener->write_to_term)(ibus->im.listener->self, (u_char *)text->text, strlen(text->text),
ibus->term_encoding == VT_UTF8 ? NULL : parser_utf8);
}
@@ -308,7 +306,7 @@ static void forward_key_event(IBusInputContext *context, guint keyval, guint key
) {
ibus->prev_key.state |= IBUS_IGNORED_MASK;
#ifdef USE_XLIB
- XPutBackEvent(ibus->prev_key.display, &ibus->prev_key);
+ XPutBackEvent(ibus->prev_key.display, (XEvent *)&ibus->prev_key);
#endif
memset(&ibus->prev_key, 0, sizeof(XKeyEvent));
}
@@ -439,7 +437,7 @@ static int add_event_source(void) {
* regarded as GSocketConnection.
*/
if ((ibus_bus_fd = g_socket_get_fd(g_socket_connection_get_socket(
- g_dbus_connection_get_stream(ibus_bus_get_connection(ibus_bus))))) == -1) {
+ G_SOCKET_CONNECTION(g_dbus_connection_get_stream(ibus_bus_get_connection(ibus_bus)))))) == -1) {
return 0;
}
#endif
diff --git a/inputmethod/skk/dict.c b/inputmethod/skk/dict.c
index c7b562a82715..0e96c2f48644 100644
--- a/inputmethod/skk/dict.c
+++ b/inputmethod/skk/dict.c
@@ -119,7 +119,7 @@ static u_char *make_entry(u_char *str) {
return entry;
}
-static u_int16_t get_entry_time(u_char *entry, char *data, size_t data_size) {
+static u_int16_t get_entry_time(char *entry, char *data, size_t data_size) {
if (entry < data || data + data_size <= entry) {
size_t len;
@@ -569,7 +569,7 @@ static int connect_to_server(void) {
memcpy(&sa.sin_addr, host->h_addr_list[0], sizeof(sa.sin_addr));
- if (connect(sock, &sa, sizeof(struct sockaddr_in)) == -1) {
+ if (connect(sock, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) {
goto error;
}
@@ -632,7 +632,7 @@ static void unconcat(char *str) {
}
}
-static int candidate_exists(const char **cands, u_int num_cands, const char *cand) {
+static int candidate_exists(char **cands, u_int num_cands, const char *cand) {
u_int count;
for (count = 0; count < num_cands; count++) {
@@ -923,11 +923,13 @@ u_int dict_completion(ef_char_t *caption, u_int caption_len, void **aux, int ste
ef_parser_t *parser;
if (!*aux) {
- if (!(*aux = compl = calloc(1, sizeof(completion_t) + sizeof(*caption) * caption_len))) {
+ void *buffer = calloc(1, sizeof(completion_t) + sizeof(*caption) * caption_len);
+
+ if (!(*aux = compl = buffer)) {
return caption_len;
}
- compl->caption_orig = (char *)(compl + 1);
+ compl->caption_orig = buffer + sizeof(completion_t);
memcpy(compl->caption_orig, caption, sizeof(*caption) * caption_len);
compl->caption_orig_len = caption_len;
@@ -1068,11 +1070,13 @@ u_int dict_candidate(ef_char_t *caption, u_int caption_len, void **aux, int step
ef_parser_t *parser;
if (!*aux) {
- if (!(*aux = cand = calloc(1, sizeof(candidate_t) + sizeof(*caption) * caption_len))) {
+ void *buffer = calloc(1, sizeof(candidate_t) + sizeof(*caption) * caption_len);
+
+ if (!(*aux = cand = buffer)) {
return caption_len;
}
- cand->caption_orig = (char *)(cand + 1);
+ cand->caption_orig = buffer + sizeof(candidate_t);
memcpy(cand->caption_orig, caption, sizeof(*caption) * caption_len);
cand->caption_orig_len = caption_len;
diff --git a/inputmethod/skk/im_skk.c b/inputmethod/skk/im_skk.c
index 4893eb9e53ac..73d1d12699b9 100644
--- a/inputmethod/skk/im_skk.c
+++ b/inputmethod/skk/im_skk.c
@@ -596,15 +596,16 @@ static void destroy(ui_im_t *im) {
static int switch_mode(ui_im_t *im) {
im_skk_t *skk;
+ static ef_char_t empty[1] = {0};
skk = (im_skk_t*)im;
if ((skk->is_enabled = (!skk->is_enabled))) {
skk->mode = HIRAGANA;
- preedit(skk, "", 0, 0, skk->status[skk->mode], 0, "");
+ preedit(skk, empty, 0, 0, skk->status[skk->mode], 0, "");
} else {
preedit_clear(skk);
- preedit(skk, "", 0, 0, "", 0, "");
+ preedit(skk, empty, 0, 0, "", 0, "");
}
return 1;
@@ -724,6 +725,8 @@ static void candidate_clear(im_skk_t *skk) {
}
static int fix(im_skk_t *skk) {
+ static ef_char_t empty[1] = {0};
+
if (skk->preedit_len > 0) {
if (skk->candidate) {
dict_candidate_add_to_local(skk->candidate);
@@ -733,9 +736,9 @@ static int fix(im_skk_t *skk) {
memcpy(skk->new_word + skk->new_word_len, skk->preedit,
skk->preedit_len * sizeof(skk->preedit[0]));
skk->new_word_len += skk->preedit_len;
- preedit(skk, "", 0, 0, skk->status[skk->mode], 0, "");
+ preedit(skk, empty, 0, 0, skk->status[skk->mode], 0, "");
} else {
- preedit(skk, "", 0, 0, skk->status[skk->mode], 0, "");
+ preedit(skk, empty, 0, 0, skk->status[skk->mode], 0, "");
commit(skk);
}
preedit_clear(skk);
diff --git a/main/main_loop.c b/main/main_loop.c
index 9a309ba412a9..32aba30cdf32 100644
--- a/main/main_loop.c
+++ b/main/main_loop.c
@@ -111,7 +111,7 @@ int main_loop_init(int argc, char **argv) {
u_int num_startup_screens;
u_int depth;
char *invalid_msg = "%s %s is not valid.\n";
- char *orig_argv;
+ char **orig_argv;
#if defined(USE_FRAMEBUFFER) || defined(USE_WAYLAND) || defined(USE_SDL2)
int use_aafont = 0;
#endif
diff --git a/tool/mlconfig/Makefile.in b/tool/mlconfig/Makefile.in
index 95a01ec989ef..1d7ca26026b3 100644
--- a/tool/mlconfig/Makefile.in
+++ b/tool/mlconfig/Makefile.in
@@ -35,7 +35,7 @@ LIBS1 = $(LIBS_LOCAL) @INTL_LIBS@ @DL_SELF@ @DL_LIBS_IM@ @GTK_LIBS_FOR_MLCONFIG@
# -lX11 is for http://fedoraproject.org/wiki/Features/ChangeInImplicitDSOLinking
LIBS2_xlib = $(LPOBL) @X_LIBS@
-LIBS2_wayland = $(LPOBL)
+LIBS2_wayland = $(LPOBL) @X_LIBS@
LIBS2_sdl2 = $(LPOBL)
diff --git a/tool/mlconfig/mc_combo.c b/tool/mlconfig/mc_combo.c
index 02cc25a8bb14..0fc84f8b9879 100644
--- a/tool/mlconfig/mc_combo.c
+++ b/tool/mlconfig/mc_combo.c
@@ -10,13 +10,13 @@
/* --- global functions --- */
GtkWidget *mc_combo_new(const char *label_name, char **item_names, u_int item_num,
- char *selected_item_name, int is_readonly, GtkWidget **entry) {
+ const char *selected_item_name, int is_readonly, GtkWidget **entry) {
return mc_combo_new_with_width(label_name, item_names, item_num, selected_item_name, is_readonly,
0, entry);
}
GtkWidget *mc_combo_new_with_width(const char *label_name, char **item_names, u_int item_num,
- char *selected_item_name, int is_readonly, int entry_width,
+ const char *selected_item_name, int is_readonly, int entry_width,
GtkWidget **entry) {
GtkWidget *hbox;
GtkWidget *label;
@@ -93,9 +93,9 @@ GtkWidget *mc_combo_new_with_width(const char *label_name, char **item_names, u_
}
#if GTK_CHECK_VERSION(4, 0, 0)
- gtk_entry_set_width_chars(gtk_combo_box_get_child(GTK_COMBO_BOX(combo)), width_chars);
+ gtk_entry_set_width_chars(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(combo))), width_chars);
#else
- gtk_entry_set_width_chars(gtk_bin_get_child(GTK_BIN(combo)), width_chars);
+ gtk_entry_set_width_chars(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), width_chars);
#endif
#else
gtk_widget_set_size_request(gtk_bin_get_child(GTK_BIN(combo)), entry_width, -1);
diff --git a/tool/mlconfig/mc_combo.h b/tool/mlconfig/mc_combo.h
index 14dc7c05b9c4..bf30835b047d 100644
--- a/tool/mlconfig/mc_combo.h
+++ b/tool/mlconfig/mc_combo.h
@@ -11,10 +11,10 @@
#define MC_COMBO_TOTAL_WIDTH 2
GtkWidget *mc_combo_new(const char *label_name, char **item_names, u_int item_num,
- char *selected_item_name, int is_readonly, GtkWidget **entry);
+ const char *selected_item_name, int is_readonly, GtkWidget **entry);
GtkWidget *mc_combo_new_with_width(const char *label_name, char **item_names, u_int item_num,
- char *selected_item_name, int is_readonly, int entry_width,
+ const char *selected_item_name, int is_readonly, int entry_width,
GtkWidget **entry);
#endif
diff --git a/tool/mlconfig/mc_font.c b/tool/mlconfig/mc_font.c
index a1802007a1dc..bf5f88c51ebc 100644
--- a/tool/mlconfig/mc_font.c
+++ b/tool/mlconfig/mc_font.c
@@ -327,7 +327,7 @@ static void fontsize_selected(GtkWidget *widget, gpointer data) {
}
static void specify_width(GtkWidget *widget, int flag) {
- gchar *fontname;
+ const gchar *fontname;
if (((fontname = new_fontname_list[selected_cs]) ||
(fontname = gtk_entry_get_text(GTK_ENTRY(fontname_entry)))) &&
diff --git a/tool/mlconfig/mc_opentype.c b/tool/mlconfig/mc_opentype.c
index 52b7faa87ced..474e251e4e4a 100644
--- a/tool/mlconfig/mc_opentype.c
+++ b/tool/mlconfig/mc_opentype.c
@@ -50,7 +50,7 @@ static GtkWidget *script_button;
/* --- static functions --- */
-static char *ascii_strcasestr(const char *str1 /* separated by ',' */,
+static const char *ascii_strcasestr(const char *str1 /* separated by ',' */,
const char *str2 /* 4 bytes/Lower case */) {
const char *p1 = str1;
const char *p2 = str2;
@@ -74,8 +74,8 @@ static char *ascii_strcasestr(const char *str1 /* separated by ',' */,
}
}
-static int contains(char *values, char *value) {
- char *p;
+static int contains(const char *values, const char *value) {
+ const char *p;
if ((p = ascii_strcasestr(values, value))) {
if (p == values || *(p - 1) == ',') {
@@ -199,7 +199,7 @@ static void edit_features(GtkWidget *widget, gpointer data) {
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
- gtk_box_pack_start(gtk_dialog_get_content_area(GTK_DIALOG(dialog)), vbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, FALSE, FALSE, 0);
for (count = 0; count < BL_ARRAY_SIZE(features_tbl); count++) {
if (count % 8 == 0) {
@@ -259,7 +259,7 @@ static void edit_script(GtkWidget *widget, gpointer data) {
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
- gtk_box_pack_start(gtk_dialog_get_content_area(GTK_DIALOG(dialog)), vbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, FALSE, FALSE, 0);
for (count = 0; count < BL_ARRAY_SIZE(scripts_tbl); count++) {
if (count % 8 == 0) {
diff --git a/uitoolkit/console/ui_display.c b/uitoolkit/console/ui_display.c
index 10635f4e1113..a3094281be1c 100644
--- a/uitoolkit/console/ui_display.c
+++ b/uitoolkit/console/ui_display.c
@@ -693,7 +693,7 @@ static int receive_stdin_event(ui_display_t *disp) {
#endif
set_blocking(fileno(disp->display->fp), 1);
- ui_window_receive_event(win, &bev);
+ ui_window_receive_event(win, (XEvent *)&bev);
set_blocking(fileno(disp->display->fp), 0);
continue;
@@ -868,7 +868,7 @@ static int receive_stdin_event(ui_display_t *disp) {
}
set_blocking(fileno(disp->display->fp), 1);
- receive_event_for_multi_roots(disp, &kev);
+ receive_event_for_multi_roots(disp, (XEvent*)&kev);
set_blocking(fileno(disp->display->fp), 0);
}
diff --git a/uitoolkit/console/ui_window.c b/uitoolkit/console/ui_window.c
index 40425dd1a2d5..d6e8c5b7d47f 100644
--- a/uitoolkit/console/ui_window.c
+++ b/uitoolkit/console/ui_window.c
@@ -29,7 +29,7 @@
static ui_color_t black = {TP_COLOR, 0, 0, 0, 0};
#endif
-#define ParentRelative (1L)
+#define ParentRelative ((void *)1L)
#define DummyPixmap (2L)
#define COL_WIDTH (win->disp->display->col_width)
@@ -1309,7 +1309,7 @@ void ui_window_console_draw_string(ui_window_t *win, ui_font_t *font, ui_color_t
void ui_window_console_draw_string16(ui_window_t *win, ui_font_t *font, ui_color_t *fg_color,
ui_color_t *bg_color, int x, int y, XChar2b *str, u_int len,
int line_style) {
- draw_string(win, font, fg_color, bg_color, x, y, str, len, 2, line_style);
+ draw_string(win, font, fg_color, bg_color, x, y, (u_char *)str, len, 2, line_style);
}
void ui_window_draw_rect_frame(ui_window_t *win, int x1, int y1, int x2, int y2) {
diff --git a/uitoolkit/fb/ui_display.c b/uitoolkit/fb/ui_display.c
index a2ccf912278d..df0c4de1aca6 100644
--- a/uitoolkit/fb/ui_display.c
+++ b/uitoolkit/fb/ui_display.c
@@ -652,7 +652,7 @@ static void save_hidden_region(void) {
static void draw_mouse_cursor_line(int y) {
u_char *fb;
ui_window_t *win;
- char *shape;
+ const char *shape;
u_char image[MAX_CURSOR_SHAPE_WIDTH * sizeof(u_int32_t)];
int x;
@@ -898,7 +898,7 @@ static int check_virtual_kbd(XButtonEvent *bev) {
draw_mouse_cursor();
if (ret == 1) {
- receive_event_for_multi_roots(&kev);
+ receive_event_for_multi_roots((XEvent *)&kev);
}
}
@@ -1061,7 +1061,7 @@ static int receive_stdin_key_event(void) {
}
if (xev.ksym) {
- receive_event_for_multi_roots(&xev);
+ receive_event_for_multi_roots((XEvent *)&xev);
} else {
for (count = 0; count < len; count++) {
xev.ksym = buf[count];
@@ -1083,7 +1083,7 @@ static int receive_stdin_key_event(void) {
xev.state = ControlMask;
}
- receive_event_for_multi_roots(&xev);
+ receive_event_for_multi_roots((XEvent *)&xev);
}
}
}
@@ -1095,8 +1095,9 @@ static int receive_stdin_key_event(void) {
static fb_cmap_t *cmap_new(int num_colors) {
fb_cmap_t *cmap;
+ void *buffer = malloc(sizeof(*cmap) + sizeof(*(cmap->red)) * num_colors * 3);
- if (!(cmap = malloc(sizeof(*cmap) + sizeof(*(cmap->red)) * num_colors * 3))) {
+ if (!(cmap = buffer)) {
return NULL;
}
@@ -1110,7 +1111,7 @@ static fb_cmap_t *cmap_new(int num_colors) {
cmap->transp = NULL;
#endif
CMAP_SIZE(cmap) = num_colors;
- cmap->red = cmap + 1;
+ cmap->red = buffer + sizeof(*cmap);
cmap->green = cmap->red + num_colors;
cmap->blue = cmap->green + num_colors;
diff --git a/uitoolkit/fb/ui_display_linux.c b/uitoolkit/fb/ui_display_linux.c
index b3934cd27b38..2e94904c7df8 100644
--- a/uitoolkit/fb/ui_display_linux.c
+++ b/uitoolkit/fb/ui_display_linux.c
@@ -526,7 +526,7 @@ static int open_display(u_int depth) {
#ifdef DEBUG
bl_debug_printf("MOUSE2: /dev/input/event%d\n", mouse_num[1]);
#endif
- _disp_mouse2.display = &_mouse2;
+ _disp_mouse2.display = (Display *)&_mouse2;
opened_disps[num_opened_displays++] = &_disp_mouse2;
}
}
@@ -540,7 +540,7 @@ static int open_display(u_int depth) {
bl_debug_printf("KBD2: /dev/input/event%d\n", kbd_num[1]);
#endif
_kbd2.is_kbd = 1;
- _disp_kbd2.display = &_kbd2;
+ _disp_kbd2.display = (Display *)&_kbd2;
opened_disps[num_opened_displays++] = &_disp_kbd2;
}
}
@@ -680,7 +680,7 @@ static int receive_mouse_event(int fd) {
xev.x -= win->x;
xev.y -= win->y;
- ui_window_receive_event(win, &xev);
+ ui_window_receive_event(win, (XEvent*)&xev);
}
} else if (ev.type == EV_REL) {
XMotionEvent xev;
@@ -753,7 +753,7 @@ static int receive_mouse_event(int fd) {
xev.x -= win->x;
xev.y -= win->y;
- ui_window_receive_event(win, &xev);
+ ui_window_receive_event(win, (XEvent *)&xev);
save_hidden_region();
draw_mouse_cursor();
@@ -827,7 +827,7 @@ static int receive_key_event(int fd) {
xev.keycode = ev.code;
if ((xev.ksym = kcode_to_ksym(ev.code, ent.kb_value, &xev.state)) > 0) {
- receive_event_for_multi_roots(&xev);
+ receive_event_for_multi_roots((XEvent *)&xev);
}
}
} else if (ev.value == 0 /* Released */) {
diff --git a/uitoolkit/fb/ui_font.c b/uitoolkit/fb/ui_font.c
index 3a889ef9e9b1..956027d772a9 100644
--- a/uitoolkit/fb/ui_font.c
+++ b/uitoolkit/fb/ui_font.c
@@ -780,7 +780,7 @@ face_found:
goto error;
}
- face->generic.data = ((int)face->generic.data) + 1; /* ref_count */
+ face->generic.data = ((void *)face->generic.data) + 1; /* ref_count */
if (force_height) {
xfont->height = force_height;
@@ -969,7 +969,7 @@ static void unload_ft(XFontStruct *xfont) {
free(xfont->file);
face = xfont->face;
- face->generic.data = ((int)face->generic.data) - 1;
+ face->generic.data = ((void *)face->generic.data) - 1;
if (!face->generic.data) {
FT_Done_Face(xfont->face);
}
@@ -1722,11 +1722,12 @@ static u_char *get_ft_bitmap(XFontStruct *xfont, u_int32_t ch, int use_ot_layout
#endif
if (!fc_files) {
- if (!(fc_files = calloc(num_fc_files, sizeof(*fc_charsets) + sizeof(*fc_files)))) {
+ void *buffer = calloc(num_fc_files, sizeof(*fc_charsets) + sizeof(*fc_files));
+ if (!(fc_files = buffer)) {
return NULL;
}
- fc_charsets = fc_files + num_fc_files;
+ fc_charsets = buffer + sizeof(*fc_charsets);
}
if (!xfont->compl_xfonts &&
diff --git a/uitoolkit/fb/ui_imagelib.c b/uitoolkit/fb/ui_imagelib.c
index c2485d16600e..536aaa62fc31 100644
--- a/uitoolkit/fb/ui_imagelib.c
+++ b/uitoolkit/fb/ui_imagelib.c
@@ -116,7 +116,7 @@ static void modify_pixmap(Display *display, Pixmap pixmap, ui_picture_modifier_t
value_table = NULL;
}
- src = dst = pixmap->image;
+ src = (void *)pixmap->image; dst = pixmap->image;
num_pixels = pixmap->width * pixmap->height;
for (count = 0; count < num_pixels; count++) {
diff --git a/uitoolkit/fb/ui_window.c b/uitoolkit/fb/ui_window.c
index 10ae1c8d3274..344d30344051 100644
--- a/uitoolkit/fb/ui_window.c
+++ b/uitoolkit/fb/ui_window.c
@@ -27,7 +27,7 @@
static ui_color_t black = {TP_COLOR, 0, 0, 0, 0};
#endif
-#define ParentRelative (1L)
+#define ParentRelative ((void *)1L)
#define DummyPixmap (2L)
/* XXX Check if win is input method window or not. */
@@ -313,7 +313,7 @@ static void draw_string_intern(ui_window_t *win, XFontStruct *xfont, u_int font_
case 2:
for (; y_off < font_height; y_off++, y_off_bytes += xfont->glyph_width_bytes) {
p = (picture ? memcpy(src, (picture += picture_line_len), size)
- : memset16(src, bg_pixel, size / 2));
+ : memset16((u_int16_t *)src, bg_pixel, size / 2));
for (count = 0; count < len; count++) {
if (!ui_get_bitmap_line(xfont, bitmaps[count], y_off_bytes, bitmap_line)) {
@@ -340,7 +340,7 @@ static void draw_string_intern(ui_window_t *win, XFontStruct *xfont, u_int font_
default:
for (; y_off < font_height; y_off++, y_off_bytes += xfont->glyph_width_bytes) {
p = (picture ? memcpy(src, (picture += picture_line_len), size)
- : memset32(src, bg_pixel, size / 4));
+ : memset32((u_int32_t *)src, bg_pixel, size / 4));
for (count = 0; count < len; count++) {
if (!ui_get_bitmap_line(xfont, bitmaps[count], y_off_bytes, bitmap_line)) {
@@ -379,12 +379,12 @@ static void draw_string_intern(ui_window_t *win, XFontStruct *xfont, u_int font_
break;
case 2:
- memset16(src, bg_pixel, size / 2);
+ memset16((u_int16_t *)src, bg_pixel, size / 2);
break;
/* case 4: */
default:
- memset32(src, bg_pixel, size / 4);
+ memset32((u_int32_t *)src, bg_pixel, size / 4);
break;
}
}
@@ -455,12 +455,12 @@ static void draw_string_intern(ui_window_t *win, XFontStruct *xfont, u_int font_
break;
case 2:
- memset16(src, bg_pixel, size / 2);
+ memset16((u_int16_t *)src, bg_pixel, size / 2);
break;
/* case 4: */
default:
- memset32(src, bg_pixel, size / 4);
+ memset32((u_int32_t *)src, bg_pixel, size / 4);
break;
}
}
@@ -2341,7 +2341,7 @@ void ui_window_draw_string(ui_window_t *win, ui_font_t *font, ui_color_t *fg_col
void ui_window_draw_string16(ui_window_t *win, ui_font_t *font, ui_color_t *fg_color, int x, int y,
XChar2b *str, u_int len) {
- draw_string(win, font, fg_color, NULL, x, y, str, len, 2, 0);
+ draw_string(win, font, fg_color, NULL, x, y, (u_char *)str, len, 2, 0);
}
void ui_window_draw_image_string(ui_window_t *win, ui_font_t *font, ui_color_t *fg_color,
@@ -2365,7 +2365,7 @@ void ui_window_draw_image_string16(ui_window_t *win, ui_font_t *font, ui_color_t
}
#endif
- draw_string(win, font, fg_color, bg_color, x, y, str, len, 2, bg_color == NULL);
+ draw_string(win, font, fg_color, bg_color, x, y, (u_char *)str, len, 2, bg_color == NULL);
}
void ui_window_draw_rect_frame(ui_window_t *win, int x1, int y1, int x2, int y2) {
diff --git a/uitoolkit/libtype/ui_window_cairo.c b/uitoolkit/libtype/ui_window_cairo.c
index 2cc119001afa..62bab69f8e9f 100644
--- a/uitoolkit/libtype/ui_window_cairo.c
+++ b/uitoolkit/libtype/ui_window_cairo.c
@@ -328,7 +328,7 @@ static int draw_string32(ui_window_t *win, cairo_scaled_font_t *xfont, ui_font_t
#ifdef USE_OT_LAYOUT
if (font->use_ot_layout /* && font->ot_font */) {
- buf = str;
+ buf = (u_char *)str;
} else
#endif
{
diff --git a/uitoolkit/sdl2/ui.h b/uitoolkit/sdl2/ui.h
index 09dcfed29269..0e8676e6bedc 100644
--- a/uitoolkit/sdl2/ui.h
+++ b/uitoolkit/sdl2/ui.h
@@ -63,7 +63,7 @@ typedef struct {
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
- unsigned char *fb;
+ void *fb;
unsigned int bytes_per_pixel;
unsigned int line_length;
diff --git a/uitoolkit/sdl2/ui_display.c b/uitoolkit/sdl2/ui_display.c
index 1c29a660c0ea..a92b053f4735 100644
--- a/uitoolkit/sdl2/ui_display.c
+++ b/uitoolkit/sdl2/ui_display.c
@@ -573,7 +573,8 @@ static void present_displays(void) {
}
}
-static void receive_mouse_event(ui_display_t *disp, XButtonEvent *xev) {
+static void receive_mouse_event(ui_display_t *disp, XEvent *_xev) {
+ XButtonEvent *xev = &_xev->xbutton;
ui_window_t *win;
if (rotate_display) {
@@ -591,7 +592,7 @@ static void receive_mouse_event(ui_display_t *disp, XButtonEvent *xev) {
xev->x -= win->x;
xev->y -= win->y;
- ui_window_receive_event(win, xev);
+ ui_window_receive_event(win, (XEvent *)xev);
}
static u_int get_mod_state(SDL_Keymod mod) {
@@ -762,7 +763,7 @@ static void poll_event(void) {
xev.xbutton.x = ev.button.x;
xev.xbutton.y = ev.button.y;
- receive_mouse_event(disp, &xev.xbutton);
+ receive_mouse_event(disp, &xev);
break;
@@ -781,7 +782,7 @@ static void poll_event(void) {
xev.xbutton.button = 5;
}
- receive_mouse_event(disp, &xev.xbutton);
+ receive_mouse_event(disp, &xev);
}
break;
@@ -804,7 +805,7 @@ static void poll_event(void) {
xev.xmotion.x = ev.motion.x;
xev.xmotion.y = ev.motion.y;
- receive_mouse_event(disp, &xev.xmotion);
+ receive_mouse_event(disp, &xev);
#if 0 /* defined(__HAIKU__) */
/* If mouse cursor moves, garbage is left on HaikuOS, so damaged = 1 to redraw screen. */
@@ -901,15 +902,16 @@ static void poll_event(void) {
/* --- global functions --- */
ui_display_t *ui_display_open(char *disp_name, u_int depth) {
+ void *buffer = calloc(1, sizeof(ui_display_t) + sizeof(Display));
ui_display_t *disp;
void *p;
struct rgb_info rgbinfo = {0, 0, 0, 16, 8, 0};
- if (!(disp = calloc(1, sizeof(ui_display_t) + sizeof(Display)))) {
+ if (!(disp = buffer)) {
return NULL;
}
- disp->display = disp + 1;
+ disp->display = buffer + sizeof(ui_display_t);
if ((p = realloc(displays, sizeof(ui_display_t*) * (num_displays + 1))) == NULL) {
free(disp);
diff --git a/uitoolkit/ui_draw_str.c b/uitoolkit/ui_draw_str.c
index cf177a78854f..054c408615d0 100644
--- a/uitoolkit/ui_draw_str.c
+++ b/uitoolkit/ui_draw_str.c
@@ -471,6 +471,7 @@ static int fc_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
ui_color_manager_t *color_man, u_int *updated_width, vt_char_t *chars,
u_int num_chars, int x, int y, u_int height, u_int ascent,
int top_margin, int hide_underline, int underline_offset) {
+ void *buffer;
int count;
int start_draw;
int end_of_str;
@@ -557,11 +558,12 @@ static int fc_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
line_style = vt_char_line_style(&chars[count]);
- if (!(str8 = str32 = pic_glyphs = drcs_glyphs =
- alloca(BL_MAX(sizeof(*str8),
+ buffer = alloca(BL_MAX(sizeof(*str8),
BL_MAX(sizeof(*str32),
BL_MAX(sizeof(*pic_glyphs), sizeof(*drcs_glyphs)))) *
- num_chars))) {
+ num_chars);
+ str8 = buffer; str32 = buffer; pic_glyphs = buffer; drcs_glyphs = buffer;
+ if (!buffer) {
return 0;
}
@@ -817,7 +819,7 @@ static int xcore_draw_combining_chars(ui_window_t *window, ui_font_manager_t *fo
u_int len;
if (IS_ISO10646_UCS4(ch_cs)) {
- if ((len = ui_convert_ucs4_to_utf16(xch, ch_code) / 2) == 0) {
+ if ((len = ui_convert_ucs4_to_utf16((u_char *)xch, ch_code) / 2) == 0) {
continue;
}
} else {
@@ -839,6 +841,7 @@ static int xcore_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
ui_color_manager_t *color_man, u_int *updated_width, vt_char_t *chars,
u_int num_chars, int x, int y, u_int height, u_int ascent,
int top_margin, int hide_underline, int underline_offset) {
+ void *buffer;
int count;
int start_draw;
int end_of_str;
@@ -922,11 +925,11 @@ static int xcore_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
bg_color = vt_char_bg_color(&chars[count]);
line_style = vt_char_line_style(&chars[count]);
- if (!(str2b = str = pic_glyphs = drcs_glyphs =
- /* '* 2' is for UTF16 surrogate pair. */
- alloca(BL_MAX(sizeof(*str2b) * 2,
+ buffer = alloca(BL_MAX(sizeof(*str2b) * 2, /* '* 2' is for UTF16 surrogate pair. */
BL_MAX(sizeof(*str), BL_MAX(sizeof(*pic_glyphs), sizeof(*drcs_glyphs)))) *
- num_chars))) {
+ num_chars);
+ str2b = buffer; str = buffer; pic_glyphs = buffer; drcs_glyphs = buffer;
+ if (!buffer) {
return 0;
}
@@ -948,7 +951,7 @@ static int xcore_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
} else {
/* UCS4 */
- str_len += (ui_convert_ucs4_to_utf16(str2b + str_len, ch_code) / 2);
+ str_len += (ui_convert_ucs4_to_utf16((u_char *)(str2b + str_len), ch_code) / 2);
}
/*
@@ -1057,7 +1060,7 @@ static int xcore_draw_str(ui_window_t *window, ui_font_manager_t *font_man,
str_len++;
} else {
/* UCS4 */
- str_len += (ui_convert_ucs4_to_utf16(str2b + str_len, comb_code) / 2);
+ str_len += (ui_convert_ucs4_to_utf16((u_char *)(str2b + str_len), comb_code) / 2);
}
}
diff --git a/uitoolkit/ui_main_config.c b/uitoolkit/ui_main_config.c
index 821c799277c1..e4c7dee1435d 100644
--- a/uitoolkit/ui_main_config.c
+++ b/uitoolkit/ui_main_config.c
@@ -1510,11 +1510,12 @@ void ui_main_config_init(ui_main_config_t *main_config, bl_conf_t *conf, int arg
}
} else {
u_int argc;
+ void *buffer = malloc(sizeof(char *) * (argc + 1) + strlen(value) + 1);
argc = bl_count_char_in_str(value, ' ') + 1;
- if ((main_config->cmd_argv = malloc(sizeof(char *) * (argc + 1) + strlen(value) + 1))) {
- value = strcpy(main_config->cmd_argv + argc + 1, value);
+ if ((main_config->cmd_argv = buffer)) {
+ value = strcpy(buffer + sizeof(char *) * (argc + 1), value);
bl_arg_str_to_array(main_config->cmd_argv, &argc, value);
main_config->cmd_path = main_config->cmd_argv[0];
}
diff --git a/uitoolkit/ui_main_config.h b/uitoolkit/ui_main_config.h
index 2e4a91286a96..1d7a09f2d9a7 100644
--- a/uitoolkit/ui_main_config.h
+++ b/uitoolkit/ui_main_config.h
@@ -35,7 +35,7 @@ typedef struct ui_main_config {
vt_bs_mode_t bs_mode;
vt_unicode_policy_t unicode_policy;
vt_alt_color_mode_t alt_color_mode;
- u_int parent_window;
+ uintptr_t parent_window;
char *disp_name;
char *app_name;
diff --git a/uitoolkit/ui_screen.c b/uitoolkit/ui_screen.c
index e2b828c56cb0..2859f42d5309 100644
--- a/uitoolkit/ui_screen.c
+++ b/uitoolkit/ui_screen.c
@@ -1254,7 +1254,7 @@ static void dummy_draw_preedit_str(void *p, vt_char_t *chars, u_int num_chars,
/* Don't set ui_screen_t::is_preediting = 0. */
}
-static void preedit(ui_window_t *win, const char *preedit_text, const char *cur_preedit_text) {
+static void preedit(ui_window_t *win, char *preedit_text, const char *cur_preedit_text) {
ef_parser_t *utf8_parser;
vt_term_t *term = ((ui_screen_t *)win)->term;
diff --git a/uitoolkit/ui_screen_manager.c b/uitoolkit/ui_screen_manager.c
index 0158dbfef6c6..1ba6b7d7da8f 100644
--- a/uitoolkit/ui_screen_manager.c
+++ b/uitoolkit/ui_screen_manager.c
@@ -363,7 +363,7 @@ static int open_pty_intern(vt_term_t *term, char *cmd_path, char **cmd_argv,
* Set cmd_argv by cmd_path.
*/
if (cmd_path && !cmd_argv) {
- char *cmd_file;
+ const char *cmd_file;
cmd_file = bl_basename(cmd_path);
@@ -640,7 +640,7 @@ static ui_screen_t *open_screen_intern(char *disp_name, vt_term_t *term, ui_layo
}
if (!ui_display_show_root(disp, root, main_config.x, main_config.y, main_config.geom_hint,
- main_config.app_name, main_config.wm_role, main_config.parent_window)) {
+ main_config.app_name, main_config.wm_role, (Window)main_config.parent_window)) {
#ifdef DEBUG
bl_warn_printf(BL_DEBUG_TAG " ui_display_show_root() failed.\n");
#endif
diff --git a/uitoolkit/ui_window.h b/uitoolkit/ui_window.h
index 31ffcba46233..7f543d087efa 100644
--- a/uitoolkit/ui_window.h
+++ b/uitoolkit/ui_window.h
@@ -227,7 +227,7 @@ typedef struct ui_window {
void (*set_xdnd_config)(struct ui_window *, char *, char *, char *);
void (*idling)(struct ui_window *);
#ifdef UIWINDOW_SUPPORTS_PREEDITING
- void (*preedit)(struct ui_window *, const char *, const char *);
+ void (*preedit)(struct ui_window *, char *, const char *);
#endif
} ui_window_t;
diff --git a/uitoolkit/wayland/ui_display.c b/uitoolkit/wayland/ui_display.c
index 263ea0eba1fe..bf913060e807 100644
--- a/uitoolkit/wayland/ui_display.c
+++ b/uitoolkit/wayland/ui_display.c
@@ -18,6 +18,7 @@
#include "../ui_window.h"
#include "../ui_picture.h"
#include "../ui_imagelib.h"
+#include "../ui_event_source.h"
#if 0
#define __DEBUG
@@ -435,7 +436,7 @@ static void receive_key_event(ui_wlserv_t *wlserv, XKeyEvent *ev) {
/* Key event for dead surface may be received. */
if (disp && (win = search_focused_window(disp->roots[0]))) {
- ui_window_receive_event(win, ev);
+ ui_window_receive_event(win, (XEvent *)ev);
}
}
}
@@ -839,7 +840,7 @@ static void pointer_motion(void *data, struct wl_pointer *pointer,
bl_debug_printf("Motion event state %x x %d y %d in %p window.\n", ev.state, ev.x, ev.y, win);
#endif
- ui_window_receive_event(win, &ev);
+ ui_window_receive_event(win, (XEvent *)&ev);
}
}
@@ -945,7 +946,7 @@ static void pointer_button(void *data, struct wl_pointer *pointer, uint32_t seri
wlserv->serial = serial;
- ui_window_receive_event(win, &ev);
+ ui_window_receive_event(win, (XEvent *)&ev);
#ifdef COMPAT_LIBVTE
if (ev.type == ButtonPress && disp->display->parent == NULL /* Not input method */) {
@@ -1008,10 +1009,10 @@ static void pointer_axis(void *data, struct wl_pointer *pointer,
#endif
ev.type = ButtonPress;
- ui_window_receive_event(win, &ev);
+ ui_window_receive_event(win, (XEvent *)&ev);
ev.type = ButtonRelease;
- ui_window_receive_event(win, &ev);
+ ui_window_receive_event(win, (XEvent *)&ev);
}
}
@@ -2119,12 +2120,13 @@ static const struct zwp_primary_selection_source_v1_listener zxsel_source_listen
static ui_wlserv_t *open_wl_display(char *name) {
ui_wlserv_t *wlserv;
+ void *buffer = calloc(1, sizeof(ui_wlserv_t) + sizeof(*wlserv->xkb));
- if (!(wlserv = calloc(1, sizeof(ui_wlserv_t) + sizeof(*wlserv->xkb)))) {
+ if (!(wlserv = buffer)) {
return NULL;
}
- wlserv->xkb = wlserv + 1;
+ wlserv->xkb = buffer + sizeof(ui_wlserv_t);
if ((wlserv->display = wl_display_connect(name)) == NULL) {
bl_error_printf("Couldn't open display %s.\n", name);
@@ -2679,17 +2681,18 @@ static void create_surface(ui_display_t *disp, int x, int y, u_int width, u_int
ui_display_t *ui_display_open(char *disp_name, u_int depth) {
u_int count;
- ui_display_t *disp;
ui_wlserv_t *wlserv = NULL;
void *p;
struct rgb_info rgbinfo = {0, 0, 0, 16, 8, 0};
static int added_auto_repeat;
+ void *buffer = calloc(1, sizeof(ui_display_t) + sizeof(Display));
+ ui_display_t *disp = buffer;
- if (!(disp = calloc(1, sizeof(ui_display_t) + sizeof(Display)))) {
+ if (!buffer) {
return NULL;
}
- disp->display = disp + 1;
+ disp->display = buffer + sizeof(ui_display_t);
if ((p = realloc(displays, sizeof(ui_display_t*) * (num_displays + 1))) == NULL) {
free(disp);
diff --git a/uitoolkit/xlib/ui_font.c b/uitoolkit/xlib/ui_font.c
index 7c260685defa..34c8f0ac4c76 100644
--- a/uitoolkit/xlib/ui_font.c
+++ b/uitoolkit/xlib/ui_font.c
@@ -197,7 +197,7 @@ static u_int xcore_calculate_char_width(Display *display, XFontStruct *xfont, u_
} else {
XChar2b c[2];
- width = XTextWidth16(xfont, c, ui_convert_ucs4_to_utf16(c, ch) / 2);
+ width = XTextWidth16(xfont, c, ui_convert_ucs4_to_utf16((u_char *)c, ch) / 2);
}
if (width < 0) {
diff --git a/uitoolkit/xlib/ui_imagelib.c b/uitoolkit/xlib/ui_imagelib.c
index 9e53cff23b73..826a32bc998c 100644
--- a/uitoolkit/xlib/ui_imagelib.c
+++ b/uitoolkit/xlib/ui_imagelib.c
@@ -417,18 +417,18 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
u_int *width, /* Can be NULL */
u_int *height, /* Can be NULL */
int *transparent /* Can be NULL */) {
+ u_int w, h;
+ void *buffer = load_sixel_from_file(path, &w, &h, transparent);
XImage *image;
- u_int32_t *data;
- u_int32_t *in;
- u_int w;
- u_int h;
+ u_int32_t *data = buffer;
+ u_int32_t *in = buffer;
u_int x;
u_int y;
int bytes_per_pixel;
GC mask_gc;
int num_cells;
- if (!(data = in = load_sixel_from_file(path, &w, &h, transparent))) {
+ if (!buffer) {
return 0;
}
@@ -464,7 +464,7 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
}
bytes_per_pixel = 1;
- out8 = data;
+ out8 = (u_char *)data;
#ifdef USE_FS
if ((diff_cur = calloc(1, w * 3)) == NULL || (diff_next = calloc(1, w * 3)) == NULL) {
@@ -540,7 +540,7 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
if (disp->depth == 16) {
bytes_per_pixel = 2;
- out16 = data;
+ out16 = (u_int16_t *)data;
} else /* if (disp->depth == 32 || disp->depth == 24) */ {
bytes_per_pixel = 4;
out32 = data;
@@ -587,7 +587,7 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
if (disp->depth < 8) {
XGCValues gcv;
GC gc = XCreateGC(disp->display, ui_display_get_group_leader(disp), 0, &gcv);
- u_char *out8 = data;
+ u_char *out8 = (u_char *)data;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
@@ -599,7 +599,7 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
free(data);
XFreeGC(disp->display, gc);
} else {
- image = XCreateImage(disp->display, disp->visual, disp->depth, ZPixmap, 0, data, w, h,
+ image = XCreateImage(disp->display, disp->visual, disp->depth, ZPixmap, 0, (char *)data, w, h,
/* in case depth isn't multiple of 8 */
bytes_per_pixel * 8, w * bytes_per_pixel);
#ifdef WORDS_BIGENDIAN
@@ -1426,7 +1426,7 @@ static u_int32_t *create_cardinals_from_file(char *path, u_int32_t width, u_int3
cardinal[1] = height;
size -= (sizeof(u_int32_t) * 2);
- p = &cardinal[2];
+ p = (u_char *)&cardinal[2];
while ((n_rd = read(read_fd, p, size)) > 0) {
p += n_rd;
size -= n_rd;
diff --git a/uitoolkit/xlib/ui_window.c b/uitoolkit/xlib/ui_window.c
index 95dfd205b35c..9b921f3002a4 100644
--- a/uitoolkit/xlib/ui_window.c
+++ b/uitoolkit/xlib/ui_window.c
@@ -3170,7 +3170,7 @@ void ui_window_set_icon(ui_window_t *win, ui_icon_picture_t *icon) {
/* set extended window manager hint's icon */
if (icon->cardinal && icon->cardinal[0] && icon->cardinal[1]) {
int num;
- u_long *data;
+ u_int32_t *data;
/* width * height + 2 */
num = icon->cardinal[0] * icon->cardinal[1] + 2;
diff --git a/vtemu/libctl/vt_bidi.c b/vtemu/libctl/vt_bidi.c
index f92d6c08f10a..032707238d49 100644
--- a/vtemu/libctl/vt_bidi.c
+++ b/vtemu/libctl/vt_bidi.c
@@ -101,9 +101,9 @@ static void adjust_comb_pos_in_order(vt_char_t *vtstr, FriBidiChar *str,
/*
* Don't call this functions with type_p == FRIBIDI_TYPE_ON and size == cur_pos.
*/
-static void log2vis(FriBidiChar *str, u_int size, FriBidiCharType *type_p, vt_bidi_mode_t bidi_mode,
+static void log2vis(FriBidiChar *str, u_int size, FriBidiParType *type_p, vt_bidi_mode_t bidi_mode,
FriBidiStrIndex *order, u_int cur_pos, int append) {
- FriBidiCharType type;
+ FriBidiParType type;
u_int pos;
if (size > cur_pos) {
@@ -215,7 +215,7 @@ void TEST_vt_bidi(void);
int vt_bidi(vt_bidi_state_t state, vt_char_t *src, u_int size, vt_bidi_mode_t bidi_mode,
const char *separators) {
FriBidiChar *fri_src;
- FriBidiCharType fri_type;
+ FriBidiParType fri_type;
FriBidiStrIndex *fri_order;
u_int cur_pos;
ef_charset_t cs;
@@ -457,7 +457,7 @@ int vt_is_rtl_char(u_int32_t ch) {
static void TEST_vt_bidi_1(void) {
FriBidiChar str[] = { 0x6b1, 0x644, 0x627, 0x644, 0x622, 0x6b3, };
- FriBidiCharType type = FRIBIDI_TYPE_ON;
+ FriBidiParType type = FRIBIDI_TYPE_ON;
FriBidiStrIndex order[sizeof(str)/sizeof(str[0])];
FriBidiStrIndex order_ok1[] = { 5, 4, 3, 2, 1, 0, };
FriBidiStrIndex order_ok2[] = { 3, 2, 2, 1, 1, 0, };
@@ -471,7 +471,7 @@ static void TEST_vt_bidi_1(void) {
static void TEST_vt_bidi_2(void) {
FriBidiChar str[] = { 0x6b1, 0x644, 0x627, 0x644, 0x622, 0x6b3, };
- FriBidiCharType type = FRIBIDI_TYPE_ON;
+ FriBidiParType type = FRIBIDI_TYPE_ON;
FriBidiStrIndex order[sizeof(str)/sizeof(str[0])];
FriBidiStrIndex order_ok1[] = { 5, 4, 3, 2, 1, 0, };
FriBidiStrIndex order_ok2[] = { 3, 2, 2, 1, 1, 0, };
@@ -486,7 +486,7 @@ static void TEST_vt_bidi_2(void) {
static void TEST_vt_bidi_3(void) {
FriBidiChar str[] = { 0x61, 0x6b1, 0x644, 0x627, 0x20, 0x644, 0x622, 0x6b3, };
- FriBidiCharType type = FRIBIDI_TYPE_ON;
+ FriBidiParType type = FRIBIDI_TYPE_ON;
FriBidiStrIndex order[sizeof(str)/sizeof(str[0])];
FriBidiStrIndex order_ok1[] = { 0, 3, 2, 1, 4, 7, 6, 5, };
FriBidiStrIndex order_ok2[] = { 0, 2, 1, 1, 3, 5, 5, 4, };
diff --git a/vtemu/libctl/vt_iscii.c b/vtemu/libctl/vt_iscii.c
index 50cd4fbb28d9..cdb9bd561b7f 100644
--- a/vtemu/libctl/vt_iscii.c
+++ b/vtemu/libctl/vt_iscii.c
@@ -104,9 +104,9 @@ static char *iscii_table_files[] = {
* 11 means ISCII_ASSAMESE - ISCII_ROMAN.
* ISCII_ROMAN is disabled (see ef_charset.h) and 10 is enough for now.
*/
-static struct tabl *(*get_iscii_tables[11])(u_int *);
-static struct a2i_tabl *(*get_inscript_table)(u_int *);
-static struct a2i_tabl *(*get_iitkeyb_table)(u_int *);
+static struct tabl *(*get_iscii_tables[11])(size_t *);
+static struct a2i_tabl *(*get_inscript_table)(size_t *);
+static struct a2i_tabl *(*get_iitkeyb_table)(size_t *);
static int8_t file_not_found_flags[11];
diff --git a/vtemu/libptyssh/vt_pty_ssh.c b/vtemu/libptyssh/vt_pty_ssh.c
index 46a606fae07e..707f7f248b3b 100644
--- a/vtemu/libptyssh/vt_pty_ssh.c
+++ b/vtemu/libptyssh/vt_pty_ssh.c
@@ -110,7 +110,7 @@ typedef struct scp {
/* --- static variables --- */
-static char *pass_response;
+static const char *pass_response;
static ssh_session_t **sessions;
static u_int num_sessions = 0;
@@ -858,7 +858,7 @@ static int zombie(vt_pty_ssh_t *pty) {
return 0;
}
-static ssize_t write_to_pty(vt_pty_t *pty, u_char *buf, size_t len) {
+static ssize_t write_to_pty(vt_pty_t *pty, const u_char *buf, size_t len) {
ssize_t ret;
if (((vt_pty_ssh_t *)pty)->session->suspended) {
@@ -1032,7 +1032,7 @@ static ssize_t lo_read_pty(vt_pty_t *pty, u_char *buf, size_t len) {
return read(pty->master, buf, len);
}
-static ssize_t lo_write_to_pty(vt_pty_t *pty, u_char *buf, size_t len) {
+static ssize_t lo_write_to_pty(vt_pty_t *pty, const u_char *buf, size_t len) {
#ifdef __CYGWIN__
if (check_sig_child(pty->config_menu.pid)) {
/*
@@ -1868,6 +1868,7 @@ static void save_data_for_reconnect(ssh_session_t *session, const char *cmd_path
char **env, const char *pass, const char *pubkey,
const char *privkey, u_int cols, u_int rows,
u_int width_pix, u_int height_pix) {
+ void *buffer;
size_t len;
u_int array_size[2];
int idx;
@@ -1893,13 +1894,14 @@ static void save_data_for_reconnect(ssh_session_t *session, const char *cmd_path
}
}
- if ((session->stored = calloc(len, 1))) {
+ buffer = calloc(len, 1);
+ if ((session->stored = buffer)) {
char *str;
char **dst;
- session->stored->argv = session->stored + 1;
- session->stored->env = session->stored->argv + array_size[0];
- str = session->stored->env + array_size[1];
+ session->stored->argv = buffer + sizeof(*session->stored);
+ session->stored->env = buffer + sizeof(*session->stored) + array_size[0];
+ str = buffer + sizeof(*session->stored) + array_size[0] + array_size[1];
session->stored->pass = strcpy(str, pass);
str += (strlen(pass) + 1);
if (cmd_path) {
@@ -1959,15 +1961,17 @@ vt_pty_t *vt_pty_ssh_new(const char *cmd_path, /* can be NULL */
u_int cols, u_int rows, u_int width_pix, u_int height_pix) {
vt_pty_ssh_t *pty;
char *uri_dup;
- char *user;
+ const char *user;
char *proto;
char *host;
char *port;
+ char *tmp_user;
if ((uri_dup = alloca(strlen(uri) + 1)) == NULL ||
- !bl_parse_uri(&proto, &user, &host, &port, NULL, NULL, strcpy(uri_dup, uri))) {
+ !bl_parse_uri(&proto, &tmp_user, &host, &port, NULL, NULL, strcpy(uri_dup, uri))) {
return NULL;
}
+ user = tmp_user;
if (!user && !(user = bl_get_user_name())) {
return NULL;
diff --git a/vtemu/vt_edit.c b/vtemu/vt_edit.c
index baeeae5575ec..8028b64fc306 100644
--- a/vtemu/vt_edit.c
+++ b/vtemu/vt_edit.c
@@ -1536,13 +1536,13 @@ vt_protect_store_t *vt_edit_save_protected_chars(vt_edit_t *edit,
for (count = 0; count < num; count++, src++) {
if (vt_char_is_protected(src)) {
if (!save) {
- if (!(save = malloc(sizeof(vt_protect_store_t) +
+ void * buffer = malloc(sizeof(vt_protect_store_t) +
sizeof(vt_char_t) * (vt_edit_get_cols(edit) + 1) *
- (end_row - row + 1)))) {
+ (end_row - row + 1));
+ if (!(save = buffer)) {
return NULL;
}
-
- dst = save->chars = save + 1;
+ dst = save->chars = buffer + sizeof(vt_protect_store_t);
vt_str_init(dst, (vt_edit_get_cols(edit) + 1) * (end_row - row + 1));
dst += count;
save->beg_row = row;
diff --git a/vtemu/vt_parser.c b/vtemu/vt_parser.c
index 4d65ecd68979..c2b1df35afe4 100644
--- a/vtemu/vt_parser.c
+++ b/vtemu/vt_parser.c
@@ -2763,7 +2763,7 @@ static void iterm2_proprietary_set(vt_parser_t *vt_parser, char *pt) {
if ((beg = strstr(args, "name=")) &&
((end = strchr((beg += 5), ';')) || (end = beg + strlen(beg))) &&
(path = malloc(7 + (end - beg) + 1))) {
- char *file;
+ const char *file;
char *new_path;
size_t d_len;
@@ -3153,7 +3153,7 @@ static void reset_color_rgb(vt_parser_t *vt_parser, u_char *pt, int is_spcolor)
}
}
} else {
- while ((p = bl_str_sep(&pt, ";"))) {
+ while ((p = bl_str_sep((char **)&pt, ";"))) {
if (is_spcolor) {
if ('0' <= *p && *p <= '4') {
config_protocol_set_simple(vt_parser, get_special_color_name(*p), "", 0);
@@ -5821,7 +5821,7 @@ inline static int parse_vt100_escape_sequence(
} else if (ps[0] == 10) {
/* XXX full screen is not supported for now. */
} else if (ps[0] == 7) {
- const char cmd[] = "update_all";
+ char cmd[] = "update_all";
config_protocol_set(vt_parser, cmd, 0);
} else if (ps[0] == 11) {
vt_write_to_pty(vt_parser->pty, "\x1b[1t", 4); /* XXX always non-iconified */
diff --git a/vtemu/vt_pty.c b/vtemu/vt_pty.c
index b8503b52c18e..235bd6a75618 100644
--- a/vtemu/vt_pty.c
+++ b/vtemu/vt_pty.c
@@ -128,9 +128,9 @@ int vt_set_pty_winsize(vt_pty_t *pty, u_int cols, u_int rows, u_int width_pix, u
/*
* Return size of lost bytes.
*/
-size_t vt_write_to_pty(vt_pty_t *pty, u_char *buf, size_t len /* if 0, flushing buffer. */
+size_t vt_write_to_pty(vt_pty_t *pty, const u_char *buf, size_t len /* if 0, flushing buffer. */
) {
- u_char *w_buf;
+ const u_char *w_buf;
size_t w_buf_size;
ssize_t written_size;
void *p;
@@ -176,15 +176,19 @@ size_t vt_write_to_pty(vt_pty_t *pty, u_char *buf, size_t len /* if 0, flushing
w_buf = pty->buf;
} else if (/* pty->buf == NULL && */ pty->left == 0) {
w_buf = buf;
- } else if ((w_buf = alloca(w_buf_size))) {
- memcpy(w_buf, pty->buf, pty->left);
- memcpy(&w_buf[pty->left], buf, len);
} else {
+ u_char * new_w_buf = alloca(w_buf_size);
+ if (new_w_buf) {
+ memcpy(new_w_buf, pty->buf, pty->left);
+ memcpy(&new_w_buf[pty->left], buf, len);
+ w_buf = new_w_buf;
+ } else {
#ifdef DEBUG
- bl_warn_printf(BL_DEBUG_TAG " alloca() failed. %d characters not written.\n", len);
+ bl_warn_printf(BL_DEBUG_TAG " alloca() failed. %d characters not written.\n", len);
#endif
- return len;
+ return len;
+ }
}
#ifdef __DEBUG
diff --git a/vtemu/vt_pty.h b/vtemu/vt_pty.h
index eed4485b7a49..3da8a19a719b 100644
--- a/vtemu/vt_pty.h
+++ b/vtemu/vt_pty.h
@@ -61,7 +61,7 @@ typedef struct vt_pty {
int (*final)(struct vt_pty *);
int (*set_winsize)(struct vt_pty *, u_int, u_int, u_int, u_int);
- ssize_t (*write)(struct vt_pty *, u_char*, size_t);
+ ssize_t (*write)(struct vt_pty *, const u_char*, size_t);
ssize_t (*read)(struct vt_pty *, u_char*, size_t);
vt_pty_event_listener_t *pty_listener;
@@ -71,7 +71,7 @@ typedef struct vt_pty {
struct _stored {
int master;
int slave;
- ssize_t (*write)(struct vt_pty *, u_char*, size_t);
+ ssize_t (*write)(struct vt_pty *, const u_char*, size_t);
ssize_t (*read)(struct vt_pty *, u_char*, size_t);
u_int ref_count;
@@ -98,7 +98,7 @@ int vt_pty_destroy(vt_pty_t *pty);
int vt_set_pty_winsize(vt_pty_t *pty, u_int cols, u_int rows, u_int width_pix, u_int height_pix);
-size_t vt_write_to_pty(vt_pty_t *pty, u_char *buf, size_t len);
+size_t vt_write_to_pty(vt_pty_t *pty, const u_char *buf, size_t len);
size_t vt_read_pty(vt_pty_t *pty, u_char *buf, size_t left);
@@ -134,7 +134,7 @@ int vt_pty_ssh_set_use_loopback(vt_pty_t *pty, int use);
int vt_pty_ssh_scp(vt_pty_t *pty, vt_char_encoding_t pty_encoding,
vt_char_encoding_t path_encoding, char *dst_path, char *src_path,
- int use_scp_full, const char *recv_dir, u_int progress_len);
+ int use_scp_full, char *recv_dir, u_int progress_len);
void vt_pty_ssh_set_cipher_list(const char *list);
diff --git a/vtemu/vt_pty_ssh.c b/vtemu/vt_pty_ssh.c
index 49055b133a76..0c2686ba5dfd 100644
--- a/vtemu/vt_pty_ssh.c
+++ b/vtemu/vt_pty_ssh.c
@@ -228,10 +228,10 @@ void vt_pty_ssh_set_pty_read_trigger(void (*func)(void)) {
int vt_pty_ssh_scp(vt_pty_t *pty, vt_char_encoding_t pty_encoding, /* Not VT_UNKNOWN_ENCODING */
vt_char_encoding_t path_encoding, /* Not VT_UNKNOWN_ENCODING */
char *dst_path, char *src_path, int use_scp_full,
- const char *recv_dir, u_int progress_len) {
+ char *recv_dir, u_int progress_len) {
int dst_is_remote;
int src_is_remote;
- char *file;
+ const char *file;
char *_dst_path;
char *_src_path;
size_t len;
diff --git a/vtemu/vt_pty_unix.c b/vtemu/vt_pty_unix.c
index 341de983c83b..e3f2de4b8877 100644
--- a/vtemu/vt_pty_unix.c
+++ b/vtemu/vt_pty_unix.c
@@ -93,7 +93,7 @@ static int set_winsize(vt_pty_t *pty, u_int cols, u_int rows, u_int width_pix, u
return 1;
}
-static ssize_t write_to_pty(vt_pty_t *pty, u_char *buf, size_t len) {
+static ssize_t write_to_pty(vt_pty_t *pty, const u_char *buf, size_t len) {
#ifdef __APPLE__
ssize_t ret;
diff --git a/vtemu/zmodem.c b/vtemu/zmodem.c
index 3c9a0c9c1691..ed550781772c 100644
--- a/vtemu/zmodem.c
+++ b/vtemu/zmodem.c
@@ -63,6 +63,10 @@
#include <pobl/bl_types.h> /* u_int32_t */
#include <pobl/bl_path.h> /* bl_basename */
+#if defined(HAVE_BASENAME)
+#include <libgen.h> /* dirname */
+#endif
+
#ifndef uint32_t
#define uint32_t u_int32_t
#endif