[gnome-calculator] Fixed degree unit conversions (#211)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Fixed degree unit conversions (#211)
- Date: Mon, 8 Mar 2021 08:57:30 +0000 (UTC)
commit f5f355259280051b19be2c6afae09ec13d564ec8
Author: Robert Roth <robert roth off gmail com>
Date: Mon Mar 8 10:55:26 2021 +0200
Fixed degree unit conversions (#211)
lib/equation-lexer.vala | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/lib/equation-lexer.vala b/lib/equation-lexer.vala
index 6c2a5f02..36e8d9bd 100644
--- a/lib/equation-lexer.vala
+++ b/lib/equation-lexer.vala
@@ -142,7 +142,7 @@ public class PreLexer : Object
if (c == '½' || c == '⅓' || c == '⅔' || c == '¼' || c == '¾' || c == '⅕' || c == '⅖' || c == '⅗' ||
c == '⅘' || c == '⅙' || c == '⅚' || c == '⅛' || c == '⅜' || c == '⅝' || c == '⅞')
return LexerTokenType.PL_FRACTION;
- if (c == '°')
+ if (c == '˚' || c == '°')
return LexerTokenType.PL_DEGREE;
if (c == '\'')
@@ -381,6 +381,7 @@ public class Lexer : Object
/* Ignore whitespace */
var type = prelexer.get_next_token ();
+
while (type == LexerTokenType.PL_SKIP)
{
prelexer.set_marker ();
@@ -448,6 +449,13 @@ public class Lexer : Object
if (type == LexerTokenType.PL_LETTER)
return insert_letter ();
+ if (type == LexerTokenType.PL_DEGREE)
+ {
+ type = prelexer.get_next_token ();
+ if ((type == LexerTokenType.PL_HEX || type == LexerTokenType.PL_LETTER) && check_if_unit ())
+ return insert_token (LexerTokenType.UNIT);
+ }
+
if (type == LexerTokenType.PL_EOS)
return insert_token (LexerTokenType.PL_EOS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]