diff --git a/src/Actions.c b/src/Actions.c index 2fb8844089afa0a51877b67a82ec3fda56ae5685..ad26cea800f91eadf7d7a08f730e7f588daa26e7 100644 --- a/src/Actions.c +++ b/src/Actions.c @@ -111,7 +111,7 @@ static Bool prim(XawEvalInfo*); static String XawConvertActionRes(XawActionResList*, Widget w, String); static char * _XawEscapeActionVarValue(String); -static String _XawUnescapeActionVarValue(String); +static char * _XawUnescapeActionVarValue(String); static XawActionResList *_XawCreateActionResList(WidgetClass); static XawActionResList *_XawFindActionResList(WidgetClass); static void _XawBindActionResList(XawActionResList*); @@ -151,7 +151,7 @@ static Cardinal num_variable_list; Bool XawParseBoolean(Widget w, String param, XEvent *event, Bool *succed) { - char *tmp = param; + char *tmp = (char *)param; int value; if (!param) @@ -206,7 +206,7 @@ XawBooleanExpression(Widget w, String param, XEvent *event) info.parse_proc = XawParseBoolean; info.event = event; - info.cp = info.lp = param; + info.cp = info.lp = (char *)param; #ifdef DIAGNOSTIC fprintf(stderr, "(*) Parsing expression \"%s\"\n", param); @@ -423,7 +423,7 @@ XawSetValuesAction(Widget w, XEvent *event, vlist = XawGetActionVarList(w); num_args = 0; - arglist = (Arg *)XtMalloc(sizeof(Arg) * ((*num_params) >> 1)); + arglist = (Arg *)XtMalloc((Cardinal)sizeof(Arg) * ((*num_params) >> 1)); for (count = 1; count < *num_params; count += 2) { @@ -437,8 +437,8 @@ XawSetValuesAction(Widget w, XEvent *event, continue; } value = XawConvertActionVar(vlist, params[count + 1]); - from.size = strlen(value) + 1; - from.addr = value; + from.size = (Cardinal) strlen(value) + 1; + from.addr = (char *)value; to.size = resource->size; switch (to.size) { @@ -646,13 +646,15 @@ XawPrintActionErrorMsg(String action_name, Widget w, char msg[1024]; unsigned int size, idx; - size = snprintf(msg, sizeof(msg), "%s(): bad number of parameters.\n\t(", - action_name); + size = (unsigned)snprintf(msg, + sizeof(msg), + "%s(): bad number of parameters.\n\t(", + action_name); idx = 0; while (idx < *num_params - 1 && size < sizeof(msg)) - size += snprintf(&msg[size], sizeof(msg) - size, "%s, ", - params[idx++]); + size += (unsigned)snprintf(&msg[size], sizeof(msg) - size, "%s, ", + params[idx++]); if (*num_params) snprintf(&msg[size], sizeof(msg) - size, "%s)", params[idx]); else @@ -677,8 +679,8 @@ static int qcmp_action_resource_list(register _Xconst void *left, register _Xconst void *right) { - return ((char *)((*(XawActionResList **)left)->widget_class) - - (char *)((*(XawActionResList **)right)->widget_class)); + return (int)((char *)((*(XawActionResList **)left)->widget_class) - + (char *)((*(XawActionResList **)right)->widget_class)); } static XawActionResList * @@ -686,7 +688,7 @@ _XawCreateActionResList(WidgetClass wc) { XawActionResList *list; - list = (XawActionResList *)XtMalloc(sizeof(XawActionResList)); + list = (XawActionResList *)XtMalloc((Cardinal)sizeof(XawActionResList)); list->widget_class = wc; list->num_common_resources = list->num_constraint_resources = 0; list->resources = NULL; @@ -694,14 +696,14 @@ _XawCreateActionResList(WidgetClass wc) if (!resource_list) { num_resource_list = 1; - resource_list = (XawActionResList **)XtMalloc(sizeof(XawActionResList*)); + resource_list = (XawActionResList **)XtMalloc((Cardinal)sizeof(XawActionResList*)); resource_list[0] = list; } else { ++num_resource_list; resource_list = (XawActionResList **)XtRealloc((char *)resource_list, - sizeof(XawActionResList*) + (Cardinal) sizeof(XawActionResList*) * num_resource_list); resource_list[num_resource_list - 1] = list; qsort(resource_list, num_resource_list, sizeof(XawActionResList*), @@ -717,7 +719,8 @@ static int bcmp_action_resource_list(register _Xconst void *wc, register _Xconst void *list) { - return ((char *)wc - (char *)((*(XawActionResList **)list)->widget_class)); + return (int)((char *)wc + - (char *)((*(XawActionResList **)list)->widget_class)); } static XawActionResList * @@ -761,7 +764,7 @@ _XawBindActionResList(XawActionResList *list) list->num_constraint_resources = num_cons; list->resources = (XawActionRes **) - XtMalloc(sizeof(XawActionRes*) * (num_xt + num_cons)); + XtMalloc((Cardinal)sizeof(XawActionRes*) * (num_xt + num_cons)); #ifdef DIAGNOSTIC fprintf(stderr, "Common resources\n---\n"); @@ -769,7 +772,7 @@ _XawBindActionResList(XawActionResList *list) for (i = 0; i < num_xt; i++) { - list->resources[i] = (XawActionRes *)XtMalloc(sizeof(XawActionRes)); + list->resources[i] = (XawActionRes *)XtMalloc((Cardinal)sizeof(XawActionRes)); list->resources[i]->qname = XrmPermStringToQuark(xt_list[i].resource_name); list->resources[i]->qtype = @@ -790,7 +793,7 @@ _XawBindActionResList(XawActionResList *list) for (; i < num_xt + num_cons; i++) { - list->resources[i] = (XawActionRes *)XtMalloc(sizeof(XawActionRes)); + list->resources[i] = (XawActionRes *)XtMalloc((Cardinal)sizeof(XawActionRes)); list->resources[i]->qname = XrmPermStringToQuark(cons_list[i - num_xt].resource_name); list->resources[i]->qtype = @@ -866,7 +869,7 @@ _XawEscapeActionVarValue(String value) if (value[0] == '$' || value[0] == '\\') { - escape = XtMalloc(strlen(value) + 2); + escape = XtMalloc((Cardinal)strlen(value) + 2); escape[0] = '\\'; strcpy(escape + 1, value); return (escape); @@ -875,14 +878,14 @@ _XawEscapeActionVarValue(String value) } /* For speed, only does memory allocation when really required */ -static String +static char * _XawUnescapeActionVarValue(String value) { - String unescape; + char * unescape; if (value[0] == '\\') { - unescape = XtMalloc(strlen(value)); + unescape = XtMalloc((Cardinal)strlen(value)); strcpy(unescape, value + 1); return (unescape); } @@ -893,7 +896,7 @@ static void XawDeclareActionVar(XawActionVarList *list, String name, String value) { XawActionVar *variable; - String escape = NULL; + char * escape = NULL; if (name[0] != XAW_PRIV_VAR_PREFIX) { @@ -932,7 +935,7 @@ static String XawConvertActionVar(XawActionVarList *list, String name) { XawActionVar *variable; - String unescape; + char * unescape; XrmQuark quark; if (name[0] != XAW_PRIV_VAR_PREFIX) @@ -969,8 +972,8 @@ static int qcmp_action_variable_list(register _Xconst void *left, register _Xconst void *right) { - return ((char *)((*(XawActionVarList **)left)->widget) - - (char *)((*(XawActionVarList **)right)->widget)); + return (int)((char *)((*(XawActionVarList **)left)->widget) - + (char *)((*(XawActionVarList **)right)->widget)); } static XawActionVarList * @@ -983,7 +986,7 @@ _XawCreateActionVarList(Widget w) XtName(w), w); #endif - list = (XawActionVarList *)XtMalloc(sizeof(XawActionVarList)); + list = (XawActionVarList *)XtMalloc((Cardinal)sizeof(XawActionVarList)); list->widget = w; list->num_variables = 0; list->variables = NULL; @@ -991,7 +994,7 @@ _XawCreateActionVarList(Widget w) if (!variable_list) { num_variable_list = 1; - variable_list = (XawActionVarList **)XtMalloc(sizeof(XawActionVarList*)); + variable_list = (XawActionVarList **)XtMalloc((Cardinal)sizeof(XawActionVarList*)); variable_list[0] = list; } else @@ -999,7 +1002,7 @@ _XawCreateActionVarList(Widget w) ++num_variable_list; variable_list = (XawActionVarList **) XtRealloc((char *)variable_list, - sizeof(XawActionVarList *) * num_variable_list); + (Cardinal)sizeof(XawActionVarList *) * num_variable_list); variable_list[num_variable_list - 1] = list; qsort(variable_list, num_variable_list, sizeof(XawActionVarList*), qcmp_action_variable_list); @@ -1015,7 +1018,8 @@ static int bcmp_action_variable_list(register _Xconst void *widget, register _Xconst void *list) { - return ((char *)widget - (char *)((*(XawActionVarList **)list)->widget)); + return (int)((char *)widget + - (char *)((*(XawActionVarList **)list)->widget)); } static XawActionVarList * @@ -1051,21 +1055,21 @@ _XawCreateActionVar(XawActionVarList *list, String name) name, XtName(list->widget), list->widget); #endif - variable = (XawActionVar *)XtMalloc(sizeof(XawActionVar)); + variable = (XawActionVar *)XtMalloc((Cardinal)sizeof(XawActionVar)); variable->qname = XrmStringToQuark(name); variable->qvalue = NULLQUARK; if (!list->variables) { list->num_variables = 1; - list->variables = (XawActionVar **)XtMalloc(sizeof(XawActionVar*)); + list->variables = (XawActionVar **)XtMalloc((Cardinal)sizeof(XawActionVar*)); list->variables[0] = variable; } else { ++list->num_variables; list->variables = (XawActionVar **)XtRealloc((char *)list->variables, - sizeof(XawActionVar *) * + (Cardinal) sizeof(XawActionVar *) * list->num_variables); list->variables[list->num_variables - 1] = variable; qsort(list->variables, list->num_variables, sizeof(XawActionVar*), @@ -1117,7 +1121,7 @@ _XawDestroyActionVarList(Widget w, XtPointer client_data, XtPointer call_data) memmove(&variable_list[i], &variable_list[i + 1], (num_variable_list - i) * sizeof(XawActionVarList *)); variable_list = (XawActionVarList **) - XtRealloc((char *)variable_list, sizeof(XawActionVarList *) * + XtRealloc((char *)variable_list, (Cardinal) sizeof(XawActionVarList *) * num_variable_list); } else diff --git a/src/AsciiSink.c b/src/AsciiSink.c index 1cccb1cecad2d122050e175df559f957dbdf5f60..41cac7d9cf6cc1cb81f17e5a068445e9534f7256 100644 --- a/src/AsciiSink.c +++ b/src/AsciiSink.c @@ -302,7 +302,7 @@ GetTextWidth(TextWidget ctx, int current_width, XFontStruct *font, while (length > 0) { pos = XawTextSourceRead(ctx->text.source, from, &block, length); - length -= pos - from; + length = (int)(length - (pos - from)); from = pos; for (i = 0; i < block.length; i++) width += CharWidth((AsciiSinkObject)ctx->text.sink, font, @@ -364,7 +364,7 @@ void CalculateBearing(TextWidget ctx, XawTextPosition position, int x, int y, c = ' '; else if ((c & 0177) < XawSP || c == 0177) { if (sink->ascii_sink.display_nonprinting) - c = c > 0177 ? (c & 7) + '0' : c + '@'; + c = (unsigned char)(c > 0177 ? (c & 7) + '0' : c + '@'); else c = ' '; } @@ -382,10 +382,10 @@ void CalculateBearing(TextWidget ctx, XawTextPosition position, int x, int y, paint->max_ascent = ascent; paint->max_descent = descent; paint->backtabs = NULL; - paint->highlight = highlight; + paint->highlight = (Boolean)highlight; paint->length = 1; paint->text = XtMalloc(1); - paint->text[0] = c; + paint->text[0] = (char)c; } } } @@ -400,7 +400,7 @@ void CalculateBearing(TextWidget ctx, XawTextPosition position, int x, int y, c = ' '; else if ((c & 0177) < XawSP || c == 0177) { if (sink->ascii_sink.display_nonprinting) - c = c > 0177 ? '\\' : c + '^'; + c = (unsigned char)(c > 0177 ? '\\' : c + '^'); else c = ' '; } @@ -418,10 +418,10 @@ void CalculateBearing(TextWidget ctx, XawTextPosition position, int x, int y, paint->max_ascent = ascent; paint->max_descent = descent; paint->backtabs = NULL; - paint->highlight = highlight; + paint->highlight = (Boolean)highlight; paint->length = 1; paint->text = XtMalloc(1); - paint->text[0] = c; + paint->text[0] = (char)c; } } } @@ -470,7 +470,7 @@ AsciiPreparePaint(Widget w, int y, int line, tmp = pos; pos = anchor->position + entity->offset + entity->length; if ((length = XawMin(from, pos) - tmp) > 0) - x += GetTextWidth(ctx, x, font, tmp, length); + x += GetTextWidth(ctx, x, font, tmp, (int)length); ascent = XawMax(font->ascent, ascent); descent = XawMax(font->descent, descent); } @@ -484,7 +484,7 @@ AsciiPreparePaint(Widget w, int y, int line, else { if ((length = XawMin(from, pos) - tmp) > 0) { x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, - length); + (int)length); tmp += length; } if (pos < right) { @@ -496,7 +496,7 @@ AsciiPreparePaint(Widget w, int y, int line, else font = sink->ascii_sink.font; if ((length = XawMin(from, pos) - tmp) > 0) - x += GetTextWidth(ctx, x, font, tmp, length); + x += GetTextWidth(ctx, x, font, tmp, (int)length); ascent = XawMax(font->ascent, ascent); descent = XawMax(font->descent, descent); } @@ -507,14 +507,14 @@ AsciiPreparePaint(Widget w, int y, int line, if (anchor->entities == NULL) { tmp = XawMin(pos, from); if ((length = from - tmp) > 0) - x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, length); + x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, (int)length); break; } } else { tmp = XawMin(pos, from); if ((length = from - tmp) > 0) - x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, length); + x += GetTextWidth(ctx, x, sink->ascii_sink.font, tmp, (int)length); ascent = XawMax(sink->ascii_sink.font->ascent, ascent); descent = XawMax(sink->ascii_sink.font->descent, descent); break; @@ -539,7 +539,7 @@ AsciiPreparePaint(Widget w, int y, int line, paint->max_ascent = ascent; paint->max_descent = descent; paint->backtabs = NULL; - paint->highlight = highlight; + paint->highlight = (Boolean)highlight; tmp = pos; if (XawTextSourceAnchorAndEntity(ctx->text.source, pos, @@ -568,27 +568,27 @@ AsciiPreparePaint(Widget w, int y, int line, pos = XawMin(pos, to); length = pos - tmp; - paint->text = XtMalloc(bufsiz = pos - tmp + 4); + paint->text = XtMalloc((Cardinal)(bufsiz = (int)(pos - tmp + 4))); paint->length = 0; segment.x1 = x; pos2 = tmp; while (length > 0) { - pos2 = XawTextSourceRead(ctx->text.source, tmp, &block, length); + pos2 = XawTextSourceRead(ctx->text.source, tmp, &block, (int)length); length = pos - pos2; tmp = pos2; for (i = 0; i < block.length; i++) { unsigned char c = (unsigned char)block.ptr[i]; if (paint->length + 4 > bufsiz) - paint->text = XtRealloc(paint->text, bufsiz += 32); - paint->text[paint->length] = c; + paint->text = XtRealloc(paint->text, (Cardinal)(bufsiz += 32)); + paint->text[paint->length] = (char)c; if (c == '\n') { x += CharWidth(sink, font, 0, ' '); continue; } if (c == '\t') { - x += XTextWidth(font, paint->text, paint->length); + x += XTextWidth(font, paint->text, (int)paint->length); segment.x2 = x + CharWidth(sink, font, x, '\t'); if (XmuValidSegment(&segment)) { @@ -642,9 +642,9 @@ AsciiPreparePaint(Widget w, int y, int line, paint->max_ascent = ascent; paint->max_descent = descent; paint->backtabs = NULL; - paint->highlight = highlight; - paint->text = XtMalloc(bufsiz = pos - tmp - length + - block.length - i + 4); + paint->highlight = (Boolean)highlight; + paint->text = XtMalloc((Cardinal)(bufsiz = (int)(pos - tmp - length + + block.length - i + 4))); paint->length = 0; continue; } @@ -652,14 +652,14 @@ AsciiPreparePaint(Widget w, int y, int line, if (sink->ascii_sink.display_nonprinting) { if (c > 0177) { paint->text[paint->length++] = '\\'; - paint->text[paint->length++] = ((c >> 6) & 7) + '0'; - paint->text[paint->length++] = ((c >> 3) & 7) + '0'; - paint->text[paint->length] = (c & 7) + '0'; + paint->text[paint->length++] = (char)(((c >> 6) & 7) + '0'); + paint->text[paint->length++] = (char)(((c >> 3) & 7) + '0'); + paint->text[paint->length] = (char)((c & 7) + '0'); } else { c |= 0100; paint->text[paint->length++] = '^'; - paint->text[paint->length] = c == 0177 ? '?' : c; + paint->text[paint->length] = (char)(c == 0177 ? '?' : c); } } else @@ -669,7 +669,7 @@ AsciiPreparePaint(Widget w, int y, int line, } } - x += XTextWidth(font, paint->text, paint->length); + x += XTextWidth(font, paint->text, (int)paint->length); segment.x2 = x; if (XmuValidSegment(&segment)) { /* erase only what really is needed */ @@ -724,8 +724,8 @@ AsciiPreparePaint(Widget w, int y, int line, static int qcmp_paint_struct(_Xconst void *left, _Xconst void *right) { - return ((*(XawTextPaintStruct**)left)->property - - (*(XawTextPaintStruct**)right)->property); + return (int)((*(XawTextPaintStruct**)left)->property - + (*(XawTextPaintStruct**)right)->property); } static void @@ -759,8 +759,8 @@ AsciiDoPaint(Widget w) for (seg = scan->segment; seg; seg = seg->next) _XawTextSinkClearToBackground(ctx->text.sink, seg->x1, scan->y, - seg->x2 - seg->x1, - scan->next->y - scan->y); + (unsigned)(seg->x2 - seg->x1), + (unsigned)(scan->next->y - scan->y)); /* pass 2: optimize drawing list to avoid too much GC change requests */ /* XXX this assumes there will not exist entities drawn over other @@ -791,13 +791,13 @@ AsciiDoPaint(Widget w) ++n_paints; } paints = (XawTextPaintStruct**) - XtMalloc(n_paints * sizeof(XawTextPaintStruct)); + XtMalloc((Cardinal)((size_t)n_paints * sizeof(XawTextPaintStruct))); paint = list->paint; while (paint) { paints[i++] = paint; paint = paint->next; } - qsort((void*)paints, n_paints, sizeof(XawTextPaintStruct*), + qsort((void*)paints, (size_t)n_paints, sizeof(XawTextPaintStruct*), qcmp_paint_struct); list->paint = paints[0]; for (i = 0; i < n_paints - 1; i++) @@ -813,8 +813,8 @@ AsciiDoPaint(Widget w) rect.y = ctx->text.r_margin.top; width = (int)XtWidth(ctx) - RHMargins(ctx); height = (int)XtHeight(ctx) - RVMargins(ctx); - rect.width = width; - rect.height = height; + rect.width = (unsigned short)width; + rect.height = (unsigned short)height; if (width >= 0 && height >= 0) XSetClipRectangles(XtDisplay((Widget)ctx), gc, 0, 0, &rect, 1, Unsorted); @@ -842,12 +842,12 @@ AsciiDoPaint(Widget w) } if (i_rects <= n_rects) rects = (XRectangle*) - XtRealloc((XtPointer)rects, sizeof(XRectangle) * - ++n_rects); - rects[i_rects].x = paint->x; - rects[i_rects].y = paint->y - font->ascent; - rects[i_rects].width = paint->width; - rects[i_rects++].height = font->ascent + font->descent; + XtRealloc((XtPointer)rects, (Cardinal)(sizeof(XRectangle) * + (size_t)++n_rects)); + rects[i_rects].x = (short)paint->x; + rects[i_rects].y = (short)(paint->y - font->ascent); + rects[i_rects].width = (unsigned short)paint->width; + rects[i_rects++].height = (unsigned short)(font->ascent + font->descent); if (paint->backtabs) { for (scan = paint->backtabs->scanline; scan && scan->next; @@ -855,12 +855,12 @@ AsciiDoPaint(Widget w) for (seg = scan->segment; seg; seg = seg->next) { if (i_rects <= n_rects) rects = (XRectangle*) - XtRealloc((XtPointer)rects, sizeof(XRectangle) * - ++n_rects); - rects[i_rects].x = seg->x1; - rects[i_rects].y = scan->y; - rects[i_rects].width = seg->x2 - seg->x1; - rects[i_rects++].height = scan->next->y - scan->y; + XtRealloc((XtPointer)rects, (Cardinal)(sizeof(XRectangle) * + (size_t)++n_rects)); + rects[i_rects].x = (short)seg->x1; + rects[i_rects].y = (short)scan->y; + rects[i_rects].width = (unsigned short)(seg->x2 - seg->x1); + rects[i_rects++].height = (unsigned short)(scan->next->y - scan->y); } } @@ -879,12 +879,12 @@ AsciiDoPaint(Widget w) XSetForeground(XtDisplay(ctx), gc, sink->text_sink.cursor_color); if (i_rects <= n_rects) rects = (XRectangle*) - XtRealloc((XtPointer)rects, sizeof(XRectangle) * - ++n_rects); - rects[i_rects].x = paint->x; - rects[i_rects].y = paint->y - paint->max_ascent; - rects[i_rects].width = paint->width; - rects[i_rects++].height = paint->max_ascent + paint->max_descent + 1; + XtRealloc((XtPointer)rects, (Cardinal)(sizeof(XRectangle) * + (size_t)++n_rects)); + rects[i_rects].x = (short)paint->x; + rects[i_rects].y = (short)(paint->y - paint->max_ascent); + rects[i_rects].width = (unsigned short)paint->width; + rects[i_rects++].height = (unsigned short)(paint->max_ascent + paint->max_descent + 1); } paint = paint->next; } @@ -897,12 +897,12 @@ AsciiDoPaint(Widget w) sink->text_sink.cursor_color); if (i_rects <= n_rects) rects = (XRectangle*) - XtRealloc((XtPointer)rects, sizeof(XRectangle) * - ++n_rects); - rects[i_rects].x = seg->x1; - rects[i_rects].y = scan->y; - rects[i_rects].width = seg->x2 - seg->x1; - rects[i_rects++].height = scan->next->y - scan->y; + XtRealloc((XtPointer)rects, (Cardinal)(sizeof(XRectangle) * + (size_t)++n_rects)); + rects[i_rects].x = (short)seg->x1; + rects[i_rects].y = (short)scan->y; + rects[i_rects].width = (unsigned short)(seg->x2 - seg->x1); + rects[i_rects++].height = (unsigned short)(scan->next->y - scan->y); } } @@ -946,7 +946,7 @@ AsciiDoPaint(Widget w) if (paint->x < XtWidth(ctx) && paint->x + paint->width > 0) { XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, paint->x, paint->y, - paint->text, paint->length); + paint->text, (int)paint->length); if (property) { if (property->mask & XAW_TPROP_UNDERLINE) { if (line_width != property->underline_thickness) { @@ -982,7 +982,7 @@ AsciiDoPaint(Widget w) /* dont care on order of drawing or caching of state (by now) */ paint = list->bearings; while (paint) { - XRectangle rect; + XRectangle rect2; if (paint->highlight) XSetForeground(XtDisplay(ctx), gc, sink->text_sink.background); @@ -999,14 +999,14 @@ AsciiDoPaint(Widget w) XSetForeground(XtDisplay(ctx), gc, paint->property->foreground); } if (paint->x < XtWidth(ctx) && paint->x + paint->width > 0) { - rect.x = paint->x + paint->width; - rect.width = XawAbs(paint->width); /* more than enough */ - rect.y = paint->y - font->ascent; - rect.height = rect.y + font->ascent + font->descent; + rect2.x = (short)(paint->x + paint->width); + rect2.width = (XawAbs(paint->width)); /* more than enough */ + rect2.y = (short)(paint->y - font->ascent); + rect2.height = (unsigned short)(rect2.y + font->ascent + font->descent); XSetClipRectangles(XtDisplay((Widget)ctx), gc, - 0, 0, &rect, 1, Unsorted); + 0, 0, &rect2, 1, Unsorted); XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, paint->x, paint->y, - paint->text, paint->length); + paint->text, (int)paint->length); } paint = paint->next; } @@ -1040,18 +1040,19 @@ PaintText(Widget w, GC gc, int x, int y, char *buf, int len, Bool clear_bg) int width = XTextWidth(sink->ascii_sink.font, buf, len); if ((x > XtWidth(ctx)) || width <= -x) /* Don't draw if we can't see it */ - return (width); + return (unsigned)(width); if (clear_bg) { _XawTextSinkClearToBackground(w, x, y - sink->ascii_sink.font->ascent, - width, sink->ascii_sink.font->ascent - + sink->ascii_sink.font->descent); + (unsigned)width, + (unsigned)(sink->ascii_sink.font->ascent + + sink->ascii_sink.font->descent)); XDrawString(XtDisplay(ctx), XtWindow(ctx), gc, x, y, buf, len); } else XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc, x, y, buf, len); - return (width); + return (unsigned)(width); } static void @@ -1085,15 +1086,15 @@ DisplayText(Widget w, int x, int y, y += sink->ascii_sink.font->ascent; for (j = 0; pos1 < pos2;) { - pos1 = XawTextSourceRead(source, pos1, &blk, pos2 - pos1); + pos1 = XawTextSourceRead(source, pos1, &blk, (int)(pos2 - pos1)); for (k = 0; k < blk.length; k++) { if (j >= sizeof(buf) - 4) { /* buffer full, dump the text */ - if ((x += PaintText(w, gc, x, y, (char*)buf, j, clear_bg)) + if ((x = (int)((unsigned)x + PaintText(w, gc, x, y, (char*)buf, j, clear_bg))) >= max_x) return; j = 0; } - buf[j] = blk.ptr[k]; + buf[j] = (unsigned char)blk.ptr[k]; if (buf[j] == XawLF) /* line feeds ('\n') are not printed */ continue; @@ -1101,18 +1102,18 @@ DisplayText(Widget w, int x, int y, int width; if (j != 0 - && (x += PaintText(w, gc, x, y, (char*)buf, j, clear_bg)) + && (x = (int)((unsigned)x + PaintText(w, gc, x, y, (char*)buf, j, clear_bg))) >= max_x) return; if ((width = CharWidth(sink, font, x, '\t')) > -x) { if (clear_bg) - _XawTextSinkClearToBackground(w, x, y-font->ascent, width, - font->ascent+font->descent); + _XawTextSinkClearToBackground(w, x, y-font->ascent, (unsigned)width, + (unsigned)(font->ascent+font->descent)); else XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), - tabgc, x, y - font->ascent, width, - font->ascent + font->descent); + tabgc, x, y - font->ascent, (unsigned)width, + (unsigned)(font->ascent + font->descent)); } if ((x += width) >= max_x) @@ -1126,9 +1127,9 @@ DisplayText(Widget w, int x, int y, if (c > 0177) { buf[j++] = '\\'; - buf[j++] = ((c >> 6) & 7) + '0'; - buf[j++] = ((c >> 3) & 7) + '0'; - buf[j] = (c & 7) + '0'; + buf[j++] = (unsigned char)(((c >> 6) & 7) + '0'); + buf[j++] = (unsigned char)(((c >> 3) & 7) + '0'); + buf[j] = (unsigned char)((c & 7) + '0'); } else { c |= 0100; @@ -1196,14 +1197,14 @@ GetCursorBounds(Widget w, XRectangle *rect) ch = ' '; #endif - rect->width = CharWidth(sink, font, 0, ch); - rect->height = font->descent + font->ascent + 1; + rect->width = (unsigned short)(CharWidth(sink, font, 0, ch)); + rect->height = (unsigned short)(font->descent + font->ascent + 1); rect->x = sink->ascii_sink.cursor_x; - rect->y = sink->ascii_sink.cursor_y - font->ascent; + rect->y = (short)(sink->ascii_sink.cursor_y - font->ascent); } -/* this function is required to support diferent fonts and correctly place +/* this function is required to support different fonts and correctly place * the cursor. There are better ways to calculate the base line, but there is * no place/code (yet) to store this information. */ @@ -1280,7 +1281,7 @@ InsertCursor(Widget w, int x, int y, XawTextInsertState state) XFontStruct *font = sink->ascii_sink.font; TextWidget ctx = (TextWidget)XtParent(w); XawTextPosition position = XawTextGetInsertionPoint((Widget)ctx); - Boolean overflow = (x & 0xffff8000) != 0; + Boolean overflow = ((unsigned)x & 0xffff8000) != 0; #ifndef OLDXAW XawTextAnchor *anchor; XawTextEntity *entity; @@ -1305,19 +1306,19 @@ InsertCursor(Widget w, int x, int y, XawTextInsertState state) if (ctx->text.hasfocus) XFillRectangle(XtDisplay(ctx), XtWindow(ctx), sink->ascii_sink.xorgc, x, y, - width + 1, fheight + 1); + (unsigned)(width + 1), (unsigned)(fheight + 1)); else XDrawRectangle(XtDisplay(ctx), XtWindow(ctx), sink->ascii_sink.xorgc, x, y, - width, fheight); + (unsigned)width, (unsigned)fheight); } else _XawTextSinkClearToBackground(w, x, y, - width + 1, fheight + 1); + (unsigned)(width + 1), (unsigned)(fheight + 1)); } - sink->ascii_sink.cursor_x = x; - sink->ascii_sink.cursor_y = y; + sink->ascii_sink.cursor_x = (short)x; + sink->ascii_sink.cursor_y = (short)y; sink->ascii_sink.laststate = state; return; } @@ -1359,16 +1360,18 @@ InsertCursor(Widget w, int x, int y, XawTextInsertState state) if (ctx->text.hasfocus && !has_selection) XFillRectangle(XtDisplay(ctx), XtWindow(ctx), sink->ascii_sink.xorgc, x, y - font->ascent, - CharWidth(sink, font, 0, ch), fheight + 1); + (unsigned)CharWidth(sink, font, 0, ch), + (unsigned)(fheight + 1)); else XDrawRectangle(XtDisplay(ctx), XtWindow(ctx), sink->ascii_sink.xorgc, x, y - font->ascent, - CharWidth(sink, font, 0, ch) - 1, fheight); + (unsigned)(CharWidth(sink, font, 0, ch) - 1), + (unsigned)fheight); } } - sink->ascii_sink.cursor_x = overflow ? -16384 : x; - sink->ascii_sink.cursor_y = y; + sink->ascii_sink.cursor_x = (short)(overflow ? -16384 : x); + sink->ascii_sink.cursor_y = (short)y; sink->ascii_sink.laststate = state; sink->ascii_sink.cursor_position = position; } @@ -1402,8 +1405,8 @@ FindDistance(Widget w, XawTextPosition fromPos, int fromx, while (!done) { if (XawTextSourceAnchorAndEntity(source, pos, &anchor, &entity)) { - length = anchor->position + entity->offset + entity->length; - length = XawMin(toPos, length) - pos; + length = (Cardinal)(anchor->position + entity->offset + entity->length); + length = (XawMin(toPos, length) - pos); if ((property = XawTextSinkGetProperty((Widget)sink, entity->property)) != NULL && (property->mask & XAW_TPROP_FONT)) @@ -1416,21 +1419,21 @@ FindDistance(Widget w, XawTextPosition fromPos, int fromx, while (entity && anchor->position + entity->offset < pos) entity = entity->next; if (entity) { - length = anchor->position + entity->offset; - length = XawMin(toPos, length) - pos; + length = (Cardinal)(anchor->position + entity->offset); + length = (XawMin(toPos, length) - pos); } else - length = XawMin(toPos - pos, 4096); + length = (XawMin(toPos - pos, 4096)); } else - length = XawMin(toPos - pos, 4096); + length = (XawMin(toPos - pos, 4096)); font = sink->ascii_sink.font; } ascent = XawMax(font->ascent, ascent); descent = XawMax(font->descent, descent); - pos = XawTextSourceRead(source, pos, &blk, length); + pos = XawTextSourceRead(source, pos, &blk, (int)length); if (blk.length == 0 && pos == idx) /* eof reached */ break; @@ -1438,7 +1441,7 @@ FindDistance(Widget w, XawTextPosition fromPos, int fromx, for (i = 0; idx < toPos; i++, idx++) { if (i >= blk.length) break; - c = blk.ptr[i]; + c = (unsigned char)blk.ptr[i]; rWidth += CharWidth(sink, font, fromx + rWidth, c); if (c == XawLF) { idx++; @@ -1515,7 +1518,7 @@ FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width, while (!done) { font = sink->ascii_sink.font; if (XawTextSourceAnchorAndEntity(source, pos, &anchor, &entity)) { - length = anchor->position + entity->offset + entity->length - pos; + length = (Cardinal)(anchor->position + entity->offset + entity->length - pos); if ((property = XawTextSinkGetProperty((Widget)sink, entity->property)) != NULL && (property->mask & XAW_TPROP_FONT)) @@ -1526,7 +1529,7 @@ FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width, while (entity && anchor->position + entity->offset < pos) entity = entity->next; if (entity) - length = anchor->position + entity->offset - pos; + length = (Cardinal)(anchor->position + entity->offset - pos); else length = 4096; } @@ -1537,13 +1540,13 @@ FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width, ascent = XawMax(font->ascent, ascent); descent = XawMax(font->descent, descent); - pos = XawTextSourceRead(source, pos, &blk, length); + pos = XawTextSourceRead(source, pos, &blk, (int)length); if (blk.length == 0 && pos == idx) /* eof reached */ break; idx = blk.firstPos; for (i = 0; rWidth <= width && i < blk.length; i++, idx++) { - c = blk.ptr[i]; + c = (unsigned char)blk.ptr[i]; lastWidth = rWidth; rWidth += CharWidth(sink, font, fromx + rWidth, c); @@ -1653,7 +1656,7 @@ GetGC(AsciiSinkObject sink) XGCValues values; /* XXX We dont want do share a gc that will change the clip-mask */ - values.clip_x_origin = (long)sink; + values.clip_x_origin = (int)sink; values.clip_mask = None; values.font = sink->ascii_sink.font->fid; values.graphics_exposures = False; @@ -1752,8 +1755,8 @@ XawAsciiSinkResize(Widget w) rect.y = ctx->text.r_margin.top; width = (int)XtWidth(ctx) - RHMargins(ctx); height = (int)XtHeight(ctx) - RVMargins(ctx); - rect.width = width; - rect.height = height; + rect.width = (unsigned short)width; + rect.height = (unsigned short)height; if (sink->ascii_sink.normgc) { if (width >= 0 && height >= 0) @@ -1919,20 +1922,20 @@ SetTabs(Widget w, int tab_count, short *tabs) || figure_width == 0)) { if (font->per_char && font->min_char_or_byte2 <= '$' && font->max_char_or_byte2 >= '$') - figure_width = font->per_char['$' - font->min_char_or_byte2].width; + figure_width = (unsigned long)font->per_char['$' - font->min_char_or_byte2].width; else - figure_width = font->max_bounds.width; + figure_width = (unsigned long)font->max_bounds.width; } if (tab_count > sink->text_sink.tab_count) { sink->text_sink.tabs = (Position *) - XtRealloc((char*)sink->text_sink.tabs, tab_count * sizeof(Position)); + XtRealloc((char*)sink->text_sink.tabs, (Cardinal)((size_t)tab_count * sizeof(Position))); sink->text_sink.char_tabs = (short *) - XtRealloc((char*)sink->text_sink.char_tabs, tab_count * sizeof(short)); + XtRealloc((char*)sink->text_sink.char_tabs, (Cardinal)((size_t)tab_count * sizeof(short))); } for (i = 0 ; i < tab_count ; i++) { - sink->text_sink.tabs[i] = tabs[i] * figure_width; + sink->text_sink.tabs[i] = (Position)((size_t)tabs[i] * figure_width); sink->text_sink.char_tabs[i] = tabs[i]; } diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c index 74f05aa5ec3e0961902b221cbc44de9b21f2cbed..b9b847cd9f92aff7b882fa148985aaf235f9c349 100644 --- a/src/AsciiSrc.c +++ b/src/AsciiSrc.c @@ -297,7 +297,7 @@ XawAsciiSrcInitialize(Widget request, Widget cnew, /* * Set correct flags (override resources) depending upon widget class */ - src->text_src.text_format = XawFmt8Bit; + src->text_src.text_format = (XrmQuark)XawFmt8Bit; #ifdef ASCII_DISK if (XtIsSubclass(XtParent(cnew), asciiDiskWidgetClass)) { @@ -383,16 +383,16 @@ ReadText(Widget w, XawTextPosition pos, XawTextBlock *text, int length) offset = anchor->position + entity->offset; end = XawMin(end, offset + block->length); - if ((length = end - pos) < 0) + if ((length = (int)(end - pos)) < 0) length = 0; text->length = length; text->format = XawFmt8Bit; if (length == 0) { - text->firstPos = end = offset + entity->length; + text->firstPos = (int)(end = (offset + entity->length)); text->ptr = ""; } else { - text->firstPos = pos; + text->firstPos = (int)pos; text->ptr = block->ptr + (pos - offset); if (pos + length < offset + block->length) end = pos + length; /* there is data left to be read */ @@ -403,15 +403,15 @@ ReadText(Widget w, XawTextPosition pos, XawTextBlock *text, int length) return (end); } - if ((length = end - pos) < 0) + if ((length = (int)(end - pos)) < 0) length = 0; #endif piece = FindPiece(src, pos, &start); - text->firstPos = pos; + text->firstPos = (int)pos; text->ptr = piece->text + (pos - start); count = piece->used - (pos - start); - text->length = Max(0, (length > count) ? count : length); + text->length = (Max(0, (length > count) ? count : length)); text->format = XawFmt8Bit; return (pos + text->length); @@ -493,7 +493,7 @@ ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos, c = ' '; else if ((c & 0177) < XawSP || c == 0177) { if (sink->ascii_sink.display_nonprinting) - c = c > 0177 ? '\\' : c + '^'; + c = (unsigned char)(c > 0177 ? '\\' : c + '^'); else c = ' '; } @@ -678,7 +678,7 @@ Scan(Widget w, register XawTextPosition position, XawTextScanType type, lim = piece->text + piece->used; } - c = *ptr++; + c = (unsigned char)*ptr++; ++position; if (type == XawstEOL) { @@ -752,7 +752,7 @@ Scan(Widget w, register XawTextPosition position, XawTextScanType type, lim = piece->text; } - c = *ptr--; + c = (unsigned char)*ptr--; --position; if (type == XawstEOL) { @@ -845,7 +845,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, position--; } - buf = XtMalloc((unsigned)sizeof(unsigned char) * text->length); + buf = XtMalloc((unsigned)sizeof(unsigned char) * (unsigned)text->length); memcpy(buf, text->ptr, (unsigned)text->length); piece = FindPiece(src, position, &first); ptr = (position - first) + piece->text; @@ -872,7 +872,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, if (ptr < piece->text) { do { - cnt = piece->text - ptr; + cnt = (int)(piece->text - ptr); piece = piece->prev; if (piece == NULL) { XtFree(buf); @@ -885,7 +885,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, position++; if (ptr >= (piece->text + piece->used)) { do { - cnt = ptr - (piece->text + piece->used); + cnt = (int)(ptr - (piece->text + piece->used)); piece = piece->next; if (piece == NULL) { XtFree(buf); @@ -919,7 +919,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, if (ptr >= (piece->text + piece->used)) { do { - cnt = ptr - (piece->text + piece->used); + cnt = (int)(ptr - (piece->text + piece->used)); piece = piece->next; if (piece == NULL) { XtFree(buf); @@ -932,7 +932,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, position--; if (ptr < piece->text) { do { - cnt = piece->text - ptr; + cnt = (int)(piece->text - ptr); piece = piece->prev; if (piece == NULL) { XtFree(buf); @@ -1012,7 +1012,7 @@ XawAsciiSrcSetValues(Widget current, Widget request, Widget cnew, if (!total_reset && old_src->ascii_src.piece_size != src->ascii_src.piece_size) { - String string = StorePiecesInString(old_src); + char * string = StorePiecesInString(old_src); FreeAllPieces(old_src); LoadPieces(src, NULL, string); @@ -1203,9 +1203,9 @@ XawAsciiSaveAsFile(Widget w, _Xconst char *name) if (src->ascii_src.type == XawAsciiFile) ret = WritePiecesToFile(src, (String)name); else { - String string = StorePiecesInString(src); + char * string = StorePiecesInString(src); - ret = WriteToFile(string, (String)name, src->ascii_src.length); + ret = WriteToFile(string, (String)name, (unsigned)src->ascii_src.length); XtFree(string); } @@ -1321,12 +1321,12 @@ WritePiecesToFile(AsciiSrcObject src, String name) piece = src->ascii_src.first_piece; while (piece) { - int bytes = src->ascii_src.piece_size - piece->used; + int bytes = (int)(src->ascii_src.piece_size - piece->used); if (bytes > 0 && (tmp = piece->next) != NULL) { - bytes = XawMin(bytes, tmp->used); - memcpy(piece->text + piece->used, tmp->text, bytes); - memmove(tmp->text, tmp->text + bytes, tmp->used - bytes); + bytes = (XawMin(bytes, tmp->used)); + memcpy(piece->text + piece->used, tmp->text, (size_t)bytes); + memmove(tmp->text, tmp->text + bytes, (size_t)(tmp->used - bytes)); piece->used += bytes; if ((tmp->used -= bytes) == 0) { RemovePiece(src, tmp); @@ -1341,7 +1341,7 @@ WritePiecesToFile(AsciiSrcObject src, String name) return (False); for (piece = src->ascii_src.first_piece; piece; piece = piece->next) - if (write(fd, piece->text, piece->used) == -1) { + if (write(fd, piece->text, (size_t)piece->used) == -1) { close(fd); return (False); } @@ -1413,15 +1413,15 @@ InitStringOrFile(AsciiSrcObject src, Bool newString) else if (!src->ascii_src.use_string_in_place) { src->ascii_src.string = XtNewString(src->ascii_src.string); src->ascii_src.allocated_string = True; - src->ascii_src.length = strlen(src->ascii_src.string); + src->ascii_src.length = (XawTextPosition)strlen(src->ascii_src.string); } if (src->ascii_src.use_string_in_place) { if (src->ascii_src.string != NULL) - src->ascii_src.length = strlen(src->ascii_src.string); + src->ascii_src.length = (XawTextPosition)strlen(src->ascii_src.string); /* In case the length resource is incorrectly set */ if (src->ascii_src.length > src->ascii_src.ascii_length) - src->ascii_src.ascii_length = src->ascii_src.length; + src->ascii_src.ascii_length = (int)src->ascii_src.length; if (src->ascii_src.ascii_length == MAGIC_VALUE) src->ascii_src.piece_size = src->ascii_src.length; @@ -1477,7 +1477,7 @@ InitStringOrFile(AsciiSrcObject src, Bool newString) } if (!src->ascii_src.is_tempfile) { - if ((fd = open(src->ascii_src.string, open_mode, 0666)) != -1) { + if ((fd = open(src->ascii_src.string, (int)open_mode, 0666)) != -1) { if ((file = fdopen(fd, fdopen_mode))) { (void)fseek(file, 0, SEEK_END); src->ascii_src.length = (XawTextPosition)ftell(file); @@ -1517,7 +1517,7 @@ LoadPieces(AsciiSrcObject src, FILE *file, char *string) fseek(file, 0, SEEK_SET); while (left < src->ascii_src.length) { ptr = XtMalloc((unsigned)src->ascii_src.piece_size); - if ((len = fread(ptr, sizeof(unsigned char), + if ((len = (int)fread(ptr, sizeof(unsigned char), (size_t)src->ascii_src.piece_size, file)) < 0) XtErrorMsg("readError", "asciiSourceCreate", "XawError", "fread returned error.", NULL, NULL); @@ -1754,7 +1754,7 @@ CvtAsciiTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; diff --git a/src/AsciiText.c b/src/AsciiText.c index 8e2f0aa66719b498af070499e4431b66146cd805..65a2323f7c139b52065407e334ca430af7585c66 100644 --- a/src/AsciiText.c +++ b/src/AsciiText.c @@ -310,7 +310,7 @@ XawAsciiInitialize(Widget request, Widget cnew, } if (XtHeight(w) == DEFAULT_TEXT_HEIGHT) - XtHeight(w) = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1); + XtHeight(w) = (Dimension)(VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1)); for (i = 0, tab = 0; i < TAB_COUNT; i++) tabs[i] = (tab += 8); diff --git a/src/Box.c b/src/Box.c index 266fb08abc31606603cbce72f06af94b9a421fa7..257a82c68ce83254bf32a57c9120961136b83ab2 100644 --- a/src/Box.c +++ b/src/Box.c @@ -220,7 +220,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, && bbw->composite.children[i]->core.width > w) w = bbw->composite.children[i]->core.width; } - w += h_space; + w = (Dimension)(w + h_space); if (w > width) width = w; h = bbw->box.v_space; @@ -235,7 +235,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, if (widget->core.mapped_when_managed) num_mapped_children++; /* Compute widget width */ - bw = XtWidth(widget) + (XtBorderWidth(widget)<<1) + h_space; + bw = (Dimension)(XtWidth(widget) + (XtBorderWidth(widget)<<1) + h_space); if ((Dimension)(lw + bw) > width) { if (lw > h_space) { /* At least one widget on this line, and @@ -243,7 +243,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, */ AssignMax(w, lw); if (vbox) { - h += lh + bbw->box.v_space; + h = (Dimension)(h + (lh + bbw->box.v_space)); lh = 0; lw = h_space; } @@ -270,10 +270,10 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, */ if (XtIsRealized(widget) && widget->core.mapped_when_managed) XUnmapWindow( XtDisplay(widget), XtWindow(widget)); - XtMoveWidget(widget, (int)lw, (int)h); + XtMoveWidget(widget, (Position)lw, (Position)h); } - lw += bw; - bh = XtHeight(widget) + (XtBorderWidth(widget) << 1); + lw = (Dimension)(lw + bw); + bh = (Dimension)(XtHeight(widget) + (XtBorderWidth(widget) << 1)); AssignMax(lh, bh); } } @@ -281,7 +281,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, if (!vbox && width && lw > width && lh < height) { /* reduce width if too wide and height not filled */ Dimension sw = lw, sh = lh; - Dimension width_needed = width; + Dimension width_needed = (Dimension)width; XtOrientation orientation = bbw->box.orientation; bbw->box.orientation = XtorientVertical; @@ -308,7 +308,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, if (bbw->composite.num_children == num_mapped_children) XMapSubwindows(XtDisplay((Widget)bbw), XtWindow((Widget)bbw)); else { - int ii = bbw->composite.num_children; + int ii = (int)bbw->composite.num_children; Widget *childP = bbw->composite.children; for (; ii > 0; childP++, ii--) @@ -321,7 +321,7 @@ DoLayout(BoxWidget bbw, unsigned int width, unsigned int height, /* Finish off last line */ if (lw > h_space) { AssignMax(w, lw); - h += lh + bbw->box.v_space; + h = (Dimension)(h + (lh + bbw->box.v_space)); } *reply_width = Max(w, 1); @@ -395,7 +395,7 @@ XawBoxQueryGeometry(Widget widget, XtWidgetGeometry *constraint, if (width > (constraint->width >> 1)) /* avoid short int overflow */ width = constraint->width; else - width <<= 1; + width = (Dimension)(width << 1); DoLayout(w, width, 0, &preferred_width, &preferred_height, False); } while (preferred_height > constraint->height && width < constraint->width); @@ -627,7 +627,7 @@ XawBoxRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes) #ifndef OLDXAW if (w->core.background_pixmap > XtUnspecifiedPixmap) { pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w), - w->core.colormap, w->core.depth); + w->core.colormap, (int)w->core.depth); if (pixmap && pixmap->mask) XawReshapeWidget(w, pixmap); } @@ -649,10 +649,10 @@ XawBoxSetValues(Widget current, Widget request, Widget cnew, opix = XawPixmapFromXPixmap(b_old->core.background_pixmap, XtScreen(b_old), b_old->core.colormap, - b_old->core.depth); + (int)b_old->core.depth); npix = XawPixmapFromXPixmap(b_new->core.background_pixmap, XtScreen(b_new), b_new->core.colormap, - b_new->core.depth); + (int)b_new->core.depth); if ((npix && npix->mask) || (opix && opix->mask)) XawReshapeWidget(cnew, npix); } diff --git a/src/Command.c b/src/Command.c index 4535423a01d12a811f376e28fa494b4c98860d85..57f363168e43ec9ce21726d2c349bf434a13dcdd 100644 --- a/src/Command.c +++ b/src/Command.c @@ -295,9 +295,9 @@ HighlightRegion(CommandWidget cbw) rect.width = XtWidth(cbw); rect.height = XtHeight(cbw); XUnionRectWithRegion(&rect, emptyRegion, outerRegion); - rect.x = rect.y = cbw->command.highlight_thickness; - rect.width -= cbw->command.highlight_thickness * 2; - rect.height -= cbw->command.highlight_thickness * 2; + rect.x = rect.y = (short)cbw->command.highlight_thickness; + rect.width = (rect.width - cbw->command.highlight_thickness * 2); + rect.height = (rect.height - cbw->command.highlight_thickness * 2); XUnionRectWithRegion(&rect, emptyRegion, innerRegion); XSubtractRegion(outerRegion, innerRegion, outerRegion); @@ -469,13 +469,13 @@ PaintCommandWidget(Widget w, XEvent *event, Region region, Bool change) XClearArea(XtDisplay(w), XtWindow(w), 0, cbw->command.highlight_thickness, cbw->command.highlight_thickness, - XtHeight(cbw) - (cbw->command.highlight_thickness<<1), + (unsigned)(XtHeight(cbw) - (cbw->command.highlight_thickness<<1)), False); XClearArea(XtDisplay(w), XtWindow(w), XtWidth(cbw) - cbw->command.highlight_thickness, cbw->command.highlight_thickness, cbw->command.highlight_thickness, - XtHeight(cbw) - (cbw->command.highlight_thickness<<1), + (unsigned)(XtHeight(cbw) - (cbw->command.highlight_thickness<<1)), False); XClearArea(XtDisplay(w), XtWindow(w), 0, XtHeight(cbw) - cbw->command.highlight_thickness, @@ -486,8 +486,8 @@ PaintCommandWidget(Widget w, XEvent *event, Region region, Bool change) int offset = cbw->command.highlight_thickness / 2; XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset, - XtWidth(cbw) - cbw->command.highlight_thickness, - XtHeight(cbw) - cbw->command.highlight_thickness); + (unsigned)(XtWidth(cbw) - cbw->command.highlight_thickness), + (unsigned)(XtHeight(cbw) - cbw->command.highlight_thickness)); } } } @@ -593,7 +593,7 @@ ShapeButton(CommandWidget cbw, Bool checkRectangular) if (cbw->command.shape_style == XawShapeRoundedRectangle) { corner_size = XtWidth(cbw) < XtHeight(cbw) ? XtWidth(cbw) : XtHeight(cbw); - corner_size = (corner_size * cbw->command.corner_round) / 100; + corner_size = (Dimension)((corner_size * cbw->command.corner_round) / 100); } if (checkRectangular || cbw->command.shape_style != XawShapeRectangle) { diff --git a/src/Converters.c b/src/Converters.c index 9795671cd3b2319646da945dc47f3c8bf43cce6f..4b9b89e09215d14ba7b065cc4abbfb2a19fa1079 100644 --- a/src/Converters.c +++ b/src/Converters.c @@ -259,7 +259,7 @@ _XawCvtBooleanToString(Display *dpy, XrmValue *args, Cardinal *num_args, snprintf(buffer, sizeof(buffer), "%s", *(Boolean *)fromVal->addr ? XtEtrue : XtEfalse); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -278,7 +278,7 @@ _XawCvtBoolToString(Display *dpy, XrmValue *args, Cardinal *num_args, snprintf(buffer, sizeof(buffer), "%s", *(Bool *)fromVal->addr ? XtEtrue : XtEfalse); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -296,7 +296,7 @@ _XawCvtPositionToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XtRPosition); snprintf(buffer, sizeof(buffer), "%d", *(Position *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -314,7 +314,7 @@ _XawCvtShortToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XtRShort); snprintf(buffer, sizeof(buffer), "%d", *(short *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -332,7 +332,7 @@ _XawCvtDimensionToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XtRDimension); snprintf(buffer, sizeof(buffer), "%u", *(Dimension *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -350,7 +350,7 @@ _XawCvtCARD32ToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, "CARD32"); snprintf(buffer, sizeof(buffer), "0x%08hx", *(int *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -368,7 +368,7 @@ _XawCvtIntToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XtRInt); snprintf(buffer, sizeof(buffer), "%d", *(int *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -386,7 +386,7 @@ _XawCvtCardinalToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XtRCardinal); snprintf(buffer, sizeof(buffer), "%u", *(Cardinal *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -419,7 +419,7 @@ _XawCvtAtomToString(Display *dpy, XrmValue *args, Cardinal *num_args, return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -455,7 +455,7 @@ _XawCvtPixelToString(Display *dpy, XrmValue *args, Cardinal *num_args, XQueryColor(dpy, colormap, &color); snprintf(buffer, sizeof(buffer), "rgb:%04hx/%04hx/%04hx", color.red, color.green, color.blue); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -486,7 +486,7 @@ _XawCvtFontStructToString(Display *dpy, XrmValue *args, Cardinal *num_args, if (tmp) { snprintf(buffer, sizeof(buffer), "%s", tmp); - size = strlen(tmp); + size = (Cardinal)strlen(tmp); XFree(tmp); } } @@ -516,7 +516,7 @@ _XawCvtUnsignedCharToString(Display *dpy, XrmValue *args, Cardinal *num_args, snprintf(buffer, sizeof(buffer), "%u", *(unsigned char *)fromVal->addr); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -577,7 +577,7 @@ _XawCvtDisplayListToString(Display *dpy, XrmValue *args, Cardinal *num_args, TypeToStringNoArgsWarning(dpy, XawRDisplayList); buffer = XawDisplayListString(*(XawDisplayList **)(fromVal[0].addr)); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } @@ -690,7 +690,7 @@ _XawCvtPixmapToString(Display *dpy, XrmValue *args, Cardinal *num_args, return (_XawCvtCARD32ToString(dpy, args, num_args, fromVal, toVal, converter_data)); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); string_done(buffer); } diff --git a/src/Dialog.c b/src/Dialog.c index 9c98d36969caf1a9d8d7d811e4d96a30bb070eed..25cd67a814c47e263ae7f7ecfb73da5042840089 100644 --- a/src/Dialog.c +++ b/src/Dialog.c @@ -357,7 +357,7 @@ static void XawDialogGetValuesHook(Widget w, ArgList args, Cardinal *num_args) { Arg a[1]; - String s; + char * s; DialogWidget src = (DialogWidget)w; unsigned int i; diff --git a/src/DisplayList.c b/src/DisplayList.c index 0581bf7081ab4de3a23223a37b3f68969a6f158d..7c90916ce74b6910e3fc16f90662a57424735830 100644 --- a/src/DisplayList.c +++ b/src/DisplayList.c @@ -177,7 +177,7 @@ read_token(char *src, char *dst, Cardinal size, int *status) { if (esc) { - dst[i++] = ch; + dst[i++] = (char)ch; esc = False; continue; } @@ -216,7 +216,7 @@ read_token(char *src, char *dst, Cardinal size, int *status) } else esc = False; - dst[i++] = ch; + dst[i++] = (char)ch; } *status = DLERR; @@ -287,7 +287,7 @@ _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, } if (fp) { - snprintf(cname, fp - fname + 1, "%s", fname); + snprintf(cname, (size_t)(fp - fname + 1), "%s", fname); memmove(fname, fp + 1, strlen(fp)); lc = cname[0] ? XawGetDisplayListClass(cname) : xlibc; if (!lc) @@ -337,8 +337,8 @@ _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, { ++dlist->num_procs; dlist->procs = (XawDLProc**) - XtRealloc((char *)dlist->procs, sizeof(XawDLProc*) * - dlist->num_procs); + XtRealloc((char *)dlist->procs, (Cardinal)(sizeof(XawDLProc*) * + dlist->num_procs)); } dlist->procs[dlist->num_procs - 1] = proc; @@ -368,8 +368,8 @@ _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, { ++proc->num_params; proc->params = (String *)XtRealloc((char *)proc->params, - sizeof(String) * - proc->num_params); + (Cardinal)(sizeof(String) * + proc->num_params)); } proc->params[proc->num_params - 1] = XtNewString(aname); } @@ -401,8 +401,8 @@ _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, { ++dlist->num_data; dlist->data = (XawDLData **) - XtRealloc((char *)dlist->data, sizeof(XawDLData*) * - dlist->num_data); + XtRealloc((char *)dlist->data, (Cardinal)(sizeof(XawDLData*) * + dlist->num_data)); } dlist->data[dlist->num_data - 1] = data; } @@ -478,7 +478,7 @@ XawDestroyDisplayList(_XawDisplayList *dlist) } for (j = 0; j < proc->num_params; j++) - XtFree(proc->params[j]); + XtFree((char *)proc->params[j]); if (proc->num_params) XtFree((char *)proc->params); XtFree((char *)proc); @@ -544,12 +544,12 @@ typedef struct _XawDLImageArgs { int depth; } XawDLImageArgs; -#define X_ARG(x) (Position)(((x).denom != 0) ? \ +#define X_ARG(x) ((Position)(((x).denom != 0) ? \ ((float)XtWidth(w) * ((float)(x).pos / (float)(x).denom)) : \ - ((x).high ? XtWidth(w) - (x).pos : (x).pos)) -#define Y_ARG(x) (Position)(((x).denom != 0) ? \ + (float)((x).high ? XtWidth(w) - (x).pos : (x).pos))) +#define Y_ARG(x) ((Position)(((x).denom != 0) ? \ ((float)XtHeight(w) * ((float)(x).pos / (float)(x).denom)): \ - ((x).high ? XtHeight(w) - (x).pos : (x).pos)) + (float)((x).high ? XtHeight(w) - (x).pos : (x).pos))) #define DRECT 0 #define FRECT 1 #define LINE 2 @@ -600,17 +600,17 @@ Dl1Point(Widget w, XtPointer args, XtPointer data, int id) Window window; Position x, y; - x = X_ARG(pos[0]); - y = Y_ARG(pos[1]); + x = (Position)(X_ARG(pos[0])); + y = (Position)(Y_ARG(pos[1])); if (!XtIsWidget(w)) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); - x += xpad; - y += ypad; + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); + x = (Position)(x + xpad); + y = (Position)(y + ypad); display = XtDisplayOfObject(w); window = XtWindowOfObject(w); } @@ -656,10 +656,10 @@ Dl2Points(Widget w, XtPointer args, XtPointer data, int id) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); - x1 += xpad; y1 += ypad; - x2 += xpad; y2 += ypad; + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); + x1 = (Position)(x1 + xpad); y1 = (Position)(y1 + ypad); + x2 = (Position)(x2 + xpad); y2 = (Position)(y2 + ypad); display = XtDisplayOfObject(w); window = XtWindowOfObject(w); } @@ -670,9 +670,9 @@ Dl2Points(Widget w, XtPointer args, XtPointer data, int id) } if (id == DRECT) - XDrawRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1); + XDrawRectangle(display, window, xdata->gc, x1, y1, (unsigned)(x2 - x1), (unsigned)(y2 - y1)); else if (id == FRECT) - XFillRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1); + XFillRectangle(display, window, xdata->gc, x1, y1, (unsigned)(x2 - x1), (unsigned)(y2 - y1)); else if (id == LINE) XDrawLine(display, window, xdata->gc, x1, y1, x2, y2); } @@ -726,20 +726,20 @@ DlXPoints(Widget w, XtPointer args, XtPointer data, int id) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); if (xdata->mode != CoordModePrevious) { for (i = 0; i < num_points; i++) { - points[i].x += xpad; - points[i].y += ypad; + points[i].x = (short)(points[i].x + xpad); + points[i].y = (short)(points[i].y + ypad); } } else { - points[0].x += xpad; - points[0].y += ypad; + points[0].x = (short)(points[0].x + xpad); + points[0].y = (short)(points[0].y + ypad); } display = XtDisplayOfObject(w); window = XtWindowOfObject(w); @@ -751,12 +751,12 @@ DlXPoints(Widget w, XtPointer args, XtPointer data, int id) } if (id == FPOLY) - XFillPolygon(display, window, xdata->gc, points, num_points, + XFillPolygon(display, window, xdata->gc, points, (int)num_points, xdata->shape, xdata->mode); else if (id == DLINES) - XDrawLines(display, window, xdata->gc, points, num_points, xdata->mode); + XDrawLines(display, window, xdata->gc, points, (int)num_points, xdata->mode); else if (id == POINTS) - XDrawPoints(display, window, xdata->gc, points, num_points, xdata->mode); + XDrawPoints(display, window, xdata->gc, points, (int)num_points, xdata->mode); XawStackFree(points, points_buf); } @@ -835,12 +835,12 @@ DlArc(Widget w, XtPointer args, XtPointer data, Bool fill) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); - x1 += xpad; - y1 += ypad; - x2 += xpad; - y2 += ypad; + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); + x1 = (Position)(x1 + xpad); + y1 = (Position)(y1 + ypad); + x2 = (Position)(x2 + xpad); + y2 = (Position)(y2 + ypad); display = XtDisplayOfObject(w); window = XtWindowOfObject(w); } @@ -851,10 +851,10 @@ DlArc(Widget w, XtPointer args, XtPointer data, Bool fill) } if (fill) - XFillArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1, + XFillArc(display, window, xdata->gc, x1, y1, (unsigned)(x2 - x1), (unsigned)(y2 - y1), arc->angle1, arc->angle2); else - XDrawArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1, + XDrawArc(display, window, xdata->gc, x1, y1, (unsigned)(x2 - x1), (unsigned)(y2 - y1), arc->angle1, arc->angle2); } @@ -888,10 +888,10 @@ DlMask(Widget w, XtPointer args, XtPointer data, { XRectangle rect; - rect.x = event->xexpose.x; - rect.y = event->xexpose.y; - rect.width = event->xexpose.width; - rect.height = event->xexpose.height; + rect.x = (short)event->xexpose.x; + rect.y = (short)event->xexpose.y; + rect.width = (unsigned short)event->xexpose.width; + rect.height = (unsigned short)event->xexpose.height; XSetClipRectangles(display, xdata->gc, 0, 0, &rect, 1, Unsorted); } } @@ -912,12 +912,12 @@ DlLineWidth(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - unsigned line_width = (unsigned long)args; + unsigned line_width = (unsigned)(unsigned long)args; if (xdata->values.line_width != line_width) { xdata->mask |= GCLineWidth; - xdata->values.line_width = line_width; + xdata->values.line_width = (int)line_width; XChangeGC(XtDisplayOfObject(w), xdata->gc, GCLineWidth, &xdata->values); } } @@ -959,14 +959,14 @@ DlDrawSegments(Widget w, XtPointer args, XtPointer data, { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); for (i = 0; i < num_segments; i++) { - segments[i].x1 += xpad; - segments[i].y1 += ypad; - segments[i].x2 += xpad; - segments[i].y2 += ypad; + segments[i].x1 = (short)(segments[i].x1 + xpad); + segments[i].y1 = (short)(segments[i].y1 + ypad); + segments[i].x2 = (short)(segments[i].x2 + xpad); + segments[i].y2 = (short)(segments[i].y2 + ypad); } display = XtDisplayOfObject(w); window = XtWindowOfObject(w); @@ -977,7 +977,7 @@ DlDrawSegments(Widget w, XtPointer args, XtPointer data, window = XtWindow(w); } - XDrawSegments(display, window, xdata->gc, segments, num_segments); + XDrawSegments(display, window, xdata->gc, segments, (int)num_segments); XawStackFree(segments, segments_buf); } @@ -988,7 +988,7 @@ DlArcMode(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int arc_mode = (long)args; + int arc_mode = (int)(long)args; if (xdata->values.arc_mode != arc_mode) { @@ -1004,7 +1004,7 @@ DlCoordMode(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int mode = (long)args; + int mode = (int)(long)args; xdata->mode = mode; } @@ -1015,7 +1015,7 @@ DlShapeMode(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int shape = (long)args; + int shape = (int)(long)args; xdata->shape = shape; } @@ -1026,7 +1026,7 @@ DlLineStyle(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int line_style = (long)args; + int line_style = (int)(long)args; if (xdata->values.line_style != line_style) { @@ -1042,7 +1042,7 @@ DlCapStyle(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int cap_style = (long)args; + int cap_style = (int)(long)args; if (xdata->values.cap_style != cap_style) { @@ -1058,7 +1058,7 @@ DlJoinStyle(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int join_style = (long)args; + int join_style = (int)(long)args; if (xdata->values.join_style != join_style) { @@ -1074,7 +1074,7 @@ DlFillStyle(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int fill_style = (long)args; + int fill_style = (int)(long)args; if (xdata->values.fill_style != fill_style) { @@ -1090,7 +1090,7 @@ DlFillRule(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int fill_rule = (long)args; + int fill_rule = (int)(long)args; if (xdata->values.fill_rule != fill_rule) { @@ -1145,7 +1145,7 @@ DlFunction(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int function = (long)args; + int function = (int)(long)args; if (function != xdata->values.function) { @@ -1180,17 +1180,17 @@ DlString(Widget w, XtPointer args, XtPointer data, Bool image) Window window; Position x, y; - x = X_ARG(string->pos[0]); - y = Y_ARG(string->pos[1]); + x = (Position)(X_ARG(string->pos[0])); + y = (Position)(Y_ARG(string->pos[1])); if (!XtIsWidget(w)) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); - x += xpad; - y += ypad; + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); + x = (Position)(x + xpad); + y = (Position)(y + ypad); display = XtDisplayOfObject(w); window = XtWindowOfObject(w); } @@ -1260,7 +1260,7 @@ DlSubwindowMode(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { XawXlibData *xdata = (XawXlibData *)data; - int subwindow_mode = (long)args; + int subwindow_mode = (int)(long)args; if (xdata->values.subwindow_mode != subwindow_mode) { @@ -1339,24 +1339,24 @@ DlClipRectangles(Widget w, XtPointer args, XtPointer data, y2 = Y_ARG(pos[3]); rects[i].x = XawMin(x1, x2); rects[i].y = XawMin(y1, y2); - rects[i].width = XawMax(x1, x2) - rects[i].x; - rects[i].height = XawMax(y1, y2) - rects[i].y; + rects[i].width = (unsigned short)(XawMax(x1, x2) - rects[i].x); + rects[i].height = (unsigned short)(XawMax(y1, y2) - rects[i].y); } if (!XtIsWidget(w)) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); for (i = 0; i < num_rects; i++) { - rects[i].x += xpad; - rects[i].y += ypad; + rects[i].x = (short)(rects[i].x + xpad); + rects[i].y = (short)(rects[i].y + ypad); } } - XSetClipRectangles(XtDisplayOfObject(w), xdata->gc, 0, 0, rects, num_rects, Unsorted); + XSetClipRectangles(XtDisplayOfObject(w), xdata->gc, 0, 0, rects, (int)num_rects, Unsorted); XawStackFree(rects, rects_buf); } @@ -1406,8 +1406,8 @@ DlCopy(Widget w, XtPointer args, XtPointer data, Bool plane) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); src_x += xpad; src_y += ypad; dst_x += xpad; @@ -1417,12 +1417,12 @@ DlCopy(Widget w, XtPointer args, XtPointer data, Bool plane) if (plane) XCopyPlane(XtDisplayOfObject(w), XtWindowOfObject(w), copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w), - xdata->gc, src_x, src_y, width, height, dst_x, dst_y, - copy->plane ? copy->plane : 1); + xdata->gc, src_x, src_y, (unsigned)width, (unsigned)height, dst_x, dst_y, + (unsigned long)(copy->plane ? copy->plane : 1)); else XCopyArea(XtDisplayOfObject(w), copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w), - XtWindowOfObject(w), xdata->gc, src_x, src_y, width, height, dst_x, dst_y); + XtWindowOfObject(w), xdata->gc, src_x, src_y, (unsigned)width, (unsigned)height, dst_x, dst_y); } /* ARGSUSED */ @@ -1473,8 +1473,8 @@ DlImage(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) { Position xpad, ypad; - xpad = XtX(w) + XtBorderWidth(w); - ypad = XtY(w) + XtBorderWidth(w); + xpad = (Position)(XtX(w) + XtBorderWidth(w)); + ypad = (Position)(XtY(w) + XtBorderWidth(w)); xe += xpad; ye += ypad; xe += xpad; @@ -1496,11 +1496,11 @@ DlImage(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) XSetClipMask(display, xdata->gc, image->pixmap->mask); if (image->depth == 1) XCopyPlane(display, image->pixmap->pixmap, window, xdata->gc, - 0, 0, XawMin(width, xe - x), XawMin(height, ye - y), + 0, 0, (unsigned)XawMin(width, xe - x), (unsigned)XawMin(height, ye - y), x, y, 1L); else XCopyArea(display, image->pixmap->pixmap, window, xdata->gc, 0, 0, - XawMin(width, xe - x), XawMin(height, ye - y), x, y); + (unsigned)XawMin(width, xe - x), (unsigned)XawMin(height, ye - y), x, y); } XSetClipMask(display, xdata->gc, None); @@ -1631,14 +1631,14 @@ read_position(char *arg, XawDLPosition *pos) ++str; if (ch == '-') pos->high = True; - pos->pos = read_int(str, NULL); + pos->pos = (Position)read_int(str, NULL); } else if (isdigit(ch)) { - pos->pos = read_int(str, &str); + pos->pos = (Position)read_int(str, &str); ch = *str++; if (ch == '/') - pos->denom = read_int(str, NULL); + pos->denom = (Position)read_int(str, NULL); } } @@ -1668,7 +1668,7 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 4); for (i = 0; i < 4; i++) - read_position(params[i], &pos[i]); + read_position((char *)params[i], &pos[i]); retval = (void *)pos; } break; @@ -1679,8 +1679,8 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, { XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 2); - read_position(params[0], &pos[0]); - read_position(params[1], &pos[1]); + read_position((char *)params[0], &pos[0]); + read_position((char *)params[1], &pos[1]); retval = (void *)pos; } break; @@ -1691,11 +1691,11 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, { XawDLPositionPtr *pos = XtNew(XawDLPositionPtr); - pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * - *num_params); + pos->pos = (XawDLPosition *)XtCalloc(1, (Cardinal)(sizeof(XawDLPosition) * + (size_t)*num_params)); pos->num_pos = *num_params; for (i = 0; i < *num_params; i++) - read_position(params[i], &pos->pos[i]); + read_position((char *)params[i], &pos->pos[i]); retval = (void *)pos; } break; @@ -1705,11 +1705,11 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, { XawDLPositionPtr *pos = XtNew(XawDLPositionPtr); - pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * - *num_params); + pos->pos = (XawDLPosition *)XtCalloc(1, (Cardinal)(sizeof(XawDLPosition) * + (size_t)*num_params)); pos->num_pos = *num_params; for (i = 0; i < *num_params; i++) - read_position(params[i], &pos->pos[i]); + read_position((char *)params[i], &pos->pos[i]); retval = (void *)pos; } break; @@ -1722,11 +1722,11 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, args->angle1 = 0; args->angle2 = 360; for (i = 0; i < 4; i++) - read_position(params[i], &args->pos[i]); + read_position((char *)params[i], &args->pos[i]); if (*num_params > 4) - args->angle1 = read_int(params[4], NULL); + args->angle1 = (int)read_int((char *)params[4], NULL); if (*num_params > 5) - args->angle2 = read_int(params[5], NULL); + args->angle2 = (int)read_int((char *)params[5], NULL); args->angle1 *= 64; args->angle2 *= 64; retval = (void *)args; @@ -1749,7 +1749,7 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, break; case LWIDTH: if (*num_params == 1) - retval = (void *)read_int(params[0], NULL); + retval = (void *)read_int((char *)params[0], NULL); break; case ARCMODE: if (*num_params == 1) @@ -1894,7 +1894,7 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, break; case PLANEMASK: if (*num_params == 1) - retval = (void *)read_int(params[0], NULL); + retval = (void *)read_int((char *)params[0], NULL); break; case DSTRING: case PSTRING: @@ -1903,10 +1903,10 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, XawDLStringArgs *string = (XawDLStringArgs *) XtCalloc(1, sizeof(XawDLStringArgs)); - read_position(params[0], &string->pos[0]); - read_position(params[1], &string->pos[1]); + read_position((char *)params[0], &string->pos[0]); + read_position((char *)params[1], &string->pos[1]); string->string = XtNewString(params[2]); - string->length = strlen(string->string); + string->length = (int)strlen(string->string); retval = string; } break; @@ -1922,8 +1922,8 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, dashes = XtMalloc(*num_params + 1); for (i = 0; i < *num_params; i++) - dashes[i + 1] = read_int(params[i], NULL); - *dashes = *num_params; + dashes[i + 1] = (char)read_int((char *)params[i], NULL); + *dashes = (char)*num_params; retval = dashes; } break; @@ -1940,7 +1940,7 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, if (*num_params == 1) { if (isdigit(params[0][0]) || params[0][0] == '+' || params[0][0] == '-') - retval = (void *)read_int(params[0], NULL); + retval = (void *)read_int((char *)params[0], NULL); else if (XmuCompareISOLatin1(params[0], "true") == 0 || XmuCompareISOLatin1(params[0], "on") == 0) retval = (void *)True; @@ -1983,9 +1983,9 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, if (retval != XAWDL_CONVERT_ERROR) { for (i = 1; i < *num_params && i < 7; i++) - read_position(params[i], &args->pos[i - 1]); + read_position((char *)params[i], &args->pos[i - 1]); if (*num_params > 7) - args->plane = read_int(params[7], NULL); + args->plane = (int)read_int((char *)params[7], NULL); } } break; @@ -2008,7 +2008,7 @@ _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, { args->depth = depth; for (i = 1; i < *num_params && i < 5; i++) - read_position(params[i], &args->pos[i - 1]); + read_position((char *)params[i], &args->pos[i - 1]); } } break; @@ -2144,7 +2144,7 @@ Bool XawDeclareDisplayListProc(XawDLClass *lc, String name, { ++lc->num_infos; lc->infos = (XawDLInfo **) - XtRealloc((char *)lc->infos, sizeof(XawDLInfo*) * lc->num_infos); + XtRealloc((char *)lc->infos, (Cardinal)(sizeof(XawDLInfo*) * (size_t)lc->num_infos)); } lc->infos[lc->num_infos - 1] = info; @@ -2218,7 +2218,7 @@ XawCreateDisplayListClass(String name, { ++num_classes; classes = (XawDLClass **)XtRealloc((char *)classes, - sizeof(XawDLClass) * num_classes); + (Cardinal)(sizeof(XawDLClass) * (size_t)num_classes)); } classes[num_classes - 1] = lc; diff --git a/src/Form.c b/src/Form.c index dcc26f3a671ec3e879a93755f201af25f93ab716..786c130ae9f5d181df9e69f7d8e259f3880c132e 100644 --- a/src/Form.c +++ b/src/Form.c @@ -304,7 +304,7 @@ XawFormRealize(Widget w, Mask *mask, XSetWindowAttributes *attr) if (w->core.background_pixmap > XtUnspecifiedPixmap) { pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w), - w->core.colormap, w->core.depth); + w->core.colormap, (int)w->core.depth); if (pixmap && pixmap->mask) XawReshapeWidget(w, pixmap); } @@ -384,7 +384,7 @@ CvtEdgeTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; @@ -490,8 +490,8 @@ ChangeFormGeometry(Widget w, Bool query_only, if (width == XtWidth(fw) && height == XtHeight(fw)) return (True); - request.width = width; - request.height = height; + request.width = (Dimension)width; + request.height = (Dimension)height; request.request_mode = CWWidth | CWHeight; if (query_only) request.request_mode |= XtCWQueryOnly; @@ -543,7 +543,7 @@ static Boolean Layout(FormWidget fw, unsigned int width, unsigned int height, Bool force_relayout) { - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; WidgetList children = fw->composite.children; Widget *childP; Dimension maxx, maxy; @@ -564,26 +564,26 @@ Layout(FormWidget fw, unsigned int width, unsigned int height, LayoutChild(*childP); - x = form->form.new_x + XtWidth(*childP) - + (XtBorderWidth(*childP) << 1); + x = (Position)(form->form.new_x + XtWidth(*childP) + + (XtBorderWidth(*childP) << 1)); if (x > (int)maxx) - maxx = x; + maxx = (Dimension)x; - y = form->form.new_y + XtHeight(*childP) - + (XtBorderWidth(*childP) << 1); + y = (Position)(form->form.new_y + XtHeight(*childP) + + (XtBorderWidth(*childP) << 1)); if (y > (int)maxy) - maxy = y; + maxy = (Dimension)y; } } - fw->form.preferred_width = (maxx += fw->form.default_spacing); - fw->form.preferred_height = (maxy += fw->form.default_spacing); + fw->form.preferred_width = (maxx = (Dimension)(maxx + fw->form.default_spacing)); + fw->form.preferred_height = (maxy = (Dimension)(maxy + fw->form.default_spacing)); if (fw->form.resize_in_layout) { Boolean always_resize_children; always_resize_children = - ChangeFormGeometry((Widget)fw, False, maxx, maxy, NULL, NULL); + (Boolean)ChangeFormGeometry((Widget)fw, False, maxx, maxy, NULL, NULL); #ifdef OLDXAW fw->form.old_width = fw->core.width; @@ -621,7 +621,7 @@ static void ResizeChildren(Widget w) { FormWidget fw = (FormWidget)w; - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; WidgetList children = fw->composite.children; Widget *childP; @@ -635,9 +635,9 @@ ResizeChildren(Widget w) form = (FormConstraints)(*childP)->core.constraints; if (fw->form.old_width && fw->form.old_height) { - x = TransformCoord(form->form.new_x, fw->form.old_width, + x = (Position)TransformCoord(form->form.new_x, fw->form.old_width, XtWidth(fw), form->form.left); - y = TransformCoord(form->form.new_y, fw->form.old_height, + y = (Position)TransformCoord(form->form.new_y, fw->form.old_height, XtHeight(fw), form->form.top); } else { @@ -687,21 +687,25 @@ LayoutChild(Widget w) } return; } - form->form.new_x = form->form.dx; - form->form.new_y = form->form.dy; + form->form.new_x = (Position)form->form.dx; + form->form.new_y = (Position)form->form.dy; if ((ref = form->form.horiz_base) != NULL) { FormConstraints ref_form = (FormConstraints)ref->core.constraints; LayoutChild(ref); - form->form.new_x += ref_form->form.new_x + XtWidth(ref) + - (XtBorderWidth(ref) << 1); + form->form.new_x = (Position)(form->form.new_x + + (ref_form->form.new_x + + XtWidth(ref) + + (XtBorderWidth(ref) << 1))); } if ((ref = form->form.vert_base) != NULL) { FormConstraints ref_form = (FormConstraints)ref->core.constraints; LayoutChild(ref); - form->form.new_y += ref_form->form.new_y + XtHeight(ref) + - (XtBorderWidth(ref) << 1); + form->form.new_y = (Position)(form->form.new_y + + (ref_form->form.new_y + + XtHeight(ref) + + (XtBorderWidth(ref) << 1))); } form->form.layout_state = LayoutDone; @@ -725,7 +729,7 @@ XawFormResize(Widget w) { FormWidget fw = (FormWidget)w; WidgetList children = fw->composite.children; - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; Widget *childP; int x, y; int width, height; @@ -781,7 +785,9 @@ XawFormResize(Widget w) width = width < 1 ? 1 : width; height = height < 1 ? 1 : height; - XtConfigureWidget(*childP, x, y, width, height, + XtConfigureWidget(*childP, + (Position)x, (Position)y, + (Dimension)width, (Dimension)height, XtBorderWidth(*childP)); } @@ -863,7 +869,7 @@ XawFormGeometryManager(Widget w, XtWidgetGeometry *request, fw->form.resize_in_layout = True; - always_resize_children = ChangeFormGeometry(w, True, + always_resize_children = (Boolean)ChangeFormGeometry(w, True, fw->form.preferred_width, fw->form.preferred_height, &ret_width, &ret_height); @@ -879,7 +885,7 @@ XawFormGeometryManager(Widget w, XtWidgetGeometry *request, if ((*((FormWidgetClass)fw->core.widget_class)->form_class.layout) (fw, XtWidth(w), XtHeight(w), False)) { Widget *childP; - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; WidgetList children = fw->composite.children; if (fw->form.no_refigure) { @@ -913,8 +919,8 @@ XawFormGeometryManager(Widget w, XtWidgetGeometry *request, nform->form.virtual_x = XtX(nw); nform->form.virtual_y = XtY(nw); #endif - nform->form.virtual_width = XtWidth(nw); - nform->form.virtual_height = XtHeight(nw); + nform->form.virtual_width = (short)XtWidth(nw); + nform->form.virtual_height = (short)XtHeight(nw); } } } @@ -941,9 +947,9 @@ XawFormSetValues(Widget current, Widget request, Widget cnew, XawPixmap *opix, *npix; opix = XawPixmapFromXPixmap(f_old->core.background_pixmap, XtScreen(f_old), - f_old->core.colormap, f_old->core.depth); + f_old->core.colormap, (int)f_old->core.depth); npix = XawPixmapFromXPixmap(f_new->core.background_pixmap, XtScreen(f_new), - f_new->core.colormap, f_new->core.depth); + f_new->core.colormap, (int)f_new->core.depth); if ((npix && npix->mask) || (opix && opix->mask)) XawReshapeWidget(cnew, npix); } @@ -964,8 +970,8 @@ XawFormConstraintInitialize(Widget request, Widget cnew, form->form.virtual_x = XtX(cnew); form->form.virtual_y = XtY(cnew); #endif - form->form.virtual_width = XtWidth(cnew); - form->form.virtual_height = XtHeight(cnew); + form->form.virtual_width = (short)XtWidth(cnew); + form->form.virtual_height = (short)XtHeight(cnew); if (form->form.dx == default_value) form->form.dx = fw->form.default_spacing; @@ -1015,7 +1021,7 @@ XawFormChangeManaged(Widget w) FormWidget fw = (FormWidget)w; FormConstraints form; WidgetList children, childP; - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; Widget child; (*((FormWidgetClass)w->core.widget_class)->form_class.layout) @@ -1034,8 +1040,8 @@ XawFormChangeManaged(Widget w) form->form.virtual_x = XtX(child); form->form.virtual_y = XtY(child); #endif - form->form.virtual_width = XtWidth(child); - form->form.virtual_height = XtHeight(child); + form->form.virtual_width = (short)XtWidth(child); + form->form.virtual_height = (short)XtHeight(child); } } @@ -1076,7 +1082,7 @@ XawFormDoLayout(Widget w, { Widget *childP; FormWidget fw = (FormWidget)w; - int num_children = fw->composite.num_children; + int num_children = (int)fw->composite.num_children; WidgetList children = fw->composite.children; if ((fw->form.no_refigure = !force) == True || !XtIsRealized(w)) diff --git a/src/Label.c b/src/Label.c index 024d01aa85d564c4f816a4f1513b7cf61e715eef..1eec7e49b311125aa0758c604605e35e32c54b84 100644 --- a/src/Label.c +++ b/src/Label.c @@ -290,9 +290,9 @@ SetTextWidthAndHeight(LabelWidget lw) if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y, &width, &height, &bw, &depth)) { - lw->label.label_height = height; - lw->label.label_width = width; - lw->label.label_len = depth; + lw->label.label_height = (Dimension)height; + lw->label.label_width = (Dimension)width; + lw->label.label_len = (Dimension)depth; return; } } @@ -314,26 +314,26 @@ SetTextWidthAndHeight(LabelWidget lw) int width = XmbTextEscapement(fset, label, (int)(nl - label)); if (width > (int)lw->label.label_width) - lw->label.label_width = width; + lw->label.label_width = (Dimension)width; label = nl + 1; if (*label) - lw->label.label_height += ext->max_ink_extent.height; + lw->label.label_height = (Dimension)(lw->label.label_height + ext->max_ink_extent.height); } if (*label) { - int width = XmbTextEscapement(fset, label, strlen(label)); + int width = XmbTextEscapement(fset, label, (int)strlen(label)); if (width > (int)lw->label.label_width) - lw->label.label_width = width; + lw->label.label_width = (Dimension)width; } } else { - lw->label.label_len = strlen(lw->label.label); + lw->label.label_len = (Dimension)strlen(lw->label.label); lw->label.label_width = - XmbTextEscapement(fset, lw->label.label, lw->label.label_len); + (Dimension)XmbTextEscapement(fset, lw->label.label, lw->label.label_len); } } else { - lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent; + lw->label.label_height = (Dimension)(fs->max_bounds.ascent + fs->max_bounds.descent); if (lw->label.label == NULL) { lw->label.label_len = 0; lw->label.label_width = 0; @@ -351,32 +351,32 @@ SetTextWidthAndHeight(LabelWidget lw) else width = XTextWidth(fs, label, (int)(nl - label)); if (width > (int)lw->label.label_width) - lw->label.label_width = width; + lw->label.label_width = (Dimension)width; label = nl + 1; if (*label) lw->label.label_height += fs->max_bounds.ascent + fs->max_bounds.descent; } if (*label) { - int width = XTextWidth(fs, label, strlen(label)); + int width = XTextWidth(fs, label, (int)strlen(label)); if (lw->label.encoding) - width = XTextWidth16(fs, (XChar2b *)label, strlen(label) / 2); + width = XTextWidth16(fs, (XChar2b *)label, (int)(strlen(label) / 2)); else - width = XTextWidth(fs, label, strlen(label)); + width = XTextWidth(fs, label, (int)strlen(label)); if (width > (int) lw->label.label_width) - lw->label.label_width = width; + lw->label.label_width = (Dimension)width; } } else { - lw->label.label_len = strlen(lw->label.label); + lw->label.label_len = (Dimension)strlen(lw->label.label); if (lw->label.encoding) lw->label.label_width = - XTextWidth16(fs, (XChar2b *)lw->label.label, + (Dimension)XTextWidth16(fs, (XChar2b *)lw->label.label, (int)lw->label.label_len / 2); else lw->label.label_width = - XTextWidth(fs, lw->label.label, (int)lw->label.label_len); + (Dimension)XTextWidth(fs, lw->label.label, (int)lw->label.label_len); } } } @@ -442,8 +442,9 @@ compute_bitmap_offsets(LabelWidget lw) * (internal_width, internal_height + lbm_y) */ if (lw->label.lbm_height != 0) - lw->label.lbm_y = (XtHeight(lw) - (lw->label.internal_height * 2 + - lw->label.lbm_height)) / 2; + lw->label.lbm_y = (int)((XtHeight(lw) + - ((lw->label.internal_height * 2) + + lw->label.lbm_height)) / 2); else lw->label.lbm_y = 0; } @@ -486,13 +487,14 @@ XawLabelInitialize(Widget request, Widget cnew, SetTextWidthAndHeight(lw); if (XtHeight(lw) == 0) - XtHeight(lw) = lw->label.label_height + 2 * lw->label.internal_height; + XtHeight(lw) = (Dimension)(lw->label.label_height + 2 * lw->label.internal_height); set_bitmap_info(lw); /* need core.height */ if (XtWidth(lw) == 0) /* need label.lbm_width */ - XtWidth(lw) = lw->label.label_width + 2 * lw->label.internal_width + - LEFT_OFFSET(lw); + XtWidth(lw) = (lw->label.label_width + + (2 * lw->label.internal_width) + + LEFT_OFFSET(lw)); lw->label.label_x = lw->label.label_y = 0; (*XtClass(cnew)->core_class.resize)((Widget)lw); @@ -517,7 +519,7 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) if (w->label.pixmap == None) { int len = w->label.label_len; char *label = w->label.label; - Position y = w->label.label_y + w->label.font->max_bounds.ascent; + Position y = (Position)(w->label.label_y + w->label.font->max_bounds.ascent); Position ksy = w->label.label_y; /* display left bitmap */ @@ -530,7 +532,7 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) if (w->simple.international == True) { XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset); - ksy += XawAbs(ext->max_ink_extent.y); + ksy = (ksy + XawAbs(ext->max_ink_extent.y)); if (len == MULTI_LINE_LABEL) { char *nl; @@ -539,10 +541,10 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc, w->label.label_x, ksy, label, (int)(nl - label)); - ksy += ext->max_ink_extent.height; + ksy = (ksy + ext->max_ink_extent.height); label = nl + 1; } - len = strlen(label); + len = (int)strlen(label); } if (len) XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc, @@ -560,11 +562,11 @@ XawLabelRedisplay(Widget gw, XEvent *event, Region region) else XDrawString(XtDisplay(gw), XtWindow(gw), gc, w->label.label_x, y, label, (int)(nl - label)); - y += w->label.font->max_bounds.ascent + - w->label.font->max_bounds.descent; + y += (w->label.font->max_bounds.ascent + + w->label.font->max_bounds.descent); label = nl + 1; } - len = strlen(label); + len = (int)strlen(label); } if (len) { if (w->label.encoding) @@ -596,28 +598,28 @@ _Reposition(LabelWidget lw, unsigned int width, unsigned int height, Position *dx, Position *dy) { Position newPos; - Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw); + Position leftedge = (lw->label.internal_width + LEFT_OFFSET(lw)); switch (lw->label.justify) { case XtJustifyLeft: newPos = leftedge; break; case XtJustifyRight: - newPos = width - (lw->label.label_width + lw->label.internal_width); + newPos = (Position)(width - (unsigned)(lw->label.label_width + lw->label.internal_width)); break; case XtJustifyCenter: /*FALLTRHOUGH*/ default: - newPos = (int)(width - lw->label.label_width) >> 1; + newPos = (Position)((int)(width - lw->label.label_width) >> 1); break; } if (newPos < (Position)leftedge) newPos = leftedge; - *dx = newPos - lw->label.label_x; + *dx = (Position)(newPos - lw->label.label_x); lw->label.label_x = newPos; - newPos = (height - lw->label.label_height) >> 1; - *dy = newPos - lw->label.label_y; + newPos = (Position)((height - lw->label.label_height) >> 1); + *dy = (Position)(newPos - lw->label.label_y); lw->label.label_y = newPos; } @@ -658,7 +660,7 @@ XawLabelSetValues(Widget current, Widget request, Widget cnew, } if (newlw->label.label == NULL) - newlw->label.label = newlw->core.name; + newlw->label.label = (char *)newlw->core.name; /* * resize on bitmap change @@ -692,14 +694,15 @@ XawLabelSetValues(Widget current, Widget request, Widget cnew, /* recalculate the window size if something has changed */ if (newlw->label.resize && was_resized) { if (XtHeight(curlw) == XtHeight(reqlw) && !checks[HEIGHT]) - XtHeight(newlw) = newlw->label.label_height + - (newlw->label.internal_height << 1); + XtHeight(newlw) = (Dimension)(newlw->label.label_height + + (newlw->label.internal_height << 1)); set_bitmap_info(newlw); if (XtWidth(curlw) == XtWidth(reqlw) && !checks[WIDTH]) - XtWidth(newlw) = newlw->label.label_width + LEFT_OFFSET(newlw) + - (newlw->label.internal_width << 1); + XtWidth(newlw) = (newlw->label.label_width + + LEFT_OFFSET(newlw) + + (unsigned)(newlw->label.internal_width << 1)); } if (curlw->label.foreground != newlw->label.foreground @@ -750,10 +753,11 @@ XawLabelQueryGeometry(Widget w, XtWidgetGeometry *intended, LabelWidget lw = (LabelWidget)w; preferred->request_mode = CWWidth | CWHeight; - preferred->width = lw->label.label_width + - (lw->label.internal_width << 1) + LEFT_OFFSET(lw); - preferred->height = lw->label.label_height + - (lw->label.internal_height << 1); + preferred->width = (lw->label.label_width + + (unsigned)(lw->label.internal_width << 1) + + LEFT_OFFSET(lw)); + preferred->height = (Dimension)(lw->label.label_height + + (lw->label.internal_height << 1)); if (((intended->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight)) && intended->width == preferred->width diff --git a/src/List.c b/src/List.c index ce0ab5f23ce78fe47faa7db79e103303abb67838..93f9804bac453dfba80a06ebde0ac1117a0c38a4 100644 --- a/src/List.c +++ b/src/List.c @@ -374,10 +374,10 @@ CalculatedValues(Widget w) for (i = 0 ; i < lw->list.nitems; i++) { if (lw->simple.international == True) len = XmbTextEscapement(lw->list.fontset, lw->list.list[i], - strlen(lw->list.list[i])); + (int)strlen(lw->list.list[i])); else len = XTextWidth(lw->list.font, lw->list.list[i], - strlen(lw->list.list[i])); + (int)strlen(lw->list.list[i])); if (len > lw->list.longest) lw->list.longest = len; } @@ -435,8 +435,8 @@ ChangeSize(Widget w, unsigned int width, unsigned int height) XtWidgetGeometry request, reply; request.request_mode = CWWidth | CWHeight; - request.width = width; - request.height = height; + request.width = (Dimension)width; + request.height = (Dimension)height; switch (XtMakeGeometryRequest(w, &request, &reply)) { case XtGeometryYes: @@ -628,10 +628,10 @@ static void HighlightBackground(Widget w, int x, int y, GC gc) { ListWidget lw = (ListWidget)w; - Dimension width = lw->list.col_width; - Dimension height = lw->list.row_height; - Dimension frame_limited_width = XtWidth(w) - lw->list.internal_width - x; - Dimension frame_limited_height= XtHeight(w) - lw->list.internal_height - y; + Dimension width = (Dimension)lw->list.col_width; + Dimension height = (Dimension)lw->list.row_height; + Dimension frame_limited_width = (Dimension)(XtWidth(w) - lw->list.internal_width - x); + Dimension frame_limited_height= (Dimension)(XtHeight(w) - lw->list.internal_height - y); /* Clip the rectangle width and height to the edge of the drawable area */ if (width > frame_limited_width) @@ -641,11 +641,11 @@ HighlightBackground(Widget w, int x, int y, GC gc) /* Clip the rectangle x and y to the edge of the drawable area */ if (x < lw->list.internal_width) { - width = width - (lw->list.internal_width - x); + width = (Dimension)(width - (lw->list.internal_width - x)); x = lw->list.internal_width; } if (y < lw->list.internal_height) { - height = height - (lw->list.internal_height - y); + height = (Dimension)(height - (lw->list.internal_height - y)); y = lw->list.internal_height; } @@ -670,12 +670,12 @@ ClipToShadowInteriorAndLongest(ListWidget lw, GC *gc_p, unsigned int x) { XRectangle rect; - rect.x = x; - rect.y = lw->list.internal_height; - rect.height = XtHeight(lw) - (lw->list.internal_height << 1); - rect.width = XtWidth(lw) - lw->list.internal_width - x; + rect.x = (short)x; + rect.y = (short)lw->list.internal_height; + rect.height = (unsigned short)(XtHeight(lw) - (lw->list.internal_height << 1)); + rect.width = (unsigned short)(XtWidth(lw) - (unsigned)lw->list.internal_width - x); if (rect.width > lw->list.longest) - rect.width = lw->list.longest; + rect.width = (unsigned short)lw->list.longest; XSetClipRectangles(XtDisplay((Widget)lw), *gc_p, 0, 0, &rect, 1, YXBanded); } @@ -748,13 +748,13 @@ PaintItemName(Widget w, int item) str = lw->list.list[item]; /* draw it */ - ClipToShadowInteriorAndLongest(lw, &gc, x); + ClipToShadowInteriorAndLongest(lw, &gc, (unsigned)x); if (lw->simple.international == True) XmbDrawString(XtDisplay(w), XtWindow(w), lw->list.fontset, - gc, x, str_y, str, strlen(str)); + gc, x, str_y, str, (int)strlen(str)); else - XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, strlen(str)); + XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, (int)strlen(str)); XSetClipMask(XtDisplay(w), gc, None); } @@ -876,13 +876,13 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) /* this counts the same number of inter-column column_space 's as columns. There should thus be a half column_space margin on each side of each column...*/ - width2 = lw->list.ncols * lw->list.col_width + - (lw->list.internal_width << 1); + width2 = (unsigned long)(lw->list.ncols * lw->list.col_width + + (lw->list.internal_width << 1)); change = True; } if (yfree) { - height2 = lw->list.nrows * lw->list.row_height + - (lw->list.internal_height << 1); + height2 = (unsigned long)(lw->list.nrows * lw->list.row_height + + (lw->list.internal_height << 1)); change = True; } } @@ -902,10 +902,10 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) || (lw->list.ncols = wid / lw->list.col_width) <= 0) lw->list.ncols = 1; } - width2 = lw->list.ncols * lw->list.col_width - + (lw->list.internal_width << 1); - height2 = (lw->list.nrows * lw->list.row_height) - + (lw->list.internal_height << 1); + width2 = (unsigned long)((lw->list.ncols * lw->list.col_width) + + (lw->list.internal_width << 1)); + height2 = (unsigned long)((lw->list.nrows * lw->list.row_height) + + (lw->list.internal_height << 1)); change = True; } @@ -921,8 +921,8 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) lw->list.ncols = 1; lw->list.nrows = ((lw->list.nitems - 1) / lw->list.ncols) + 1; if (yfree) { - height2 = lw->list.nrows * lw->list.row_height + - (lw->list.internal_height << 1); + height2 = (unsigned long)((lw->list.nrows * lw->list.row_height) + + (lw->list.internal_height << 1)); change = True; } } @@ -938,8 +938,8 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) if (lw->list.nrows <= 0) lw->list.nrows = 1; lw->list.ncols = ((lw->list.nitems - 1) / lw->list.nrows) + 1; - width2 = lw->list.ncols * lw->list.col_width + - (lw->list.internal_width << 1); + width2 = (unsigned long)((lw->list.ncols * lw->list.col_width) + + (lw->list.internal_width << 1)); change = True; } @@ -947,10 +947,10 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) /*CONSTCOND*/ while (1) { lw->list.nrows = ((lw->list.nitems - 1) / lw->list.ncols) + 1; - width2 = lw->list.ncols * lw->list.col_width + - (lw->list.internal_width << 1); - height2 = lw->list.nrows * lw->list.row_height + - (lw->list.internal_height << 1); + width2 = (unsigned long)((lw->list.ncols * lw->list.col_width) + + (lw->list.internal_width << 1)); + height2 = (unsigned long)((lw->list.nrows * lw->list.row_height) + + (lw->list.internal_height << 1)); if (width2 >= MaxSize && height2 >= MaxSize) break; if (height2 > MaxSize) @@ -962,9 +962,9 @@ Layout(Widget w, Bool xfree, Bool yfree, Dimension *width, Dimension *height) } } if (width2) - *width = width2; + *width = (Dimension)width2; if (height2) - *height = height2; + *height = (Dimension)height2; return (change); } @@ -1001,7 +1001,7 @@ Notify(Widget w, XEvent *event, String *params, Cardinal *num_params) return; } - item_len = strlen(lw->list.list[item]); + item_len = (int)strlen(lw->list.list[item]); if (lw->list.paste) /* if XtNpasteBuffer set then paste it */ XStoreBytes(XtDisplay(w), lw->list.list[item], item_len); @@ -1143,7 +1143,7 @@ XawListSetValues(Widget current, Widget request, Widget cnew, redraw = True; } - return (redraw); + return (Boolean)(redraw); } static void diff --git a/src/MultiSink.c b/src/MultiSink.c index 77eb42fd9fd62ff1135012c8945c7cbd8562a950..c1b6da09f3f2617f402419a00015fd16163b739f 100644 --- a/src/MultiSink.c +++ b/src/MultiSink.c @@ -308,7 +308,7 @@ PaintText(Widget w, GC gc, int x, int y, wchar_t *buf, int len, Bool clear_bg) MultiSinkObject sink = (MultiSinkObject)w; TextWidget ctx = (TextWidget)XtParent(w); XFontSet fontset = sink->multi_sink.fontset; - unsigned int width = XwcTextEscapement(fontset, buf, len); + unsigned int width = (unsigned)XwcTextEscapement(fontset, buf, len); if (((int)width) <= -x) /* Don't draw if we can't see it */ return (width); @@ -363,11 +363,11 @@ DisplayText(Widget w, int x, int y, y += abs(ext->max_logical_extent.y); for (j = 0; pos1 < pos2;) { - pos1 = XawTextSourceRead(source, pos1, &blk, (int) pos2 - pos1); + pos1 = XawTextSourceRead(source, pos1, &blk, (int) (pos2 - pos1)); for (k = 0; k < blk.length; k++) { if ((unsigned) j >= (sizeof(buf) / sizeof(wchar_t)) - 1) { /* buffer full, dump the text */ - if ((x += PaintText(w, gc, x, y, buf, j, clear_bg)) >= max_x) + if ((x = (int)((unsigned)x + PaintText(w, gc, x, y, buf, j, clear_bg))) >= max_x) return; j = 0; } @@ -379,10 +379,10 @@ DisplayText(Widget w, int x, int y, unsigned int width; if (j != 0 && - (x += PaintText(w, gc, x, y, buf, j, clear_bg)) >= max_x) + (x = (int)((unsigned)x + PaintText(w, gc, x, y, buf, j, clear_bg))) >= max_x) return; - width = CharWidth(sink, fontset, x, _Xaw_atowc(XawTAB)); + width = (unsigned)CharWidth(sink, fontset, x, _Xaw_atowc(XawTAB)); if (clear_bg) _XawTextSinkClearToBackground(w, x, y - abs(ext->max_logical_extent.y), @@ -393,7 +393,7 @@ DisplayText(Widget w, int x, int y, y - abs(ext->max_logical_extent.y), width, ext->max_logical_extent.height); - x += width; + x = (int)((unsigned)x + width); j = -1; } else if (XwcTextEscapement(sink->multi_sink.fontset, &buf[j], 1) @@ -427,11 +427,11 @@ GetCursorBounds(Widget w, XRectangle *rect) { MultiSinkObject sink = (MultiSinkObject)w; - rect->width = CharWidth(sink, sink->multi_sink.fontset, 0, _Xaw_atowc(XawSP)); + rect->width = (unsigned short)CharWidth(sink, sink->multi_sink.fontset, 0, _Xaw_atowc(XawSP)); rect->height = (XExtentsOfFontSet(sink->multi_sink.fontset) ->max_logical_extent.height); rect->x = sink->multi_sink.cursor_x; - rect->y = sink->multi_sink.cursor_y - (short)rect->height; + rect->y = (short)(sink->multi_sink.cursor_y - (short)rect->height); } /* @@ -481,9 +481,9 @@ InsertCursor(Widget w, int x, int y, XawTextInsertState state) if (!ochar) _XawTextSinkClearToBackground(w, sink->multi_sink.cursor_x, (sink->multi_sink.cursor_y - 1 - - fheight), CharWidth(sink, fontset, - 0, wspace[0]), - fheight); + fheight), + (unsigned)CharWidth(sink, fontset, 0, wspace[0]), + (unsigned)fheight); else { if (XwcTextEscapement(sink->multi_sink.fontset, ochar, 1) != 0) DisplayText(w, sink->multi_sink.cursor_x, @@ -527,13 +527,13 @@ InsertCursor(Widget w, int x, int y, XawTextInsertState state) sink->multi_sink.xorgc ? sink->multi_sink.xorgc : sink->multi_sink.normgc, x, y - 1 - fheight, - CharWidth(sink, fontset, 0, *nchar) - 1, - fheight - 1); + (unsigned)(CharWidth(sink, fontset, 0, *nchar) - 1), + (unsigned)(fheight - 1)); } } - sink->multi_sink.cursor_x = x; - sink->multi_sink.cursor_y = y; + sink->multi_sink.cursor_x = (short)x; + sink->multi_sink.cursor_y = (short)y; sink->multi_sink.laststate = state; sink->multi_sink.cursor_position = position; } @@ -556,12 +556,12 @@ FindDistance(Widget w, XawTextPosition fromPos, int fromx, XawTextBlock blk; int i, rWidth; - pos = XawTextSourceRead(source, fromPos, &blk, toPos - fromPos); + pos = XawTextSourceRead(source, fromPos, &blk, (int)(toPos - fromPos)); rWidth = 0; for (i = 0, idx = fromPos; idx < toPos; i++, idx++) { if (i >= blk.length) { i = 0; - XawTextSourceRead(source, pos, &blk, toPos - pos); + XawTextSourceRead(source, pos, &blk, (int)(toPos - pos)); if (blk.length == 0) break; } @@ -659,7 +659,7 @@ GetGC(MultiSinkObject sink) XGCValues values; /* XXX We dont want do share a gc that will change the clip-mask */ - values.clip_x_origin = (long)sink; + values.clip_x_origin = (int)(long)sink; values.clip_mask = None; values.graphics_exposures = False; @@ -766,8 +766,8 @@ XawMultiSinkResize(Widget w) (int)ctx->text.r_margin.right - (int)ctx->text.r_margin.left; height = (int)XtHeight(ctx) - (int)ctx->text.r_margin.top - (int)ctx->text.r_margin.bottom; - rect.width = width; - rect.height = height; + rect.width = (unsigned short)width; + rect.height = (unsigned short)height; if (sink->multi_sink.normgc) { if (width >= 0 && height >= 0) @@ -868,7 +868,7 @@ MaxLines(Widget w, unsigned int height) XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset); font_height = ext->max_logical_extent.height; - return (height / font_height); + return (int)(height / (unsigned)font_height); } /* @@ -938,22 +938,22 @@ SetTabs(Widget w, int tab_count, short* tabs) || figure_width == 0)) { if (font->per_char && font->min_char_or_byte2 <= '$' && font->max_char_or_byte2 >= '$') - figure_width = font->per_char['$' - font->min_char_or_byte2].width; + figure_width = (unsigned long)font->per_char['$' - font->min_char_or_byte2].width; else - figure_width = font->max_bounds.width; + figure_width = (unsigned long)font->max_bounds.width; } if (tab_count > sink->text_sink.tab_count) { sink->text_sink.tabs = (Position *) XtRealloc((char *)sink->text_sink.tabs, - (Cardinal)(tab_count * sizeof(Position))); + (Cardinal)((unsigned long)tab_count * sizeof(Position))); sink->text_sink.char_tabs = (short *) XtRealloc((char *)sink->text_sink.char_tabs, - (Cardinal)(tab_count * sizeof(short))); + (Cardinal)((unsigned long)tab_count * sizeof(short))); } for (i = 0 ; i < tab_count ; i++) { - sink->text_sink.tabs[i] = tabs[i] * figure_width; + sink->text_sink.tabs[i] = (Position)((unsigned long)tabs[i] * figure_width); sink->text_sink.char_tabs[i] = tabs[i]; } @@ -971,5 +971,5 @@ _XawMultiSinkPosToXY(Widget w, XawTextPosition pos, Position *x, Position *y) XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset); _XawTextPosToXY(w, pos, x, y); - *y += abs(ext->max_logical_extent.y); + *y = (Position)(*y + abs(ext->max_logical_extent.y)); } diff --git a/src/MultiSrc.c b/src/MultiSrc.c index 15bdaf8c7fe1fbc622a203d947c973c9e7b52fab..51973e1c131a5a5b74a1a9d647f68d5e28cc71c5 100644 --- a/src/MultiSrc.c +++ b/src/MultiSrc.c @@ -298,7 +298,7 @@ XawMultiSrcInitialize(Widget request, Widget cnew, if (file != NULL) fclose(file); - src->text_src.text_format = XawFmtWide; + src->text_src.text_format = (XrmQuark)XawFmtWide; } /* @@ -325,10 +325,10 @@ ReadText(Widget w, XawTextPosition pos, XawTextBlock *text, int length) MultiPiece *piece = FindPiece(src, pos, &start); text->format = XawFmtWide; - text->firstPos = pos; + text->firstPos = (int)pos; text->ptr = (char *)(piece->text + (pos - start)); count = piece->used - (pos - start); - text->length = Max(0, (length > count) ? count : length); + text->length = (Max(0, (length > count) ? count : length)); return (pos + text->length); } @@ -420,7 +420,7 @@ ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos, end_piece->used -= endPos - end_first; if (end_piece->used != 0) memmove(end_piece->text, end_piece->text + endPos - end_first, - end_piece->used * sizeof(wchar_t)); + (size_t)end_piece->used * sizeof(wchar_t)); } else { /* We are fully in one piece */ if ((start_piece->used -= endPos - startPos) == 0) { @@ -430,7 +430,7 @@ ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos, else { memmove(start_piece->text + (startPos - start_first), start_piece->text + (endPos - start_first), - (start_piece->used - (startPos - start_first)) * + (size_t)(start_piece->used - (startPos - start_first)) * sizeof(wchar_t)); if (src->multi_src.use_string_in_place && ((src->multi_src.length - (endPos - startPos)) @@ -475,10 +475,10 @@ ReplaceText(Widget w, XawTextPosition startPos, XawTextPosition endPos, fill = Min((int)(src->multi_src.piece_size - start_piece->used), length); ptr = start_piece->text + (startPos - start_first); - memmove(ptr + fill, ptr, (start_piece->used - + memmove(ptr + fill, ptr, (size_t)(start_piece->used - (startPos - start_first)) * sizeof(wchar_t)); wptr =(wchar_t *)text.ptr; - (void)wcsncpy(ptr, wptr + firstPos, fill); + (void)wcsncpy(ptr, wptr + firstPos, (size_t)fill); startPos += fill; firstPos += fill; @@ -598,7 +598,7 @@ Scan(Widget w, register XawTextPosition position, XawTextScanType type, position += inc; if (type == XawstAlphaNumeric) { - if (!iswalnum(c)) { + if (!iswalnum((wint_t)c)) { if (non_space) break; } @@ -720,8 +720,8 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, effectively factored out of the following computations */ /* STEP 3: SEARCH! */ - buf = (wchar_t *)XtMalloc(sizeof(wchar_t) * wtarget_len); - (void)wcsncpy(buf, wtarget, wtarget_len); + buf = (wchar_t *)XtMalloc((Cardinal)(sizeof(wchar_t) * (size_t)wtarget_len)); + (void)wcsncpy(buf, wtarget, (size_t)wtarget_len); piece = FindPiece(src, position, &first); ptr = (position - first) + piece->text; @@ -746,7 +746,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, position += inc; while (ptr < piece->text) { - cnt = piece->text - ptr; + cnt = (int)(piece->text - ptr); piece = piece->prev; if (piece == NULL) { /* Begining of text */ @@ -757,7 +757,7 @@ Search(Widget w, register XawTextPosition position, XawTextScanDirection dir, } while (ptr >= piece->text + piece->used) { - cnt = ptr - (piece->text + piece->used); + cnt = (int)(ptr - (piece->text + piece->used)); piece = piece->next; if (piece == NULL) { /* End of text */ @@ -1119,16 +1119,16 @@ StorePiecesInString(MultiSrcObject src) { wchar_t *wc_string; char *mb_string; - int char_count = src->multi_src.length; + int char_count = (int)src->multi_src.length; XawTextPosition first; MultiPiece *piece; /* I believe the char_count + 1 and the NULL termination are unneeded! FS */ - wc_string = (wchar_t*)XtMalloc((char_count + 1) * sizeof(wchar_t)); + wc_string = (wchar_t*)XtMalloc((Cardinal)((size_t)(char_count + 1) * sizeof(wchar_t))); for (first = 0, piece = src->multi_src.first_piece ; piece != NULL; first += piece->used, piece = piece->next) - (void)wcsncpy(wc_string + first, piece->text, piece->used); + (void)wcsncpy(wc_string + first, piece->text, (size_t)piece->used); wc_string[char_count] = 0; @@ -1180,17 +1180,17 @@ InitStringOrFile(MultiSrcObject src, Bool newString) src->multi_src.allocated_string = True; src->multi_src.string = temp; - length = strlen((char *)src->multi_src.string); + length = (int)strlen((char *)src->multi_src.string); /* Wasteful, throwing away the WC string, but need side effect! */ (void)_XawTextMBToWC(d, (char *)src->multi_src.string, &length); src->multi_src.length = (XawTextPosition)length; } else { - src->multi_src.length = strlen((char *)src->multi_src.string); + src->multi_src.length = (XawTextPosition)strlen((char *)src->multi_src.string); /* In case the length resource is incorrectly set */ if (src->multi_src.length > src->multi_src.multi_length) - src->multi_src.multi_length = src->multi_src.length; + src->multi_src.multi_length = (int)src->multi_src.length; if (src->multi_src.multi_length == MAGIC_VALUE) src->multi_src.piece_size = src->multi_src.length; @@ -1249,7 +1249,7 @@ InitStringOrFile(MultiSrcObject src, Bool newString) } if (!src->multi_src.is_tempfile) { - if ((fd = open((char *)src->multi_src.string, open_mode, 0666)) != -1) { + if ((fd = open((char *)src->multi_src.string, (int)open_mode, 0666)) != -1) { if ((file = fdopen(fd, fdopen_mode)) != NULL) { (void)fseek(file, 0, SEEK_END); src->multi_src.length = (XawTextPosition)ftell(file); @@ -1296,7 +1296,7 @@ LoadPieces(MultiSrcObject src, FILE *file, char *string) * in as MB length, out as WC length. We want local_length to be * WC count. */ - int local_length = src->multi_src.length; + int local_length = (int)src->multi_src.length; if (string != NULL) { /* @@ -1312,24 +1312,24 @@ LoadPieces(MultiSrcObject src, FILE *file, char *string) * here, we are not changing the contents, just reloading, * so don't change len... */ - local_length = src->multi_src.string ? - strlen((char *)src->multi_src.string) : 0; + local_length = (int)(src->multi_src.string ? + strlen((char *)src->multi_src.string) : 0); local_str = _XawTextMBToWC(d, (char *)src->multi_src.string, &local_length); } else { if (src->multi_src.length != 0) { temp_mb_holder = - XtMalloc((src->multi_src.length + 1) * sizeof(unsigned char)); + XtMalloc(((size_t)(src->multi_src.length + 1) * sizeof(unsigned char))); fseek(file, 0, SEEK_SET); - src->multi_src.length = fread(temp_mb_holder, + src->multi_src.length = (XawTextPosition)fread(temp_mb_holder, sizeof(unsigned char), (size_t)src->multi_src.length, file); if (src->multi_src.length <= 0) XtAppErrorMsg(XtWidgetToApplicationContext ((Widget) src), "readError", "multiSource", "XawError", "fread returned error.", NULL, NULL); - local_length = src->multi_src.length; + local_length = (int)src->multi_src.length; local_str = _XawTextMBToWC(d, temp_mb_holder, &local_length); src->multi_src.length = local_length; @@ -1349,7 +1349,7 @@ LoadPieces(MultiSrcObject src, FILE *file, char *string) "not representable in this locale.", params, &num_params); src->multi_src.length = sizeof err_text; - local_length = src->multi_src.length; + local_length = (int)src->multi_src.length; local_str = _XawTextMBToWC(d, err_text, &local_length); src->multi_src.length = local_length; } @@ -1378,7 +1378,7 @@ LoadPieces(MultiSrcObject src, FILE *file, char *string) * bytes)); piece->used = Min(left, src->multi_src.piece_size); if (piece->used != 0) - (void)wcsncpy(piece->text, ptr, piece->used); + (void)wcsncpy(piece->text, ptr, (size_t)piece->used); left -= piece->used; ptr += piece->used; @@ -1527,9 +1527,9 @@ BreakPiece(MultiSrcObject src, MultiPiece *piece) MultiPiece *cnew = AllocNewPiece(src, piece); cnew->text = (wchar_t *) - XtMalloc(src->multi_src.piece_size * sizeof(wchar_t)); + XtMalloc((Cardinal)((size_t)src->multi_src.piece_size * sizeof(wchar_t))); (void)wcsncpy(cnew->text, piece->text + HALF_PIECE, - src->multi_src.piece_size - HALF_PIECE); + (size_t)(src->multi_src.piece_size - HALF_PIECE)); piece->used = HALF_PIECE; cnew->used = src->multi_src.piece_size - HALF_PIECE; } @@ -1583,7 +1583,7 @@ CvtMultiTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; diff --git a/src/OS.c b/src/OS.c index 974ad3f912ed94f9c863e09dae232a9c7d2a6fb6..bbd4079c656b3036e1f1ee296d95f97d63835857 100644 --- a/src/OS.c +++ b/src/OS.c @@ -34,12 +34,12 @@ _XawGetPageSize(void) /* Try each supported method in the preferred order */ #if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE) - pagesize = sysconf(_SC_PAGESIZE); + pagesize = (int) sysconf(_SC_PAGESIZE); #endif #ifdef _SC_PAGE_SIZE if (pagesize == -1) - pagesize = sysconf(_SC_PAGE_SIZE); + pagesize = (int) sysconf(_SC_PAGE_SIZE); #endif #ifdef HAVE_GETPAGESIZE diff --git a/src/Paned.c b/src/Paned.c index 26ff81261b1ea75af8223f24e9aaed15e4cf7f4c..b562fe013648931ab7209f753504546320af027f 100644 --- a/src/Paned.c +++ b/src/Paned.c @@ -506,20 +506,20 @@ AdjustPanedSize(PanedWidget pw, unsigned int off_size, int size = Max(PaneInfo(*childP)->size, (int)PaneInfo(*childP)->min); AssignMin(size, (int)PaneInfo(*childP)->max); - newsize += size + pw->paned.internal_bw; + newsize = (newsize + (size + pw->paned.internal_bw)); } - newsize -= pw->paned.internal_bw; + newsize = (Dimension)(newsize - pw->paned.internal_bw); if (newsize < 1) newsize = 1; if (IsVert(pw)) { - request.width = off_size; + request.width = (Dimension)off_size; request.height = newsize; } else { request.width = newsize; - request.height = off_size; + request.height = (Dimension)off_size; } if (result_ret != NULL) { @@ -530,7 +530,7 @@ AdjustPanedSize(PanedWidget pw, unsigned int off_size, if (newsize == old_size || *result_ret == XtGeometryNo) { *on_size_ret = old_size; - *off_size_ret = off_size; + *off_size_ret = (Dimension)off_size; return; } if (*result_ret != XtGeometryAlmost) { @@ -679,7 +679,7 @@ LoopAndRefigureChildren(PanedWidget pw, int paneindex, Direction dir, * Try to resize this pane so that all panes will fit, take min and max * into account */ - old = pane->size; + old = (Dimension) pane->size; pane->size += pane_size - *sizeused; if (from_stack) { @@ -758,7 +758,7 @@ RefigureLocations(PanedWidget pw, int paneindex, Direction dir) */ if (paneindex != NO_INDEX && dir != AnyPane) { Pane pane = PaneInfo(*(pw->composite.children + paneindex)); - Dimension old = pane->size; + Dimension old = (Dimension)pane->size; pane->size += pane_size - sizeused; AssignMax(pane->size, (int) pane->min); @@ -774,7 +774,7 @@ RefigureLocations(PanedWidget pw, int paneindex, Direction dir) */ ForAllPanes(pw, childP) { PaneInfo(*childP)->delta = loc; - loc += PaneInfo(*childP)->size + pw->paned.internal_bw; + loc = (Position)(loc + (PaneInfo(*childP)->size + pw->paned.internal_bw)); } } @@ -802,7 +802,7 @@ CommitNewLocations(PanedWidget pw) if (IsVert(pw)) { XtMoveWidget(*childP, (Position) 0, pane->delta); - XtResizeWidget(*childP, XtWidth(pw), pane->size, 0); + XtResizeWidget(*childP, XtWidth(pw), (Dimension)pane->size, 0); if (HasGrip(*childP)) { /* Move and Display the Grip */ changes.x = XtWidth(pw) - pw->paned.grip_indent - @@ -814,7 +814,7 @@ CommitNewLocations(PanedWidget pw) } else { XtMoveWidget(*childP, pane->delta, 0); - XtResizeWidget(*childP, pane->size, XtHeight(pw), 0); + XtResizeWidget(*childP, (Dimension)pane->size, (Dimension)XtHeight(pw), 0); if (HasGrip(*childP)) { /* Move and Display the Grip */ changes.x = XtX(*childP) + XtWidth(*childP) - @@ -831,8 +831,8 @@ CommitNewLocations(PanedWidget pw) */ if (HasGrip(*childP)) { - XtX(grip) = changes.x; - XtY(grip) = changes.y; + XtX(grip) = (Position)changes.x; + XtY(grip) = (Position)changes.y; if (XtIsRealized(pane->grip)) XConfigureWindow(XtDisplay(pane->grip), XtWindow(pane->grip), @@ -1165,12 +1165,12 @@ CommitGripAdjustment(PanedWidget pw) if (pw->paned.whichadd) { Pane pane = PaneInfo(pw->paned.whichadd); - pane->wp_size = pane->size; + pane->wp_size = (Dimension)pane->size; } if (pw->paned.whichsub) { Pane pane = PaneInfo(pw->paned.whichsub); - pane->wp_size = pane->size; + pane->wp_size = (Dimension)pane->size; } } @@ -1293,7 +1293,7 @@ ManageAndUnmanageGrips(PanedWidget pw) Widget *managedP, *unmanagedP, *childP; Cardinal alloc_size; - alloc_size = sizeof(Widget) * (pw->composite.num_children >> 1); + alloc_size = (Cardinal)(sizeof(Widget) * (pw->composite.num_children >> 1)); managedP = managed_grips = (WidgetList)XtMalloc(alloc_size); unmanagedP = unmanaged_grips = (WidgetList)XtMalloc(alloc_size); @@ -1307,11 +1307,11 @@ ManageAndUnmanageGrips(PanedWidget pw) if (managedP != managed_grips) { *unmanagedP++ = *--managedP; /* Last grip is never managed */ - XtManageChildren(managed_grips, managedP - managed_grips); + XtManageChildren(managed_grips, (Cardinal)(managedP - managed_grips)); } if (unmanagedP != unmanaged_grips) - XtUnmanageChildren(unmanaged_grips, unmanagedP - unmanaged_grips); + XtUnmanageChildren(unmanaged_grips, (Cardinal)(unmanagedP - unmanaged_grips)); XtFree((char *)managed_grips); XtFree((char *)unmanaged_grips); @@ -1417,11 +1417,11 @@ SetChildrenPrefSizes(PanedWidget pw, unsigned int off_size) else { if(vert) { request.request_mode = CWWidth; - request.width = off_size; + request.width = (Dimension) off_size; } else { request.request_mode = CWHeight; - request.height = off_size; + request.height = (Dimension) off_size; } if ((XtQueryGeometry(*childP, &request, &reply) @@ -1613,15 +1613,15 @@ XawPanedGeometryManager(Widget w, XtWidgetGeometry *request, if ((XtIsRealized((Widget)pw) && !pane->allow_resize) || !(mask & (vert ? CWHeight : CWWidth)) - ||(mask & ~(CWWidth | CWHeight)) + || (mask & (XtGeometryMask)(~(CWWidth | CWHeight))) || GetRequestInfo(request, vert) == PaneSize(w, vert)) return (XtGeometryNo); old_paned_size = PaneSize((Widget)pw, vert); old_wpsize = pane->wp_size; - old_size = pane->size; + old_size = (Dimension)pane->size; - pane->wp_size = pane->size = GetRequestInfo(request, vert); + pane->wp_size = (Dimension)(pane->size = GetRequestInfo(request, vert)); AdjustPanedSize(pw, PaneSize((Widget)pw, !vert), &result, &on_size, &off_size); @@ -1645,13 +1645,13 @@ XawPanedGeometryManager(Widget w, XtWidgetGeometry *request, */ if (vert) { XtHeight(pw) = old_paned_size; - reply->height = pane->size; + reply->height = (Dimension) pane->size; reply->width = off_size; } else { XtWidth(pw) = old_paned_size; reply->height = off_size; - reply->width = pane->size; + reply->width = (Dimension) pane->size; } /* @@ -1673,7 +1673,7 @@ XawPanedGeometryManager(Widget w, XtWidgetGeometry *request, } almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert); - almost |= (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert)); + almost = (Boolean)(almost | (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert))); if ((mask & XtCWQueryOnly) || almost) { pane->wp_size = old_wpsize; @@ -1970,8 +1970,8 @@ XawPanedSetMinMax(Widget widget, int min, int max) { Pane pane = PaneInfo(widget); - pane->min = min; - pane->max = max; + pane->min = (Dimension) min; + pane->max = (Dimension) max; RefigureLocationsAndCommit(widget->core.parent); } diff --git a/src/Panner.c b/src/Panner.c index aa902336ee61dfcf2a6b819b087650ced472cc55..8cacde16cf8bbe058466be8a946b6033eee002c7 100644 --- a/src/Panner.c +++ b/src/Panner.c @@ -420,11 +420,9 @@ reset_xor_gc(PannerWidget pw) static void check_knob(PannerWidget pw, Bool knob) { - Position pad = pw->panner.internal_border << 1; - Position maxx = (Position)XtWidth(pw) - pad - - (Position)pw->panner.knob_width; - Position maxy = (Position)XtHeight(pw) - pad - - (Position)pw->panner.knob_height; + Position pad = (Position)(pw->panner.internal_border << 1); + Position maxx = (Position)(XtWidth(pw) - pad - pw->panner.knob_width); + Position maxy = (Position)(XtHeight(pw) - pad - pw->panner.knob_height); Position *x = knob ? &pw->panner.knob_x : &pw->panner.tmp.x; Position *y = knob ? &pw->panner.knob_y : &pw->panner.tmp.y; @@ -461,15 +459,15 @@ move_shadow(PannerWidget pw) if (pw->panner.knob_height > lw && pw->panner.knob_width > lw) { XRectangle *r = pw->panner.shadow_rects; - r->x = pw->panner.knob_x + pad + pw->panner.knob_width; - r->y = pw->panner.knob_y + pad + lw; - r->width = pw->panner.shadow_thickness; - r->height = pw->panner.knob_height - lw; + r->x = (short)(pw->panner.knob_x + pad + pw->panner.knob_width); + r->y = (short)(pw->panner.knob_y + pad + lw); + r->width = (unsigned short)(pw->panner.shadow_thickness); + r->height = (unsigned short)(pw->panner.knob_height - lw); r++; - r->x = pw->panner.knob_x + pad + lw; - r->y = pw->panner.knob_y + pad + pw->panner.knob_height; - r->width = pw->panner.knob_width - lw + pw->panner.shadow_thickness; - r->height = pw->panner.shadow_thickness; + r->x = (short)(pw->panner.knob_x + pad + lw); + r->y = (short)(pw->panner.knob_y + pad + pw->panner.knob_height); + r->width = (unsigned short)(pw->panner.knob_width - lw + pw->panner.shadow_thickness); + r->height = (unsigned short)(pw->panner.shadow_thickness); pw->panner.shadow_valid = True; return; } @@ -528,10 +526,10 @@ rescale(PannerWidget pw) static void get_default_size(PannerWidget pw, Dimension *wp, Dimension *hp) { - Dimension pad = pw->panner.internal_border << 1; + Dimension pad = (Dimension)(pw->panner.internal_border << 1); - *wp = PANNER_DSCALE(pw, pw->panner.canvas_width) + pad; - *hp = PANNER_DSCALE(pw, pw->panner.canvas_height) + pad; + *wp = (Dimension)(PANNER_DSCALE(pw, pw->panner.canvas_width) + pad); + *hp = (Dimension)(PANNER_DSCALE(pw, pw->panner.canvas_height) + pad); } static Bool @@ -618,10 +616,10 @@ parse_page_string(char *s, int pagesize, int canvassize, Bool *relative) { \ XDrawRectangle(XtDisplay(pw), XtWindow(pw), \ pw->panner.xor_gc, \ - pw->panner.tmp.x + pw->panner.internal_border, \ - pw->panner.tmp.y + pw->panner.internal_border, \ - pw->panner.knob_width - 1, \ - pw->panner.knob_height - 1); \ + (pw->panner.tmp.x + pw->panner.internal_border), \ + (pw->panner.tmp.y + pw->panner.internal_border), \ + (unsigned)(pw->panner.knob_width - 1), \ + (unsigned)(pw->panner.knob_height - 1)); \ pw->panner.tmp.showing = !pw->panner.tmp.showing; \ } @@ -686,7 +684,7 @@ XawPannerRealize(Widget gw, XtValueMask *valuemaskp, if (PIXMAP_OKAY(pm)) { attr->background_pixmap = pm; *valuemaskp |= CWBackPixmap; - *valuemaskp &= ~CWBackPixel; + *valuemaskp &= (XtValueMask)(~CWBackPixel); gotpm = True; } } @@ -721,7 +719,7 @@ XawPannerRedisplay(Widget gw, XEvent *event, Region region) Window w = XtWindow(gw); int pad = pw->panner.internal_border; Dimension lw = pw->panner.line_width; - Dimension extra = pw->panner.shadow_thickness + (lw << 1); + Dimension extra = (Dimension)(pw->panner.shadow_thickness + (lw << 1)); int kx = pw->panner.knob_x + pad, ky = pw->panner.knob_y + pad; if (Superclass->core_class.expose) @@ -731,18 +729,20 @@ XawPannerRedisplay(Widget gw, XEvent *event, Region region) XClearArea(XtDisplay(pw), XtWindow(pw), (int)pw->panner.last_x - ((int)lw) + pad, (int)pw->panner.last_y - ((int)lw) + pad, - pw->panner.knob_width + extra, - pw->panner.knob_height + extra, + (unsigned)(pw->panner.knob_width + extra), + (unsigned)(pw->panner.knob_height + extra), False); pw->panner.last_x = pw->panner.knob_x; pw->panner.last_y = pw->panner.knob_y; XFillRectangle(dpy, w, pw->panner.slider_gc, kx, ky, - pw->panner.knob_width - 1, pw->panner.knob_height - 1); + (unsigned)(pw->panner.knob_width - 1), + (unsigned)(pw->panner.knob_height - 1)); if (lw) XDrawRectangle(dpy, w, pw->panner.shadow_gc, kx, ky, - pw->panner.knob_width - 1, pw->panner.knob_height - 1); + (unsigned)(pw->panner.knob_width - 1), + (unsigned)(pw->panner.knob_height - 1)); if (pw->panner.shadow_valid) XFillRectangles(dpy, w, pw->panner.shadow_gc, pw->panner.shadow_rects, 2); @@ -830,7 +830,7 @@ XawPannerSetValues(Widget gcur, Widget greq, Widget gnew, } } - return (redisplay); + return (Boolean)(redisplay); } static void @@ -878,8 +878,8 @@ ActionStart(Widget gw, XEvent *event, String *params, Cardinal *num_params) pw->panner.tmp.doing = True; pw->panner.tmp.startx = pw->panner.knob_x; pw->panner.tmp.starty = pw->panner.knob_y; - pw->panner.tmp.dx = x - pw->panner.knob_x; - pw->panner.tmp.dy = y - pw->panner.knob_y; + pw->panner.tmp.dx = (Position)(x - pw->panner.knob_x); + pw->panner.tmp.dy = (Position)(y - pw->panner.knob_y); pw->panner.tmp.x = pw->panner.knob_x; pw->panner.tmp.y = pw->panner.knob_y; if (pw->panner.rubber_band) @@ -894,8 +894,8 @@ ActionStop(Widget gw, XEvent *event, String *params, Cardinal *num_params) int x, y; if (get_event_xy(pw, event, &x, &y)) { - pw->panner.tmp.x = x - pw->panner.tmp.dx; - pw->panner.tmp.y = y - pw->panner.tmp.dy; + pw->panner.tmp.x = (Position)(x - pw->panner.tmp.dx); + pw->panner.tmp.y = (Position)(y - pw->panner.tmp.dy); if (!pw->panner.allow_off) check_knob(pw, False); } @@ -939,8 +939,8 @@ ActionMove(Widget gw, XEvent *event, String *params, Cardinal *num_params) if (pw->panner.rubber_band) UNDRAW_TMP(pw); - pw->panner.tmp.x = x - pw->panner.tmp.dx; - pw->panner.tmp.y = y - pw->panner.tmp.dy; + pw->panner.tmp.x = (Position)(x - pw->panner.tmp.dx); + pw->panner.tmp.y = (Position)(y - pw->panner.tmp.dy); if (!pw->panner.rubber_band) ActionNotify(gw, event, params, num_params); @@ -987,8 +987,8 @@ ActionPage(Widget gw, XEvent *event, String *params, Cardinal *num_params) } else { pw->panner.tmp.doing = True; - pw->panner.tmp.x = x; - pw->panner.tmp.y = y; + pw->panner.tmp.x = (Position)x; + pw->panner.tmp.y = (Position)y; ActionNotify(gw, event, NULL, &zero); pw->panner.tmp.doing = False; } @@ -1017,14 +1017,14 @@ ActionNotify(Widget gw, XEvent *event, String *params, Cardinal *num_params) Position tmp; if (pw->panner.slider_x - > (tmp = (Position)pw->panner.canvas_width - - (Position)pw->panner.slider_width)) + > (tmp = (Position)(pw->panner.canvas_width - + pw->panner.slider_width))) pw->panner.slider_x = tmp; if (pw->panner.slider_x < 0) pw->panner.slider_x = 0; if (pw->panner.slider_y - > (tmp = (Position)pw->panner.canvas_height - - (Position)pw->panner.slider_height)) + > (tmp = (Position)(pw->panner.canvas_height - + pw->panner.slider_height))) pw->panner.slider_y = tmp; if (pw->panner.slider_y < 0) pw->panner.slider_y = 0; diff --git a/src/Pixmap.c b/src/Pixmap.c index d2fa1ef02a46ed2dc72adb245dba14e156d38d85..a359bb92c963f81b39ecbc3ac831e6e2385f316d 100644 --- a/src/Pixmap.c +++ b/src/Pixmap.c @@ -213,7 +213,7 @@ XawParseParamsString(String name) ++xaw_params->num_args; xaw_params->args = (XawArgVal **) XtRealloc((char *)xaw_params->args, - sizeof(XawArgVal*) * xaw_params->num_args); + (Cardinal)(sizeof(XawArgVal*) * (size_t)xaw_params->num_args)); } xaw_params->args[xaw_params->num_args - 1] = xaw_arg; } @@ -359,7 +359,7 @@ XawAddPixmapLoader(String type, String ext, XawPixmapLoader loader) ++num_loader_info; loader_info = (XawPixmapLoaderInfo**) XtRealloc((char *)loader_info, - sizeof(XawPixmapLoaderInfo) * num_loader_info); + (Cardinal)(sizeof(XawPixmapLoaderInfo) * (size_t)num_loader_info)); } loader_info[num_loader_info - 1] = info; @@ -401,8 +401,8 @@ bcmp_x_cache(register _Xconst void *pixmap, register _Xconst void *xaw) static int qcmp_long(register _Xconst void *left, register _Xconst void *right) { - return ((long)((*(XawCache **)left)->value) - - (long)((*(XawCache **)right)->value)); + return (int)((long)((*(XawCache **)left)->value) - + (long)((*(XawCache **)right)->value)); } static int @@ -415,7 +415,7 @@ qcmp_string(register _Xconst void *left, register _Xconst void *right) static int bcmp_long(register _Xconst void *value, register _Xconst void *cache) { - return ((long)value - (long)((*(XawCache **)cache)->value)); + return (int)((long)value - (long)((*(XawCache **)cache)->value)); } static int @@ -490,7 +490,7 @@ _XawGetCache(XawCache *xaw, Screen *screen, Colormap colormap, int depth) ++xaw->num_elems; xaw->elems = (XtPointer*) XtRealloc((char *)xaw->elems, - sizeof(XtPointer) * xaw->num_elems); + (Cardinal)(sizeof(XtPointer) * (size_t)xaw->num_elems)); } pcache->value = (long)screen; pcache->elems = NULL; @@ -516,7 +516,7 @@ _XawGetCache(XawCache *xaw, Screen *screen, Colormap colormap, int depth) ++s_cache->num_elems; s_cache->elems = (XtPointer*) XtRealloc((char *)s_cache->elems, - sizeof(XtPointer) * s_cache->num_elems); + (Cardinal)(sizeof(XtPointer) * s_cache->num_elems)); } pcache->value = (long)colormap; pcache->elems = NULL; @@ -543,7 +543,7 @@ _XawGetCache(XawCache *xaw, Screen *screen, Colormap colormap, int depth) ++c_cache->num_elems; c_cache->elems = (XtPointer*) XtRealloc((char *)c_cache->elems, - sizeof(XtPointer) * c_cache->num_elems); + (Cardinal)(sizeof(XtPointer) * c_cache->num_elems)); } pcache->value = (long)depth; pcache->elems = NULL; @@ -622,8 +622,8 @@ _XawCachePixmap(XawPixmap *pixmap, { ++xaw_cache->num_elems; xaw_cache->elems = (XtPointer*)XtRealloc((char *)xaw_cache->elems, - sizeof(XtPointer) * - xaw_cache->num_elems); + (Cardinal)(sizeof(XtPointer) * + xaw_cache->num_elems)); } xaw_cache->elems[xaw_cache->num_elems - 1] = (XtPointer)pixmap; @@ -641,8 +641,8 @@ _XawCachePixmap(XawPixmap *pixmap, { ++x_cache->num_elems; x_cache->elems = (XtPointer*)XtRealloc((char *)x_cache->elems, - sizeof(XtPointer) * - x_cache->num_elems); + (Cardinal)(sizeof(XtPointer) * + x_cache->num_elems)); } x_cache->elems[x_cache->num_elems - 1] = (XtPointer)pixmap; @@ -679,18 +679,18 @@ GetResourcePixmapPath(Display *display) char *tok, *buffer = XtNewString(value.addr); for (tok = strtok(buffer, ":"); tok; tok = strtok(NULL, ":")) { - int toklen = strlen(tok); + int toklen = (int)strlen(tok); if (toklen) { - pixmap_path = XtRealloc(pixmap_path, length + toklen + 5); + pixmap_path = XtRealloc(pixmap_path, (Cardinal)(length + toklen + 5)); strcpy(pixmap_path + length, tok); if (length) pixmap_path[length++] = ':'; sprintf(pixmap_path + length, "%s/%%N", tok); - length += strlen(tok) + 3; + length = (length + (int)strlen(tok) + 3); } } - pixmap_path = XtRealloc(pixmap_path, length + strlen(default_path) + 2); + pixmap_path = XtRealloc(pixmap_path, (Cardinal)((size_t)length + strlen(default_path) + 2)); if (length) pixmap_path[length++] = ':'; strcpy(pixmap_path + length, default_path); @@ -762,13 +762,13 @@ BitmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth, pixmap = XCreatePixmapFromBitmapData(DisplayOfScreen(screen), RootWindowOfScreen(screen), (char *)data, - width, height, fg, bg, depth); + width, height, fg, bg, (unsigned)depth); if (data) XFree(data); *pixmap_return = pixmap; *mask_return = None; - *width_return = width; - *height_return = height; + *width_return = (Dimension)width; + *height_return = (Dimension)height; retval = True; } @@ -850,8 +850,8 @@ GradientLoader(XawParams *params, Screen *screen, Colormap colormap, int depth, if ((pixmap = XCreatePixmap(DisplayOfScreen(screen), RootWindowOfScreen(screen), - orientation == VERTICAL ? 1 : dimension, - orientation == VERTICAL ? dimension : 1, depth)) + (unsigned)(orientation == VERTICAL ? 1 : dimension), + (unsigned)(orientation == VERTICAL ? dimension : 1), (unsigned)depth)) == 0) return (False); @@ -916,8 +916,8 @@ GradientLoader(XawParams *params, Screen *screen, Colormap colormap, int depth, *pixmap_return = pixmap; *mask_return = None; - *width_return = orientation == VERTICAL ? 1 : dimension; - *height_return = orientation == VERTICAL ? dimension : 1; + *width_return = (Dimension)(orientation == VERTICAL ? 1 : dimension); + *height_return = (Dimension)(orientation == VERTICAL ? dimension : 1); XFreeGC(DisplayOfScreen(screen), gc); @@ -942,7 +942,7 @@ XPixmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth, if ((argval = XawFindArgVal(params, "closeness")) != NULL && argval->value) - closeness = atoi(argval->value); + closeness = (unsigned)atoi(argval->value); if (params->name[0] != '/' && params->name[0] != '.') { @@ -965,8 +965,8 @@ XPixmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth, RootWindowOfScreen(screen), filename, pixmap_return, mask_return, &xpm_attributes) == XpmSuccess) { - *width_return = xpm_attributes.width; - *height_return = xpm_attributes.height; + *width_return = (Dimension)xpm_attributes.width; + *height_return = (Dimension)xpm_attributes.height; return (True); } diff --git a/src/Porthole.c b/src/Porthole.c index 4842e70d7895995c4fdd829196daaf863684919f..c87be98b5f91e5b4560a25a6c9ec91be060ba1f4 100644 --- a/src/Porthole.c +++ b/src/Porthole.c @@ -156,8 +156,8 @@ SendReport(PortholeWidget pw, unsigned int changed) XawPannerReport prep; prep.changed = changed; - prep.slider_x = -XtX(child); /* porthole is "inner" */ - prep.slider_y = -XtY(child); /* child is outer since it is larger */ + prep.slider_x = (Position)(-XtX(child)); /* porthole is "inner" */ + prep.slider_y = (Position)(-XtY(child)); /* child is outer since it is larger */ prep.slider_width = XtWidth(pw); prep.slider_height = XtHeight(pw); prep.canvas_width = XtWidth(child); @@ -199,8 +199,8 @@ layout_child(PortholeWidget pw, Widget child, XtWidgetGeometry *geomp, * Make sure that the child is still on the screen. Note that this must * be done *after* the size computation so that we know where to put it */ - minx = (Position)XtWidth(pw) - (Position)*widthp; - miny = (Position)XtHeight(pw) - (Position)*heightp; + minx = (Position)(XtWidth(pw) - *widthp); + miny = (Position)(XtHeight(pw) - *heightp); if (*xp < minx) *xp = minx; diff --git a/src/Private.h b/src/Private.h index ca70d5f3035187c48a1a056c4ae51e47fc0f68ff..9067204de981f1fef1c2bf93ae04447995ea480b 100644 --- a/src/Private.h +++ b/src/Private.h @@ -35,7 +35,7 @@ #define XawStackAlloc(size, stk_buffer) \ ((size) <= sizeof(stk_buffer) \ ? (XtPointer)(stk_buffer) \ - : XtMalloc((unsigned)(size))) + : XtMalloc((Cardinal)(size))) #define XawStackFree(pointer, stk_buffer) \ do { \ diff --git a/src/Repeater.c b/src/Repeater.c index 9b16ced7cab8597c2acfb0a6d3a349a8c4be4a94..65d9e6e1f20691d889d1efad0b0e1e32ee09226f 100644 --- a/src/Repeater.c +++ b/src/Repeater.c @@ -228,7 +228,7 @@ tic(XtPointer client_data, XtIntervalId *id) } DO_CALLBACK(rw); - rw->repeater.timer = ADD_TIMEOUT(rw, rw->repeater.next_delay); + rw->repeater.timer = ADD_TIMEOUT(rw, (unsigned long)rw->repeater.next_delay); if (rw->repeater.decay) { rw->repeater.next_delay -= rw->repeater.decay; @@ -282,7 +282,7 @@ ActionStart(Widget gw, XEvent *event, String *params, Cardinal *num_params) XtCallCallbackList(gw, rw->repeater.start_callbacks, NULL); DO_CALLBACK(rw); - rw->repeater.timer = ADD_TIMEOUT(rw, rw->repeater.initial_delay); + rw->repeater.timer = ADD_TIMEOUT(rw, (unsigned long)rw->repeater.initial_delay); rw->repeater.next_delay = rw->repeater.repeat_delay; } diff --git a/src/Scrollbar.c b/src/Scrollbar.c index 5e4fdcf471c701782a2f1c922d4f22d9055697db..d1893840710eb287037647192016e1a58b0853a2 100644 --- a/src/Scrollbar.c +++ b/src/Scrollbar.c @@ -363,7 +363,7 @@ FractionLoc(ScrollbarWidget w, int x, int y) { float result; - result = PICKLENGTH(w, x / (float)XtWidth(w), y / (float)XtHeight(w)); + result = PICKLENGTH(w, (float)x / (float)XtWidth(w), (float)y / (float)XtHeight(w)); return (FloatInRange(result, 0.0, 1.0)); } @@ -382,26 +382,26 @@ FillArea(ScrollbarWidget w, int top, int bottom, int thumb) if (bottom <= top) return; - length = bottom - top; + length = (Dimension)(bottom - top); switch(thumb) { /* Fill the new Thumb location */ case 1: if (w->scrollbar.orientation == XtorientHorizontal) XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc, - top, 1, length, XtHeight(w) - 2); + top, 1, length, (unsigned)(XtHeight(w) - 2)); else XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc, - 1, top, XtWidth(w) - 2, length); + 1, top, (unsigned)(XtWidth(w) - 2), length); break; /* Clear the old Thumb location */ case 0: if (w->scrollbar.orientation == XtorientHorizontal) XClearArea(XtDisplay(w), XtWindow(w), - top, 1, length, XtHeight(w) - 2, False); + top, 1, length, (unsigned)(XtHeight(w) - 2), False); else XClearArea(XtDisplay(w), XtWindow(w), - 1, top, XtWidth(w) - 2, length, False); + 1, top, (unsigned)(XtWidth(w) - 2), length, False); break; } } @@ -416,13 +416,13 @@ PaintThumb(ScrollbarWidget w) Position oldtop, oldbot, newtop, newbot; oldtop = w->scrollbar.topLoc; - oldbot = oldtop + w->scrollbar.shownLength; - newtop = w->scrollbar.length * w->scrollbar.top; - newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown); + oldbot = (Position)(oldtop + w->scrollbar.shownLength); + newtop = (Position)(w->scrollbar.length * w->scrollbar.top); + newbot = (Position)(newtop + (int)(w->scrollbar.length * w->scrollbar.shown)); if (newbot < newtop + (int)w->scrollbar.min_thumb) - newbot = newtop + w->scrollbar.min_thumb; + newbot = (Position)(newtop + w->scrollbar.min_thumb); w->scrollbar.topLoc = newtop; - w->scrollbar.shownLength = newbot - newtop; + w->scrollbar.shownLength = (Dimension)(newbot - newtop); if (XtIsRealized((Widget)w)) { if (newtop < oldtop) @@ -595,20 +595,20 @@ XawScrollbarRedisplay(Widget gw, XEvent *event, Region region) if (w->scrollbar.orientation == XtorientHorizontal) { x = w->scrollbar.topLoc; y = 1; - width = w->scrollbar.shownLength; - height = XtHeight(w) - 2; + width = (unsigned)(w->scrollbar.shownLength); + height = (unsigned)(XtHeight(w) - 2); } else { x = 1; y = w->scrollbar.topLoc; - width = XtWidth(w) - 2; - height = w->scrollbar.shownLength; + width = (unsigned)(XtWidth(w) - 2); + height = (unsigned)(w->scrollbar.shownLength); } if (region == NULL || XRectInRegion(region, x, y, width, height) != RectangleOut) { /* Forces entire thumb to be painted */ - w->scrollbar.topLoc = -(w->scrollbar.length + 1); + w->scrollbar.topLoc = (Position)(-(w->scrollbar.length + 1)); PaintThumb(w); } } @@ -729,23 +729,23 @@ ExtractPosition(XEvent *event, Position *x, Position *y) { switch(event->type) { case MotionNotify: - *x = event->xmotion.x; - *y = event->xmotion.y; + *x = (Position)event->xmotion.x; + *y = (Position)event->xmotion.y; break; case ButtonPress: case ButtonRelease: - *x = event->xbutton.x; - *y = event->xbutton.y; + *x = (Position)event->xbutton.x; + *y = (Position)event->xbutton.y; break; case KeyPress: case KeyRelease: - *x = event->xkey.x; - *y = event->xkey.y; + *x = (Position)event->xkey.x; + *y = (Position)event->xkey.y; break; case EnterNotify: case LeaveNotify: - *x = event->xcrossing.x; - *y = event->xcrossing.y; + *x = (Position)event->xcrossing.x; + *y = (Position)event->xcrossing.y; break; default: *x = 0; @@ -876,9 +876,16 @@ XawScrollbarSetThumb(Widget gw, if (w->scrollbar.direction == 'c') /* if still thumbing */ return; - w->scrollbar.top = top > 1.0 ? 1.0 : top >= 0.0 ? top : w->scrollbar.top; - - w->scrollbar.shown = shown > 1.0 ? 1.0 : shown >= 0.0 ? - shown : w->scrollbar.shown; + w->scrollbar.top = (float)((top > 1.0) + ? 1.0 + : ((top >= 0.0) + ? top + : w->scrollbar.top)); + + w->scrollbar.shown = (float)((shown > 1.0) + ? 1.0 + : (shown >= 0.0 + ? shown + : w->scrollbar.shown)); PaintThumb(w); } diff --git a/src/Simple.c b/src/Simple.c index be5597b2b9eb5cb0e5071bcd669f73c0874b15f3..74083bbe3d9c8580304ff3b1484788981a61e19f 100644 --- a/src/Simple.c +++ b/src/Simple.c @@ -328,7 +328,7 @@ XawSimpleRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes) w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border; *valueMask |= CWBorderPixmap; - *valueMask &= ~CWBorderPixel; + *valueMask &= (Mask)(~CWBorderPixel); } ConvertCursor(w); @@ -345,7 +345,7 @@ XawSimpleRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes) #ifndef OLDXAW if (w->core.background_pixmap > XtUnspecifiedPixmap) { pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w), - w->core.colormap, w->core.depth); + w->core.colormap, (int)w->core.depth); if (pixmap && pixmap->mask) XawReshapeWidget(w, pixmap); } @@ -376,7 +376,7 @@ ConvertCursor(Widget w) return; from.addr = (XPointer)simple->simple.cursor_name; - from.size = strlen((char *)from.addr) + 1; + from.size = (unsigned)strlen((char *)from.addr) + 1; to.size = sizeof(Cursor); to.addr = (XPointer)&cursor; @@ -434,10 +434,10 @@ XawSimpleSetValues(Widget current, Widget request, Widget cnew, opix = XawPixmapFromXPixmap(s_old->core.background_pixmap, XtScreen(s_old), s_old->core.colormap, - s_old->core.depth); + (int)s_old->core.depth); npix = XawPixmapFromXPixmap(s_new->core.background_pixmap, XtScreen(s_new), s_new->core.colormap, - s_new->core.depth); + (int)s_new->core.depth); if ((npix && npix->mask) || (opix && opix->mask)) XawReshapeWidget(cnew, npix); } diff --git a/src/SimpleMenu.c b/src/SimpleMenu.c index 8defdf7d3af915f7d34c1b002a5cd8dd28eb638a..4a1548dfa49229ada583d19af28396f497efe663 100644 --- a/src/SimpleMenu.c +++ b/src/SimpleMenu.c @@ -518,14 +518,14 @@ XawSimpleMenuRealize(Widget w, XtValueMask *mask, XSetWindowAttributes *attrs) attrs->backing_store = smw->simple_menu.backing_store; } else - *mask &= ~CWBackingStore; + *mask &= (XtValueMask)(~CWBackingStore); (*Superclass->core_class.realize)(w, mask, attrs); #ifndef OLDXAW if (w->core.background_pixmap > XtUnspecifiedPixmap) { pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w), - w->core.colormap, w->core.depth); + w->core.colormap, (int)w->core.depth); if (pixmap && pixmap->mask) XawReshapeWidget(w, pixmap); } @@ -622,10 +622,10 @@ XawSimpleMenuSetValues(Widget current, Widget request, Widget cnew, opix = XawPixmapFromXPixmap(smw_old->core.background_pixmap, XtScreen(smw_old), smw_old->core.colormap, - smw_old->core.depth); + (int)smw_old->core.depth); npix = XawPixmapFromXPixmap(smw_new->core.background_pixmap, XtScreen(smw_new), smw_new->core.colormap, - smw_new->core.depth); + (int)smw_new->core.depth); if ((npix && npix->mask) || (opix && opix->mask)) XawReshapeWidget(cnew, npix); } @@ -814,19 +814,19 @@ PositionMenuAction(Widget w, XEvent *event, switch (event->type) { case ButtonPress: case ButtonRelease: - loc.x = event->xbutton.x_root; - loc.y = event->xbutton.y_root; + loc.x = (short)event->xbutton.x_root; + loc.y = (short)event->xbutton.y_root; PositionMenu(menu, &loc); break; case EnterNotify: case LeaveNotify: - loc.x = event->xcrossing.x_root; - loc.y = event->xcrossing.y_root; + loc.x = (short)event->xcrossing.x_root; + loc.y = (short)event->xcrossing.y_root; PositionMenu(menu, &loc); break; case MotionNotify: - loc.x = event->xmotion.x_root; - loc.y = event->xmotion.y_root; + loc.x = (short)event->xmotion.x_root; + loc.y = (short)event->xmotion.y_root; PositionMenu(menu, &loc); break; default: @@ -1065,7 +1065,7 @@ CreateLabel(Widget w) next_child = NULL; for (child = smw->composite.children + smw->composite.num_children, - i = smw->composite.num_children; i > 0; i--, child--) { + i = (int)smw->composite.num_children; i > 0; i--, child--) { if (next_child != NULL) *next_child = *child; next_child = child; @@ -1156,17 +1156,17 @@ Layout(Widget w, Dimension *width_ret, Dimension *height_ret) widths = (Dimension *)XtMalloc(sizeof(Dimension)); #ifndef OLDXAW - hadd = smw->simple_menu.left_margin; + hadd = (short)smw->simple_menu.left_margin; #else hadd = 0; #endif - vadd = smw->simple_menu.top_margin; + vadd = (short)smw->simple_menu.top_margin; if (smw->simple_menu.label) - vadd += XtHeight(smw->simple_menu.label); + vadd = (short)(vadd + XtHeight(smw->simple_menu.label)); count = 1; - width = tmp_w = tmp_h = n = 0; - height = vadd; + width = (Dimension)(tmp_w = tmp_h = (int)(n = 0)); + height = (Dimension)vadd; for (i = smw->simple_menu.label ? 1 : 0; i < smw->composite.num_children; @@ -1181,38 +1181,38 @@ Layout(Widget w, Dimension *width_ret, Dimension *height_ret) > XtHeight(smw))) { ++count; widths = (Dimension *)XtRealloc((char *)widths, - sizeof(Dimension) * count); - widths[count - 1] = width_kid; - width += tmp_w; + (Cardinal)(sizeof(Dimension) * count)); + widths[count - 1] = (Dimension)width_kid; + width = (Dimension)(width + tmp_w); tmp_w = width_kid; - height = height_kid + vadd; + height = (Dimension)(height_kid + vadd); } else - height += height_kid; + height = (Dimension)(height + height_kid); if (height > tmp_h) tmp_h = height; if (width_kid > tmp_w) - widths[count - 1] = tmp_w = width_kid; + widths[count - 1] = (Dimension)(tmp_w = width_kid); ++n; } - height = tmp_h + smw->simple_menu.bottom_margin; - width += tmp_w; + height = (tmp_h + smw->simple_menu.bottom_margin); + width = (Dimension)(width + tmp_w); if (smw->simple_menu.label && width < XtWidth(smw->simple_menu.label)) { float inc; - inc = (XtWidth(smw->simple_menu.label) - width) / (float)count; + inc = (float)(XtWidth(smw->simple_menu.label) - width) / (float)count; width = XtWidth(smw->simple_menu.label); for (n = 0; n < count; n++) - widths[n] += inc; + widths[n] = (Dimension)(widths[n] + inc); } #ifndef OLDXAW - width += hadd + smw->simple_menu.right_margin; + width = (Dimension)(width + (hadd + smw->simple_menu.right_margin)); #endif - x_ins = n = count = 0; + x_ins = (short)(n = count = 0); tmp_w = widths[0]; tmp_h = vadd; @@ -1227,19 +1227,19 @@ Layout(Widget w, Dimension *width_ret, Dimension *height_ret) if (n && (tmp_h + height_kid + smw->simple_menu.bottom_margin > XtHeight(smw))) { - x_ins = tmp_w; + x_ins = (short)tmp_w; y_ins = vadd; ++count; tmp_w += widths[count]; tmp_h = height_kid + vadd; } else { - y_ins = tmp_h; + y_ins = (short)tmp_h; tmp_h += height_kid; } ++n; - XtX(kid) = x_ins + hadd; + XtX(kid) = (Position)(x_ins + hadd); XtY(kid) = y_ins; XtWidth(kid) = widths[count]; } @@ -1251,12 +1251,12 @@ Layout(Widget w, Dimension *width_ret, Dimension *height_ret) if (smw->simple_menu.label) { XtX(smw->simple_menu.label) = 0; - XtY(smw->simple_menu.label) = smw->simple_menu.top_margin; - XtWidth(smw->simple_menu.label) = XtWidth(smw) + XtY(smw->simple_menu.label) = (Position)smw->simple_menu.top_margin; + XtWidth(smw->simple_menu.label) = (Dimension)(XtWidth(smw) #ifndef OLDXAW - (smw->simple_menu.left_margin + smw->simple_menu.right_margin) #endif - ; + ); } if (current_entry) { if (width_ret) @@ -1355,7 +1355,7 @@ PositionMenu(Widget w, XPoint *location) */ XtRealizeWidget(w); - location->x -= XtWidth(w) >> 1; + location->x = (short)(location->x - (XtWidth(w) >> 1)); if (smw->simple_menu.popup_entry == NULL) entry = smw->simple_menu.label; @@ -1363,7 +1363,7 @@ PositionMenu(Widget w, XPoint *location) entry = smw->simple_menu.popup_entry; if (entry != NULL) - location->y -= XtY(entry) + (XtHeight(entry) >> 1); + location->y = (short)(location->y - (XtY(entry) + (XtHeight(entry) >> 1))); MoveMenu(w, location->x, location->y); } @@ -1596,7 +1596,7 @@ GetEventEntry(Widget w, XEvent *event) move = warp = 0; if (move) - XtMoveWidget(w, XtX(w) + move, XtY(w)); + XtMoveWidget(w, (Position)(XtX(w) + move), XtY(w)); if (warp) XWarpPointer(XtDisplay(w), None, None, 0, 0, 0, 0, warp, 0); @@ -1616,13 +1616,13 @@ CalculateNewSize(Widget w, Dimension *width_return, Dimension *height_return) Boolean try_layout = False; #ifndef OLDXAW - hadd = xaw->simple_menu.left_margin + xaw->simple_menu.right_margin; + hadd = (short)(xaw->simple_menu.left_margin + xaw->simple_menu.right_margin); #else hadd = 0; #endif - vadd = xaw->simple_menu.top_margin + xaw->simple_menu.bottom_margin; + vadd = (short)(xaw->simple_menu.top_margin + xaw->simple_menu.bottom_margin); if (xaw->simple_menu.label) - vadd += XtHeight(xaw->simple_menu.label); + vadd = (short)(vadd + XtHeight(xaw->simple_menu.label)); if (*height_return) max_dim = *height_return; @@ -1674,8 +1674,8 @@ CalculateNewSize(Widget w, Dimension *width_return, Dimension *height_return) if (xaw->simple_menu.label) width = XawMax(width, XtWidth(xaw->simple_menu.label) + hadd); - *width_return = width; - *height_return = height; + *width_return = (Dimension)width; + *height_return = (Dimension)height; if (try_layout && columns > 1 && num_children > 2) { int space; @@ -1690,7 +1690,7 @@ CalculateNewSize(Widget w, Dimension *width_return, Dimension *height_return) height = max_dim - space / columns; if (height % test_h) height += test_h - (height % test_h); - *height_return = height + vadd; + *height_return = (Dimension)(height + vadd); CalculateNewSize(w, width_return, height_return); } } @@ -1762,17 +1762,21 @@ PopupSubMenu(SimpleMenuWidget smw) popleft = (smw->simple_menu.state & SMW_POPLEFT) != 0; if (popleft) - XtTranslateCoords((Widget)smw, -(int)XtWidth(menu), - XtY(entry) - XtBorderWidth(menu), &menu_x, &menu_y); + XtTranslateCoords((Widget)smw, + (Position)(-(int)XtWidth(menu)), + (Position)(XtY(entry) - XtBorderWidth(menu)), + &menu_x, &menu_y); else - XtTranslateCoords((Widget)smw, XtWidth(smw), XtY(entry) - - XtBorderWidth(menu), &menu_x, &menu_y); + XtTranslateCoords((Widget)smw, + (Position)XtWidth(smw), + (Position)(XtY(entry) - XtBorderWidth(menu)), + &menu_x, &menu_y); if (!popleft && menu_x >= 0) { int scr_width = WidthOfScreen(XtScreen(menu)); if (menu_x + XtWidth(menu) > scr_width) { - menu_x -= XtWidth(menu) + XtWidth(smw); + menu_x = (Position)(menu_x - (XtWidth(menu) + XtWidth(smw))); popleft = True; } } @@ -1784,7 +1788,7 @@ PopupSubMenu(SimpleMenuWidget smw) int scr_height = HeightOfScreen(XtScreen(menu)); if (menu_y + XtHeight(menu) > scr_height) - menu_y = scr_height - XtHeight(menu) - XtBorderWidth(menu); + menu_y = (Position)(scr_height - XtHeight(menu) - XtBorderWidth(menu)); } if (menu_y < 0) menu_y = 0; @@ -1797,7 +1801,7 @@ PopupSubMenu(SimpleMenuWidget smw) if (popleft) ((SimpleMenuWidget)menu)->simple_menu.state |= SMW_POPLEFT; else - ((SimpleMenuWidget)menu)->simple_menu.state &= ~SMW_POPLEFT; + ((SimpleMenuWidget)menu)->simple_menu.state &= (unsigned char)(~SMW_POPLEFT); XtPopup(menu, XtGrabNone); } @@ -1824,6 +1828,6 @@ PopupCB(Widget w, XtPointer client_data, XtPointer call_data) { SimpleMenuWidget smw = (SimpleMenuWidget)w; - smw->simple_menu.state &= ~(SMW_UNMAPPING | SMW_POPLEFT); + smw->simple_menu.state &= (unsigned char)(~(SMW_UNMAPPING | SMW_POPLEFT)); } #endif /* OLDXAW */ diff --git a/src/SmeBSB.c b/src/SmeBSB.c index 52a789ae8675b2130f6d38ccdfedc960390a7c30..0b4f94f17ed37a998d1e63998f6f4c97d86ff221 100644 --- a/src/SmeBSB.c +++ b/src/SmeBSB.c @@ -348,7 +348,7 @@ XawSmeBSBRedisplay(Widget w, XEvent *event, Region region) if (entry->sme_bsb.label != NULL) { int x_loc = entry->sme_bsb.left_margin; - int len = strlen(entry->sme_bsb.label); + int len = (int)strlen(entry->sme_bsb.label); char *label = entry->sme_bsb.label; int width, t_width; @@ -573,28 +573,28 @@ GetDefaultSize(Widget w, Dimension *width, Dimension *height) if (entry->sme_bsb.label == NULL) *width = 0; else - *width = XmbTextEscapement(entry->sme_bsb.fontset, + *width = (Dimension)XmbTextEscapement(entry->sme_bsb.fontset, entry->sme_bsb.label, - strlen(entry->sme_bsb.label)); - *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin; + (int)strlen(entry->sme_bsb.label)); + *width = (Dimension)(*width + (entry->sme_bsb.left_margin + entry->sme_bsb.right_margin)); *height = ext->max_ink_extent.height; - *height = ((int)*height * (ONE_HUNDRED + - entry->sme_bsb.vert_space)) / ONE_HUNDRED; + *height = (Dimension)(((int)*height * (ONE_HUNDRED + + entry->sme_bsb.vert_space)) / ONE_HUNDRED); } else { if (entry->sme_bsb.label == NULL) *width = 0; else - *width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label, - strlen(entry->sme_bsb.label)); + *width = (Dimension)XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label, + (int)strlen(entry->sme_bsb.label)); - *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin; + *width = (Dimension)(*width + (entry->sme_bsb.left_margin + entry->sme_bsb.right_margin)); - *height = entry->sme_bsb.font->max_bounds.ascent + - entry->sme_bsb.font->max_bounds.descent; + *height = (Dimension)(entry->sme_bsb.font->max_bounds.ascent + + entry->sme_bsb.font->max_bounds.descent); - *height = ((int)*height * (ONE_HUNDRED + - entry->sme_bsb.vert_space)) / ONE_HUNDRED; + *height = (Dimension)(((int)*height * (ONE_HUNDRED + + entry->sme_bsb.vert_space)) / ONE_HUNDRED); } } @@ -678,16 +678,16 @@ GetBitmapInfo(Widget w, Bool is_left) XGetGeometry(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap, &root, &x, &y, &width, &height, &bw, &depth)) { - entry->sme_bsb.left_bitmap_width = width; - entry->sme_bsb.left_bitmap_height = height; + entry->sme_bsb.left_bitmap_width = (Dimension)width; + entry->sme_bsb.left_bitmap_height = (Dimension)height; } } else if (entry->sme_bsb.right_bitmap != None && XGetGeometry(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap, &root, &x, &y, &width, &height, &bw, &depth)) { - entry->sme_bsb.right_bitmap_width = width; - entry->sme_bsb.right_bitmap_height = height; + entry->sme_bsb.right_bitmap_width = (Dimension)width; + entry->sme_bsb.right_bitmap_height = (Dimension)height; } } diff --git a/src/StripChart.c b/src/StripChart.c index 401036bdf6af31c7061d8ed04ca609557ec83b2e..4b66c0a101bb1d57c72061794cd739c854e589ae 100644 --- a/src/StripChart.c +++ b/src/StripChart.c @@ -266,7 +266,7 @@ XawStripChartInitialize(Widget greq, Widget gnew, if (w->strip_chart.update > 0) w->strip_chart.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext(gnew), - w->strip_chart.update * MS_PER_SEC, + (unsigned long)(w->strip_chart.update * MS_PER_SEC), draw_it, (XtPointer)gnew); CreateGC(w, ALL_GCS); @@ -316,7 +316,7 @@ draw_it(XtPointer client_data, XtIntervalId *id) if (w->strip_chart.update > 0) w->strip_chart.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)w), - w->strip_chart.update * MS_PER_SEC,draw_it, + (unsigned long)(w->strip_chart.update * MS_PER_SEC), draw_it, client_data); if ((w->strip_chart.interval >= XtWidth(w)) || @@ -349,13 +349,13 @@ draw_it(XtPointer client_data, XtIntervalId *id) XFillRectangle(XtDisplay(w), XtWindow(w), w->strip_chart.fgGC, w->strip_chart.interval, y, - 1, XtHeight(w) - y); + 1, (unsigned)(XtHeight(w) - y)); /* * Fill in the graph lines we just painted over */ if (w->strip_chart.points != NULL) { - w->strip_chart.points[0].x = w->strip_chart.interval; + w->strip_chart.points[0].x = (short)w->strip_chart.interval; XDrawPoints(XtDisplay(w), XtWindow(w), w->strip_chart.hiGC, w->strip_chart.points, w->strip_chart.scale - 1, CoordModePrevious); @@ -386,7 +386,7 @@ repaint_window(StripChartWidget w, int left, int width) /* Compute the minimum scale required to graph the data, but don't go lower than min_scale */ if (w->strip_chart.interval != 0 || scale <= w->strip_chart.max_value) - scale = w->strip_chart.max_value + 1; + scale = (int)(w->strip_chart.max_value + 1); if (scale < w->strip_chart.min_scale) scale = w->strip_chart.min_scale; @@ -418,11 +418,11 @@ repaint_window(StripChartWidget w, int left, int width) /* Draw data point lines */ for (i = left; i < width; i++) { - int y = XtHeight(w) - (XtHeight(w) * w->strip_chart.valuedata[i]) - / w->strip_chart.scale; + int y = (int)(XtHeight(w) - (XtHeight(w) * w->strip_chart.valuedata[i]) + / w->strip_chart.scale); XFillRectangle(dpy, win, w->strip_chart.fgGC, - i, y, 1, XtHeight(w) - y); + i, y, 1, (unsigned)(XtHeight(w) - y)); } /* Draw graph reference lines */ @@ -471,7 +471,7 @@ MoveChart(StripChartWidget w, Bool blit) (void)memmove((char *)w->strip_chart.valuedata, (char *)(w->strip_chart.valuedata + next - j), - j * sizeof(double)); + (size_t)j * sizeof(double)); next = w->strip_chart.interval = j; /* @@ -495,10 +495,10 @@ MoveChart(StripChartWidget w, Bool blit) } XCopyArea(XtDisplay((Widget)w), XtWindow((Widget)w), XtWindow((Widget)w), - w->strip_chart.hiGC, (int)XtWidth(w) - j, 0, j, XtHeight(w), 0, 0); + w->strip_chart.hiGC, (int)XtWidth(w) - j, 0, (unsigned)j, XtHeight(w), 0, 0); XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w), - j, 0, XtWidth(w) - j, XtHeight(w), False); + j, 0, (unsigned)(XtWidth(w) - j), XtHeight(w), False); /* Draw graph reference lines */ left = j; @@ -525,7 +525,7 @@ XawStripChartSetValues(Widget current, Widget request, Widget cnew, if (w->strip_chart.update > 0) w->strip_chart.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext(cnew), - w->strip_chart.update * MS_PER_SEC, + (unsigned long)(w->strip_chart.update * MS_PER_SEC), draw_it, (XtPointer)w); } @@ -545,7 +545,7 @@ XawStripChartSetValues(Widget current, Widget request, Widget cnew, DestroyGC(old, new_gc); CreateGC(w, new_gc); - return (ret_val); + return (Boolean)(ret_val); } /* @@ -572,7 +572,7 @@ XawStripChartResize(Widget widget) return; } - size = sizeof(XPoint) * (w->strip_chart.scale - 1); + size = (Cardinal)(sizeof(XPoint) * (size_t)(w->strip_chart.scale - 1)); points = (XPoint *)XtRealloc((XtPointer)w->strip_chart.points, size); w->strip_chart.points = points; @@ -581,6 +581,6 @@ XawStripChartResize(Widget widget) for (i = 1; i < w->strip_chart.scale; i++) { points[i - 1].x = 0; - points[i - 1].y = XtHeight(w) / w->strip_chart.scale; + points[i - 1].y = (short)(XtHeight(w) / w->strip_chart.scale); } } diff --git a/src/Text.c b/src/Text.c index 81001226d7647f62b8661bf04538572d4569dd07..ff3efb8861ef959f22d9c07ef36b8c91b9bcd205 100644 --- a/src/Text.c +++ b/src/Text.c @@ -527,7 +527,7 @@ CvtScrollModeToString(Display *dpy, XrmValue *args, Cardinal *num_args, toVal->size = 0; return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; @@ -591,7 +591,7 @@ CvtWrapModeToString(Display *dpy, XrmValue *args, Cardinal *num_args, toVal->size = 0; return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; @@ -666,7 +666,7 @@ CvtJustifyModeToString(Display *dpy, XrmValue *args, Cardinal *num_args, toVal->size = 0; return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; @@ -687,9 +687,9 @@ static void XawTextClassInitialize(void) { if (!XawFmt8Bit) - FMT8BIT = XawFmt8Bit = XrmPermStringToQuark("FMT8BIT"); + FMT8BIT = XawFmt8Bit = (unsigned long)XrmPermStringToQuark("FMT8BIT"); if (!XawFmtWide) - XawFmtWide = XrmPermStringToQuark("FMTWIDE"); + XawFmtWide = (unsigned long)XrmPermStringToQuark("FMTWIDE"); XawInitializeWidgetSet(); @@ -739,12 +739,12 @@ PositionHScrollBar(TextWidget ctx) return; if (vbar != NULL) - x = XtWidth(vbar); + x = (Position)XtWidth(vbar); else - x = -XtBorderWidth(hbar); - y = XtHeight(ctx) - XtHeight(hbar) - XtBorderWidth(hbar); + x = (Position)(-XtBorderWidth(hbar)); + y = (Position)(XtHeight(ctx) - XtHeight(hbar) - XtBorderWidth(hbar)); if (vbar != NULL) { - width = XtWidth(ctx) - XtWidth(vbar) - XtBorderWidth(vbar); + width = (Dimension)(XtWidth(ctx) - XtWidth(vbar) - XtBorderWidth(vbar)); if (width > XtWidth(ctx)) width = XtWidth(ctx); } @@ -775,7 +775,7 @@ PositionVScrollBar(TextWidget ctx) if (vbar == NULL) return; - x = y = -XtBorderWidth(vbar); + x = y = (Position)(-XtBorderWidth(vbar)); height = XtHeight(ctx); width = XtWidth(vbar); @@ -795,7 +795,7 @@ CreateVScrollBar(TextWidget ctx) XtAddCallback(vbar, XtNscrollProc, VScroll, (XtPointer)ctx); XtAddCallback(vbar, XtNjumpProc, VJump, (XtPointer)ctx); - ctx->text.r_margin.left += XtWidth(vbar) + XtBorderWidth(vbar); + ctx->text.r_margin.left += (XtWidth(vbar) + XtBorderWidth(vbar)); ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left; PositionVScrollBar(ctx); @@ -827,7 +827,7 @@ DestroyVScrollBar(TextWidget ctx) if (vbar == NULL) return; - ctx->text.r_margin.left -= XtWidth(vbar) + XtBorderWidth(vbar); + ctx->text.r_margin.left = (Position)(ctx->text.r_margin.left - (XtWidth(vbar) + XtBorderWidth(vbar))); ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left; XtDestroyWidget(vbar); @@ -856,7 +856,7 @@ CreateHScrollBar(TextWidget ctx) bottom = ctx->text.r_margin.bottom + XtHeight(hbar) + XtBorderWidth(hbar); - ctx->text.margin.bottom = ctx->text.r_margin.bottom = bottom; + ctx->text.margin.bottom = ctx->text.r_margin.bottom = (Position)bottom; PositionHScrollBar(ctx); TextSinkResize(ctx->text.sink); @@ -886,7 +886,9 @@ DestroyHScrollBar(TextWidget ctx) if (hbar == NULL) return; - ctx->text.r_margin.bottom -= XtHeight(hbar) + XtBorderWidth(hbar); + ctx->text.r_margin.bottom = (Position)(ctx->text.r_margin.bottom + - (XtHeight(hbar) + + XtBorderWidth(hbar))); ctx->text.margin.bottom = ctx->text.r_margin.bottom; XtDestroyWidget(hbar); @@ -946,7 +948,7 @@ XawTextInitialize(Widget request, Widget cnew, #endif if (XtHeight(ctx) == DEFAULT_TEXT_HEIGHT) { - XtHeight(ctx) = VMargins(ctx); + XtHeight(ctx) = (Dimension)VMargins(ctx); if (ctx->text.sink != NULL) XtHeight(ctx) += XawTextSinkMaxHeight(ctx->text.sink, 1); } @@ -1046,7 +1048,7 @@ InsertCursor(Widget w, XawTextInsertState state) else y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1; - XawTextSinkInsertCursor(ctx->text.sink, x, y, state); + XawTextSinkInsertCursor(ctx->text.sink, (Position)x, (Position)y, state); } /* Keep Input Method up to speed */ @@ -1097,7 +1099,7 @@ _XawTextGetText(TextWidget ctx, XawTextPosition left, XawTextPosition right) bytes = 1; /* leave space for ZERO */ - tempResult = result = XtMalloc((unsigned)(right - left + ONE) * bytes); + tempResult = result = XtMalloc((unsigned)(right - left + ONE) * (unsigned)bytes); while (left < right) { left = SrcRead(ctx->text.source, left, &text, (int)(right - left)); @@ -1131,7 +1133,7 @@ _XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right) if (XawTextFormat(ctx, XawFmtWide)) { MultiSinkObject sink = (MultiSinkObject)ctx->text.sink; ws = (wchar_t *)_XawTextGetText(ctx, left, right); - n = wcslen(ws); + n = (long)wcslen(ws); for (j = 0, i = 0; j < n; j++) { wc = ws[j]; if (XwcTextEscapement (sink->multi_sink.fontset, &wc, 1) @@ -1145,7 +1147,7 @@ _XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right) else { s = (unsigned char *)_XawTextGetText(ctx, left, right); /* only HT and NL control chars are allowed, strip out others */ - n = strlen((char *)s); + n = (long)strlen((char *)s); i = 0; for (j = 0; j < n; j++) { c = s[j]; @@ -1255,10 +1257,10 @@ _XawTextBuildLineTable(TextWidget ctx, XawTextPosition position, Cardinal size; if ((int)XtHeight(ctx) > VMargins(ctx)) { - height = XtHeight(ctx) - VMargins(ctx); + height = (Dimension)(XtHeight(ctx) - VMargins(ctx)); lines = XawTextSinkMaxLines(ctx->text.sink, height); } - size = sizeof(XawTextLineTableEntry) * (lines + 1); + size = (Cardinal)(sizeof(XawTextLineTableEntry) * (size_t)(lines + 1)); if (lines != ctx->text.lt.lines || ctx->text.lt.info == NULL) { ctx->text.lt.info = (XawTextLineTableEntry *) @@ -1383,9 +1385,9 @@ _BuildLineTable(TextWidget ctx, XawTextPosition position, int line) if (lt->textWidth != width) { if (lt->textWidth > width) ctx->text.clear_to_eol = True; - lt->textWidth = width; + lt->textWidth = (unsigned)width; } - y += height; + y = (Position)(y + height); if (end > ctx->text.lastPos) { position = end; @@ -1406,7 +1408,7 @@ _BuildLineTable(TextWidget ctx, XawTextPosition position, int line) } lt->position = ++position; lt->textWidth = 0; - y += height; + y = (Position)(y + height); } if (update_from >= 0) _XawTextNeedsUpdating(ctx, update_from, @@ -1424,7 +1426,7 @@ _BuildLineTable(TextWidget ctx, XawTextPosition position, int line) /* grow the line table */ ctx->text.lt.info = (XawTextLineTableEntry *) XtRealloc((char *)ctx->text.lt.info, - sizeof(XawTextLineTableEntry) * (line + 1)); + (Cardinal)(sizeof(XawTextLineTableEntry) * (size_t)(line + 1))); lt = ctx->text.lt.info + line; bzero(lt, sizeof(XawTextLineTableEntry)); ++ctx->text.lt.lines; @@ -1490,10 +1492,10 @@ _XawTextSetScrollBars(TextWidget ctx) if (ctx->text.lastPos == 0) first = 0.0; else - first = ctx->text.lt.top / (float)ctx->text.lastPos; + first = (float)ctx->text.lt.top / (float)ctx->text.lastPos; if (ctx->text.lt.info[ctx->text.lt.lines].position < ctx->text.lastPos) - last = ctx->text.lt.info[ctx->text.lt.lines].position / + last = (float)ctx->text.lt.info[ctx->text.lt.lines].position / (float)ctx->text.lastPos; else last = 1.0; @@ -1502,13 +1504,13 @@ _XawTextSetScrollBars(TextWidget ctx) } if (ctx->text.scroll_horiz == XawtextScrollAlways) { - denom = GetWidestLine(ctx); + denom = (float)GetWidestLine(ctx); if (denom <= 0) - denom = (int)XtWidth(ctx) - RHMargins(ctx); + denom = (float)((int)XtWidth(ctx) - RHMargins(ctx)); if (denom <= 0) denom = 1; - widest = ((int)XtWidth(ctx) - RHMargins(ctx)) / denom; - first = ctx->text.r_margin.left - ctx->text.left_margin; + widest = (float)((int)XtWidth(ctx) - RHMargins(ctx)) / denom; + first = (float)(ctx->text.r_margin.left - ctx->text.left_margin); first /= denom; XawScrollbarSetThumb(ctx->text.hbar, first, widest); @@ -1533,8 +1535,8 @@ DoCopyArea(TextWidget ctx, int src_x, int src_y, src_y = XawMax(y1, XawMin(src_y, y2)); dst_x = XawMax(x1, XawMin(dst_x, x2)); dst_y = XawMax(y1, XawMin(dst_y, y2)); - width = XawMax(0, XawMin(x2 - dst_x, (int)width)); - height = XawMax(0, XawMin(y2 - dst_y, (int)height)); + width = (unsigned)XawMax(0, XawMin(x2 - dst_x, (int)width)); + height = (unsigned)XawMax(0, XawMin(y2 - dst_y, (int)height)); XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc, src_x, src_y, width, height, dst_x, dst_y); @@ -1703,8 +1705,8 @@ XawTextScroll(TextWidget ctx, int vlines, int hpixels) update_to = lt->info[-vlines + 1].position - 1; y1 = lt->info[lt->lines + vlines].y; y2 = lt->info[-vlines].y; - DoCopyArea(ctx, ctx->text.r_margin.left, y0, vwidth, - y1 - y0, + DoCopyArea(ctx, ctx->text.r_margin.left, y0, (unsigned)vwidth, + (unsigned)(y1 - y0), ctx->text.r_margin.left, y2); } else { @@ -1713,7 +1715,7 @@ XawTextScroll(TextWidget ctx, int vlines, int hpixels) y1 = lt->info[lt->lines - vlines].y; y2 = lt->info[vlines].y; DoCopyArea(ctx, ctx->text.r_margin.left, y2, - vwidth, lt->info[lt->lines].y - y2, + (unsigned)vwidth, (unsigned)(lt->info[lt->lines].y - y2), ctx->text.r_margin.left, y0); } _XawTextNeedsUpdating(ctx, update_from, update_to); @@ -1749,7 +1751,7 @@ HScroll(Widget w, XtPointer closure, XtPointer callData) if (pixels) { _XawTextPrepareToUpdate(ctx); - XawTextScroll(ctx, 0, pixels); + XawTextScroll(ctx, 0, (int)pixels); _XawTextExecuteUpdate(ctx); } } @@ -1763,7 +1765,7 @@ HJump(Widget w, XtPointer closure, XtPointer callData) long pixels; pixels = ctx->text.left_margin - - (ctx->text.r_margin.left - (int)(percent * GetWidestLine(ctx))); + (ctx->text.r_margin.left - (int)(percent * (float)GetWidestLine(ctx))); HScroll(w, (XtPointer)ctx, (XtPointer)pixels); } @@ -1803,7 +1805,7 @@ UpdateTextInLine(TextWidget ctx, int line, int x1, int x2) False, &left, &width, &height); if (line == ctx->text.lt.lines) right = -1; - else if (x2 >= lt->textWidth - from_x) + else if (x2 >= (lt->textWidth - (unsigned)from_x)) right = lt[1].position - 1; else { from_x += width; @@ -1835,7 +1837,7 @@ VScroll(Widget w, XtPointer closure, XtPointer callData) height = 1; lines = (lines * ctx->text.lt.lines) / height; _XawTextPrepareToUpdate(ctx); - XawTextScroll(ctx, lines, 0); + XawTextScroll(ctx, (int)lines, 0); _XawTextExecuteUpdate(ctx); } @@ -1850,7 +1852,7 @@ VJump(Widget w, XtPointer closure, XtPointer callData) int dim, vlines = 0, wwidth = GetMaxTextWidth(ctx); Bool scroll = True; - position = percent * ctx->text.lastPos; + position = (XawTextPosition)(percent * (float)ctx->text.lastPos); top = lt->top; if (!lt->lines || (position >= lt->top && position < lt->info[1].position)) { @@ -1972,8 +1974,8 @@ TextConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, target, type, (XPointer*)&std_targets, &std_length, format); - *length = 7 + (edit_mode == XawtextEdit) + std_length; - *value = XtMalloc((unsigned)sizeof(Atom)*(*length)); + *length = 7 + (unsigned long)(edit_mode == XawtextEdit) + std_length; + *value = XtMalloc((Cardinal)(sizeof(Atom)*(*length))); targetP = *(Atom**)value; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); @@ -2043,9 +2045,9 @@ TextConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, *length = strlen((char *)*value); } else { - *value = XtMalloc((salt->length + 1) * sizeof(unsigned char)); + *value = XtMalloc(((size_t)(salt->length + 1) * sizeof(unsigned char))); strcpy ((char *)*value, salt->contents); - *length = salt->length; + *length = (unsigned long)salt->length; } /* Got *value,*length, now in COMPOUND_TEXT format. */ if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) { @@ -2256,7 +2258,7 @@ _XawTextSaltAwaySelection(TextWidget ctx, Atom *selections, int num_atoms) XtMalloc((unsigned)sizeof(XawTextSelectionSalt)); if (!salt) return; - salt->s.selections = (Atom *)XtMalloc((unsigned)(num_atoms * sizeof(Atom))); + salt->s.selections = (Atom *)XtMalloc((Cardinal)((size_t)num_atoms * sizeof(Atom))); if (!salt->s.selections) { XtFree((char *)salt); return; @@ -2277,10 +2279,10 @@ _XawTextSaltAwaySelection(TextWidget ctx, Atom *selections, int num_atoms) } XtFree(salt->contents); salt->contents = (char *)textprop.value; - salt->length = textprop.nitems; + salt->length = (int)textprop.nitems; } else - salt->length = strlen (salt->contents); + salt->length = (int)strlen (salt->contents); salt->next = ctx->text.salt; ctx->text.salt = salt; j = 0; @@ -2340,7 +2342,7 @@ _SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right, #ifndef OLDXAW if (needs_updating) { _XawTextExecuteUpdate(tw); - tw->text.showposition = showposition; + tw->text.showposition = (Boolean)showposition; } } #endif /* OLDXAW */ @@ -2360,7 +2362,7 @@ _SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right, */ if ((buffer = GetCutBufferNumber(selection)) != NOT_A_CUT_BUFFER) { unsigned char *ptr, *tptr; - unsigned int amount, max_len = MAX_CUT_LEN(XtDisplay(w)); + unsigned int amount, max_len = (unsigned)MAX_CUT_LEN(XtDisplay(w)); unsigned long len; tptr= ptr= (unsigned char *)_XawTextGetSTRING(ctx, @@ -2386,10 +2388,10 @@ _SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right, _CreateCutBuffers(XtDisplay(w)); XRotateBuffers(XtDisplay(w), 1); } - amount = Min ((len = strlen((char *)ptr)), max_len); + amount = (unsigned)Min ((len = strlen((char *)ptr)), max_len); XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0), selection, XA_STRING, 8, PropModeReplace, - ptr, amount); + ptr, (int)amount); while (len > max_len) { len -= max_len; @@ -2397,7 +2399,7 @@ _SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right, amount = Min (len, max_len); XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0), selection, XA_STRING, 8, PropModeAppend, - tptr, amount); + tptr, (int)amount); } XtFree ((char *)ptr); } @@ -2430,7 +2432,7 @@ _XawTextSetLineAndColumnNumber(TextWidget ctx, Bool force) XawTextPositionInfo info; ctx->text.line_number = info.line_number = line_number; - ctx->text.column_number = info.column_number = column_number; + ctx->text.column_number = (short)(info.column_number = column_number); info.insert_position = ctx->text.insertPos; info.last_position = ctx->text.lastPos; info.overwrite_mode = ctx->text.overwrite; @@ -2446,7 +2448,7 @@ ResolveColumnNumber(TextWidget ctx) short column_number = 0; XawTextPosition position; XawTextBlock block; - unsigned long format = _XawTextFormat(ctx); + unsigned long format = (unsigned long)_XawTextFormat(ctx); TextSinkObject sink = (TextSinkObject)ctx->text.sink; short *char_tabs = sink->text_sink.char_tabs; int tab_count = sink->text_sink.tab_count; @@ -2456,11 +2458,11 @@ ResolveColumnNumber(TextWidget ctx) return (ctx->text.column_number); position = SrcScan(src, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, False); - XawTextSourceRead(src, position, &block, ctx->text.insertPos - position); + XawTextSourceRead(src, position, &block, (int)(ctx->text.insertPos - position)); for (; position < ctx->text.insertPos; position++) { if (position - block.firstPos >= block.length) - XawTextSourceRead(src, position, &block, ctx->text.insertPos - position); + XawTextSourceRead(src, position, &block, (int)(ctx->text.insertPos - position)); if ((format == XawFmt8Bit && block.ptr[position - block.firstPos] == '\t') || (format == XawFmtWide && ((wchar_t*)block.ptr)[position - block.firstPos] == _Xaw_atowc(XawTAB))) { while (tab_base + tab_column <= column_number) { @@ -2478,7 +2480,7 @@ ResolveColumnNumber(TextWidget ctx) else tab_column += DEFAULT_TAB_SIZE; } - column_number = tab_base + tab_column; + column_number = (short)(tab_base + tab_column); } else ++column_number; @@ -2528,7 +2530,7 @@ _XawTextSourceChanged(Widget w, XawTextPosition left, XawTextPosition right, update_from = left; update_to = left + block->length; update_to = SrcScan(src, update_to, XawstEOL, XawsdRight, 1, False); - delta = block->length - (right - left); + delta = (int)(block->length - (right - left)); if (delta < 0) ctx->text.clear_to_eol = True; if (update_to == update_from) @@ -2719,7 +2721,7 @@ OldDisplayText(Widget w, XawTextPosition left, XawTextPosition right) x = ctx->text.left_margin; if (cleol) { - segment.x1 = ctx->text.lt.info[line].textWidth + x; + segment.x1 = (int)(ctx->text.lt.info[line].textWidth + (unsigned)x); if (XmuValidSegment(&segment)) { scanline.y = y; next.y = ctx->text.lt.info[line + 1].y; @@ -2736,7 +2738,8 @@ OldDisplayText(Widget w, XawTextPosition left, XawTextPosition right) for (seg = scan->segment; seg; seg = seg->next) SinkClearToBG(ctx->text.sink, seg->x1, scan->y, - seg->x2 - seg->x1, scan->next->y - scan->y); + (unsigned)(seg->x2 - seg->x1), + (unsigned)(scan->next->y - scan->y)); XmuDestroyArea(clip); } } @@ -2795,7 +2798,7 @@ DisplayText(Widget w, XawTextPosition left, XawTextPosition right) } if (cleol) { - segment.x1 = ctx->text.lt.info[line].textWidth + ctx->text.left_margin; + segment.x1 = (int)(ctx->text.lt.info[line].textWidth + (unsigned)ctx->text.left_margin); if (XmuValidSegment(&segment)) { scanline.y = y; next.y = ctx->text.lt.info[line + 1].y; @@ -3110,13 +3113,13 @@ _XawTextSelectionList(TextWidget ctx, String *list, Cardinal nelems) int n; if (nelems > (Cardinal)ctx->text.s.array_size) { - sel = (Atom *)XtRealloc((char *)sel, sizeof(Atom) * nelems); - ctx->text.s.array_size = nelems; + sel = (Atom *)XtRealloc((char *)sel, (Cardinal)(sizeof(Atom) * (size_t)nelems)); + ctx->text.s.array_size = (int)nelems; ctx->text.s.selections = sel; } - for (n = nelems; --n >= 0; sel++, list++) + for (n = (int)nelems; --n >= 0; sel++, list++) *sel = XInternAtom(dpy, *list, False); - ctx->text.s.atom_count = nelems; + ctx->text.s.atom_count = (int)nelems; return (ctx->text.s.selections); } @@ -3254,16 +3257,16 @@ XawTextExpose(Widget w, XEvent *event, Region region) XRectangle expose; if (event->type == Expose) { - expose.x = event->xexpose.x; - expose.y = event->xexpose.y; - expose.width = event->xexpose.width; - expose.height = event->xexpose.height; + expose.x = (short)event->xexpose.x; + expose.y = (short)event->xexpose.y; + expose.width = (unsigned short)event->xexpose.width; + expose.height = (unsigned short)event->xexpose.height; } else if (event->type == GraphicsExpose) { - expose.x = event->xgraphicsexpose.x; - expose.y = event->xgraphicsexpose.y; - expose.width = event->xgraphicsexpose.width; - expose.height = event->xgraphicsexpose.height; + expose.x = (short)event->xgraphicsexpose.x; + expose.y = (short)event->xgraphicsexpose.y; + expose.width = (unsigned short)event->xgraphicsexpose.width; + expose.height = (unsigned short)event->xgraphicsexpose.height; } else return; @@ -3679,8 +3682,9 @@ XawTextSetValues(Widget current, Widget request, Widget cnew, if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) { newtw->text.margin.bottom = newtw->text.r_margin.bottom; if (newtw->text.hbar != NULL) - newtw->text.margin.bottom += newtw->text.hbar->core.height + - newtw->text.hbar->core.border_width; + newtw->text.margin.bottom = (Position)(newtw->text.margin.bottom + + (newtw->text.hbar->core.height + + newtw->text.hbar->core.border_width)); redisplay = True; } @@ -3818,8 +3822,8 @@ _XawTextPosToXY(Widget w, XawTextPosition pos, Position *x, Position *y) int line, ix, iy; LineAndXYForPosition((TextWidget)w, pos, &line, &ix, &iy); - *x = ix; - *y = iy; + *x = (Position)ix; + *y = (Position)iy; } /******************************************************************* diff --git a/src/TextAction.c b/src/TextAction.c index 10ac931a2ea0e70281b8a255b410462806678f73..34457e02e0882c3d219dbb1907ad86610ce40cc8 100644 --- a/src/TextAction.c +++ b/src/TextAction.c @@ -307,24 +307,24 @@ NotePosition(TextWidget ctx, XEvent *event) switch (event->type) { case ButtonPress: case ButtonRelease: - ctx->text.ev_x = event->xbutton.x; - ctx->text.ev_y = event->xbutton.y; + ctx->text.ev_x = (Position)event->xbutton.x; + ctx->text.ev_y = (Position)event->xbutton.y; break; case KeyPress: case KeyRelease: { XRectangle cursor; XawTextSinkGetCursorBounds(ctx->text.sink, &cursor); - ctx->text.ev_x = cursor.x + cursor.width / 2; - ctx->text.ev_y = cursor.y + cursor.height / 2; + ctx->text.ev_x = (Position)(cursor.x + cursor.width / 2); + ctx->text.ev_y = (Position)(cursor.y + cursor.height / 2); } break; case MotionNotify: - ctx->text.ev_x = event->xmotion.x; - ctx->text.ev_y = event->xmotion.y; + ctx->text.ev_x = (Position)(event->xmotion.x); + ctx->text.ev_y = (Position)(event->xmotion.y); break; case EnterNotify: case LeaveNotify: - ctx->text.ev_x = event->xcrossing.x; - ctx->text.ev_y = event->xcrossing.y; + ctx->text.ev_x = (Position)(event->xcrossing.x); + ctx->text.ev_y = (Position)(event->xcrossing.y); } } @@ -438,7 +438,7 @@ _SelectionReceived(Widget w, XtPointer client_data, Atom *selection, } text.ptr = (char*)value; text.firstPos = 0; - text.length = *length; + text.length = (int)*length; if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell(XtDisplay(ctx), 0); EndAction(ctx); @@ -481,7 +481,7 @@ GetSelection(Widget w, Time timev, String *params, Cardinal num_params) Atom type = XA_STRING; char *line = XFetchBuffer(XtDisplay(w), &nbytes, buffer); - if ((length = nbytes) != 0L) + if ((length = (unsigned long)nbytes) != 0L) _SelectionReceived(w, NULL, &selection, &type, line, &length, &fmt8); else if (num_params > 1) GetSelection(w, timev, params+1, num_params-1); @@ -524,12 +524,12 @@ Move(TextWidget ctx, XEvent *event, XawTextScanDirection dir, short mult = MULT(ctx); if (mult < 0) { - mult = -mult; + mult = (short)(-mult); dir = dir == XawsdLeft ? XawsdRight : XawsdLeft; } insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, - type, dir, mult, include); + type, dir, mult, (Boolean)include); StartAction(ctx, event); @@ -586,7 +586,7 @@ MoveForwardParagraph(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MoveBackwardParagraph(w, event, p, n); return; } @@ -632,7 +632,7 @@ MoveBackwardParagraph(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MoveForwardParagraph(w, event, p, n); return; } @@ -694,7 +694,7 @@ MoveLine(TextWidget ctx, XEvent *event, XawTextScanDirection dir) XawTextUnsetSelection((Widget)ctx); if (dir == XawsdLeft) - mult = mult == 0 ? 5 : mult + 1; + mult = (short)((mult == 0) ? 5 : mult + 1); cnew = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, False); @@ -738,7 +738,7 @@ MoveNextLine(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MovePreviousLine(w, event, p, n); return; } @@ -756,7 +756,7 @@ MovePreviousLine(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MoveNextLine(w, event, p, n); return; } @@ -788,7 +788,7 @@ Scroll(TextWidget ctx, XEvent *event, XawTextScanDirection dir) short mult = MULT(ctx); if (mult < 0) { - mult = -mult; + mult = (short)(-mult); dir = dir == XawsdLeft ? XawsdRight : XawsdLeft; } @@ -881,7 +881,7 @@ MoveNextPage(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MovePreviousPage(w, event, p, n); return; } @@ -906,7 +906,7 @@ MovePreviousPage(Widget w, XEvent *event, String *p, Cardinal *n) short mult = MULT(ctx); if (mult < 0) { - ctx->text.mult = -mult; + ctx->text.mult = (short)(-mult); MoveNextPage(w, event, p, n); return; } @@ -968,8 +968,8 @@ ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, target, type, (XPointer *)&std_targets, &std_length, format); - *length = 7 + (edit_mode == XawtextEdit) + std_length; - *value = XtMalloc((unsigned)sizeof(Atom)*(*length)); + *length = (7 + (unsigned long)(edit_mode == XawtextEdit) + std_length); + *value = XtMalloc((Cardinal)((unsigned)sizeof(Atom)*(*length))); targetP = *(Atom**)value; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); @@ -1035,9 +1035,9 @@ ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, *length = strlen(*value); } else { - *value = XtMalloc((salt->length + 1) * sizeof(unsigned char)); + *value = XtMalloc(((size_t)(salt->length + 1) * sizeof(unsigned char))); strcpy (*value, salt->contents); - *length = salt->length; + *length = (unsigned long)salt->length; } /* Got *value,*length, now in COMPOUND_TEXT format. */ if (XawTextFormat(ctx, XawFmtWide)) { @@ -1278,10 +1278,10 @@ _DeleteOrKill(TextWidget ctx, XawTextPosition from, XawTextPosition to, } XtFree(string); string = (char *)textprop.value; - length = textprop.nitems; + length = (int)textprop.nitems; } else - length = strlen(string); + length = (int)strlen(string); salt->length = length + size; @@ -1289,16 +1289,16 @@ _DeleteOrKill(TextWidget ctx, XawTextPosition from, XawTextPosition to, if (!append) salt->contents = string; else { - salt->contents = XtMalloc(length + size + 1); + salt->contents = XtMalloc((length + size + 1)); if (from >= old_from) { - strncpy(salt->contents, ring, size); + strncpy(salt->contents, ring, (size_t)size); salt->contents[size] = '\0'; - strncat(salt->contents, string, length); + strncat(salt->contents, string, (size_t)length); } else { - strncpy(salt->contents, string, length); + strncpy(salt->contents, string, (size_t)length); salt->contents[length] = '\0'; - strncat(salt->contents, ring, size); + strncat(salt->contents, ring, (size_t)size); } salt->contents[length + size] = '\0'; XtFree(ring); @@ -1329,7 +1329,7 @@ _DeleteOrKill(TextWidget ctx, XawTextPosition from, XawTextPosition to, text.length = 0; text.firstPos = 0; - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); text.ptr = ""; if (_XawTextReplace(ctx, from, to, &text)) { @@ -1349,7 +1349,7 @@ DeleteOrKill(TextWidget ctx, XEvent *event, XawTextScanDirection dir, short mult = MULT(ctx); if (mult < 0) { - mult = -mult; + mult = (short)(-mult); dir = dir == XawsdLeft ? XawsdRight : XawsdLeft; } @@ -1359,7 +1359,7 @@ DeleteOrKill(TextWidget ctx, XEvent *event, XawTextScanDirection dir, _XawSourceSetUndoMerge((TextSrcObject)ctx->text.source, True); #endif to = SrcScan(ctx->text.source, ctx->text.insertPos, - type, dir, mult, include); + type, dir, mult, (Boolean)include); /* * If no movement actually happened, then bump the count and try again. @@ -1368,7 +1368,7 @@ DeleteOrKill(TextWidget ctx, XEvent *event, XawTextScanDirection dir, */ if (to == ctx->text.insertPos) to = SrcScan(ctx->text.source, ctx->text.insertPos, - type, dir, mult + 1, include); + type, dir, mult + 1, (Boolean)include); if (dir == XawsdLeft) { from = to; @@ -1399,7 +1399,7 @@ DeleteChar(Widget w, XEvent *event, XawTextScanDirection dir) short mul = MULT(ctx); if (mul < 0) { - ctx->text.mult = mul = -mul; + ctx->text.mult = mul = (short)(-mul); dir = dir == XawsdLeft ? XawsdRight : XawsdLeft; } DeleteOrKill(ctx, event, dir, XawstPositions, True, False); @@ -1487,7 +1487,7 @@ KillToEndOfLine(Widget w, XEvent *event, String *p, Cardinal *n) if (mult < 0) { dir = XawsdLeft; - mult = -mult; + mult = (short)(-mult); } StartAction(ctx, event); @@ -1604,7 +1604,7 @@ StripSpaces(TextWidget ctx, XawTextPosition left, XawTextPosition right, text.length = 1; position = XawTextSourceRead(ctx->text.source, position, - &block, right - left); + &block, (int)(right - left)); done = False; space = False; /* convert tabs and returns to spaces */ @@ -1632,7 +1632,7 @@ StripSpaces(TextWidget ctx, XawTextPosition left, XawTextPosition right, } tmp += i; position = XawTextSourceRead(ctx->text.source, tmp, - &block, right - tmp); + &block, (int)(right - tmp)); if (block.length == 0 || tmp == position || tmp >= right) done = True; } @@ -1641,7 +1641,7 @@ StripSpaces(TextWidget ctx, XawTextPosition left, XawTextPosition right, text.length = 0; position = tmp = left; position = XawTextSourceRead(ctx->text.source, position, - &block, right - left); + &block, (int)(right - left)); ipos = ctx->text.insertPos; done = False; while (!done) { @@ -1693,7 +1693,7 @@ StripSpaces(TextWidget ctx, XawTextPosition left, XawTextPosition right, tmp += i + 1; count = 0; position = XawTextSourceRead(ctx->text.source, tmp, - &block, right - tmp); + &block, (int)(right - tmp)); if (block.length == 0 || tmp == position || tmp >= right) done = True; } @@ -1722,7 +1722,7 @@ Tabify(TextWidget ctx, XawTextPosition left, XawTextPosition right, text.length = 1; position = XawTextSourceRead(ctx->text.source, position, - &block, right - left); + &block, (int)(right - left)); ipos = ctx->text.insertPos; done = zero = False; if (tab_count) @@ -1837,7 +1837,7 @@ Tabify(TextWidget ctx, XawTextPosition left, XawTextPosition right, count = 0; tmp = left + offset; position = XawTextSourceRead(ctx->text.source, tmp, - &block, right - tmp); + &block, (int)(right - tmp)); if (tmp == position || tmp >= right) done = True; } @@ -1866,7 +1866,7 @@ Untabify(TextWidget ctx, XawTextPosition left, XawTextPosition right, text.ptr = tabs; position = XawTextSourceRead(ctx->text.source, position, - &block, right - left); + &block, (int)(right - left)); ipos = ctx->text.insertPos; done = False; zero = False; @@ -1913,7 +1913,7 @@ Untabify(TextWidget ctx, XawTextPosition left, XawTextPosition right, if (text.length > 8) { int j; - text.ptr = XtMalloc(text.length); + text.ptr = XtMalloc((Cardinal)text.length); for (j = 0; j < text.length; j++) text.ptr[j] = ' '; } @@ -1962,7 +1962,7 @@ Untabify(TextWidget ctx, XawTextPosition left, XawTextPosition right, tab_base = tab_column = tab_index = 0; } position = XawTextSourceRead(ctx->text.source, tmp, - &block, right - tmp); + &block, (int)(right - tmp)); if (tmp == position || tmp >= right) done = True; } @@ -1988,8 +1988,8 @@ FormatText(TextWidget ctx, XawTextPosition left, Bool force, undo = src->textSrc.enable_undo && src->textSrc.undo_state == False; if (undo) { if (!pos) { - num_pos = src->textSrc.num_text; - pos = XawStackAlloc(sizeof(XawTextPosition) * num_pos, buf); + num_pos = (int)src->textSrc.num_text; + pos = (XawStackAlloc(sizeof(XawTextPosition) * (size_t)num_pos, buf)); for (i = 0; i < num_pos; i++) pos[i] = ((TextWidget)src->textSrc.text[i])->text.insertPos; freepos = True; @@ -1998,8 +1998,8 @@ FormatText(TextWidget ctx, XawTextPosition left, Bool force, freepos = False; src->textSrc.undo_state = True; block.ptr = NULL; - block.firstPos = left; - block.length = right - left; + block.firstPos = (int)left; + block.length = (int)(right - left); text = █ } else @@ -2011,23 +2011,23 @@ FormatText(TextWidget ctx, XawTextPosition left, Bool force, unsigned llen, rlen, size; ptr = lbuf = block.ptr; - llen = block.length; - rlen = llen + (ctx->text.lastPos - end); + llen = (unsigned)block.length; + rlen = (unsigned)(llen + (ctx->text.lastPos - end)); block.firstPos = 0; - block.format = _XawTextFormat(ctx); + block.format = (unsigned long)_XawTextFormat(ctx); rbuf = _XawTextGetText(ctx, left, left + rlen); size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char); if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) { block.ptr = lbuf; - block.length = llen; + block.length = (int)llen; _XawTextReplace(ctx, left, left + rlen, &block); src->textSrc.undo_state = False; block.ptr = rbuf; - block.length = rlen; + block.length = (int)rlen; _XawTextReplace(ctx, left, left + llen, &block); } else @@ -2064,7 +2064,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, int i, count, cpos; Bool done, force2 = force, recurse = False; - position = XawTextSourceRead(ctx->text.source, left, &block, right - left); + position = XawTextSourceRead(ctx->text.source, left, &block, (int)(right - left)); if (block.length == 0 || left >= right || (level == 1 && ((XawTextFormat(ctx, XawFmt8Bit) && block.ptr[0] != ' ' && @@ -2073,7 +2073,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, (XawTextFormat(ctx, XawFmtWide) && _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr && _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr && - !iswalnum(*(wchar_t*)block.ptr))))) + !iswalnum((wint_t)*(wchar_t*)block.ptr))))) return (XawEditDone); if (level == 1 && !paragraph) { @@ -2082,7 +2082,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, return (XawEditError); right += ctx->text.lastPos - tmp; position = XawTextSourceRead(ctx->text.source, left, &block, - right - left); + (int)(right - left)); } text.firstPos = 0; @@ -2113,7 +2113,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, } tmp = position; position = XawTextSourceRead(ctx->text.source, position, - &block, right - position); + &block, (int)(right - position)); if (tmp == position) done = True; } @@ -2199,7 +2199,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, else count = ctx->text.right_column; if (count > right - left) - count -= right - left; + count = (int)(count - (right - left)); else count = 0; } @@ -2219,7 +2219,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, if ((XawTextFormat(ctx, XawFmt8Bit) && isalnum(*(unsigned char*)block.ptr)) || (XawTextFormat(ctx, XawFmtWide) - && iswalnum(*(wchar_t*)block.ptr))) + && iswalnum((wint_t)*(wchar_t*)block.ptr))) alnum = 1; } count = (count + alnum) >> 1; @@ -2348,14 +2348,14 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) } if (undo) { - llen = to - from; + llen = (unsigned)(to - from); end = ctx->text.lastPos; lbuf = _XawTextGetText(ctx, from, to); src->textSrc.undo_state = True; } tmp = ctx->text.lastPos; - if (!Untabify(ctx, from, to, pos, src->textSrc.num_text, NULL)) { + if (!Untabify(ctx, from, to, pos, (int)src->textSrc.num_text, NULL)) { XBell(XtDisplay(ctx), 0); EndAction(ctx); XawStackFree(pos, posbuf); @@ -2421,22 +2421,22 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) } if (!format) - Tabify(ctx, from, to, pos, src->textSrc.num_text, NULL); + Tabify(ctx, from, to, pos, (int)src->textSrc.num_text, NULL); if (undo) { - rlen = llen + (ctx->text.lastPos - end); + rlen = (unsigned)(llen + (ctx->text.lastPos - end)); rbuf = _XawTextGetText(ctx, from, from + rlen); - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char); if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) { text.ptr = lbuf; - text.length = llen; + text.length = (int)llen; _XawTextReplace(ctx, from, from + rlen, &text); src->textSrc.undo_state = False; text.ptr = rbuf; - text.length = rlen; + text.length = (int)rlen; _XawTextReplace(ctx, from, from + llen, &text); } else @@ -2487,20 +2487,20 @@ InsertNewLineAndBackupInternal(TextWidget ctx) return (XawEditError); } - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); text.length = mult; text.firstPos = 0; if (text.format == XawFmtWide) { wchar_t *wptr; - text.ptr = XawStackAlloc(sizeof(wchar_t) * mult, buf); + text.ptr = (XawStackAlloc(sizeof(wchar_t) * (size_t)mult, buf)); wptr = (wchar_t *)text.ptr; for (count = 0; count < mult; count++) wptr[count] = _Xaw_atowc(XawLF); } else { - text.ptr = XawStackAlloc(sizeof(char) * mult, buf); + text.ptr = (XawStackAlloc(sizeof(char) * (size_t)mult, buf)); for (count = 0; count < mult; count++) text.ptr[count] = XawLF; } @@ -2579,29 +2579,29 @@ InsertNewLineAndIndent(Widget w, XEvent *event, String *p, Cardinal *n) line_to_ip = _XawTextGetText(ctx, pos1, ctx->text.insertPos); - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); text.firstPos = 0; if (text.format == XawFmtWide) { wchar_t *ptr; - text.ptr = XtMalloc((2 + wcslen((wchar_t*)line_to_ip)) - * sizeof(wchar_t)); + text.ptr = XtMalloc((Cardinal)((2 + wcslen((wchar_t*)line_to_ip)) + * sizeof(wchar_t))); ptr = (wchar_t*)text.ptr; ptr[0] = _Xaw_atowc(XawLF); wcscpy((wchar_t*)++ptr, (wchar_t*)line_to_ip); - length = wcslen((wchar_t*)text.ptr); + length = (int)wcslen((wchar_t*)text.ptr); while (length && (iswspace(*ptr) || *ptr == _Xaw_atowc(XawTAB))) ptr++, length--; *ptr = (wchar_t)0; - text.length = wcslen((wchar_t*)text.ptr); + text.length = (int)wcslen((wchar_t*)text.ptr); } else { char *ptr; - length = strlen(line_to_ip); - text.ptr = XtMalloc((2 + length) * sizeof(char)); + length = (int)strlen(line_to_ip); + text.ptr = XtMalloc(((size_t)(2 + length) * sizeof(char))); ptr = text.ptr; ptr[0] = XawLF; strcpy(++ptr, line_to_ip); @@ -2610,7 +2610,7 @@ InsertNewLineAndIndent(Widget w, XEvent *event, String *p, Cardinal *n) while (length && (isspace(*ptr) || (*ptr == XawTAB))) ptr++, length--; *ptr = '\0'; - text.length = strlen(text.ptr); + text.length = (int)strlen(text.ptr); } XtFree(line_to_ip); @@ -2784,7 +2784,7 @@ SelectSave(Widget w, XEvent *event, String *params, Cardinal *num_params) Atom selections[256]; StartAction((TextWidget)w, event); - num_atoms = *num_params; + num_atoms = (int)*num_params; if (num_atoms > 256) num_atoms = 256; for (sel = selections, n = 0; n < num_atoms; n++, sel++, params++) @@ -2881,8 +2881,8 @@ TextFocusIn(Widget w, XEvent *event, String *p, Cardinal *n) break; if (i >= num_focus) { focus = (struct _focus*) - XtRealloc((XtPointer)focus, sizeof(struct _focus) * (num_focus + 1)); - i = num_focus; + XtRealloc((XtPointer)focus, (Cardinal)(sizeof(struct _focus) * (num_focus + 1))); + i = (int)num_focus; focus[i].widget = NULL; focus[i].display = XtDisplay(w); num_focus++; @@ -3061,13 +3061,13 @@ InsertChar(Widget w, XEvent *event, String *p, Cardinal *n) return; } - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); if (text.format == XawFmtWide) { - text.ptr = ptr = XawStackAlloc(sizeof(wchar_t) * text.length - * mult, ptrbuf); + text.ptr = ptr = XawStackAlloc(sizeof(wchar_t) * (size_t)text.length + * (size_t)mult, ptrbuf); for (count = 0; count < mult; count++) { - memcpy((char*)ptr, (char *)strbuf, sizeof(wchar_t) * text.length); - ptr += sizeof(wchar_t) * text.length; + memcpy((char*)ptr, (char *)strbuf, sizeof(wchar_t) * (size_t)text.length); + ptr += sizeof(wchar_t) * (size_t)text.length; } #ifndef OLDXAW if (mult == 1) @@ -3077,7 +3077,7 @@ InsertChar(Widget w, XEvent *event, String *p, Cardinal *n) else { /* == XawFmt8Bit */ text.ptr = ptr = XawStackAlloc(text.length * mult, ptrbuf); for (count = 0; count < mult; count++) { - strncpy(ptr, strbuf, text.length); + strncpy(ptr, strbuf, (size_t)text.length); ptr += text.length; } #ifndef OLDXAW @@ -3225,7 +3225,7 @@ IfHexConvertHexElseReturnParam(char *param, int *len_return) /* reject if it doesn't begin with 0x and at least one more character. */ if ((param[0] != '0') || (param[1] != 'x') || (param[2] == '\0')) { - *len_return = strlen(param); + *len_return = (int)strlen(param); return(param); } @@ -3235,13 +3235,13 @@ IfHexConvertHexElseReturnParam(char *param, int *len_return) hexval[ind] = '\0'; for (p = param+2; (c = *p) != '\0'; p++) { - hexval[ind] *= 16; + hexval[ind] = (char)(hexval[ind] * 16); if (c >= '0' && c <= '9') - hexval[ind] += c - '0'; + hexval[ind] = (char)(hexval[ind] + (c - '0')); else if (c >= 'a' && c <= 'f') - hexval[ind] += c - 'a' + 10; + hexval[ind] = (char)(hexval[ind] + (c - 'a' + 10)); else if (c >= 'A' && c <= 'F') - hexval[ind] += c - 'A' + 10; + hexval[ind] = (char)(hexval[ind] + (c - 'A' + 10)); else break; @@ -3253,7 +3253,7 @@ IfHexConvertHexElseReturnParam(char *param, int *len_return) if (++ind < XawTextActionMaxHexChars) hexval[ind] = '\0'; else { - *len_return = strlen(param); + *len_return = (int)strlen(param); return(param); } } @@ -3261,13 +3261,13 @@ IfHexConvertHexElseReturnParam(char *param, int *len_return) /* We quit the above loop becasue we hit a non hex. If that char is \0... */ if ((c == '\0') && first_digit) { - *len_return = strlen(hexval); + *len_return = (int)strlen(hexval); return (hexval); /* ...it was a legal hex string, so return it */ } /* Else, there were non-hex chars or odd digit count, so... */ - *len_return = strlen(param); + *len_return = (int)strlen(param); return (param); /* ...return the verbatim string. */ } @@ -3291,10 +3291,10 @@ InsertString(Widget w, XEvent *event, String *params, Cardinal *num_params) int i; text.firstPos = 0; - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); StartAction(ctx, event); - for (i = *num_params; i; i--, params++) { /* DO FOR EACH PARAMETER */ + for (i = (int)*num_params; i; i--, params++) { /* DO FOR EACH PARAMETER */ text.ptr = IfHexConvertHexElseReturnParam(*params, &text.length); if (text.length == 0) @@ -3370,7 +3370,7 @@ DisplayCaret(Widget w, XEvent *event, String *params, Cardinal *num_params) if (*num_params > 0) { /* default arg is "True" */ XrmValue from, to; - from.size = strlen(from.addr = params[0]); + from.size = (unsigned)strlen(from.addr = params[0]); XtConvert(w, XtRString, &from, XtRBoolean, &to); if (to.addr != NULL) @@ -3379,7 +3379,7 @@ DisplayCaret(Widget w, XEvent *event, String *params, Cardinal *num_params) return; } StartAction(ctx, event); - ctx->text.display_caret = display_caret; + ctx->text.display_caret = (Boolean)display_caret; EndAction(ctx); } @@ -3416,13 +3416,13 @@ Numeric(Widget w, XEvent *event, String *params, Cardinal *num_params) return; } else if (mult == 32767) { - mult = ctx->text.mult = - (params[0][0] - '0'); + mult = ctx->text.mult = (short)(- (params[0][0] - '0')); return; } else { mult = mult * 10 + (params[0][0] - '0') * (mult < 0 ? -1 : 1); - ctx->text.mult = ctx->text.mult * 10 + (params[0][0] - '0') * - (mult < 0 ? -1 : 1); + ctx->text.mult = (short)(ctx->text.mult * 10 + (params[0][0] - '0') * + (mult < 0 ? -1 : 1)); } if (mult != ctx->text.mult || mult >= 32767) { /* checks for overflow */ XBell(XtDisplay(w), 0); @@ -3507,7 +3507,7 @@ Multiply(Widget w, XEvent *event, String *params, Cardinal *num_params) return; } - ctx->text.mult *= mult; + ctx->text.mult = (short)(ctx->text.mult * mult); } /* StripOutOldCRs() - called from FormRegion @@ -3529,7 +3529,7 @@ StripOutOldCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to, /* Initialize our TextBlock with two spaces. */ text.firstPos = 0; - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); if (text.format == XawFmt8Bit) text.ptr= " "; else { @@ -3571,7 +3571,7 @@ StripOutOldCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to, next_word = SrcScan(src, endPos, XawstWhiteSpace, XawsdRight, 1, False); - len = next_word - periodPos; + len = (int)(next_word - periodPos); text.length = 1; buf = _XawTextGetText(ctx, periodPos, next_word); @@ -3634,7 +3634,7 @@ InsertNewCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to, text.firstPos = 0; text.length = 1; - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); if (text.format == XawFmt8Bit) text.ptr = "\n"; @@ -3770,7 +3770,7 @@ BlankLine(Widget w, XawTextPosition pos, int *blanks_return) XawTextPosition r = SrcScan(src, pos, XawstEOL, XawsdRight, 1, False); while (l < r) { - l = XawTextSourceRead(src, l, &block, r - l); + l = XawTextSourceRead(src, l, &block, (int)(r - l)); if (block.length == 0) { if (blanks_return) *blanks_return = blanks; @@ -3836,7 +3836,7 @@ GetBlockBoundaries(TextWidget ctx, (XawTextFormat(ctx, XawFmtWide) && _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr && _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr && - !iswalnum(*(wchar_t*)block.ptr)) || + !iswalnum((wint_t)*(wchar_t*)block.ptr)) || BlankLine((Widget)ctx, from, NULL)) { from = tmp; break; @@ -3864,7 +3864,7 @@ GetBlockBoundaries(TextWidget ctx, (XawTextFormat(ctx, XawFmtWide) && _Xaw_atowc(XawSP) != *(wchar_t*)block.ptr && _Xaw_atowc(XawTAB) != *(wchar_t*)block.ptr && - !iswalnum(*(wchar_t*)block.ptr)) || + !iswalnum((wint_t)*(wchar_t*)block.ptr)) || BlankLine((Widget)ctx, to, NULL)) break; if (to == tmp && !first) @@ -3938,7 +3938,7 @@ FormParagraph(Widget w, XEvent *event, String *params, Cardinal *num_params) endPos = ctx->text.lastPos; } - if (FormRegion(ctx, from, to, pos, src->textSrc.num_text) == XawReplaceError) { + if (FormRegion(ctx, from, to, pos, (int)src->textSrc.num_text) == XawReplaceError) { XawStackFree(pos, buf); pos = buf; #else @@ -3963,23 +3963,23 @@ FormParagraph(Widget w, XEvent *event, String *params, Cardinal *num_params) unsigned llen, rlen, size; XawTextBlock block; - llen = to - from; - rlen = llen + (ctx->text.lastPos - endPos); + llen = (unsigned)(to - from); + rlen = (unsigned)(llen + (ctx->text.lastPos - endPos)); block.firstPos = 0; - block.format = _XawTextFormat(ctx); + block.format = (unsigned long)_XawTextFormat(ctx); rbuf = _XawTextGetText(ctx, from, from + rlen); size = XawTextFormat(ctx, XawFmtWide) ? sizeof(wchar_t) : sizeof(char); if (llen != rlen || memcmp(lbuf, rbuf, llen * size)) { block.ptr = lbuf; - block.length = llen; + block.length = (int)llen; _XawTextReplace(ctx, from, from + rlen, &block); src->textSrc.undo_state = False; block.ptr = rbuf; - block.length = rlen; + block.length = (int)rlen; _XawTextReplace(ctx, from, from + llen, &block); } else @@ -4049,7 +4049,7 @@ TransposeCharacters(Widget w, XEvent *event, ctx->text.insertPos = end; text.firstPos = 0; - text.format = _XawTextFormat(ctx); + text.format = (unsigned long)_XawTextFormat(ctx); /* Retrieve text and swap the characters. */ if (text.format == XawFmtWide) { @@ -4057,7 +4057,7 @@ TransposeCharacters(Widget w, XEvent *event, wchar_t *wbuf; wbuf = (wchar_t*)_XawTextGetText(ctx, start, end); - text.length = wcslen(wbuf); + text.length = (int)wcslen(wbuf); wc = wbuf[0]; for (i = 1; i < text.length; i++) wbuf[i - 1] = wbuf[i]; @@ -4068,7 +4068,7 @@ TransposeCharacters(Widget w, XEvent *event, char c; buf = _XawTextGetText(ctx, start, end); - text.length = strlen(buf); + text.length = (int)strlen(buf); c = buf[0]; for (i = 1; i < text.length; i++) buf[i - 1] = buf[i]; @@ -4097,7 +4097,7 @@ Undo(Widget w, XEvent *event, String *params, Cardinal *num_params) if (mul < 0) { toggle = True; _XawTextSrcToggleUndo((TextSrcObject)ctx->text.source); - ctx->text.mult = mul = -mul; + ctx->text.mult = (short)(mul = -mul); } StartAction(ctx, event); @@ -4232,8 +4232,8 @@ CaseProc(Widget w, XEvent *event, int cmd) left = SrcScan(ctx->text.source, right = ctx->text.insertPos, XawstAlphaNumeric, XawsdLeft, 1 + -mul, False); block.firstPos = 0; - block.format = _XawTextFormat(ctx); - block.length = right - left; + block.format = (unsigned long)_XawTextFormat(ctx); + block.length = (int)(right - left); block.ptr = _XawTextGetText(ctx, left, right); count = 0; @@ -4242,16 +4242,16 @@ CaseProc(Widget w, XEvent *event, int cmd) if (!IsAlnum(*mb = (unsigned char)block.ptr[i])) count = 0; else if (++count == 1 || cmd != CAPITALIZE) { - ch = cmd == DOWNCASE ? ToLower(*mb) : ToUpper(*mb); + ch = (unsigned char)((cmd == DOWNCASE) ? ToLower(*mb) : ToUpper(*mb)); if (ch != *mb) { changed = True; - block.ptr[i] = ch; + block.ptr[i] = (char)ch; } } else if (cmd == CAPITALIZE) { - if ((ch = ToLower(*mb)) != *mb) { + if ((ch = (unsigned char)(ToLower(*mb))) != *mb) { changed = True; - block.ptr[i] = ch; + block.ptr[i] = (char)ch; } } } @@ -4261,14 +4261,14 @@ CaseProc(Widget w, XEvent *event, int cmd) if (!IsAlnum(*mb)) count = 0; else if (++count == 1 || cmd != CAPITALIZE) { - ch = cmd == DOWNCASE ? ToLower(*mb) : ToUpper(*mb); + ch = (unsigned char)((cmd == DOWNCASE) ? ToLower(*mb) : ToUpper(*mb)); if (ch != *mb) { changed = True; ((wchar_t*)block.ptr)[i] = _Xaw_atowc(ch); } } else if (cmd == CAPITALIZE) { - if ((ch = ToLower(*mb)) != *mb) { + if ((ch = (unsigned char)(ToLower(*mb))) != *mb) { changed = True; ((wchar_t*)block.ptr)[i] = _Xaw_atowc(ch); } diff --git a/src/TextPop.c b/src/TextPop.c index 3ff29b9538012f1821d70d0803471e84c4490190..99c865c5d031201acfec47c77d43ab02b279f30c 100644 --- a/src/TextPop.c +++ b/src/TextPop.c @@ -313,12 +313,12 @@ InsertFileNamed(Widget tw, char *str) fseek(file, 0L, SEEK_END); text.firstPos = 0; - text.length = ftell(file); - text.ptr = XtMalloc(text.length + 1); + text.length = (int)ftell(file); + text.ptr = XtMalloc((Cardinal)(text.length + 1)); text.format = XawFmt8Bit; fseek(file, 0L, SEEK_SET); - if (fread(text.ptr, 1, text.length, file) != text.length) + if (fread(text.ptr, 1, (size_t)text.length, file) != text.length) XtErrorMsg("readError", "insertFileNamed", "XawError", "fread returned error", NULL, NULL); @@ -844,10 +844,10 @@ DoSearch(struct SearchAndReplace *search) text.firstPos = 0; text.ptr = GetStringRaw(search->search_text); - if ((text.format = _XawTextFormat(ctx)) == XawFmtWide) - text.length = wcslen((wchar_t*)text.ptr); + if ((text.format = (unsigned long)_XawTextFormat(ctx)) == XawFmtWide) + text.length = (int)wcslen((wchar_t*)text.ptr); else { - text.length = strlen(text.ptr); + text.length = (int)strlen(text.ptr); #ifndef OLDXAW if (search->case_sensitive) { @@ -877,15 +877,15 @@ DoSearch(struct SearchAndReplace *search) int len; ptr = GetString(search->search_text); - len = strlen(ptr); + len = (int)strlen(ptr); snprintf(msg, sizeof(msg), "%s", ptr); ptr = strchr(msg, '\n'); if (ptr != NULL || sizeof(msg) - 1 < len) { if (ptr != NULL) - len = ptr - msg + 4; + len = (int)(ptr - msg + 4); else - len = strlen(msg); + len = (int)strlen(msg); if (len < 4) strcpy(msg, "..."); @@ -1006,18 +1006,18 @@ Replace(struct SearchAndReplace *search, Bool once_only, Bool show_current) Bool redisplay; find.ptr = GetStringRaw(search->search_text); - if ((find.format = _XawTextFormat(ctx)) == XawFmtWide) - find.length = (XawTextPosition)wcslen((wchar_t*)find.ptr); + if ((find.format = (unsigned long)_XawTextFormat(ctx)) == XawFmtWide) + find.length = (int)(XawTextPosition)wcslen((wchar_t*)find.ptr); else - find.length = (XawTextPosition)strlen(find.ptr); + find.length = (int)(XawTextPosition)strlen(find.ptr); find.firstPos = 0; replace.ptr = GetStringRaw(search->rep_text); replace.firstPos = 0; - if ((replace.format = _XawTextFormat(ctx)) == XawFmtWide) - replace.length = wcslen((wchar_t*)replace.ptr); + if ((replace.format = (unsigned long)_XawTextFormat(ctx)) == XawFmtWide) + replace.length = (int)wcslen((wchar_t*)replace.ptr); else - replace.length = strlen(replace.ptr); + replace.length = (int)strlen(replace.ptr); dir = (XawTextScanDirection)(unsigned long) ((XPointer)XawToggleGetCurrent(search->left_toggle) - R_OFFSET); @@ -1038,14 +1038,14 @@ Replace(struct SearchAndReplace *search, Bool once_only, Bool show_current) int len; ptr = GetString(search->search_text); - len = strlen(ptr); + len = (int)strlen(ptr); snprintf(msg, sizeof(msg), "%s", ptr); ptr = strchr(msg, '\n'); if (ptr != NULL || sizeof(msg) - 1 < len) { if (ptr != NULL) - len = ptr - msg + 4; + len = (int)(ptr - msg + 4); else - len = strlen(msg); + len = (int)strlen(msg); if (len < 4) strcpy(msg, "..."); @@ -1356,13 +1356,13 @@ CenterWidgetOnPoint(Widget w, XEvent *event) switch (event->type) { case ButtonPress: case ButtonRelease: - x = event->xbutton.x_root; - y = event->xbutton.y_root; + x = (Position)event->xbutton.x_root; + y = (Position)event->xbutton.y_root; break; case KeyPress: case KeyRelease: - x = event->xkey.x_root; - y = event->xkey.y_root; + x = (Position)event->xkey.x_root; + y = (Position)event->xkey.y_root; break; default: return; @@ -1377,16 +1377,16 @@ CenterWidgetOnPoint(Widget w, XEvent *event) XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++; XtGetValues(w, args, num_args); - width += b_width << 1; - height += b_width << 1; + width = (Dimension)(width + (b_width << 1)); + height = (Dimension)(height + (b_width << 1)); - x -= (Position)(width >> 1); + x = (Position)(x - (width >> 1)); if (x < 0) x = 0; if (x > (max_x = (Position)(XtScreen(w)->width - width))) x = max_x; - y -= (Position)(height >> 1); + y = (Position)(y - (height >> 1)); if (y < 0) y = 0; if (y > (max_y = (Position)(XtScreen(w)->height - height))) @@ -1537,7 +1537,7 @@ SetWMProtocolTranslations(Widget w) actions[0].proc = WMProtocols; list_size++; app_context_list = (XtAppContext *)XtRealloc - ((char *)app_context_list, list_size * sizeof(XtAppContext)); + ((char *)app_context_list, (Cardinal)(list_size * sizeof(XtAppContext))); XtAppAddActions(app_context, actions, 1); app_context_list[i] = app_context; } diff --git a/src/TextSink.c b/src/TextSink.c index 244a139c0bf4f06259a7ab5dac402d8a821eba2d..758cc2bfd53f5b3257dd6201cbcf2da0add82824 100644 --- a/src/TextSink.c +++ b/src/TextSink.c @@ -423,15 +423,15 @@ ClearToBackground(Widget w, int x, int y, TextWidget xaw = (TextWidget)XtParent(w); Position x1, y1, x2, y2; - x1 = XawMax(x, xaw->text.r_margin.left); - y1 = XawMax(y, xaw->text.r_margin.top); - x2 = XawMin(x + (int)width, (int)XtWidth(xaw) - xaw->text.r_margin.right); - y2 = XawMin(y + (int)height, (int)XtHeight(xaw) - xaw->text.r_margin.bottom); + x1 = (XawMax(x, xaw->text.r_margin.left)); + y1 = (XawMax(y, xaw->text.r_margin.top)); + x2 = (XawMin(x + (int)width, (int)XtWidth(xaw) - xaw->text.r_margin.right)); + y2 = (XawMin(y + (int)height, (int)XtHeight(xaw) - xaw->text.r_margin.bottom)); x = x1; y = y1; - width = XawMax(0, x2 - x1); - height = XawMax(0, y2 - y1); + width = (unsigned)(XawMax(0, x2 - x1)); + height = (unsigned)(XawMax(0, y2 - y1)); if (height != 0 && width != 0) XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w), @@ -594,7 +594,7 @@ SetTabs(Widget w, int tab_count, short *tabs) static void GetCursorBounds(Widget w, XRectangle *rect) { - rect->x = rect->y = rect->width = rect->height = 0; + rect->x = rect->y = (short)(rect->width = rect->height = 0); } /* @@ -858,7 +858,7 @@ XawTextSinkSetTabs(Widget w, int tab_count, int *tabs) { if (tab_count > 0) { TextSinkObjectClass cclass = (TextSinkObjectClass)w->core.widget_class; - short *char_tabs = (short*)XtMalloc((unsigned)tab_count * sizeof(short)); + short *char_tabs = (short*)XtMalloc((Cardinal)((unsigned)tab_count * sizeof(short))); short *tab, len = 0; int i; @@ -1015,7 +1015,7 @@ static Cardinal num_prop_lists; static int bcmp_qident(_Xconst void *left, _Xconst void *right) { - return ((long)left - (*(XawTextProperty**)right)->identifier); + return (int)((long)left - (*(XawTextProperty**)right)->identifier); } static int @@ -1102,7 +1102,7 @@ SetXlfdDefaults(Display *display, XawTextProperty *property) atom = XInternAtom(display, "UNDERLINE_THICKNESS", True); if (XGetFontProperty(property->font, atom, &value) && (str = XGetAtomName(display, value)) != NULL) { - property->underline_thickness = atoi(str); + property->underline_thickness = (short)(atoi(str)); XFree(str); } else { @@ -1115,9 +1115,9 @@ SetXlfdDefaults(Display *display, XawTextProperty *property) */ if (property->pixel_size != NULLQUARK) { property->underline_thickness = - atoi(XrmQuarkToString(property->pixel_size)) / 10; + (short)(atoi(XrmQuarkToString(property->pixel_size)) / 10); property->underline_thickness = - XawMax(1, property->underline_thickness); + (XawMax(1, property->underline_thickness)); } else property->underline_thickness = 1; @@ -1126,7 +1126,7 @@ SetXlfdDefaults(Display *display, XawTextProperty *property) atom = XInternAtom(display, "UNDERLINE_POSITION", True); if (XGetFontProperty(property->font, atom, &value) && (str = XGetAtomName(display, value)) != NULL) { - property->underline_position = atoi(str); + property->underline_position = (short)(atoi(str)); XFree(str); } else @@ -1139,8 +1139,8 @@ SetXlfdDefaults(Display *display, XawTextProperty *property) /* I am assuming xlfd does not consider that lines are * centered in the path */ - property->underline_position += property->underline_thickness >> 1; - + property->underline_position = (short)(property->underline_position + + (property->underline_thickness >> 1)); } static void @@ -1194,7 +1194,7 @@ XawTextSinkCopyProperty(Widget w, XrmQuark property) if (cur) memcpy(ret, cur, sizeof(XawTextProperty)); ret->identifier = NULLQUARK; - ret->mask &= ~XAW_TPROP_FONT; + ret->mask &= (unsigned long)(~XAW_TPROP_FONT); return (ret); } @@ -1324,7 +1324,7 @@ _XawTextSinkAddProperty(XawTextPropertyList *list, XawTextProperty *property, SetXlfdDefaults(DisplayOfScreen(list->screen), result); } else - result->mask &= ~XAW_TPROP_FONT; + result->mask &= (unsigned long)(~XAW_TPROP_FONT); } if (result->font) @@ -1356,8 +1356,9 @@ _XawTextSinkAddProperty(XawTextPropertyList *list, XawTextProperty *property, } list->properties = (XawTextProperty**) - XtRealloc((XtPointer)list->properties, sizeof(XawTextProperty*) * - (list->num_properties + 1)); + XtRealloc((XtPointer)list->properties, + (Cardinal)(sizeof(XawTextProperty*) * + (list->num_properties + 1))); list->properties[list->num_properties++] = result; qsort((void*)list->properties, list->num_properties, sizeof(XawTextProperty*), qcmp_qident); @@ -1713,8 +1714,9 @@ XawTextSinkConvertPropertyList(String name, String spec, Screen *screen, } prop_lists = (XawTextPropertyList**) - XtRealloc((XtPointer)prop_lists, sizeof(XawTextPropertyList*) * - (num_prop_lists + 1)); + XtRealloc((XtPointer)prop_lists, + (Cardinal)(sizeof(XawTextPropertyList*) * + (num_prop_lists + 1))); prop_lists[num_prop_lists++] = propl; qsort((void*)prop_lists, num_prop_lists, sizeof(XawTextPropertyList*), qcmp_qident); @@ -1759,7 +1761,7 @@ CvtStringToPropertyList(Display *dpy, XrmValue *args, Cardinal *num_args, if (ptr) { Screen *screen = w->core.screen; Colormap colormap = w->core.colormap; - int depth = w->core.depth; + int depth = (int)w->core.depth; propl = *ptr; while (propl) { @@ -1819,7 +1821,7 @@ CvtPropertyListToString(Display *dpy, XrmValue *args, Cardinal *num_args, } buffer = XrmQuarkToString(propl->identifier); - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); if (toVal->addr != NULL) { if (toVal->size < size) { diff --git a/src/TextSrc.c b/src/TextSrc.c index 26ce4741672d5440756775f7c21e75eeb4e691ae..7137122fd018f69aed2f5be3c9ee492b2ef47561 100644 --- a/src/TextSrc.c +++ b/src/TextSrc.c @@ -550,7 +550,7 @@ CvtEditModeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, return (False); } - size = strlen(buffer) + 1; + size = (Cardinal)(strlen(buffer) + 1); if (toVal->addr != NULL) { if (toVal->size < size) { toVal->size = size; @@ -573,7 +573,7 @@ _XawTextSourceNewLineAtEOF(Widget w) XawTextBlock text; text.firstPos = 0; - if ((text.format = src->textSrc.text_format) == XawFmt8Bit) + if ((text.format = (unsigned long)src->textSrc.text_format) == XawFmt8Bit) text.ptr = SrcNL; else text.ptr = (char*)SrcWNL; @@ -600,7 +600,7 @@ _XawSourceAddText(Widget source, Widget text) if (!found) { src->textSrc.text = (WidgetList) XtRealloc((char*)src->textSrc.text, - sizeof(Widget) * (src->textSrc.num_text + 1)); + (Cardinal)(sizeof(Widget) * (src->textSrc.num_text + 1))); src->textSrc.text[src->textSrc.num_text++] = text; } } @@ -757,13 +757,13 @@ XawTextSourceReplace(Widget w, XawTextPosition left, break; } l_state->buffer = _XawTextGetText((TextWidget)ctx, left, right); - l_state->length = right - left; + l_state->length = (unsigned)(right - left); } else { l_state->length = 0; l_state->buffer = NULL; } - l_state->format = src->textSrc.text_format; + l_state->format = (unsigned long)src->textSrc.text_format; if (l_state->length == 1) { if (l_state->format == XawFmtWide && *(wchar_t*)l_state->buffer == *SrcWNL) { @@ -786,8 +786,8 @@ XawTextSourceReplace(Widget w, XawTextPosition left, r_state->position = left; r_state->format = block->format; size = block->format == XawFmtWide ? sizeof(wchar_t) : sizeof(char); - total = size * block->length; - r_state->length = block->length; + total = (size * (unsigned)block->length); + r_state->length = (unsigned)block->length; r_state->buffer = NULL; if (total == size) { if (r_state->format == XawFmtWide && @@ -953,8 +953,8 @@ XawTextSourceReplace(Widget w, XawTextPosition left, else { src->textSrc.undo->undo = (XawTextUndoBuffer**) XtRealloc((char*)src->textSrc.undo->undo, - (2 + src->textSrc.undo->num_undo) - * sizeof(XawTextUndoBuffer)); + (Cardinal)((2 + src->textSrc.undo->num_undo) + * sizeof(XawTextUndoBuffer))); src->textSrc.undo->undo[src->textSrc.undo->num_undo++] = l_state; src->textSrc.undo->undo[src->textSrc.undo->num_undo++] = r_state; @@ -1019,9 +1019,9 @@ XawTextSourceReplace(Widget w, XawTextPosition left, /* adjust entity length */ if (entity && offset <= left) { if (offset + entity->length < right) - entity->length = left - offset + block->length; + entity->length = (Cardinal)(left - offset + block->length); else - entity->length += diff; + entity->length = (Cardinal)(entity->length + diff); if (entity->length == 0) { enext = entity->next; @@ -1051,7 +1051,7 @@ XawTextSourceReplace(Widget w, XawTextPosition left, offset = anchor->position + entity->offset + entity->length; if (offset > right) { - entity->length = XawMin(entity->length, offset - right); + entity->length = (XawMin(entity->length, offset - right)); goto exit_anchor_loop; } @@ -1068,7 +1068,7 @@ XawTextSourceReplace(Widget w, XawTextPosition left, else if (i < --src->textSrc.num_anchors) { memmove(&src->textSrc.anchors[i], &src->textSrc.anchors[i + 1], - (src->textSrc.num_anchors - i) * + (size_t)(src->textSrc.num_anchors - i) * sizeof(XawTextAnchor*)); XtFree((XtPointer)anchor); } @@ -1158,7 +1158,7 @@ exit_anchor_loop: anchor->cache = NULL; if ((anchor->entities = entity) != NULL) { if ((entity->offset += diff) < 0) { - entity->length += entity->offset; + entity->length = (Cardinal)(entity->length + entity->offset); entity->offset = 0; } } @@ -1229,7 +1229,7 @@ _XawTextSrcUndo(TextSrcObject src, XawTextPosition *insert_pos) src->textSrc.changed = True; block.firstPos = 0; - block.length = r_state->length; + block.length = (int)r_state->length; block.ptr = r_state->buffer ? r_state->buffer : (char*)&wnull; block.format = r_state->format; @@ -1343,7 +1343,7 @@ FreeUndoBuffer(XawTextUndo *undo) undo->l_no_change = undo->r_no_change = NULL; undo->undo = NULL; undo->dir = XawsdLeft; - undo->num_undo = undo->num_list = undo->erase = undo->merge = 0; + undo->num_undo = undo->num_list = (unsigned)(undo->erase = undo->merge = 0); } static void @@ -1538,7 +1538,7 @@ _XawTextWCToMB(Display *d, wchar_t *wstr, int *len_in_out) *len_in_out = 0; return (NULL); } - *len_in_out = textprop.nitems; + *len_in_out = (int)textprop.nitems; return ((char *)textprop.value); } @@ -1563,9 +1563,9 @@ _XawTextMBToWC(Display *d, char *str, int *len_in_out) if (*len_in_out == 0) return (NULL); - buf = XtMalloc(*len_in_out + 1); + buf = XtMalloc((Cardinal)(*len_in_out + 1)); - strncpy(buf, str, *len_in_out); + strncpy(buf, str, (size_t)*len_in_out); *(buf + *len_in_out) = '\0'; if (XmbTextListToTextProperty(d, &buf, 1, XTextStyle, &textprop) != Success) { XtWarningMsg("convertError", "textSource", "XawError", @@ -1584,7 +1584,7 @@ _XawTextMBToWC(Display *d, char *str, int *len_in_out) return (NULL); } wstr = wlist[0]; - *len_in_out = wcslen(wstr); + *len_in_out = (int)wcslen(wstr); XtFree((XtPointer)wlist); return (wstr); @@ -1594,8 +1594,8 @@ _XawTextMBToWC(Display *d, char *str, int *len_in_out) static int qcmp_anchors(_Xconst void *left, _Xconst void *right) { - return ((*(XawTextAnchor**)left)->position - - (*(XawTextAnchor**)right)->position); + return (int)((*(XawTextAnchor**)left)->position - + (*(XawTextAnchor**)right)->position); } XawTextAnchor * @@ -1658,10 +1658,12 @@ XawTextSourceAddAnchor(Widget w, XawTextPosition position) anchor->cache = NULL; src->textSrc.anchors = (XawTextAnchor**) - XtRealloc((XtPointer)src->textSrc.anchors, sizeof(XawTextAnchor*) * - (src->textSrc.num_anchors + 1)); + XtRealloc((XtPointer)src->textSrc.anchors, + (Cardinal)(sizeof(XawTextAnchor*) * + (size_t)(src->textSrc.num_anchors + 1))); src->textSrc.anchors[src->textSrc.num_anchors++] = anchor; - qsort((void*)src->textSrc.anchors, src->textSrc.num_anchors, + qsort((void*)src->textSrc.anchors, + (size_t)src->textSrc.num_anchors, sizeof(XawTextAnchor*), qcmp_anchors); return (anchor); @@ -1782,7 +1784,7 @@ XawTextSourceRemoveAnchor(Widget w, XawTextAnchor *anchor) if (i < --src->textSrc.num_anchors) { memmove(&src->textSrc.anchors[i], &src->textSrc.anchors[i + 1], - (src->textSrc.num_anchors - i) * + (size_t)(src->textSrc.num_anchors - i) * sizeof(XawTextAnchor*)); return (src->textSrc.anchors[i]); @@ -1865,8 +1867,8 @@ XawTextSourceAddEntity(Widget w, int type, int flags, XtPointer data, } entity = XtNew(XawTextEntity); - entity->type = type; - entity->flags = flags; + entity->type = (short)type; + entity->flags = (short)flags; entity->data = data; entity->offset = position - anchor->position; entity->length = length; @@ -1926,7 +1928,7 @@ XawTextSourceClearEntities(Widget w, XawTextPosition left, XawTextPosition right offset = anchor->position + entity->offset; if (offset <= left) { - length = XawMin(entity->length, left - offset); + length = (XawMin(entity->length, left - offset)); if (length <= 0) { enext = entity->next; @@ -1947,7 +1949,7 @@ XawTextSourceClearEntities(Widget w, XawTextPosition left, XawTextPosition right entity = enext; } else { - entity->length = length; + entity->length = (Cardinal)length; eprev = entity; entity = entity->next; } @@ -1961,7 +1963,7 @@ XawTextSourceClearEntities(Widget w, XawTextPosition left, XawTextPosition right if (offset > right) { anchor->cache = NULL; entity->offset = XawMax(entity->offset, right - anchor->position); - entity->length = XawMin(entity->length, offset - right); + entity->length = (XawMin(entity->length, offset - right)); return; } diff --git a/src/Tip.c b/src/Tip.c index 8328aace37bb4490dfbe91f8c7c98985b8c355eb..7a3391d1d365a28feac73c5d721fe946b2d9b339 100644 --- a/src/Tip.c +++ b/src/Tip.c @@ -297,7 +297,7 @@ XawTipRealize(Widget w, Mask *mask, XSetWindowAttributes *attr) attr->backing_store = tip->tip.backing_store; } else - *mask &= ~CWBackingStore; + *mask &= (Mask)(~CWBackingStore); *mask |= CWOverrideRedirect; attr->override_redirect = True; @@ -319,26 +319,26 @@ XawTipExpose(Widget w, XEvent *event, Region region) TipWidget tip = (TipWidget)w; GC gc = tip->tip.gc; char *nl, *label = tip->tip.label; - Position y = tip->tip.top_margin + tip->tip.font->max_bounds.ascent; + Position y = (Position)(tip->tip.top_margin + tip->tip.font->max_bounds.ascent); int len; if (tip->tip.display_list) XawRunDisplayList(w, tip->tip.display_list, event, region); if (tip->tip.international == True) { - Position ksy = tip->tip.top_margin; + Position ksy = (Position)tip->tip.top_margin; XFontSetExtents *ext = XExtentsOfFontSet(tip->tip.fontset); - ksy += XawAbs(ext->max_ink_extent.y); + ksy = (ksy + XawAbs(ext->max_ink_extent.y)); while ((nl = index(label, '\n')) != NULL) { XmbDrawString(XtDisplay(w), XtWindow(w), tip->tip.fontset, gc, tip->tip.left_margin, ksy, label, (int)(nl - label)); - ksy += ext->max_ink_extent.height; + ksy = (ksy + ext->max_ink_extent.height); label = nl + 1; } - len = strlen(label); + len = (int)strlen(label); if (len) XmbDrawString(XtDisplay(w), XtWindow(w), tip->tip.fontset, gc, tip->tip.left_margin, ksy, label, len); @@ -352,11 +352,11 @@ XawTipExpose(Widget w, XEvent *event, Region region) else XDrawString(XtDisplay(w), XtWindow(w), gc, tip->tip.left_margin, y, label, (int)(nl - label)); - y += tip->tip.font->max_bounds.ascent + - tip->tip.font->max_bounds.descent; + y = (Position)(y + (tip->tip.font->max_bounds.ascent + + tip->tip.font->max_bounds.descent)); label = nl + 1; } - len = strlen(label); + len = (int)strlen(label); if (len) { if (tip->tip.encoding) XDrawString16(XtDisplay(w), XtWindow(w), gc, @@ -426,7 +426,7 @@ TipLayout(XawTipInfo *info) } } else - width = XmbTextEscapement(fset, label, strlen(label)); + width = XmbTextEscapement(fset, label, (int)strlen(label)); } else { height = fs->max_bounds.ascent + fs->max_bounds.descent; @@ -449,13 +449,13 @@ TipLayout(XawTipInfo *info) } else width = info->tip->tip.encoding ? - XTextWidth16(fs, (XChar2b*)label, strlen(label) >> 1) : - XTextWidth(fs, label, strlen(label)); + XTextWidth16(fs, (XChar2b*)label, (int)(strlen(label) >> 1)) : + XTextWidth(fs, label, (int)strlen(label)); } - XtWidth(info->tip) = width + info->tip->tip.left_margin + - info->tip->tip.right_margin; - XtHeight(info->tip) = height + info->tip->tip.top_margin + - info->tip->tip.bottom_margin; + XtWidth(info->tip) = (width + info->tip->tip.left_margin + + info->tip->tip.right_margin); + XtHeight(info->tip) = (height + info->tip->tip.top_margin + + info->tip->tip.bottom_margin); } #define DEFAULT_TIP_Y_OFFSET 12 @@ -469,14 +469,14 @@ TipPosition(XawTipInfo *info) XQueryPointer(XtDisplay((Widget)info->tip), XtWindow((Widget)info->tip), &r, &c, &rx, &ry, &wx, &wy, &mask); - x = rx - (XtWidth(info->tip) >> 1); - y = ry + DEFAULT_TIP_Y_OFFSET; + x = (Position)(rx - (XtWidth(info->tip) >> 1)); + y = (Position)(ry + DEFAULT_TIP_Y_OFFSET); if (x >= 0) { int scr_width = WidthOfScreen(XtScreen(info->tip)); if (x + XtWidth(info->tip) + XtBorderWidth(info->tip) > scr_width) - x = scr_width - XtWidth(info->tip) - XtBorderWidth(info->tip); + x = (Position)(scr_width - XtWidth(info->tip) - XtBorderWidth(info->tip)); } if (x < 0) x = 0; @@ -484,8 +484,8 @@ TipPosition(XawTipInfo *info) int scr_height = HeightOfScreen(XtScreen(info->tip)); if (y + XtHeight(info->tip) + XtBorderWidth(info->tip) > scr_height) - y -= XtHeight(info->tip) + XtBorderWidth(info->tip) + - (DEFAULT_TIP_Y_OFFSET << 1); + y = (Position)(y - (XtHeight(info->tip) + XtBorderWidth(info->tip) + + (DEFAULT_TIP_Y_OFFSET << 1))); } if (y < 0) y = 0; @@ -548,7 +548,8 @@ ResetTip(XawTipInfo *info, Bool add_timeout) if (add_timeout) { info->tip->tip.timer = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)info->tip), - info->tip->tip.timeout, TipTimeoutCallback, + (unsigned long)info->tip->tip.timeout, + TipTimeoutCallback, (XtPointer)info); } } diff --git a/src/Tree.c b/src/Tree.c index f4781bfd1eb46c78884e9c14f1a867992c3e3ab3..60d7cc922d4a13eb8cc1bd0548e6132d0341e7fe 100644 --- a/src/Tree.c +++ b/src/Tree.c @@ -217,7 +217,7 @@ initialize_dimensions(Dimension **listp, int *sizep, int n) } if (n > *sizep) { *listp = (Dimension *) XtRealloc((char *) *listp, - (unsigned int) (n*sizeof(Dimension))); + (Cardinal) ((size_t)n*sizeof(Dimension))); if (!*listp) { *sizep = 0; return; @@ -265,8 +265,8 @@ insert_node(Widget parent, Widget node) if (pc->tree.n_children == pc->tree.max_children) { pc->tree.max_children += (pc->tree.max_children / 2) + 2; pc->tree.children = (WidgetList) XtRealloc ((char *)pc->tree.children, - (unsigned int) - ((pc->tree.max_children) * + (Cardinal) + ((size_t)pc->tree.max_children * sizeof(Widget))); } @@ -725,7 +725,7 @@ compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth) int i; Bool horiz = IsHorizontal (tree); Dimension newwidth, newheight; - Dimension bw2 = w->core.border_width * 2; + Dimension bw2 = (Dimension)(w->core.border_width * 2); /* * Set the max-size per level. @@ -734,7 +734,7 @@ compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth) initialize_dimensions (&tree->tree.largest, &tree->tree.n_largest, depth + 1); } - newwidth = ((horiz ? w->core.width : w->core.height) + bw2); + newwidth = (Dimension)((horiz ? w->core.width : w->core.height) + bw2); if (tree->tree.largest[depth] < newwidth) tree->tree.largest[depth] = newwidth; @@ -742,8 +742,8 @@ compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth) /* * initialize */ - tc->tree.bbwidth = w->core.width + bw2; - tc->tree.bbheight = w->core.height + bw2; + tc->tree.bbwidth = (Dimension)(w->core.width + bw2); + tc->tree.bbheight = (Dimension)(w->core.height + bw2); if (tc->tree.n_children == 0) return; @@ -762,10 +762,10 @@ compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth) if (horiz) { if (newwidth < cc->tree.bbwidth) newwidth = cc->tree.bbwidth; - newheight += tree->tree.vpad + cc->tree.bbheight; + newheight = (Dimension)(newheight + (tree->tree.vpad + cc->tree.bbheight)); } else { if (newheight < cc->tree.bbheight) newheight = cc->tree.bbheight; - newwidth += tree->tree.hpad + cc->tree.bbwidth; + newwidth = (Dimension)(newwidth + (tree->tree.hpad + cc->tree.bbwidth)); } } @@ -778,12 +778,12 @@ compute_bounding_box_subtree(TreeWidget tree, Widget w, int depth) * extra padding. Be careful of unsigned arithmetic. */ if (horiz) { - tc->tree.bbwidth += tree->tree.hpad + newwidth; - newheight -= tree->tree.vpad; + tc->tree.bbwidth = (Dimension)(tc->tree.bbwidth + (tree->tree.hpad + newwidth)); + newheight = (Dimension)(newheight - tree->tree.vpad); if (newheight > tc->tree.bbheight) tc->tree.bbheight = newheight; } else { - tc->tree.bbheight += tree->tree.vpad + newheight; - newwidth -= tree->tree.hpad; + tc->tree.bbheight = (Dimension)(tc->tree.bbheight + (tree->tree.vpad + newheight)); + newwidth = (Dimension)(newwidth - tree->tree.hpad); if (newwidth > tc->tree.bbwidth) tc->tree.bbwidth = newwidth; } } @@ -803,13 +803,13 @@ set_positions(TreeWidget tw, Widget w, int level) */ switch (tw->tree.gravity) { case EastGravity: - tc->tree.x = (((Position) tw->tree.maxwidth) - - ((Position) w->core.width) - tc->tree.x); + tc->tree.x = (Position) (tw->tree.maxwidth - + w->core.width - tc->tree.x); break; case SouthGravity: - tc->tree.y = (((Position) tw->tree.maxheight) - - ((Position) w->core.height) - tc->tree.y); + tc->tree.y = (Position) (tw->tree.maxheight - + w->core.height - tc->tree.y); break; } @@ -838,15 +838,15 @@ arrange_subtree(TreeWidget tree, Widget w, int depth, int x, int y) Bool horiz = IsHorizontal (tree); Widget child = NULL; Dimension tmp; - Dimension bw2 = w->core.border_width * 2; + Dimension bw2 = (Dimension)(w->core.border_width * 2); Bool relayout = True; /* * If no children, then just lay out where requested. */ - tc->tree.x = x; - tc->tree.y = y; + tc->tree.x = (Position)x; + tc->tree.y = (Position)y; if (horiz) { int myh = (w->core.height + bw2); @@ -864,9 +864,9 @@ arrange_subtree(TreeWidget tree, Widget w, int depth, int x, int y) } } - if ((tmp = ((Dimension) x) + tc->tree.bbwidth) > tree->tree.maxwidth) + if ((tmp = (Dimension)(x + tc->tree.bbwidth)) > tree->tree.maxwidth) tree->tree.maxwidth = tmp; - if ((tmp = ((Dimension) y) + tc->tree.bbheight) > tree->tree.maxheight) + if ((tmp = (Dimension)(y + tc->tree.bbheight)) > tree->tree.maxheight) tree->tree.maxheight = tmp; if (tc->tree.n_children == 0) return; @@ -913,21 +913,21 @@ arrange_subtree(TreeWidget tree, Widget w, int depth, int x, int y) * this could collide with the position of the previous sibling. */ if (horiz) { - tc->tree.x = x; - adjusted = firstcc->tree.y + + tc->tree.x = (Position)x; + adjusted = (Position)(firstcc->tree.y + ((lastcc->tree.y + (Position) child->core.height + (Position) child->core.border_width * 2 - firstcc->tree.y - (Position) w->core.height - - (Position) w->core.border_width * 2 + 1) / 2); + (Position) w->core.border_width * 2 + 1) / 2)); if (adjusted > tc->tree.y) tc->tree.y = adjusted; } else { - adjusted = firstcc->tree.x + + adjusted = (Position)(firstcc->tree.x + ((lastcc->tree.x + (Position) child->core.width + (Position) child->core.border_width * 2 - firstcc->tree.x - (Position) w->core.width - - (Position) w->core.border_width * 2 + 1) / 2); + (Position) w->core.border_width * 2 + 1) / 2)); if (adjusted > tc->tree.x) tc->tree.x = adjusted; - tc->tree.y = y; + tc->tree.y = (Position)y; } } } @@ -937,12 +937,13 @@ set_tree_size(TreeWidget tw, Bool insetvalues, unsigned int width, unsigned int height) { if (insetvalues) { - tw->core.width = width; - tw->core.height = height; + tw->core.width = (Dimension)width; + tw->core.height = (Dimension)height; } else { Dimension replyWidth = 0, replyHeight = 0; XtGeometryResult result = XtMakeResizeRequest ((Widget) tw, - width, height, + (Dimension)width, + (Dimension)height, &replyWidth, &replyHeight); /* diff --git a/src/Vendor.c b/src/Vendor.c index d14b79682e65fe4a908f4b4a90343103dd7c80e9..d368c824ab35858c9a883bf3a55a65c7286b9190 100644 --- a/src/Vendor.c +++ b/src/Vendor.c @@ -297,9 +297,9 @@ XawCvtCompoundTextToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, "conversion from CT to MB failed.", NULL, NULL); return False; } - len = strlen(*list); - toVal->size = len; - mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */ + len = (int)strlen(*list); + toVal->size = (unsigned)len; + mbs = XtRealloc(mbs, (Cardinal)(len + 1)); /* keep buffer because no one call free :( */ strcpy(mbs, *list); XFreeStringList(list); toVal->addr = (XtPointer)mbs; @@ -432,7 +432,9 @@ XawVendorShellExtResize(Widget w) for( i = 0; i < sw->composite.num_children; i++ ) { if( XtIsManaged( sw->composite.children[ i ] ) ) { childwid = sw->composite.children[ i ]; - XtResizeWidget( childwid, sw->core.width, core_height, + XtResizeWidget( childwid, + (Dimension)sw->core.width, + (Dimension)core_height, childwid->core.border_width ); } } @@ -467,8 +469,8 @@ XawVendorShellGeometryManager(Widget wid, XtWidgetGeometry *request, my_request.request_mode |= CWWidth; } if (request->request_mode & CWHeight) { - my_request.height = request->height - + _XawImGetImAreaHeight( wid ); + my_request.height = (Dimension)(request->height + + _XawImGetImAreaHeight( wid )); my_request.request_mode |= CWHeight; } if (request->request_mode & CWBorderWidth) { @@ -489,7 +491,7 @@ XawVendorShellGeometryManager(Widget wid, XtWidgetGeometry *request, wid->core.width = shell->core.width; wid->core.height = shell->core.height; if (request->request_mode & CWBorderWidth) { - wid->core.x = wid->core.y = -request->border_width; + wid->core.x = wid->core.y = (Position)(-request->border_width); } _XawImCallVendorShellExtResize(wid); return XtGeometryYes; @@ -504,7 +506,7 @@ XawVendorShellChangeManaged(Widget wid) int i; (*SuperClass->composite_class.change_managed)(wid); - for (i = w->composite.num_children, childP = w->composite.children; + for (i = (int)w->composite.num_children, childP = w->composite.children; i; i--, childP++) { if (XtIsManaged(*childP)) { XtSetKeyboardFocus(wid, *childP); diff --git a/src/Viewport.c b/src/Viewport.c index 082682f8232068972300826f72ba99234502b7c7..d93386019b560c3116b8305dbb49d09a0156eb20 100644 --- a/src/Viewport.c +++ b/src/Viewport.c @@ -331,10 +331,10 @@ XawViewportInitialize(Widget request, Widget cnew, clip_height = XtHeight(w); if (h_bar != NULL && XtWidth(w) > XtWidth(h_bar) + XtBorderWidth(h_bar)) - clip_width -= XtWidth(h_bar) + XtBorderWidth(h_bar); + clip_width = (Dimension)(clip_width - (XtWidth(h_bar) + XtBorderWidth(h_bar))); if (v_bar != NULL && XtHeight(w) > XtHeight(v_bar) + XtBorderWidth(v_bar)) - clip_height -= XtHeight(v_bar) + XtBorderWidth(v_bar); + clip_height = (Dimension)(clip_height - (XtHeight(v_bar) + XtBorderWidth(v_bar))); arg_cnt = 0; XtSetArg(clip_args[arg_cnt], XtNwidth, clip_width); arg_cnt++; @@ -395,7 +395,7 @@ static void XawViewportChangeManaged(Widget widget) { ViewportWidget w = (ViewportWidget)widget; - int num_children = w->composite.num_children; + int num_children = (int)w->composite.num_children; Widget child, *childP; int i; @@ -479,8 +479,8 @@ SendReport(ViewportWidget w, unsigned int changed) Widget clip = w->viewport.clip; rep.changed = changed; - rep.slider_x = -XtX(child); /* child is canvas */ - rep.slider_y = -XtY(child); /* clip is slider */ + rep.slider_x = (Position) -XtX(child); /* child is canvas */ + rep.slider_y = (Position) -XtY(child); /* clip is slider */ rep.slider_width = XtWidth(clip); rep.slider_height = XtHeight(clip); rep.canvas_width = XtWidth(child); @@ -509,7 +509,7 @@ MoveChild(ViewportWidget w, int x, int y) if (y >= 0) y = 0; - XtMoveWidget(child, x, y); + XtMoveWidget(child, (Position) x, (Position) y); SendReport(w, (XawPRSliderX | XawPRSliderY)); RedrawThumbs(w); @@ -557,12 +557,12 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) intended.request_mode |= CWWidth; if (XtWidth(child) < clip_width) - intended.width = clip_width; + intended.width = (Dimension)clip_width; else intended.width = XtWidth(child); if (XtHeight(child) < clip_height) - intended.height = clip_height; + intended.height = (Dimension)clip_height; else intended.height = XtHeight(child); @@ -593,12 +593,12 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) if (w->viewport.allowhoriz && \ preferred.width > clip_width) { \ if (!needshoriz) { \ - Widget bar; \ + Widget bar2; \ \ needshoriz = True; \ - if ((bar = w->viewport.horiz_bar) == NULL) \ - bar = CreateScrollbar(w, True); \ - clip_height -= XtHeight(bar) + XtBorderWidth(bar); \ + if ((bar2 = w->viewport.horiz_bar) == NULL) \ + bar2 = CreateScrollbar(w, True); \ + clip_height -= XtHeight(bar2) + XtBorderWidth(bar2);\ if (clip_height < 1) \ clip_height = 1; \ } \ @@ -620,11 +620,11 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) intended.height = preferred.height; } if (!w->viewport.allowhoriz || preferred.width < clip_width) { - intended.width = clip_width; + intended.width = (Dimension)clip_width; intended.request_mode |= CWWidth; } if (!w->viewport.allowvert || preferred.height < clip_height) { - intended.height = clip_height; + intended.height = (Dimension)clip_height; intended.request_mode |= CWHeight; } } while (intended.request_mode != prev_mode @@ -638,13 +638,13 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) XRaiseWindow(XtDisplay(clip), XtWindow(clip)); XtMoveWidget(clip, - needsvert ? w->viewport.useright ? 0 : - XtWidth(w->viewport.vert_bar) - + XtBorderWidth(w->viewport.vert_bar) : 0, - needshoriz ? w->viewport.usebottom ? 0 : - XtHeight(w->viewport.horiz_bar) - + XtBorderWidth(w->viewport.horiz_bar) : 0); - XtResizeWidget(clip, clip_width, clip_height, 0); + (Position)(needsvert ? w->viewport.useright ? 0 : + XtWidth(w->viewport.vert_bar) + + XtBorderWidth(w->viewport.vert_bar) : 0), + (Position)(needshoriz ? w->viewport.usebottom ? 0 : + XtHeight(w->viewport.horiz_bar) + + XtBorderWidth(w->viewport.horiz_bar) : 0)); + XtResizeWidget(clip, (Dimension)clip_width, (Dimension)clip_height, 0); if (w->viewport.horiz_bar != NULL) { Widget bar = w->viewport.horiz_bar; @@ -659,12 +659,12 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) else { int bw = XtBorderWidth(bar); - XtResizeWidget(bar, clip_width, XtHeight(bar), bw); + XtResizeWidget(bar, (Dimension)clip_width, (Dimension)XtHeight(bar), (Dimension)bw); XtMoveWidget(bar, - needsvert && !w->viewport.useright - ? XtWidth(w->viewport.vert_bar) : -bw, - w->viewport.usebottom - ? XtHeight(w) - XtHeight(bar) - bw : -bw); + (Position)(needsvert && !w->viewport.useright + ? XtWidth(w->viewport.vert_bar) : -bw), + (Position)(w->viewport.usebottom + ? XtHeight(w) - XtHeight(bar) - bw : -bw)); XtSetMappedWhenManaged(bar, True); } } @@ -682,12 +682,12 @@ ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) else { int bw = bar->core.border_width; - XtResizeWidget(bar, XtWidth(bar), clip_height, bw); + XtResizeWidget(bar, (Dimension)XtWidth(bar), (Dimension)clip_height, (Dimension)bw); XtMoveWidget(bar, - w->viewport.useright - ? XtWidth(w) - XtWidth(bar) - bw : -bw, - needshoriz && !w->viewport.usebottom - ? XtHeight(w->viewport.horiz_bar) : -bw); + (Position)(w->viewport.useright + ? XtWidth(w) - XtWidth(bar) - bw : -bw), + (Position)(needshoriz && !w->viewport.usebottom + ? XtHeight(w->viewport.horiz_bar) : -bw)); XtSetMappedWhenManaged(bar, True); } } @@ -747,11 +747,11 @@ ComputeWithForceBars(Widget widget, Bool query, XtWidgetGeometry *intended, AssignMax(*clip_height, 1); if (!w->viewport.allowvert) { - intended->height = *clip_height; + intended->height = (Dimension)*clip_height; intended->request_mode = CWHeight; } if (!w->viewport.allowhoriz) { - intended->width = *clip_width; + intended->width = (Dimension)*clip_width; intended->request_mode = CWWidth; } @@ -782,9 +782,9 @@ ComputeWithForceBars(Widget widget, Bool query, XtWidgetGeometry *intended, } if (*clip_width > (int)intended->width) - intended->width = *clip_width; + intended->width = (Dimension)*clip_width; if (*clip_height > (int)intended->height) - intended->height = *clip_height; + intended->height = (Dimension)*clip_height; } static void @@ -809,7 +809,7 @@ ScrollUpDownProc(Widget widget, XtPointer closure, XtPointer call_data) { ViewportWidget w = (ViewportWidget)closure; Widget child = w->viewport.child; - int pix = (long)call_data; + int pix = (int)(long)call_data; int x, y; if (child == NULL) @@ -833,12 +833,12 @@ ThumbProc(Widget widget, XtPointer closure, XtPointer call_data) return; if (widget == w->viewport.horiz_bar) - x = -percent * XtWidth(child); + x = (int)(-percent * XtWidth(child)); else x = XtX(child); if (widget == w->viewport.vert_bar) - y = -percent * XtHeight(child); + y = (int)(-percent * XtHeight(child)); else y = XtY(child); @@ -866,8 +866,8 @@ GeometryRequestPlusScrollbar(ViewportWidget w, Bool horizontal, plusScrollbars = *request; if ((sb = w->viewport.horiz_bar) == NULL) sb = CreateScrollbar(w, horizontal); - request->width += XtWidth(sb); - request->height += XtHeight(sb); + request->width = (Dimension)(request->width + XtWidth(sb)); + request->height = (Dimension)(request->height + XtHeight(sb)); XtDestroyWidget(sb); return (XtMakeGeometryRequest((Widget)w, &plusScrollbars, reply_return)); } @@ -924,7 +924,7 @@ XawViewportGeometryManager(Widget child, XtWidgetGeometry *request, return (QueryGeometry(w, request, reply)); if (child != w->viewport.child - || request->request_mode & ~(CWWidth | CWHeight | CWBorderWidth) + || request->request_mode & (XtGeometryMask)(~(CWWidth | CWHeight | CWBorderWidth)) || ((request->request_mode & CWBorderWidth) && request->border_width > 0)) return (XtGeometryNo); @@ -946,7 +946,7 @@ XawViewportGeometryManager(Widget child, XtWidgetGeometry *request, if ((bar = w->viewport.horiz_bar) == NULL) bar = CreateScrollbar(w, True); - height_remaining -= XtHeight(bar) + XtBorderWidth(bar); + height_remaining = (height_remaining - (unsigned)(XtHeight(bar) + XtBorderWidth(bar))); reconfigured = True; } else @@ -965,14 +965,14 @@ XawViewportGeometryManager(Widget child, XtWidgetGeometry *request, allowed.request_mode |= CWWidth; } if (allowed.width > XtWidth(bar) + XtBorderWidth(bar)) - allowed.width -= XtWidth(bar) + XtBorderWidth(bar); + allowed.width = (Dimension)(allowed.width - (XtWidth(bar) + XtBorderWidth(bar))); else allowed.width = 1; reconfigured = True; } } else - allowed.height = height_remaining; + allowed.height = (Dimension)height_remaining; } if (allowed.width != request->width || allowed.height != request->height) { @@ -1003,8 +1003,8 @@ GetGeometry(Widget w, unsigned int width, unsigned int height) return (False); geometry.request_mode = CWWidth | CWHeight; - geometry.width = width; - geometry.height = height; + geometry.width = (Dimension)width; + geometry.height = (Dimension)height; if (XtIsRealized(w)) { if (((ViewportWidget)w)->viewport.allowhoriz && width > XtWidth(w)) @@ -1061,14 +1061,14 @@ XawViewportSetLocation else if (xoff < 0.0) /* if the offset is < 0.0 nothing */ x = XtX(child); else - x = (float)XtWidth(child) * xoff; + x = (int)((float)XtWidth(child) * xoff); if (yoff > 1.0) y = XtHeight(child); else if (yoff < 0.0) y = XtY(child); else - y = (float)XtHeight(child) * yoff; + y = (int)((float)XtHeight(child) * yoff); MoveChild (w, -x, -y); } @@ -1086,14 +1086,14 @@ XawViewportSetCoordinates(Widget gw, Widget child = w->viewport.child; if (x > XtWidth(child)) - x = XtWidth(child); + x = (Position)XtWidth(child); else if (x < 0) - x = XtX(child); + x = (Position)XtX(child); if (y > XtHeight(child)) - y = XtHeight(child); + y = (Position)XtHeight(child); else if (y < 0) - y = XtY(child); + y = (Position)XtY(child); MoveChild (w, -x, -y); } diff --git a/src/XawI18n.c b/src/XawI18n.c index 99ed2ca18251e263df2674ea7a5ee27068cdf120..b75f70a3265b554440fed9838c5922eb14c77804 100644 --- a/src/XawI18n.c +++ b/src/XawI18n.c @@ -68,7 +68,7 @@ _Xaw_atowc(unsigned char c) wchar_t wc; char str[2]; - str[0] = c; + str[0] = (char)c; str[1] = '\0'; mbtowc(&wc, str, 1); @@ -94,7 +94,7 @@ int _Xaw_iswalnum(wchar_t ch) { #ifdef HAVE_ISWALNUM - return iswalnum(ch); + return iswalnum((wint_t)ch); #else unsigned char mb[MB_LEN_MAX]; diff --git a/src/XawIm.c b/src/XawIm.c index 7a7152fb69846c0a20c1513c23ec0bd37d06aa1c..75be6729126c29687c1b8439341cba5adff2dddf 100644 --- a/src/XawIm.c +++ b/src/XawIm.c @@ -285,10 +285,10 @@ ConfigureCB(Widget w, XtPointer closure, XEvent *event, Boolean *unused) pe_area.width = w->core.width; pe_area.height = w->core.height; margin = &(((TextWidget)w)->text.margin); - pe_area.x += margin->left; - pe_area.y += margin->top; - pe_area.width -= (margin->left + margin->right - 1); - pe_area.height -= (margin->top + margin->bottom - 1); + pe_area.x = (short)(pe_area.x + margin->left); + pe_area.y = (short)(pe_area.y + margin->top); + pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1)); + pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1)); pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL); XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL); @@ -344,7 +344,7 @@ SetVendorShellHeight(XawVendorShellExtPart* ve, unsigned int height) if (ve->im.area_height < height || height == 0) { XtSetArg(args[i], XtNheight, (ve->parent->core.height + height - ve->im.area_height)); - ve->im.area_height = height; + ve->im.area_height = (Dimension)height; XtSetValues(ve->parent, args, 1); } return(ve->im.area_height); @@ -462,7 +462,7 @@ OpenIM(XawVendorShellExtPart *ve) xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL); } else { /* no fragment can be longer than the whole string */ - Cardinal len = strlen (ve->im.input_method) + 5; + Cardinal len = (Cardinal)strlen (ve->im.input_method) + 5; if (len < sizeof buf) pbuf = buf; else pbuf = XtMalloc (len); @@ -481,7 +481,7 @@ OpenIM(XawVendorShellExtPart *ve) while (isspace(*(end - 1))) end--; strcpy (pbuf, "@im="); - strncat (pbuf, s, end - s); + strncat (pbuf, s, (size_t)(end - s)); pbuf[end - s + 4] = '\0'; } @@ -522,11 +522,11 @@ OpenIM(XawVendorShellExtPart *ve) if (end > s) while (isspace(*(end - 1))) end--; - if (!strncmp(s, "OverTheSpot", end - s)) { + if (!strncmp(s, "OverTheSpot", (size_t)(end - s))) { input_style = (XIMPreeditPosition | XIMStatusArea); - } else if (!strncmp(s, "OffTheSpot", end - s)) { + } else if (!strncmp(s, "OffTheSpot", (size_t)(end - s))) { input_style = (XIMPreeditArea | XIMStatusArea); - } else if (!strncmp(s, "Root", end - s)) { + } else if (!strncmp(s, "Root", (size_t)(end - s))) { input_style = (XIMPreeditNothing | XIMStatusNothing); } for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) @@ -566,7 +566,7 @@ ResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve, return(FALSE); } st_area.x = 0; - st_area.y = vw->core.height - ve->im.area_height; + st_area.y = (short)(vw->core.height - ve->im.area_height); st_area.width = get_st_area->width; st_area.height = get_st_area->height; XFree(get_st_area); @@ -584,12 +584,12 @@ ResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve, if (p->xic == NULL) { return(FALSE); } - pe_area.x = st_area.width; - pe_area.y = vw->core.height - ve->im.area_height; + pe_area.x = (short)st_area.width; + pe_area.y = (short)(vw->core.height - ve->im.area_height); pe_area.width = vw->core.width; pe_area.height = get_pe_area->height; if (p->input_style & XIMStatusArea) { - pe_area.width -= st_area.width; + pe_area.width = (unsigned short)(pe_area.width - st_area.width); } XFree(get_pe_area); pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL); @@ -742,11 +742,11 @@ SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height) if (p->input_style & XIMStatusArea) { st_area.height = st_area_needed->height; st_area.x = 0; - st_area.y = height - st_area.height; + st_area.y = (short)(height - st_area.height); if (p->input_style & XIMPreeditArea) { st_area.width = st_area_needed->width; } else { - st_area.width = width; + st_area.width = (unsigned short)width; } XFree(st_area_needed); @@ -756,15 +756,15 @@ SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height) } if (p->input_style & XIMPreeditArea) { if (p->input_style & XIMStatusArea) { - pe_area.x = st_area.width; - pe_area.width = width - st_area.width; + pe_area.x = (short)st_area.width; + pe_area.width = (unsigned short)(width - st_area.width); } else { pe_area.x = 0; - pe_area.width = width; + pe_area.width = (unsigned short)width; } pe_area.height = pe_area_needed->height; XFree(pe_area_needed); - pe_area.y = height - pe_area.height; + pe_area.y = (short)(height - pe_area.height); pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL); ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++; ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++; @@ -808,10 +808,10 @@ CreateIC(Widget w, XawVendorShellExtPart *ve) st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++; st_a[st_cnt] = (XPointer) p->font_set; st_cnt++; if (p->font_set) { - height = maxAscentOfFontSet(p->font_set) - + maxDescentOfFontSet(p->font_set); + height = (Dimension)(maxAscentOfFontSet(p->font_set) + + maxDescentOfFontSet(p->font_set)); } - height = SetVendorShellHeight(ve, height); + height = (Dimension)SetVendorShellHeight(ve, height); } if (p->flg & CIFg) { pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++; @@ -840,7 +840,7 @@ CreateIC(Widget w, XawVendorShellExtPart *ve) } if (p->input_style & XIMPreeditArea) { pe_area.x = 0; - pe_area.y = ve->parent->core.height - height; + pe_area.y = (short)(ve->parent->core.height - height); pe_area.width = ve->parent->core.width; pe_area.height = height; pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++; @@ -852,10 +852,10 @@ CreateIC(Widget w, XawVendorShellExtPart *ve) pe_area.width = w->core.width; pe_area.height = w->core.height; margin = &(((TextWidget)w)->text.margin); - pe_area.x += margin->left; - pe_area.y += margin->top; - pe_area.width -= (margin->left + margin->right - 1); - pe_area.height -= (margin->top + margin->bottom - 1); + pe_area.x = (short)(pe_area.x + margin->left); + pe_area.y = (short)(pe_area.y + margin->top); + pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1)); + pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1)); pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++; pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++; if (p->flg & CICursorP) { @@ -868,7 +868,7 @@ CreateIC(Widget w, XawVendorShellExtPart *ve) } if (p->input_style & XIMStatusArea) { st_area.x = 0; - st_area.y = ve->parent->core.height - height; + st_area.y = (short)(ve->parent->core.height - height); st_area.width = ve->parent->core.width; st_area.height = height; st_a[st_cnt] = (XPointer) XNArea; st_cnt++; @@ -919,7 +919,7 @@ CreateIC(Widget w, XawVendorShellExtPart *ve) SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height); - p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS); + p->flg &= (unsigned long)(~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS)); if (!IsSharedIC(ve)) { if (p->input_style & XIMPreeditPosition) { @@ -970,7 +970,7 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus) height = maxAscentOfFontSet(p->font_set) + maxDescentOfFontSet(p->font_set); } - height = SetVendorShellHeight(ve, height); + height = (int)SetVendorShellHeight(ve, (unsigned)height); } if (p->flg & CIFg) { pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++; @@ -1011,10 +1011,10 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus) pe_area.width = w->core.width; pe_area.height = w->core.height; margin = &(((TextWidget)w)->text.margin); - pe_area.x += margin->left; - pe_area.y += margin->top; - pe_area.width -= (margin->left + margin->right - 1); - pe_area.height -= (margin->top + margin->bottom - 1); + pe_area.x = (short)(pe_area.x + margin->left); + pe_area.y = (short)(pe_area.y + margin->top); + pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1)); + pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1)); pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++; pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++; } @@ -1057,7 +1057,7 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus) if (IsSharedIC(ve) && p->flg & CIFontSet) SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height); - p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS); + p->flg &= (unsigned long)(~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS)); } static void @@ -1099,7 +1099,7 @@ SetICFocus(Widget w, XawVendorShellExtPart *ve) p->ic_focused = TRUE; XSetICFocus(p->xic); } - p->flg &= ~CIICFocus; + p->flg &= (unsigned long)(~CIICFocus); } static void @@ -1237,9 +1237,9 @@ UnsetFocus(Widget inwidg) if ((ve = GetExtPart(vw)) != NULL) { if ((p = GetIcTableShared(inwidg, ve)) == NULL) return; if (p->flg & CIICFocus) { - p->flg &= ~CIICFocus; + p->flg &= (unsigned long)(~CIICFocus); } - p->prev_flg &= ~CIICFocus; + p->prev_flg &= (unsigned long)(~CIICFocus); if (ve->im.xim && XtIsRealized((Widget)vw) && p->xic) { UnsetICFocus(inwidg, ve); } @@ -1364,7 +1364,7 @@ CompileResourceList(XtResourceList res, unsigned int num_res) xrmres->xrm_name = XrmPermStringToQuark(res->resource_name); xrmres->xrm_class = XrmPermStringToQuark(res->resource_class); xrmres->xrm_type = XrmPermStringToQuark(res->resource_type); - xrmres->xrm_offset = -res->resource_offset - 1; + xrmres->xrm_offset = (int)(-res->resource_offset - 1); xrmres->xrm_default_type = XrmPermStringToQuark(res->default_type); } #undef xrmres @@ -1443,7 +1443,7 @@ _XawImGetShellHeight(Widget w) if (!XtIsVendorShell( w ) ) return( w->core.height ); if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL ) { - return( w->core.height - ve->im.area_height ); + return (Dimension)( w->core.height - ve->im.area_height ); } return( w->core.height ); } @@ -1542,13 +1542,14 @@ _XawImWcLookupString(Widget inwidg, XKeyPressedEvent *event, if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) && ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) { - return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer/sizeof(wchar_t), + return(XwcLookupString(p->xic, event, buffer_return, + (int)((size_t)bytes_buffer/sizeof(wchar_t)), keysym_return, NULL)); } ret = XLookupString( event, tmp_buf, sizeof(tmp_buf), keysym_return, NULL ); for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) { - *buf_p++ = _Xaw_atowc(*tmp_p++); + *buf_p++ = _Xaw_atowc((unsigned char)*tmp_p++); } return( ret ); }