changeset 90770:4a4222f7a38d

(x_draw_composite_glyph_string_foreground): Fix indexing into elements of s->cmp and s->char2b.
author Kenichi Handa <handa@m17n.org>
date Tue, 20 Feb 2007 11:25:27 +0000
parents 429fb762384a
children 8380fb3b4013
files src/xterm.c
diffstat 1 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Tue Feb 20 11:02:20 2007 +0000
+++ b/src/xterm.c	Tue Feb 20 11:25:27 2007 +0000
@@ -1434,7 +1434,7 @@
 x_draw_composite_glyph_string_foreground (s)
      struct glyph_string *s;
 {
-  int i, x;
+  int i, j, x;
 
   /* If first glyph of S has a left box line, start drawing the text
      of S to the right of that box line.  */
@@ -1501,34 +1501,33 @@
 	}
       else
 	{
-	  for (i = 0; i < s->nchars; i++)
-	    if (COMPOSITION_GLYPH (s->cmp, s->gidx) != '\t')
+	  for (i = 0, j = s->gidx; i < s->nchars; i++, j++)
+	    if (COMPOSITION_GLYPH (s->cmp, j) != '\t')
 	      {
-		int xx = x + s->cmp->offsets[s->gidx * 2];
-		int yy = y - s->cmp->offsets[s->gidx * 2 + 1];
-
-		font->driver->draw (s, s->gidx, s->gidx + 1, xx, yy, 0);
+		int xx = x + s->cmp->offsets[j * 2];
+		int yy = y - s->cmp->offsets[j * 2 + 1];
+
+		font->driver->draw (s, j, j + 1, xx, yy, 0);
 		if (s->face->overstrike)
-		  font->driver->draw (s, s->gidx, s->gidx + 1, xx + 1, yy, 0);
-		s->gidx++;
+		  font->driver->draw (s, j, j + 1, xx + 1, yy, 0);
 	      }
 	}
     }
 #endif	/* USE_FONT_BACKEND */
   else
     {
-      for (i = 0; i < s->nchars; i++, ++s->gidx)
+      for (i = 0, j = s->gidx; i < s->nchars; i++, j++)
 	if (s->face)
 	  {
 	    XDrawString16 (s->display, s->window, s->gc,
-			   x + s->cmp->offsets[s->gidx * 2],
-			   s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
-			   s->char2b + s->gidx, 1);
+			   x + s->cmp->offsets[j * 2],
+			   s->ybase - s->cmp->offsets[j * 2 + 1],
+			   s->char2b + j, 1);
 	    if (s->face->overstrike)
 	      XDrawString16 (s->display, s->window, s->gc,
-			     x + s->cmp->offsets[s->gidx * 2] + 1,
-			     s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
-			     s->char2b + s->gidx, 1);
+			     x + s->cmp->offsets[j * 2] + 1,
+			     s->ybase - s->cmp->offsets[j * 2 + 1],
+			     s->char2b + j, 1);
 	  }
     }
 }