Module Name: xsrc
Committed By: mrg
Date: Thu Jul 4 05:17:50 UTC 2024
Modified Files:
xsrc/external/mit/libXaw/dist/src: Pixmap.c Text.c TextAction.c
Removed Files:
xsrc/external/mit/libXaw/dist/src: sharedlib.c
xsrc/external/mit/libpthread-stubs/dist: config.guess config.h.in
config.sub depcomp ltmain.sh stubs.c
Log Message:
merge libXaw 1.0.16, libfontenc 1.1.8, libpthread-stubs 0.5, and
util-macros 1.20.1.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/libXaw/dist/src/Pixmap.c \
xsrc/external/mit/libXaw/dist/src/TextAction.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/libXaw/dist/src/Text.c
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/libXaw/dist/src/sharedlib.c
cvs rdiff -u -r1.1.1.2 -r0 \
xsrc/external/mit/libpthread-stubs/dist/config.guess \
xsrc/external/mit/libpthread-stubs/dist/config.h.in \
xsrc/external/mit/libpthread-stubs/dist/config.sub \
xsrc/external/mit/libpthread-stubs/dist/depcomp \
xsrc/external/mit/libpthread-stubs/dist/ltmain.sh \
xsrc/external/mit/libpthread-stubs/dist/stubs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/libXaw/dist/src/Pixmap.c
diff -u xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.3 xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.4
--- xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.3 Thu Mar 23 05:26:15 2023
+++ xsrc/external/mit/libXaw/dist/src/Pixmap.c Thu Jul 4 05:17:50 2024
@@ -469,14 +469,15 @@ _XawFindCache(XawCache *xaw,
static XawCache *
_XawGetCache(XawCache *xaw, Screen *screen, Colormap colormap, int depth)
{
- XawCache *s_cache, *c_cache, *d_cache, *cache, *pcache;
+ XawCache *cache;
cache = _XawFindCache(xaw, screen, colormap, depth, FIND_ALL);
if (!cache)
{
- s_cache = _XawFindCache(xaw,
- screen, colormap, depth, FIND_SCREEN);
+ XawCache *c_cache, *d_cache, *pcache;
+ XawCache *s_cache = _XawFindCache(xaw,
+ screen, colormap, depth, FIND_SCREEN);
if (!s_cache)
{
pcache = (XawCache *)XtMalloc(sizeof(XawCache));
@@ -664,7 +665,7 @@ GetResourcePixmapPath(Display *display)
XrmRepresentation rep_type;
XrmValue value;
static char *default_path =
- "%H/%T/%N:%P/include/X11/%T/%N:/usr/X11R6/include/X11/%T/%N:/usr/include/X11/%T/%N:%N";
+ (char*)"%H/%T/%N:%P/include/X11/%T/%N:/usr/X11R6/include/X11/%T/%N:/usr/include/X11/%T/%N:%N";
xrm_name[0] = XrmPermStringToQuark("pixmapFilePath");
xrm_name[1] = NULLQUARK;
@@ -713,7 +714,7 @@ GetFileName(XawParams *params, Screen *s
{
if (!sub[0].substitution)
sub[0].substitution = getenv("HOME");
- sub[1].substitution = (char *)params->name;
+ sub[1].substitution = (_XtString)params->name;
if (pixmap_path == NULL)
GetResourcePixmapPath(DisplayOfScreen(screen));
return XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
@@ -728,7 +729,6 @@ BitmapLoader(XawParams *params, Screen *
{
Pixel fg, bg;
XColor color, exact;
- Pixmap pixmap;
unsigned int width, height;
unsigned char *data = NULL;
int hotX, hotY;
@@ -765,10 +765,11 @@ BitmapLoader(XawParams *params, Screen *
if (XReadBitmapFileData(filename, &width, &height, &data,
&hotX, &hotY) == BitmapSuccess)
{
- pixmap = XCreatePixmapFromBitmapData(DisplayOfScreen(screen),
- RootWindowOfScreen(screen),
- (char *)data,
- width, height, fg, bg, (unsigned)depth);
+ Pixmap pixmap =
+ XCreatePixmapFromBitmapData(DisplayOfScreen(screen),
+ RootWindowOfScreen(screen),
+ (char *)data,
+ width, height, fg, bg, (unsigned)depth);
if (data)
XFree(data);
*pixmap_return = pixmap;
@@ -833,7 +834,7 @@ GradientLoader(XawParams *params, Screen
value = NULL;
if ((argval = XawFindArgVal(params, "start")) != NULL)
- value = (char *)argval->value;
+ value = (char*)argval->value;
if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
&start, &color))
return (False);
@@ -844,7 +845,7 @@ GradientLoader(XawParams *params, Screen
}
value = NULL;
if ((argval = XawFindArgVal(params, "end")) != NULL)
- value = (char *)argval->value;
+ value = (char*)argval->value;
if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
&end, &color))
return (False);
Index: xsrc/external/mit/libXaw/dist/src/TextAction.c
diff -u xsrc/external/mit/libXaw/dist/src/TextAction.c:1.3 xsrc/external/mit/libXaw/dist/src/TextAction.c:1.4
--- xsrc/external/mit/libXaw/dist/src/TextAction.c:1.3 Thu Mar 23 05:26:15 2023
+++ xsrc/external/mit/libXaw/dist/src/TextAction.c Thu Jul 4 05:17:50 2024
@@ -403,14 +403,14 @@ _SelectionReceived(Widget w, XtPointer c
StartAction(ctx, NULL);
if (XawTextFormat(ctx, XawFmtWide)) {
- XTextProperty textprop;
wchar_t **wlist;
int count;
-
- textprop.encoding = *type;
- textprop.value = (unsigned char *)value;
- textprop.nitems = strlen(value);
- textprop.format = 8;
+ XTextProperty textprop = {
+ .encoding = *type,
+ .value = (unsigned char *)value,
+ .nitems = strlen(value),
+ .format = 8
+ };
if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
!= Success
@@ -950,7 +950,6 @@ ConvertSelection(Widget w, Atom *selecti
TextWidget ctx = (TextWidget)w;
Widget src = ctx->text.source;
XawTextEditType edit_mode;
- Arg args[1];
XawTextSelectionSalt *salt = NULL;
XawTextSelection *s;
@@ -960,9 +959,12 @@ ConvertSelection(Widget w, Atom *selecti
if (SrcCvtSel(src, selection, target, type, value, length, format))
return (True);
+ else {
+ Arg args[1];
- XtSetArg(args[0], XtNeditType,&edit_mode);
- XtGetValues(src, args, 1);
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(src, args, 1);
+ }
XmuConvertStandardSelection(w, ctx->text.time, selection,
target, type, (XPointer *)&std_targets,
@@ -1035,21 +1037,22 @@ ConvertSelection(Widget w, Atom *selecti
*length = strlen(*value);
}
else {
- *value = XtMalloc(((size_t)(salt->length + 1) * sizeof(unsigned char)));
+ *value = XtMalloc((Cardinal)((size_t)(salt->length + 1) * sizeof(unsigned char)));
strcpy (*value, salt->contents);
*length = (unsigned long)salt->length;
}
/* Got *value,*length, now in COMPOUND_TEXT format. */
if (XawTextFormat(ctx, XawFmtWide)) {
if (*type == XA_STRING) {
- XTextProperty textprop;
wchar_t **wlist;
int count;
+ XTextProperty textprop = {
+ .encoding = XA_COMPOUND_TEXT(d),
+ .value = (unsigned char *)*value,
+ .nitems = strlen(*value),
+ .format = 8
+ };
- textprop.encoding = XA_COMPOUND_TEXT(d);
- textprop.value = (unsigned char *)*value;
- textprop.nitems = strlen(*value);
- textprop.format = 8;
if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
< Success
|| count < 1) {
@@ -1067,14 +1070,15 @@ ConvertSelection(Widget w, Atom *selecti
XwcFreeStringList((wchar_t**) wlist);
}
else if (*type == XA_UTF8_STRING(d)) {
- XTextProperty textprop;
char **list;
int count;
+ XTextProperty textprop = {
+ .encoding = XA_COMPOUND_TEXT(d),
+ .value = (unsigned char *)*value,
+ .nitems = strlen(*value),
+ .format = 8
+ };
- textprop.encoding = XA_COMPOUND_TEXT(d);
- textprop.value = (unsigned char *)*value;
- textprop.nitems = strlen(*value);
- textprop.format = 8;
if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
< Success
|| count < 1) {
@@ -1194,7 +1198,7 @@ _LoseSelection(Widget w, Atom *selection
tail = kill_ring;
kill_ring = kill_ring->next;
}
- if (kill_ring->refcount == 0) {
+ if (tail != NULL && kill_ring->refcount == 0) {
--num_kill_rings;
tail->next = NULL;
XtFree(kill_ring->contents);
@@ -1289,16 +1293,24 @@ _DeleteOrKill(TextWidget ctx, XawTextPos
if (!append)
salt->contents = string;
else {
- salt->contents = XtMalloc((length + size + 1));
+ salt->contents = XtMalloc((Cardinal)(length + size + 1));
if (from >= old_from) {
- strncpy(salt->contents, ring, (size_t)size);
- salt->contents[size] = '\0';
+ if (ring != NULL) {
+ strncpy(salt->contents, ring, (size_t)size);
+ salt->contents[size] = '\0';
+ } else {
+ salt->contents[size = 0] = '\0';
+ }
strncat(salt->contents, string, (size_t)length);
}
else {
strncpy(salt->contents, string, (size_t)length);
salt->contents[length] = '\0';
- strncat(salt->contents, ring, (size_t)size);
+ if (ring != NULL) {
+ strncat(salt->contents, ring, (size_t)size);
+ } else {
+ size = 0;
+ }
}
salt->contents[length + size] = '\0';
XtFree(ring);
@@ -1330,7 +1342,7 @@ _DeleteOrKill(TextWidget ctx, XawTextPos
text.firstPos = 0;
text.format = (unsigned long)_XawTextFormat(ctx);
- text.ptr = "";
+ text.ptr = (char*)"";
if (_XawTextReplace(ctx, from, to, &text)) {
XBell(XtDisplay(ctx), 50);
@@ -1399,7 +1411,8 @@ DeleteChar(Widget w, XEvent *event, XawT
short mul = MULT(ctx);
if (mul < 0) {
- ctx->text.mult = mul = (short)(-mul);
+ mul = -mul;
+ ctx->text.mult = mul;
dir = dir == XawsdLeft ? XawsdRight : XawsdLeft;
}
DeleteOrKill(ctx, event, dir, XawstPositions, True, False);
@@ -1600,11 +1613,10 @@ StripSpaces(TextWidget ctx, XawTextPosit
text.firstPos = 0;
text.format = XawFmt8Bit;
- text.ptr = " ";
+ text.ptr = (char*)" ";
text.length = 1;
- position = XawTextSourceRead(ctx->text.source, position,
- &block, (int)(right - left));
+ XawTextSourceRead(ctx->text.source, position, &block, (int)(right - left));
done = False;
space = False;
/* convert tabs and returns to spaces */
@@ -1637,11 +1649,10 @@ StripSpaces(TextWidget ctx, XawTextPosit
done = True;
}
- text.ptr = "";
+ text.ptr = (char*)"";
text.length = 0;
position = tmp = left;
- position = XawTextSourceRead(ctx->text.source, position,
- &block, (int)(right - left));
+ XawTextSourceRead(ctx->text.source, position, &block, (int)(right - left));
ipos = ctx->text.insertPos;
done = False;
while (!done) {
@@ -1717,12 +1728,11 @@ Tabify(TextWidget ctx, XawTextPosition l
int tab_index = 0, tab_column = 0, TAB_SIZE = DEFAULT_TAB_SIZE;
text.firstPos = 0;
- text.ptr = "\t";
+ text.ptr = (char*)"\t";
text.format = XawFmt8Bit;
text.length = 1;
- position = XawTextSourceRead(ctx->text.source, position,
- &block, (int)(right - left));
+ XawTextSourceRead(ctx->text.source, position, &block, (int)(right - left));
ipos = ctx->text.insertPos;
done = zero = False;
if (tab_count)
@@ -1859,14 +1869,13 @@ Untabify(TextWidget ctx, XawTextPosition
short *char_tabs = sink->text_sink.char_tabs;
int tab_count = sink->text_sink.tab_count;
int tab_index = 0, tab_column = 0, tab_base = 0;
- static char *tabs = " ";
+ static char *tabs = (char*)" ";
text.firstPos = 0;
text.format = XawFmt8Bit;
text.ptr = tabs;
- position = XawTextSourceRead(ctx->text.source, position,
- &block, (int)(right - left));
+ XawTextSourceRead(ctx->text.source, position, &block, (int)(right - left));
ipos = ctx->text.insertPos;
done = False;
zero = False;
@@ -2182,7 +2191,7 @@ DoFormatText(TextWidget ctx, XawTextPosi
position = tmp;
if (position > left && position - left > ctx->text.left_column
&& position != right) {
- text.ptr = "\n";
+ text.ptr = (char*)"\n";
text.length = 1;
CHECK_SAVE();
if (_XawTextReplace(ctx, position, position + 1, &text))
@@ -2235,7 +2244,6 @@ DoFormatText(TextWidget ctx, XawTextPosi
}
XawStackFree(text.ptr, buf);
position += count;
- right += count;
if (num_pos) {
for (cpos = 0; cpos < num_pos; cpos++)
if (pos[cpos] > left)
@@ -2297,7 +2305,6 @@ DoFormatText(TextWidget ctx, XawTextPosi
inc += ii;
}
position += count;
- right += count;
XawStackFree(text.ptr, buf);
}
break;
@@ -2322,18 +2329,17 @@ Indent(Widget w, XEvent *event, String *
TextWidget ctx = (TextWidget)w;
TextSrcObject src = (TextSrcObject)ctx->text.source;
XawTextPosition from, to, tmp, end = 0, *pos, *posbuf[32];
- char buf[32];
XawTextBlock text;
int i, spaces = MULT(ctx);
char *lbuf = NULL, *rbuf;
- unsigned llen = 0, rlen, size;
+ unsigned llen = 0;
Bool undo = src->textSrc.enable_undo && src->textSrc.undo_state == False;
Bool format = ctx->text.auto_fill
&& ctx->text.left_column < ctx->text.right_column;
text.firstPos = 0;
text.format = XawFmt8Bit;
- text.ptr = "";
+ text.ptr = (char*)"";
StartAction(ctx, event);
@@ -2370,6 +2376,8 @@ Indent(Widget w, XEvent *event, String *
tmp = from;
if (spaces > 0) {
+ char buf[32];
+
text.ptr = XawStackAlloc((unsigned)spaces, buf);
for (i = 0; i < spaces; i++)
text.ptr[i] = ' ';
@@ -2424,7 +2432,9 @@ Indent(Widget w, XEvent *event, String *
Tabify(ctx, from, to, pos, (int)src->textSrc.num_text, NULL);
if (undo) {
- rlen = (unsigned)(llen + (ctx->text.lastPos - end));
+ unsigned rlen = (unsigned)(llen + (ctx->text.lastPos - end));
+ unsigned size;
+
rbuf = _XawTextGetText(ctx, from, from + rlen);
text.format = (unsigned long)_XawTextFormat(ctx);
@@ -2601,7 +2611,7 @@ InsertNewLineAndIndent(Widget w, XEvent
char *ptr;
length = (int)strlen(line_to_ip);
- text.ptr = XtMalloc(((size_t)(2 + length) * sizeof(char)));
+ text.ptr = XtMalloc((Cardinal)((size_t)(2 + length) * sizeof(char)));
ptr = text.ptr;
ptr[0] = XawLF;
strcpy(++ptr, line_to_ip);
@@ -3020,7 +3030,7 @@ AutoFill(TextWidget ctx)
return;
text.format = XawFmt8Bit;
- text.ptr = "\n";
+ text.ptr = (char*)"\n";
}
text.length = 1;
text.firstPos = 0;
@@ -3293,7 +3303,7 @@ InsertString(Widget w, XEvent *event, St
StartAction(ctx, event);
for (i = (int)*num_params; i; i--, params++) { /* DO FOR EACH PARAMETER */
- text.ptr = IfHexConvertHexElseReturnParam(*params, &text.length);
+ text.ptr = IfHexConvertHexElseReturnParam((char*) *params, &text.length);
if (text.length == 0)
continue;
@@ -3368,7 +3378,7 @@ DisplayCaret(Widget w, XEvent *event, St
if (*num_params > 0) { /* default arg is "True" */
XrmValue from, to;
- from.size = (unsigned)strlen(from.addr = (char *)params[0]);
+ from.size = (unsigned)strlen(from.addr = (char*)params[0]);
XtConvert(w, XtRString, &from, XtRBoolean, &to);
if (to.addr != NULL)
@@ -3414,7 +3424,6 @@ Numeric(Widget w, XEvent *event, String
return;
}
else if (mult == 32767) {
- mult = ctx->text.mult = (short)(- (params[0][0] - '0'));
return;
}
else {
@@ -3518,19 +3527,20 @@ static XawTextPosition
StripOutOldCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to,
XawTextPosition *pos, int num_pos)
{
- XawTextPosition startPos, endPos, eop_begin, eop_end, temp;
+ XawTextPosition startPos, endPos, eop_begin, eop_end;
Widget src = ctx->text.source;
XawTextBlock text;
char *buf;
- static wchar_t wc_two_spaces[3];
int idx;
/* Initialize our TextBlock with two spaces. */
text.firstPos = 0;
text.format = (unsigned long)_XawTextFormat(ctx);
- if (text.format == XawFmt8Bit)
- text.ptr= " ";
- else {
+ if (text.format == XawFmt8Bit) {
+ text.ptr= (char*)" ";
+ } else {
+ static wchar_t wc_two_spaces[3];
+
wc_two_spaces[0] = _Xaw_atowc(XawSP);
wc_two_spaces[1] = _Xaw_atowc(XawSP);
wc_two_spaces[2] = 0;
@@ -3538,11 +3548,13 @@ StripOutOldCRs(TextWidget ctx, XawTextPo
}
/* Strip out CR's. */
- eop_begin = eop_end = startPos = endPos = from;
+ eop_begin = eop_end = startPos = from;
/* CONSTCOND */
while (TRUE) {
- endPos=SrcScan(src, startPos, XawstEOL, XawsdRight, 1, False);
+ XawTextPosition temp;
+
+ endPos = SrcScan(src, startPos, XawstEOL, XawsdRight, 1, False);
temp = SrcScan(src, endPos, XawstWhiteSpace, XawsdLeft, 1, False);
temp = SrcScan(src, temp, XawstWhiteSpace, XawsdRight,1, False);
@@ -3624,19 +3636,19 @@ static void
InsertNewCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to,
XawTextPosition *pos, int num_pos)
{
- XawTextPosition startPos, endPos, space, eol;
+ XawTextPosition startPos;
XawTextBlock text;
- int i, width, height, len, wwidth, idx;
- char *buf;
- static wchar_t wide_CR[2];
+ int i, width, height, wwidth, idx;
text.firstPos = 0;
text.length = 1;
text.format = (unsigned long)_XawTextFormat(ctx);
- if (text.format == XawFmt8Bit)
- text.ptr = "\n";
- else {
+ if (text.format == XawFmt8Bit) {
+ text.ptr = (char*)"\n";
+ } else {
+ static wchar_t wide_CR[2];
+
wide_CR[0] = _Xaw_atowc(XawLF);
wide_CR[1] = 0;
text.ptr = (char*)wide_CR;
@@ -3655,6 +3667,10 @@ InsertNewCRs(TextWidget ctx, XawTextPosi
/* CONSTCOND */
while (TRUE) {
+ int len;
+ char *buf;
+ XawTextPosition endPos, space, eol;
+
XawTextSinkFindPosition(ctx->text.sink, startPos,
(int)ctx->text.r_margin.left, wwidth,
True, &eol, &width, &height);
@@ -3733,14 +3749,12 @@ FormRegion(TextWidget ctx, XawTextPositi
ctx->text.justify == XawjustifyFull) {
Untabify(ctx, from, to, pos, num_pos, NULL);
to += ctx->text.lastPos - len;
- len = ctx->text.insertPos;
(void)BlankLine((Widget)ctx, from, &inc);
if (from + inc >= to)
return (XawEditDone);
}
if (!StripSpaces(ctx, from + inc, to, pos, num_pos, NULL))
return (XawReplaceError);
- to += ctx->text.lastPos - len;
FormatText(ctx, from, ctx->text.justify != XawjustifyFull, pos, num_pos);
}
Index: xsrc/external/mit/libXaw/dist/src/Text.c
diff -u xsrc/external/mit/libXaw/dist/src/Text.c:1.4 xsrc/external/mit/libXaw/dist/src/Text.c:1.5
--- xsrc/external/mit/libXaw/dist/src/Text.c:1.4 Thu Mar 23 05:26:15 2023
+++ xsrc/external/mit/libXaw/dist/src/Text.c Thu Jul 4 05:17:50 2024
@@ -474,9 +474,7 @@ static XtResource resources[] = {
{ toVal->size = sizeof(type); toVal->addr = (XPointer)address; }
static XrmQuark QWrapNever, QWrapLine, QWrapWord;
-#ifndef notdef
static XrmQuark QScrollNever, QScrollWhenNeeded, QScrollAlways;
-#endif
static XrmQuark QJustifyLeft, QJustifyRight, QJustifyCenter, QJustifyFull;
/*ARGSUSED*/
@@ -795,7 +793,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 += (Position) (XtWidth(vbar) + XtBorderWidth(vbar));
ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left;
PositionVScrollBar(ctx);
@@ -950,7 +948,7 @@ XawTextInitialize(Widget request _X_UNUS
if (XtHeight(ctx) == DEFAULT_TEXT_HEIGHT) {
XtHeight(ctx) = (Dimension)VMargins(ctx);
if (ctx->text.sink != NULL)
- XtHeight(ctx) += XawTextSinkMaxHeight(ctx->text.sink, 1);
+ XtHeight(ctx) += (Dimension) XawTextSinkMaxHeight(ctx->text.sink, 1);
}
if (ctx->text.scroll_vert == XawtextScrollAlways)
@@ -1069,14 +1067,16 @@ void
_XawTextNeedsUpdating(TextWidget ctx,
XawTextPosition left, XawTextPosition right)
{
- XmuSegment segment;
-
if (left >= right)
return;
+ else {
+ XmuSegment segment = {
+ .x1 = (int)left,
+ .x2 = (int)right
+ };
- segment.x1 = (int)left;
- segment.x2 = (int)right;
- (void)XmuScanlineOrSegment(ctx->text.update, &segment);
+ (void)XmuScanlineOrSegment(ctx->text.update, &segment);
+ }
}
/*
@@ -1124,18 +1124,15 @@ _XawTextGetText(TextWidget ctx, XawTextP
char *
_XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right)
{
- unsigned char *s;
- unsigned char c;
- long i, j, n;
- wchar_t *ws, wc;
-
/* allow ESC in accordance with ICCCM */
if (XawTextFormat(ctx, XawFmtWide)) {
MultiSinkObject sink = (MultiSinkObject)ctx->text.sink;
- ws = (wchar_t *)_XawTextGetText(ctx, left, right);
- n = (long)wcslen(ws);
+ wchar_t *ws = (wchar_t *)_XawTextGetText(ctx, left, right);
+ long n = (long)wcslen(ws);
+ long i, j;
+
for (j = 0, i = 0; j < n; j++) {
- wc = ws[j];
+ wchar_t wc = ws[j];
if (XwcTextEscapement (sink->multi_sink.fontset, &wc, 1)
|| (wc == _Xaw_atowc(XawTAB)) || (wc == _Xaw_atowc(XawLF))
|| (wc == _Xaw_atowc(XawESC)))
@@ -1145,12 +1142,13 @@ _XawTextGetSTRING(TextWidget ctx, XawTex
return ((char *)ws);
}
else {
- s = (unsigned char *)_XawTextGetText(ctx, left, right);
+ unsigned char *s = (unsigned char *)_XawTextGetText(ctx, left, right);
/* only HT and NL control chars are allowed, strip out others */
- n = (long)strlen((char *)s);
- i = 0;
+ long n = (long)strlen((char *)s);
+ long i = 0, j;
+
for (j = 0; j < n; j++) {
- c = s[j];
+ unsigned char c = s[j];
if (((c >= 0x20) && c <= 0x7f)
||(c >= 0xa0) || (c == XawTAB) || (c == XawLF)
|| (c == XawESC)) {
@@ -1222,14 +1220,15 @@ static Bool
LineAndXYForPosition(TextWidget ctx, XawTextPosition pos,
int *line, int *x, int *y)
{
- XawTextPosition linePos, endPos;
Boolean visible;
- int realW, realH;
*line = 0;
*x = ctx->text.left_margin;
*y = ctx->text.margin.top + 1;
if ((visible = IsPositionVisible(ctx, pos)) != False) {
+ XawTextPosition linePos, endPos;
+ int realW, realH;
+
*line = LineForPosition(ctx, pos);
*y = ctx->text.lt.info[*line].y;
linePos = ctx->text.lt.info[*line].position;
@@ -1252,12 +1251,11 @@ void
_XawTextBuildLineTable(TextWidget ctx, XawTextPosition position,
_XtBoolean force_rebuild)
{
- Dimension height = 0;
int lines = 0;
Cardinal size;
if ((int)XtHeight(ctx) > VMargins(ctx)) {
- height = (Dimension)(XtHeight(ctx) - VMargins(ctx));
+ Dimension height = (Dimension)(XtHeight(ctx) - VMargins(ctx));
lines = XawTextSinkMaxLines(ctx->text.sink, height);
}
size = (Cardinal)(sizeof(XawTextLineTableEntry) * (size_t)(lines + 1));
@@ -1385,7 +1383,7 @@ _BuildLineTable(TextWidget ctx, XawTextP
if (lt->textWidth != (Cardinal)width) {
if (lt->textWidth > (Cardinal)width)
ctx->text.clear_to_eol = True;
- lt->textWidth = (unsigned)width;
+ lt->textWidth = (Dimension)width;
}
y = (Position)(y + height);
@@ -1486,9 +1484,11 @@ GetWidestLine(TextWidget ctx)
void
_XawTextSetScrollBars(TextWidget ctx)
{
- float first, last, denom, widest;
+ float first;
if (ctx->text.scroll_vert == XawtextScrollAlways) {
+ float last;
+
if (ctx->text.lastPos == 0)
first = 0.0;
else
@@ -1504,7 +1504,10 @@ _XawTextSetScrollBars(TextWidget ctx)
}
if (ctx->text.scroll_horiz == XawtextScrollAlways) {
- denom = (float)GetWidestLine(ctx);
+ unsigned value = GetWidestLine(ctx);
+ float denom = (float)value;
+ float widest;
+
if (denom <= 0)
denom = (float)((int)XtWidth(ctx) - RHMargins(ctx));
if (denom <= 0)
@@ -1712,7 +1715,6 @@ XawTextScroll(TextWidget ctx, int vlines
else {
update_from = lt->info[lt->lines - vlines].position;
update_to = lt->info[lt->lines].position;
- y1 = lt->info[lt->lines - vlines].y;
y2 = lt->info[vlines].y;
DoCopyArea(ctx, ctx->text.r_margin.left, y2,
(unsigned)vwidth, (unsigned)(lt->info[lt->lines].y - y2),
@@ -1762,10 +1764,11 @@ HJump(Widget w, XtPointer closure, XtPoi
{
TextWidget ctx = (TextWidget)closure;
float percent = *(float *)callData;
+ unsigned value = GetWidestLine(ctx);
long pixels;
pixels = ctx->text.left_margin -
- (ctx->text.r_margin.left - (int)(percent * (float)GetWidestLine(ctx)));
+ (ctx->text.r_margin.left - (int)(percent * (float)value));
HScroll(w, (XtPointer)ctx, (XtPointer)pixels);
}
@@ -1956,7 +1959,6 @@ TextConvertSelection(Widget w, Atom *sel
TextWidget ctx = (TextWidget)w;
Widget src = ctx->text.source;
XawTextEditType edit_mode;
- Arg args[1];
XawTextSelectionSalt *salt = NULL;
XawTextSelection *s;
@@ -1966,9 +1968,12 @@ TextConvertSelection(Widget w, Atom *sel
if (SrcCvtSel(src, selection, target, type, value, length, format))
return (True);
+ else {
+ Arg args[1];
- XtSetArg(args[0], XtNeditType, &edit_mode);
- XtGetValues(src, args, ONE);
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(src, args, ONE);
+ }
XmuConvertStandardSelection(w, ctx->text.time, selection,
target, type, (XPointer*)&std_targets,
@@ -2045,20 +2050,21 @@ TextConvertSelection(Widget w, Atom *sel
*length = strlen((char *)*value);
}
else {
- *value = XtMalloc(((size_t)(salt->length + 1) * sizeof(unsigned char)));
+ *value = XtMalloc((Cardinal)((size_t)(salt->length + 1) * sizeof(unsigned char)));
strcpy ((char *)*value, salt->contents);
*length = (unsigned long)salt->length;
}
/* Got *value,*length, now in COMPOUND_TEXT format. */
if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) {
- XTextProperty textprop;
wchar_t **wlist;
int count;
+ XTextProperty textprop = {
+ .encoding = XA_COMPOUND_TEXT(d),
+ .value = (unsigned char *)*value,
+ .nitems = strlen(*value),
+ .format = 8
+ };
- textprop.encoding = XA_COMPOUND_TEXT(d);
- textprop.value = (unsigned char *)*value;
- textprop.nitems = strlen(*value);
- textprop.format = 8;
if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
< Success
|| count < 1) {
@@ -2075,14 +2081,15 @@ TextConvertSelection(Widget w, Atom *sel
*length = textprop.nitems;
XwcFreeStringList(wlist);
} else if (*type == XA_UTF8_STRING(d)) {
- XTextProperty textprop;
char **list;
int count;
+ XTextProperty textprop = {
+ .encoding = XA_COMPOUND_TEXT(d),
+ .value = (unsigned char *)*value,
+ .nitems = strlen(*value),
+ .format = 8
+ };
- textprop.encoding = XA_COMPOUND_TEXT(d);
- textprop.value = (unsigned char *)*value;
- textprop.nitems = strlen(*value);
- textprop.format = 8;
if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
< Success
|| count < 1) {
@@ -2352,10 +2359,10 @@ _SetSelection(TextWidget ctx, XawTextPos
if (left < right) {
Widget w = (Widget)ctx;
- int buffer;
while (count) {
Atom selection = selections[--count];
+ int buffer;
/*
* If this is a cut buffer
@@ -2396,7 +2403,7 @@ _SetSelection(TextWidget ctx, XawTextPos
while (len > max_len) {
len -= max_len;
tptr += max_len;
- amount = Min (len, max_len);
+ amount = (unsigned) Min (len, max_len);
XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0),
selection, XA_STRING, 8, PropModeAppend,
tptr, (int)amount);
@@ -2679,12 +2686,13 @@ OldDisplayText(Widget w, XawTextPosition
TextWidget ctx = (TextWidget)w;
int x, y, line;
- XawTextPosition start, end, last, final;
+ XawTextPosition last;
XmuScanline *scan;
XmuSegment *seg;
XmuArea *clip = NULL;
Bool cleol = ctx->text.clear_to_eol;
Bool has_selection = ctx->text.s.right > ctx->text.s.left;
+ XawTextPosition start;
left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
@@ -2697,7 +2705,10 @@ OldDisplayText(Widget w, XawTextPosition
if (cleol)
clip = XmuCreateArea();
- for (start = left; start < right && line < ctx->text.lt.lines; line++) {
+ for (start = left;
+ start < right && line < ctx->text.lt.lines; line++) {
+ XawTextPosition end, final;
+
if ((end = ctx->text.lt.info[line + 1].position) > right)
end = right;
@@ -2756,10 +2767,11 @@ DisplayText(Widget w, XawTextPosition le
TextWidget ctx = (TextWidget)w;
int y, line;
- XawTextPosition from, to, lastPos;
+ XawTextPosition lastPos;
Bool cleol = ctx->text.clear_to_eol;
Bool has_selection = ctx->text.s.right > ctx->text.s.left;
XawTextPaintList *paint_list;
+ XawTextPosition from;
left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
@@ -2773,8 +2785,11 @@ DisplayText(Widget w, XawTextPosition le
paint_list = ((TextSinkObject)ctx->text.sink)->text_sink.paint;
- for (from = left; from < right && line < ctx->text.lt.lines; line++) {
- if ((to = ctx->text.lt.info[line + 1].position) > right)
+ for (from = left;
+ from < right && line < ctx->text.lt.lines; line++) {
+ XawTextPosition to = ctx->text.lt.info[line + 1].position;
+
+ if (to > right)
to = right;
if (to > lastPos)
@@ -2834,7 +2849,7 @@ static void
DoSelection(TextWidget ctx, XawTextPosition pos, Time time, Bool motion)
{
XawTextPosition newLeft, newRight;
- XawTextSelectType newType, *sarray;
+ XawTextSelectType newType;
Widget src = ctx->text.source;
if (motion)
@@ -2842,7 +2857,8 @@ DoSelection(TextWidget ctx, XawTextPosit
else {
if ((labs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME)
&& (pos >= ctx->text.s.left && pos <= ctx->text.s.right)) {
- sarray = ctx->text.sarray;
+ XawTextSelectType *sarray = ctx->text.sarray;
+
for (; *sarray != XawselectNull && *sarray != ctx->text.s.type;
sarray++)
;
@@ -3062,7 +3078,7 @@ _XawTextClearAndCenterDisplay(TextWidget
left_margin == ctx->text.left_margin) {
int insert_line = LineForPosition(ctx, ctx->text.insertPos);
int scroll_by = insert_line - (ctx->text.lt.lines >> 1);
- Boolean clear_to_eol = ctx->text.clear_to_eol;
+ Boolean clear_to_eol;
XawTextScroll(ctx, scroll_by, 0);
SinkClearToBG(ctx->text.sink, 0, 0, XtWidth(ctx), XtHeight(ctx));
@@ -3348,11 +3364,11 @@ CountLines(TextWidget ctx, XawTextPositi
if (ctx->text.wrap == XawtextWrapNever || left >= right)
return (1);
else {
- XawTextPosition tmp;
int dim, lines = 0, wwidth = GetMaxTextWidth(ctx);
while (left < right) {
- tmp = left;
+ XawTextPosition tmp = left;
+
XawTextSinkFindPosition(ctx->text.sink, left,
ctx->text.left_margin,
wwidth, ctx->text.wrap == XawtextWrapWord,