kieron@root.co.uk (Kieron Drake) (09/28/90)
There have been a number of reports of strange behaviour with Athena text handling widgets on Sequents. I finally got annoyed enough to investigate this afternoon (after Xman wouldn't display any directories). I found a bug (well compiler problem) in List.c. I also heard from Mathew Newman (numb@cs.amw.ac.uk) that someone at Perdue (I forget who, I'm sure they'll have posted to this news group - but all credit to whoever it was) had found a similar problem in AsciiSink.c. I therefore built a simple test file to illustrate both problems: main() { typedef unsigned short Dimension; Dimension iw, w; short x; int one, two, xloc, cw, nr; xloc = 0; cw = 15; iw = (Dimension)2; nr = 2; x = (short)1; w = (Dimension)0xfffe; /* CvtToItem() in List.c */ one = (xloc - (int) iw) / cw ; one *= nr; two = ((int)(xloc - (int) iw)) / cw ; two *= nr; printf("%d, %d\n", one, two); /* PaintText() in AsciiSink.c */ if (((int) w) <= -x) one = 1; else one = -1; { int iiw = (int) w, nx = -x; if ( iiw <= nx ) two = 1; else two = -1; } printf("%d, %d\n", one, two); exit(0); } In each case one would expect the same values for one and two (0,0 and -1,-1 respectively). This is what happens with gcc 1.36 but with Sequent's compiler the results are 572662304, 0 /* uses deid instead of quod */ 1, -1 /* sign extends w instead of zero extending */ which basically causes the List and AsciiSink widgets not to display anything. My diffs for the two widget sources are: *** List.c Thu Sep 27 16:48:42 1990 --- /usr/src/X/R4.seq/mit/lib/Xaw/List.c Mon Dec 11 20:08:58 1989 *************** *** 339,347 int ret_val = OKAY; if (lw->list.vertical_cols) { ! one = ((int)(xloc - (int) lw->list.internal_width)) / lw->list.col_width; ! one *= lw->list.nrows; ! another = ((int)(yloc - (int) lw->list.internal_height)) / lw->list.row_height; /* If out of range, return minimum possible value. */ if (another >= lw->list.nrows) { --- 339,347 ----- int ret_val = OKAY; if (lw->list.vertical_cols) { ! one = lw->list.nrows * ((xloc - (int) lw->list.internal_width) ! / lw->list.col_width); ! another = (yloc - (int) lw->list.internal_height) / lw->list.row_height; /* If out of range, return minimum possible value. */ if (another >= lw->list.nrows) { *************** *** 350,357 } } else { ! one = ((int)(yloc - (int) lw->list.internal_height)) / lw->list.row_height; ! one *= lw->list.ncols; /* If in right margin handle things right. */ another = ((int)(xloc - (int) lw->list.internal_width)) / lw->list.col_width; if (another >= lw->list.ncols) { --- 350,357 ----- } } else { ! one = (lw->list.ncols * ((yloc - (int) lw->list.internal_height) ! / lw->list.row_height)) ; /* If in right margin handle things right. */ another = (xloc - (int) lw->list.internal_width) / lw->list.col_width; if (another >= lw->list.ncols) { *************** *** 353,359 one = ((int)(yloc - (int) lw->list.internal_height)) / lw->list.row_height; one *= lw->list.ncols; /* If in right margin handle things right. */ ! another = ((int)(xloc - (int) lw->list.internal_width)) / lw->list.col_width; if (another >= lw->list.ncols) { another = lw->list.ncols - 1; ret_val = OUT_OF_RANGE; --- 353,359 ----- one = (lw->list.ncols * ((yloc - (int) lw->list.internal_height) / lw->list.row_height)) ; /* If in right margin handle things right. */ ! another = (xloc - (int) lw->list.internal_width) / lw->list.col_width; if (another >= lw->list.ncols) { another = lw->list.ncols - 1; ret_val = OUT_OF_RANGE; and *** AsciiSink.c Thu Sep 27 17:07:28 1990 --- /usr/src/X/R4.seq/mit/lib/Xaw/AsciiSink.c Fri Dec 15 00:16:33 1989 *************** *** 195,201 Position max_x; Dimension width = XTextWidth(sink->text_sink.font, (char *) buf, len); - int int_w = (int)width, neg_x = -x, junk = (((int)width) <= -x); max_x = (Position) ctx->core.width; if ( int_w <= neg_x ) /* Don't draw if we can't see it. */ --- 195,200 ----- Position max_x; Dimension width = XTextWidth(sink->text_sink.font, (char *) buf, len); max_x = (Position) ctx->core.width; if ( ((int) width) <= -x) /* Don't draw if we can't see it. */ *************** *** 198,204 int int_w = (int)width, neg_x = -x, junk = (((int)width) <= -x); max_x = (Position) ctx->core.width; ! if ( int_w <= neg_x ) /* Don't draw if we can't see it. */ return(width); XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc, --- 197,203 ----- Dimension width = XTextWidth(sink->text_sink.font, (char *) buf, len); max_x = (Position) ctx->core.width; ! if ( ((int) width) <= -x) /* Don't draw if we can't see it. */ return(width); XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc, The "junk" variable was just there for debugging purposes. You can remove it if you want! :-) I know that there is another way of getting round the AsciiSink problem but I chose to use two extra ints to avoid any #ifdef sequent hassle. kieron -- Kieron Drake MAIL: kieron@root.co.uk SNAIL: UniSoft Ltd, Saunderson House, Hayne Street, London EC1A 9HH PHONE: +44 71 315 6637 (direct) +44 71 315 6600 (switchboard)
bingle@cs.purdue.EDU (Richard Bingle) (09/29/90)
In article <2450@root44.co.uk>, kieron@root.co.uk (Kieron Drake) writes: > > There have been a number of reports of strange behaviour > with Athena text handling widgets on Sequents. I finally > got annoyed enough to investigate this afternoon (after > Xman wouldn't display any directories). I found a bug > (well compiler problem) in List.c. I also heard from > Mathew Newman (numb@cs.amw.ac.uk) that someone at Perdue ^^^^^^ > (I forget who, I'm sure they'll have posted to this news > group - but all credit to whoever it was) had found a > similar problem in AsciiSink.c. I therefore built a simple > test file to illustrate both problems: I'm glad to be of assistance. Thanks for the list widget fix, I hadn't noticed that one! ------------------------------------------------------------------------------- Richard Bingle bingle@cs.purdue.edu Computer Science Department purdue!bingle Purdue University (317) 494-0893 West Lafayette, IN 47907