From 5c5cdd398e5220a8bd77a5842c8013ac17c7e420 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Apr 2011 10:34:25 -0700 Subject: [PATCH] * term.c (tty_write_glyphs): Use size_t; this avoids overflow warning. --- src/ChangeLog | 2 ++ src/term.c | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 89946731630..30a45692ea6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-04-01 Paul Eggert + * term.c (tty_write_glyphs): Use size_t; this avoids overflow warning. + * coding.c: Remove vars that are set but not used. (DECODE_COMPOSITION_RULE): Remove 2nd arg, which is unused. All callers changed. diff --git a/src/term.c b/src/term.c index fc7726298c5..fc07c2b8d06 100644 --- a/src/term.c +++ b/src/term.c @@ -707,6 +707,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) { unsigned char *conversion_buffer; struct coding_system *coding; + size_t n, stringlen; struct tty_display_info *tty = FRAME_TTY (f); @@ -734,13 +735,12 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) the tail. */ coding->mode &= ~CODING_MODE_LAST_BLOCK; - while (len > 0) + for (stringlen = len; stringlen != 0; stringlen -= n) { /* Identify a run of glyphs with the same face. */ int face_id = string->face_id; - int n; - for (n = 1; n < len; ++n) + for (n = 1; n < stringlen; ++n) if (string[n].face_id != face_id) break; @@ -748,7 +748,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) tty_highlight_if_desired (tty); turn_on_face (f, face_id); - if (n == len) + if (n == stringlen) /* This is the last run. */ coding->mode |= CODING_MODE_LAST_BLOCK; conversion_buffer = encode_terminal_code (string, n, coding); @@ -762,7 +762,6 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) fwrite (conversion_buffer, 1, coding->produced, tty->termscript); UNBLOCK_INPUT; } - len -= n; string += n; /* Turn appearance modes off. */ -- 2.39.2