[vala] Report error for invalid escape sequences
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Report error for invalid escape sequences
- Date: Tue, 30 Jun 2009 06:27:08 +0000 (UTC)
commit c327989be420084f3ce322b8d90e763fa3bc81d4
Author: Jürg Billeter <j bitron ch>
Date: Tue Jun 30 08:26:22 2009 +0200
Report error for invalid escape sequences
Fixes bug 587375.
vala/valascanner.vala | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index adbeb45..cdac128 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -716,7 +716,24 @@ public class Vala.Scanner {
if (current[0] == '\\') {
current++;
token_length_in_chars++;
- if (current < end && current[0] == 'x') {
+ if (current >= end) {
+ break;
+ }
+
+ switch (current[0]) {
+ case '\'':
+ case '"':
+ case '\\':
+ case '0':
+ case 'b':
+ case 'f':
+ case 'n':
+ case 'r':
+ case 't':
+ current++;
+ token_length_in_chars++;
+ break;
+ case 'x':
// hexadecimal escape character
current++;
token_length_in_chars++;
@@ -724,9 +741,10 @@ public class Vala.Scanner {
current++;
token_length_in_chars++;
}
- } else {
- current++;
- token_length_in_chars++;
+ break;
+ default:
+ Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "invalid escape sequence");
+ break;
}
} else if (current[0] == '\n') {
break;
@@ -736,6 +754,7 @@ public class Vala.Scanner {
current += u.to_utf8 (null);
token_length_in_chars++;
} else {
+ current++;
Report.error (new SourceReference (source_file, line, column + token_length_in_chars, line, column + token_length_in_chars), "invalid UTF-8 character");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]