From a6bbe2fa3fceea9a153dad35294679ae54868671 Mon Sep 17 00:00:00 2001
From: Patrick McCarty <pnorcks@gmail.com>
Date: Thu, 22 Oct 2009 03:01:09 -0700
Subject: [PATCH] Fix error message output containing wide chars

Before this commit, error message output containing multibyte characters
would be displayed incorrectly for en_US.ISO-88591, en_US.UTF-8, and
other standard locales.

The characters were being split because the character count only
increased by one at the end of a loop iteration.  It is necessary to
account for characters that are 2, 3, or 4 bytes wide, and this commit
(mostly) fixes that problem.

Note that this is a temporary workaround.  Eventually, we should use
routines that are not locale-dependent, since the only information we
need is the size of each UTF-8 character.
---
 lily/source-file.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lily/source-file.cc b/lily/source-file.cc
index fc5b03483d..96264fb4fb 100644
--- a/lily/source-file.cc
+++ b/lily/source-file.cc
@@ -308,7 +308,12 @@ Source_file::get_counts (char const *pos_str0,
       else
 	(*column)++;
 
-      (*line_char)++;
+      /*
+	For accurate error output, consider multibyte
+	characters as a series of characters.
+      */
+      (*line_char) += thislen;
+
       /* Advance past this character. */
       line_chars += thislen;
       left -= thislen;
-- 
2.39.5