[vala/staging: 3/3] scanner: Improve check of "\u" escape sequence
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 3/3] scanner: Improve check of "\u" escape sequence
- Date: Mon, 25 Nov 2019 21:09:45 +0000 (UTC)
commit 8eaf15d310027c9ab2c9f148ba7b9805b588f798
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Nov 25 22:04:33 2019 +0100
scanner: Improve check of "\u" escape sequence
vala/valageniescanner.vala | 24 +++++++++++++++---------
vala/valascanner.vala | 24 +++++++++++++++---------
2 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index e6a1631fd..b5ff25f6a 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -235,12 +235,14 @@ public class Vala.Genie.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
@@ -763,12 +765,14 @@ public class Vala.Genie.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
@@ -1341,12 +1345,14 @@ public class Vala.Genie.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index cb65528a6..8f3242539 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -220,12 +220,14 @@ public class Vala.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
@@ -737,12 +739,14 @@ public class Vala.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
@@ -1177,12 +1181,14 @@ public class Vala.Scanner {
current++;
token_length_in_chars++;
int digit_length;
- for (digit_length = 0; digit_length < 4 && current <
end && current[0].isxdigit (); digit_length++) {
+ for (digit_length = 0; current < end &&
current[0].isxdigit (); digit_length++) {
current++;
token_length_in_chars++;
}
- if (digit_length != 4) {
- Report.error (get_source_reference
(token_length_in_chars), "\\u requires four hex digits");
+ if (digit_length < 1) {
+ Report.error (get_source_reference
(token_length_in_chars), "\\u used with no following hex digits");
+ } else if (digit_length < 4) {
+ Report.error (get_source_reference
(token_length_in_chars), "incomplete universal character name");
}
break;
case 'x':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]