From 67ef347023fccdeae1081fce9c86d0bf176997a1 Mon Sep 17 00:00:00 2001
From: Wang Renxin
Date: Mon, 18 Sep 2023 21:50:04 +0800
Subject: [PATCH] #79 *Improved handling of Unicode quotes.
---
HISTORY | 3 +++
LICENSE | 2 +-
README.md | 2 +-
core/my_basic.c | 15 ++++++++++++++-
core/my_basic.h | 2 +-
donate.html | 4 ++--
resource/my_basic.rc | 2 +-
shell/main.c | 4 ++--
8 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/HISTORY b/HISTORY
index 32fad2e..eb0b64e 100755
--- a/HISTORY
+++ b/HISTORY
@@ -1,3 +1,6 @@
+Sep. 18 2023
+Improved handling of Unicode quotes
+
Jul. 21 2022
Fixed an array retrieving bug in the mb_get_vars function, thanks to nurbles for pointing it out
diff --git a/LICENSE b/LICENSE
index 862b96e..e414502 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (C) 2011 - 2022 Tony Wang
+Copyright (C) 2011 - 2023 Tony Wang
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff --git a/README.md b/README.md
index 2fbb1e0..d6d46f4 100755
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
|_|_|_| |_| |_____|__|__|_____|_____|_____|
~~~~~~~~~~
-**Copyright (C) 2011 - 2022 Tony Wang**
+**Copyright (C) 2011 - 2023 Tony Wang**
[![Build status](https://github.com/paladin-t/my_basic/actions/workflows/c.yml/badge.svg)](https://github.com/paladin-t/my_basic/actions/workflows/c.yml)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
diff --git a/core/my_basic.c b/core/my_basic.c
index 0becb93..cc2f1e5 100755
--- a/core/my_basic.c
+++ b/core/my_basic.c
@@ -3,7 +3,7 @@
**
** For the latest info, see https://github.com/paladin-t/my_basic/
**
-** Copyright (C) 2011 - 2022 Tony Wang
+** Copyright (C) 2011 - 2023 Tony Wang
**
** Permission is hereby granted, free of charge, to any person obtaining a copy of
** this software and associated documentation files (the "Software"), to deal in
@@ -773,6 +773,9 @@ MBCONST static const _var_t _VAR_ARGS = { _VAR_ARGS_STR, 0 };
MBCONST static const char _MULTI_LINE_COMMENT_PREFIX[] = "'[";
MBCONST static const char _MULTI_LINE_COMMENT_POSTFIX[] = "']";
+MBCONST static const char _UNICODE_OPEN_QUOTE[] = { 0xe2, 0x80, 0x9c };
+MBCONST static const char _UNICODE_CLOSE_QUOTE[] = { 0xe2, 0x80, 0x9d };
+
typedef enum _parsing_state_e {
_PS_NORMAL,
_PS_STRING,
@@ -5888,6 +5891,16 @@ static int _parse_char(mb_interpreter_t* s, const char* str, int n, int pos, uns
case _PS_NORMAL:
#ifdef MB_ENABLE_UNICODE_ID
if(uc) {
+ if(n == countof(_UNICODE_OPEN_QUOTE)) {
+ if(memcmp(str, _UNICODE_OPEN_QUOTE, n) == 0) {
+ _handle_error_at_pos(s, SE_PS_INVALID_CHAR, s->source_file, pos, row, col, MB_FUNC_ERR, _exit, result);
+ }
+ }
+ if(n == countof(_UNICODE_CLOSE_QUOTE)) {
+ if(memcmp(str, _UNICODE_CLOSE_QUOTE, n) == 0) {
+ _handle_error_at_pos(s, SE_PS_INVALID_CHAR, s->source_file, pos, row, col, MB_FUNC_ERR, _exit, result);
+ }
+ }
if(context->symbol_state == _SS_IDENTIFIER) {
_mb_check_exit(result = _append_uu_char_to_symbol(s, str, n), _exit);
} else if(context->symbol_state == _SS_OPERATOR) {
diff --git a/core/my_basic.h b/core/my_basic.h
index e8f3a16..9c45671 100755
--- a/core/my_basic.h
+++ b/core/my_basic.h
@@ -3,7 +3,7 @@
**
** For the latest info, see https://github.com/paladin-t/my_basic/
**
-** Copyright (C) 2011 - 2022 Tony Wang
+** Copyright (C) 2011 - 2023 Tony Wang
**
** Permission is hereby granted, free of charge, to any person obtaining a copy of
** this software and associated documentation files (the "Software"), to deal in
diff --git a/donate.html b/donate.html
index 5bdad1c..cf33d4b 100644
--- a/donate.html
+++ b/donate.html
@@ -1,6 +1,6 @@
@@ -135,7 +135,7 @@
- Copyright (C) 2011 - 2022 Tony Wang, all rights reserved
+ Copyright (C) 2011 - 2023 Tony Wang, all rights reserved