[vala/staging] scanner: "\x" requires two hex digits at most



commit 44ec058d62750b4e2f3ccb3c745915ce974a9f99
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Nov 24 19:33:50 2019 +0100

    scanner: "\x" requires two hex digits at most

 tests/scanner/regex-escape-x.vala  | 2 +-
 tests/scanner/string-escape-x.vala | 2 +-
 vala/valageniescanner.vala         | 4 ++--
 vala/valascanner.vala              | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/tests/scanner/regex-escape-x.vala b/tests/scanner/regex-escape-x.vala
index b3ad7c991..ebd59b16e 100644
--- a/tests/scanner/regex-escape-x.vala
+++ b/tests/scanner/regex-escape-x.vala
@@ -1,3 +1,3 @@
 void main () {
-       Regex foo = /\x1010/s;
+       Regex foo = /\x10/s;
 }
diff --git a/tests/scanner/string-escape-x.vala b/tests/scanner/string-escape-x.vala
index d2250b6eb..090c30998 100644
--- a/tests/scanner/string-escape-x.vala
+++ b/tests/scanner/string-escape-x.vala
@@ -1,3 +1,3 @@
 void main () {
-       string foo = "\x1010";
+       string foo = "\x10";
 }
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index 8fea07804..26d34aff7 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -775,8 +775,8 @@ public class Vala.Genie.Scanner {
                                                                current++;
                                                                token_length_in_chars++;
                                                        }
-                                                       if (digit_length != 2) {
-                                                               Report.error (get_source_reference 
(token_length_in_chars), "\\x requires two hex digits");
+                                                       if (digit_length < 1 || digit_length > 2) {
+                                                               Report.error (get_source_reference 
(token_length_in_chars), "\\x requires at least one or two hex digit");
                                                        }
                                                        break;
                                                default:
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index 718b65471..e824fd618 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -749,8 +749,8 @@ public class Vala.Scanner {
                                                                current++;
                                                                token_length_in_chars++;
                                                        }
-                                                       if (digit_length < 1) {
-                                                               Report.error (get_source_reference 
(token_length_in_chars), "\\x requires at least one hex digit");
+                                                       if (digit_length < 1 || digit_length > 2) {
+                                                               Report.error (get_source_reference 
(token_length_in_chars), "\\x requires at least one or two hex digit");
                                                        }
                                                        break;
                                                default:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]