]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix error message output containing wide chars
authorPatrick McCarty <pnorcks@gmail.com>
Thu, 22 Oct 2009 10:01:09 +0000 (03:01 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Mon, 26 Oct 2009 16:39:15 +0000 (09:39 -0700)
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

index fc5b03483d78cc85582d04bf7ad576c9bb681a64..96264fb4fb476955f19eb5b37736ac469d3265cd 100644 (file)
@@ -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;