Browse Source

make all kernal files to be single ascii

Lyon 2 years ago
parent
commit
a3a3d8fb75
100 changed files with 983 additions and 2271 deletions
  1. 0 5
      package/PikaStdLib/PikaStdData_Dict.c
  2. 0 2
      package/PikaStdLib/PikaStdData_String.c
  3. 35 19
      port/linux/format.py
  4. 20 16
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc.h
  5. 12 13
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class.h
  6. 21 17
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_black_box.h
  7. 22 18
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_simple.h
  8. 22 18
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_simple_c90.h
  9. 20 16
      port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_strict.h
  10. 5 5
      port/linux/package/pikascript/pikascript-lib/PikaCV/3rd-party/tjpgd/src/tjpgd.h
  11. 2 1
      port/linux/package/pikascript/pikascript-lib/PikaCV/3rd-party/tjpgd/src/tjpgdcnf.h
  12. 2 3
      port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Converter.c
  13. 0 2
      port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Image.c
  14. 2 2
      port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Transforms.c
  15. 0 1
      port/linux/package/pikascript/pikascript-lib/PikaMath/PikaMath_Math.c
  16. 0 2
      port/linux/package/pikascript/pikascript-lib/PikaMath/PikaMath_Quaternion.c
  17. 22 29
      port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_IIC.c
  18. 0 5
      port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdData_Dict.c
  19. 0 2
      port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdData_String.c
  20. 0 1
      port/linux/package/pikascript/pikascript-lib/base64/_base64.c
  21. 0 1
      port/linux/package/pikascript/pikascript-lib/json/_pika_cJSON.c
  22. 58 53
      port/linux/package/pikascript/pikascript-lib/json/_pika_cJSON.h
  23. 17 16
      port/linux/package/pikascript/pikascript-lib/json/jsmn.h
  24. 0 1
      port/linux/package/pikascript/pikascript-lib/math/_math.c
  25. 0 1
      port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus.c
  26. 0 1
      port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus.h
  27. 0 1
      port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_rtu.h
  28. 0 1
      port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_tcp.c
  29. 0 1
      port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_tcp.h
  30. 4 4
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnect.h
  31. 6 6
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnectClient.c
  32. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnectServer.c
  33. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTDeserializePublish.c
  34. 2 1
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTFormat.c
  35. 2 1
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTFormat.h
  36. 3 4
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPacket.c
  37. 2 3
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPacket.h
  38. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPublish.h
  39. 7 7
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSerializePublish.c
  40. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribe.h
  41. 4 4
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribeClient.c
  42. 6 5
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribeServer.c
  43. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribe.h
  44. 6 6
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribeClient.c
  45. 6 5
      port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribeServer.c
  46. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/StackTrace.h
  47. 7 152
      port/linux/package/pikascript/pikascript-lib/mqtt/_mqtt__MQTT.c
  48. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_config.h
  49. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_error.h
  50. 2 3
      port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_list.c
  51. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_list.h
  52. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_log.h
  53. 3 3
      port/linux/package/pikascript/pikascript-lib/mqtt/mqttclient.c
  54. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/mqttclient.h
  55. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tcp.c
  56. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tcp.h
  57. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tls.c
  58. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/network.c
  59. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/network.h
  60. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/platform_memory.c
  61. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/platform_memory.h
  62. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/platform_net_socket.c
  63. 2 2
      port/linux/package/pikascript/pikascript-lib/mqtt/platform_net_socket.h
  64. 0 1
      port/linux/package/pikascript/pikascript-lib/mqtt/random.h
  65. 2 26
      port/linux/package/pikascript/pikascript-lib/os/os_path.c
  66. 0 2
      port/linux/package/pikascript/pikascript-lib/os/os_platform.c
  67. 0 1
      port/linux/package/pikascript/pikascript-lib/pika_cjson/cJSON.c
  68. 59 54
      port/linux/package/pikascript/pikascript-lib/pika_cjson/cJSON.h
  69. 0 1270
      port/linux/package/pikascript/pikascript-lib/pika_libc/pika_vsnprintf.c
  70. 1 1
      port/linux/package/pikascript/pikascript-lib/pika_lua/_pika_lua.c
  71. 1 1
      port/linux/package/pikascript/pikascript-lib/socket/PikaPlatform_socket.c
  72. 1 1
      port/linux/package/pikascript/pikascript-lib/socket/PikaPlatform_socket.h
  73. 1 1
      port/linux/package/pikascript/pikascript-lib/socket/_socket.c
  74. 11 12
      port/linux/package/pikascript/pikascript-lib/struct/_struct.c
  75. 20 158
      port/linux/package/pikascript/pikascript-lib/time/_time.c
  76. 0 1
      port/linux/package/pikascript/pikascript-lib/zlib/fastlz.c
  77. 2 3
      port/linux/package/pikascript/pikascript-lib/zlib/fastlz.h
  78. 0 1
      port/linux/test/PikaCV-test.cpp
  79. 0 1
      port/linux/test/PikaNN-test.cpp
  80. 0 1
      port/linux/test/ctypes-test.cpp
  81. 0 1
      port/linux/test/json-test.cpp
  82. 0 1
      port/linux/test/mem_test.cpp
  83. 0 1
      port/linux/test/module-test.cpp
  84. 6 4
      port/linux/test/mqtt-test.cpp
  85. 0 1
      port/linux/test/packtool-test.cpp
  86. 0 1
      port/linux/test/pikaui-test.cpp
  87. 369 52
      port/linux/test/py-test.cpp
  88. 4 4
      port/linux/test/requests-test.cpp
  89. 0 1
      port/linux/test/stddata-test.cpp
  90. 0 1
      port/linux/test/string-test.cpp
  91. 12 12
      src/BaseObj.c
  92. 12 13
      src/BaseObj.h
  93. 23 45
      src/PikaCompiler.c
  94. 19 22
      src/PikaObj.c
  95. 16 15
      src/PikaObj.h
  96. 12 12
      src/PikaParser.c
  97. 12 12
      src/PikaParser.h
  98. 13 13
      src/PikaPlatform.c
  99. 15 16
      src/PikaPlatform.h
  100. 12 12
      src/PikaVM.c

+ 0 - 5
package/PikaStdLib/PikaStdData_Dict.c

@@ -136,14 +136,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
                             void* context) {
     DictToStrContext* ctx = (DictToStrContext*)context;
 
-    // 判断是否需要在字符串前添加逗号
     if (!ctx->isFirst) {
         ctx->buf = arg_strAppend(ctx->buf, ", ");
     } else {
         ctx->isFirst = 0;
     }
 
-    // 将键值对添加到字符串
     ctx->buf = arg_strAppend(ctx->buf, "'");
     ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach));
     ctx->buf = arg_strAppend(ctx->buf, "'");
@@ -160,15 +158,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
 }
 
 char* PikaStdData_Dict___str__(PikaObj* self) {
-    // 初始化上下文
     DictToStrContext context;
     context.buf = arg_newStr("{");
     context.isFirst = 1;
 
-    // 使用 objDict_forEach 遍历字典
     objDict_forEach(self, dictToStrEachHandle, &context);
 
-    // 将字符串添加到结果中并返回
     context.buf = arg_strAppend(context.buf, "}");
     obj_setStr(self, "_buf", arg_getStr(context.buf));
     arg_deinit(context.buf);

+ 0 - 2
package/PikaStdLib/PikaStdData_String.c

@@ -241,9 +241,7 @@ PikaObj* PikaStdData_String_split(PikaObj* self, PikaTuple* s_) {
     } else {
         s = pikaTuple_getStr(s_, 0);
     }
-    /* 创建 list 对象 */
     PikaObj* list = newNormalObj(New_PikaStdData_List);
-    /* 初始化 list */
     PikaStdData_List___init__(list);
 
     Args buffs = {0};

+ 35 - 19
port/linux/format.py

@@ -1,11 +1,39 @@
-import os
 import sys
 import subprocess
 from pathlib import Path
+import codecs
+
+
+def format_file(filepath):
+    try:
+        subprocess.run(['clang-format', '-i', str(filepath)], check=True)
+    except subprocess.CalledProcessError as e:
+        print(f'Error formatting file: {filepath}. Error message: {str(e)}')
+
+    non_ascii_lines = []
+
+    with codecs.open(filepath, 'r', 'utf-8-sig') as file:
+        lines = file.readlines()
+        for i, line in enumerate(lines):
+            if filepath.suffix != '.cpp':
+                if not line.isascii():
+                    non_ascii_lines.append((i + 1, line))
+
+        if lines and not lines[-1].endswith('\n'):
+            lines.append('\n')
+            print(f'Added newline to file: {filepath}')
+
+    with codecs.open(filepath, 'w', 'utf-8') as file:
+        file.writelines(lines)
+
+    if non_ascii_lines:
+        # print with yellow color
+        print(f'\033[33mFound non-ASCII lines in file: {filepath}\033[0m')
+        for line_no, line in non_ascii_lines:
+            print(f'Line {filepath}:{line_no}: {line}')
 
 
 def format_files_in_dir(dir_path, dir_skip):
-    # 遍历目录及其子目录中的所有文件
     for filepath in dir_path.rglob('*'):
         # Skip if the current file's directory or any of its parents are in dir_skip
         if any(str(filepath).startswith(dir) for dir in dir_skip):
@@ -13,22 +41,7 @@ def format_files_in_dir(dir_path, dir_skip):
 
         # 只处理.c, .h, .cpp文件
         if filepath.suffix in ['.c', '.h', '.cpp']:
-            try:
-                # 使用clang-format命令格式化文件
-                subprocess.run(
-                    ['clang-format', '-i', str(filepath)], check=True)
-                print(f'Formatted file: {filepath}')
-            except subprocess.CalledProcessError as e:
-                print(
-                    f'Error formatting file: {filepath}. Error message: {str(e)}')
-
-            # 确保文件最后一行是空行
-            with open(filepath, 'r+', encoding='utf-8') as file:
-                lines = file.readlines()
-                if lines and not lines[-1].endswith('\n'):
-                    # 如果最后一行不是空行,添加一个
-                    file.write('\n')
-                    print(f'Added newline to file: {filepath}')
+            format_file(filepath)
 
 
 # 从命令行参数获取目录列表
@@ -40,7 +53,10 @@ if len(dirs) == 0:
             'package/pikascript/pikascript-core', 'test']
 
 dir_skip = ['package/pikascript/pikascript-lib/re',
-            'package/pikascript/pikascript-lib/PikaNN']
+            'package/pikascript/pikascript-lib/PikaNN',
+            'package/pikascript/pikascript-lib/modbus',
+            'package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_table_rule.h'
+            ]
 
 # 对每个目录进行处理
 for dir_path_str in dirs:

+ 20 - 16
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc.h

@@ -1,20 +1,19 @@
 /*****************************************************************************
- *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com>    *
+ *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 #ifndef __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__
 #define __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__
 
@@ -75,7 +74,8 @@ extern "C" {
 #endif
 #endif
 
-/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ MACROFIED FUNCTIONS
+ * ===========================*/
 
 /*! \note add which macro to support multiple inheriting and implementations
  *!
@@ -274,7 +274,8 @@ extern "C" {
 #define this_interface(__INTERFACE) convert_obj_as(this, __INTERFACE)
 #define base_obj(__type) convert_obj_as(this, __type)
 
-/*============================ TYPES =========================================*/
+/*============================ TYPES
+ * =========================================*/
 
 //! \name interface: u32_property_t
 //! @{
@@ -340,9 +341,12 @@ bool (*Disable)(void);
 end_def_interface(en_property_t)
 //! @}
 
-/*============================ GLOBAL VARIABLES ==============================*/
-/*============================ LOCAL VARIABLES ===============================*/
-/*============================ PROTOTYPES ====================================*/
+/*============================ GLOBAL VARIABLES
+ * ==============================*/
+/*============================ LOCAL VARIABLES
+ * ===============================*/
+/*============================ PROTOTYPES
+ * ====================================*/
 
 #ifdef __cplusplus
 }

+ 12 - 13
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class.h

@@ -1,22 +1,21 @@
 /*****************************************************************************
- *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com>    *
- *                       and  SimonQian<simonqian@simonqian.com>             *
- *         with support from  HenryLong<henry_long@163.com>                  *
+ *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
+ *                       and  SimonQian<simonqian@simonqian.com> * with
+ *support from  HenryLong<henry_long@163.com>                  *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 #if defined(__cplusplus) || defined(__OOC_CPP__)
 #undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__
 #undef PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___

+ 21 - 17
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_black_box.h

@@ -1,20 +1,19 @@
 /****************************************************************************
- *  Copyright 2017 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com)       *
+ *  Copyright 2017 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 /*============================ INCLUDES ======================================*/
 //#include <stdint.h>
 //#include <stdbool.h>
@@ -38,7 +37,8 @@ extern "C" {
 #undef __end_extern_class
 #undef class
 #undef __class
-/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ MACROFIED FUNCTIONS
+ * ===========================*/
 
 #if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
 
@@ -183,7 +183,7 @@ extern "C" {
 #endif
 
 /*----------------------------------------------------------------------------*
- * new standard (lower case)                                                  *
+ * new standard (lower case) *
  *----------------------------------------------------------------------------*/
 
 #undef __class_internal
@@ -211,11 +211,15 @@ extern "C" {
 #undef which
 #define which(...) PLOOC_VISIBLE(__VA_ARGS__)
 
-/*============================ TYPES =========================================*/
+/*============================ TYPES
+ * =========================================*/
 
-/*============================ GLOBAL VARIABLES ==============================*/
-/*============================ LOCAL VARIABLES ===============================*/
-/*============================ PROTOTYPES ====================================*/
+/*============================ GLOBAL VARIABLES
+ * ==============================*/
+/*============================ LOCAL VARIABLES
+ * ===============================*/
+/*============================ PROTOTYPES
+ * ====================================*/
 
 #undef __PLOOC_CLASS_IMPLEMENT__
 #undef __PLOOC_CLASS_INHERIT__

+ 22 - 18
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_simple.h

@@ -1,22 +1,21 @@
 /*****************************************************************************
- *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com>    *
- *                       and  SimonQian<simonqian@simonqian.com>             *
- *         with support from  HenryLong<henry_long@163.com>                  *
+ *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
+ *                       and  SimonQian<simonqian@simonqian.com> * with
+ *support from  HenryLong<henry_long@163.com>                  *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 /******************************************************************************
  * HOW TO USE                                                                 *
  ******************************************************************************/
@@ -44,7 +43,8 @@ extern "C" {
 #undef protected_member
 #undef public_member
 
-/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ MACROFIED FUNCTIONS
+ * ===========================*/
 
 #ifndef __PLOOC_CLASS_SIMPLE_H__
 #define __PLOOC_CLASS_SIMPLE_H__
@@ -201,10 +201,14 @@ extern "C" {
 #undef __PLOOC_CLASS_INHERIT__
 #undef __PLOOC_CLASS_IMPLEMENT
 #undef __PLOOC_CLASS_INHERIT
-/*============================ TYPES =========================================*/
-/*============================ GLOBAL VARIABLES ==============================*/
-/*============================ LOCAL VARIABLES ===============================*/
-/*============================ PROTOTYPES ====================================*/
+/*============================ TYPES
+ * =========================================*/
+/*============================ GLOBAL VARIABLES
+ * ==============================*/
+/*============================ LOCAL VARIABLES
+ * ===============================*/
+/*============================ PROTOTYPES
+ * ====================================*/
 
 #ifdef __cplusplus
 }

+ 22 - 18
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_simple_c90.h

@@ -1,22 +1,21 @@
 /*****************************************************************************
- *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com>    *
- *                       and  SimonQian<simonqian@simonqian.com>             *
- *         with support from  HenryLong<henry_long@163.com>                  *
+ *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
+ *                       and  SimonQian<simonqian@simonqian.com> * with
+ *support from  HenryLong<henry_long@163.com>                  *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 /******************************************************************************
  * HOW TO USE                                                                 *
  ******************************************************************************/
@@ -44,7 +43,8 @@ extern "C" {
 #undef protected_member
 #undef public_member
 
-/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ MACROFIED FUNCTIONS
+ * ===========================*/
 
 #ifndef __PLOOC_CLASS_SIMPLE_C90_H__
 #define __PLOOC_CLASS_SIMPLE_C90_H__
@@ -152,10 +152,14 @@ extern "C" {
 #undef __PLOOC_CLASS_IMPLEMENT
 #undef __PLOOC_CLASS_INHERIT
 
-/*============================ TYPES =========================================*/
-/*============================ GLOBAL VARIABLES ==============================*/
-/*============================ LOCAL VARIABLES ===============================*/
-/*============================ PROTOTYPES ====================================*/
+/*============================ TYPES
+ * =========================================*/
+/*============================ GLOBAL VARIABLES
+ * ==============================*/
+/*============================ LOCAL VARIABLES
+ * ===============================*/
+/*============================ PROTOTYPES
+ * ====================================*/
 
 #ifdef __cplusplus
 }

+ 20 - 16
port/linux/package/pikascript/pikascript-lib/PLOOC/plooc_class_strict.h

@@ -1,20 +1,19 @@
 /*****************************************************************************
- *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com>    *
+ *   Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
  *                                                                           *
- *  Licensed under the Apache License, Version 2.0 (the "License");          *
- *  you may not use this file except in compliance with the License.         *
- *  You may obtain a copy of the License at                                  *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); * you may
+ *not use this file except in compliance with the License.         * You may
+ *obtain a copy of the License at                                  *
  *                                                                           *
- *     http://www.apache.org/licenses/LICENSE-2.0                            *
+ *     http://www.apache.org/licenses/LICENSE-2.0 *
  *                                                                           *
- *  Unless required by applicable law or agreed to in writing, software      *
- *  distributed under the License is distributed on an "AS IS" BASIS,        *
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
- *  See the License for the specific language governing permissions and      *
- *  limitations under the License.                                           *
+ *  Unless required by applicable law or agreed to in writing, software *
+ *  distributed under the License is distributed on an "AS IS" BASIS, *
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and *
+ *  limitations under the License. *
  *                                                                           *
  ****************************************************************************/
-
 //#ifndef __PLOOC_CLASS_STRICT_H__          /* deliberately comment this out! */
 //#define __PLOOC_CLASS_STRICT_H__          /* deliberately comment this out! */
 
@@ -61,7 +60,8 @@ extern "C" {
 #undef end_extern_class
 #undef __end_extern_class
 
-/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ MACROFIED FUNCTIONS
+ * ===========================*/
 
 #if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
 
@@ -446,10 +446,14 @@ extern "C" {
 #undef __PLOOC_CLASS_INHERIT__
 #undef __PLOOC_CLASS_IMPLEMENT
 #undef __PLOOC_CLASS_INHERIT
-/*============================ TYPES =========================================*/
-/*============================ GLOBAL VARIABLES ==============================*/
-/*============================ LOCAL VARIABLES ===============================*/
-/*============================ PROTOTYPES ====================================*/
+/*============================ TYPES
+ * =========================================*/
+/*============================ GLOBAL VARIABLES
+ * ==============================*/
+/*============================ LOCAL VARIABLES
+ * ===============================*/
+/*============================ PROTOTYPES
+ * ====================================*/
 
 //#endif                                /* deliberately comment this out! */
 

+ 5 - 5
port/linux/package/pikascript/pikascript-lib/PikaCV/3rd-party/tjpgd/src/tjpgd.h

@@ -70,11 +70,11 @@ struct JDEC {
     uint32_t wreg;  /* Working shift register */
     uint8_t marker; /* Detected marker (0:None) */
 #if JD_FASTDECODE == 2
-    uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
-    uint16_t*
-        hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
-    uint8_t*
-        hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
+    uint8_t longofs[2][2];   /* Table offset of long code [id][dcac] */
+    uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code
+                                [id] */
+    uint8_t* hufflut_dc[2];  /* Fast huffman decode tables for DC short code
+                                [id] */
 #endif
 #endif
     void* workbuf;    /* Working buffer for IDCT and RGB output */

+ 2 - 1
port/linux/package/pikascript/pikascript-lib/PikaCV/3rd-party/tjpgd/src/tjpgdcnf.h

@@ -27,5 +27,6 @@ KB of code size. /  0: Disable /  1: Enable
 /* Optimization level
 /  0: Basic optimization. Suitable for 8/16-bit MCUs.
 /  1: + 32-bit barrel shifter. Suitable for 32-bit MCUs.
-/  2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of RAM)
+/  2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of
+RAM)
 */

+ 2 - 3
port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Converter.c

@@ -2,8 +2,8 @@
 #include "PikaCV_Transforms.h"
 #include "PikaCV_common.h"
 
-/* Session identifier for input/output functions (name, members and usage are as
- user defined) */
+/* Session identifier for input/output functions (name, members and usage
+ are as user defined) */
 typedef struct {
     uint8_t* input_ptr;  /* Pointer to input data */
     size_t input_offset; /* Offset of input data */
@@ -339,7 +339,6 @@ void PikaCV_Converter_toBMP(PikaObj* self, PikaObj* image) {
     int width = img->width;
     int height = img->height;
 
-    // bmp的每行数据的长度要4字节对齐
     row_align = align(width * 3, 4);
 
     /* convert to BMP */

+ 0 - 2
port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Image.c

@@ -407,9 +407,7 @@ PikaObj* PikaCV_Image_split(PikaObj* self) {
         PikaCV_Image___init__(img);
         PikaCV_Image_loadGray(img, src->width, src->height, RGB[i]);
         Arg* token_arg = arg_newObj(img);
-        /* 添加到 list 对象 */
         PikaStdData_List_append(list, token_arg);
-        /* 销毁 arg */
         arg_deinit(token_arg);
     }
 

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/PikaCV/PikaCV_Transforms.c

@@ -281,9 +281,9 @@ void PikaCV_Transforms_adaptiveThreshold(PikaObj* self,
     memcpy(src_copy, src_data, size);
 
     if (method == 0) {
-        PikaCV_Filter_meanFilter(self, image, subsize, subsize);  //均值滤波
+        PikaCV_Filter_meanFilter(self, image, subsize, subsize);
     } else if (method == 1) {
-        PikaCV_Filter_medianFilter(self, image);  //中值滤波
+        PikaCV_Filter_medianFilter(self, image);
     } else {
         free(src_copy);
         return;

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/PikaMath/PikaMath_Math.c

@@ -3,7 +3,6 @@
 
 #define PI (3.141592653589793115997963468544185161590576171875l)
 #define E (2.718281828459045090795598298427648842334747314453125l)
-//初始化,填入π和e的值
 void PikaMath_Math___init__(PikaObj* self) {
     obj_setFloat(self, "pi", PI);
     obj_setFloat(self, "e", E);

+ 0 - 2
port/linux/package/pikascript/pikascript-lib/PikaMath/PikaMath_Quaternion.c

@@ -264,9 +264,7 @@ PikaObj* PikaMath_Quaternion_toEuler(PikaObj* self) {
 
     for (int i = 0; i < 3; i++) {
         Arg* token_arg = arg_newFloat(rpy[i]);
-        /* 添加到 list 对象 */
         PikaStdData_List_append(list, token_arg);
-        /* 销毁 arg */
         arg_deinit(token_arg);
     }
 

+ 22 - 29
port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_IIC.c

@@ -65,17 +65,16 @@ static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
         byte <<= 1;
     }
 
-    // 在发送完字节后检查ACK信号
     _GPIO_write(cfg->SCL, 0);
     _IIC_Delay();
-    _IIC_SDA_input(cfg);       // 设置SDA为输入
-    _GPIO_write(cfg->SCL, 1);  // 将SCL线设置为高,让从设备发送ACK信号
+    _IIC_SDA_input(cfg);
+    _GPIO_write(cfg->SCL, 1);
 
     int timeout = 1000;
     uint32_t ack = 0;
     do {
         _IIC_Delay();
-        ack = !_GPIO_read(cfg->SDA);  // 如果从设备发送了ACK信号,SDA线会被拉低
+        ack = !_GPIO_read(cfg->SDA);
     } while (ack == 0 && timeout-- > 0);
 
     // pika_debug("ack timeout:%d", timeout);
@@ -83,28 +82,28 @@ static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
         pika_platform_printf("Error: IIC write byte timeout\r\n");
     }
 
-    _GPIO_write(cfg->SCL, 0);  // 将SCL线设置为低,完成一个I2C周期
+    _GPIO_write(cfg->SCL, 0);
     return ack;
 }
 
 static void _IIC_Ack(pika_hal_SOFT_IIC_config* cfg) {
-    _GPIO_write(cfg->SCL, 0);  // 拉低时钟线
-    _IIC_SDA_output(cfg);      // 设置SDA为输出
-    _GPIO_write(cfg->SDA, 0);  // 拉低数据线
+    _GPIO_write(cfg->SCL, 0);
+    _IIC_SDA_output(cfg);
+    _GPIO_write(cfg->SDA, 0);
     _IIC_Delay();
-    _GPIO_write(cfg->SCL, 1);  // 产生时钟
+    _GPIO_write(cfg->SCL, 1);
     _IIC_Delay();
-    _GPIO_write(cfg->SCL, 0);  // 拉低时钟线
+    _GPIO_write(cfg->SCL, 0);
 }
 
 static void _IIC_NAck(pika_hal_SOFT_IIC_config* cfg) {
-    _GPIO_write(cfg->SCL, 0);  // 拉低时钟线
-    _IIC_SDA_output(cfg);      // 设置SDA为输出
-    _GPIO_write(cfg->SDA, 1);  // 数据线拉高
+    _GPIO_write(cfg->SCL, 0);
+    _IIC_SDA_output(cfg);
+    _GPIO_write(cfg->SDA, 1);
     _IIC_Delay();
-    _GPIO_write(cfg->SCL, 1);  // 产生时钟
+    _GPIO_write(cfg->SCL, 1);
     _IIC_Delay();
-    _GPIO_write(cfg->SCL, 0);  // 拉低时钟线
+    _GPIO_write(cfg->SCL, 0);
 }
 
 static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
@@ -120,11 +119,10 @@ static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
         _GPIO_write(cfg->SCL, 0);
         _IIC_Delay();
     }
-    // 在读取完一个字节后发送ACK信号
     if (ack) {
-        _IIC_Ack(cfg);  // 如果ack为真,发送ACK信号
+        _IIC_Ack(cfg);
     } else {
-        _IIC_NAck(cfg);  // 如果ack为假,发送NACK信号
+        _IIC_NAck(cfg);
     }
     pika_debug(" - iic read: 0x%02X", byte);
     return byte;
@@ -136,11 +134,10 @@ int pika_hal_platform_SOFT_IIC_write(pika_dev* dev, void* buf, size_t count) {
     uint8_t* data = (uint8_t*)buf;
 
     _IIC_Start(iic_cfg);
-    uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00;  // 方向位为0代表写
+    uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00;
     // pika_debug("iic addr_write: 0x%02X", addr_write);
-    _IIC_SendByte(iic_cfg, addr_write);  // 方向位为0代表写
+    _IIC_SendByte(iic_cfg, addr_write);
 
-    // 如果启用了mem_addr_ena,将设备地址和内存地址发送到I2C总线
     if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
         if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
             _IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
@@ -164,12 +161,10 @@ int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
 
     _IIC_Start(iic_cfg);
 
-    // 如果启用了mem_addr_ena,先写设备地址和内存地址
     if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
-        uint8_t addr_write =
-            (iic_cfg->slave_addr << 1) | 0x00;  // 方向位为0代表写
+        uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00;
         // pika_debug("iic addr_write: 0x%02X", addr_write);
-        _IIC_SendByte(iic_cfg, addr_write);  // 方向位为0代表写
+        _IIC_SendByte(iic_cfg, addr_write);
         if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
             _IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
         } else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
@@ -179,9 +174,9 @@ int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
         _IIC_Start(iic_cfg);
     }
 
-    uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01;  // 方向位为1代表读
+    uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01;
     // pika_debug("iic addr_read: 0x%02X", addr_read);
-    _IIC_SendByte(iic_cfg, addr_read);  // 方向位为1代表读
+    _IIC_SendByte(iic_cfg, addr_read);
 
     for (int i = 0; i < count - 1; i++) {
         // data[i] = _IIC_ReadByte(iic_cfg, 1);
@@ -215,7 +210,6 @@ int pika_hal_platform_SOFT_IIC_ioctl_config(pika_dev* dev,
             "Error: SOFT IIC config error, SDA and SCL must be set\r\n");
         return -1;
     }
-    // 检查软件IIC配置项是否正确
     if (cfg->master_or_slave != PIKA_HAL_IIC_MASTER &&
         cfg->master_or_slave != PIKA_HAL_IIC_SLAVE) {
         __platform_printf(
@@ -240,7 +234,6 @@ int pika_hal_platform_SOFT_IIC_ioctl_config(pika_dev* dev,
             "Error: SOFT IIC config error, mem_addr_size must be set\r\n");
         return -1;
     }
-    // 在这里,我们暂时不检查speed和timeout,因为软件模拟的I2C可能无法精确控制速度和超时。
     return 0;
 }
 

+ 0 - 5
port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdData_Dict.c

@@ -136,14 +136,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
                             void* context) {
     DictToStrContext* ctx = (DictToStrContext*)context;
 
-    // 判断是否需要在字符串前添加逗号
     if (!ctx->isFirst) {
         ctx->buf = arg_strAppend(ctx->buf, ", ");
     } else {
         ctx->isFirst = 0;
     }
 
-    // 将键值对添加到字符串
     ctx->buf = arg_strAppend(ctx->buf, "'");
     ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach));
     ctx->buf = arg_strAppend(ctx->buf, "'");
@@ -160,15 +158,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
 }
 
 char* PikaStdData_Dict___str__(PikaObj* self) {
-    // 初始化上下文
     DictToStrContext context;
     context.buf = arg_newStr("{");
     context.isFirst = 1;
 
-    // 使用 objDict_forEach 遍历字典
     objDict_forEach(self, dictToStrEachHandle, &context);
 
-    // 将字符串添加到结果中并返回
     context.buf = arg_strAppend(context.buf, "}");
     obj_setStr(self, "_buf", arg_getStr(context.buf));
     arg_deinit(context.buf);

+ 0 - 2
port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdData_String.c

@@ -241,9 +241,7 @@ PikaObj* PikaStdData_String_split(PikaObj* self, PikaTuple* s_) {
     } else {
         s = pikaTuple_getStr(s_, 0);
     }
-    /* 创建 list 对象 */
     PikaObj* list = newNormalObj(New_PikaStdData_List);
-    /* 初始化 list */
     PikaStdData_List___init__(list);
 
     Args buffs = {0};

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/base64/_base64.c

@@ -1,5 +1,4 @@
 #include "_base64.h"
-
 #include "mbedtls/base64.h"
 
 Arg* _base64_b64decode(PikaObj* self, Arg* s) {

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/json/_pika_cJSON.c

@@ -19,7 +19,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 /* cJSON */
 /* JSON parser in C. */
 

+ 58 - 53
port/linux/package/pikascript/pikascript-lib/json/_pika_cJSON.h

@@ -19,7 +19,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 #ifndef pika_cJSON__h
 #define pika_cJSON__h
 
@@ -34,14 +33,14 @@ extern "C" {
 
 #ifdef __WINDOWS__
 
-/* When compiling for windows, we specify a specific calling convention to avoid
-issues where we are being called from a project with a different default calling
-convention.  For windows you have 3 define options:
+/* When compiling for windows, we specify a specific calling convention to
+avoid issues where we are being called from a project with a different
+default calling convention.  For windows you have 3 define options:
 
-pika_cJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever
-dllexport symbols pika_cJSON_EXPORT_SYMBOLS - Define this on library build when
-you want to dllexport symbols (default) pika_cJSON_IMPORT_SYMBOLS - Define this
-if you want to dllimport symbol
+pika_cJSON_HIDE_SYMBOLS - Define this in the case where you don't want to
+ever dllexport symbols pika_cJSON_EXPORT_SYMBOLS - Define this on library
+build when you want to dllexport symbols (default) pika_cJSON_IMPORT_SYMBOLS
+- Define this if you want to dllimport symbol
 
 For *nix builds that support visibility attribute, you can define similar
 behavior by
@@ -52,8 +51,8 @@ or
 -xldscope=hidden (for sun cc)
 to CFLAGS
 
-then using the pika_cJSON_API_VISIBILITY flag to "export" the same symbols the
-way pika_cJSON_EXPORT_SYMBOLS does
+then using the pika_cJSON_API_VISIBILITY flag to "export" the same symbols
+the way pika_cJSON_EXPORT_SYMBOLS does
 
 */
 
@@ -113,24 +112,26 @@ typedef struct cJSON {
      * GetArraySize/GetArrayItem/GetObjectItem */
     struct cJSON* next;
     struct cJSON* prev;
-    /* An array or object item will have a child pointer pointing to a chain of
-     * the items in the array/object. */
+    /* An array or object item will have a child pointer pointing to a chain
+     * of the items in the array/object. */
     struct cJSON* child;
 
     /* The type of the item, as above. */
     int type;
 
-    /* The item's string, if type==pika_cJSON_String  and type == pika_cJSON_Raw
+    /* The item's string, if type==pika_cJSON_String  and type ==
+     * pika_cJSON_Raw
      */
     char* valuestring;
-    /* writing to valueint is DEPRECATED, use pika_cJSON_SetNumberValue instead
+    /* writing to valueint is DEPRECATED, use pika_cJSON_SetNumberValue
+     * instead
      */
     int valueint;
     /* The item's number, if type==pika_cJSON_Number */
     double valuedouble;
 
-    /* The item's name string, if this item is the child of, or is in the list
-     * of subitems of an object. */
+    /* The item's name string, if this item is the child of, or is in the
+     * list of subitems of an object. */
     char* string;
 } cJSON;
 
@@ -156,13 +157,14 @@ pika_cJSON_PUBLIC(const char*) pika_cJSON_Version(void);
 /* Supply malloc, realloc and free functions to cJSON */
 pika_cJSON_PUBLIC(void) pika_cJSON_InitHooks(pika_cJSON_Hooks* hooks);
 
-/* Memory Management: the caller is always responsible to free the results from
- * all variants of pika_cJSON_Parse (with pika_cJSON_Delete) and
+/* Memory Management: the caller is always responsible to free the results
+ * from all variants of pika_cJSON_Parse (with pika_cJSON_Delete) and
  * pika_cJSON_Print (with stdlib free, pika_cJSON_Hooks.free_fn, or
  * pika_cJSON_free as appropriate). The exception is
- * pika_cJSON_PrintPreallocated, where the caller has full responsibility of the
- * buffer. */
-/* Supply a block of JSON, and this returns a cJSON object you can interrogate.
+ * pika_cJSON_PrintPreallocated, where the caller has full responsibility of
+ * the buffer. */
+/* Supply a block of JSON, and this returns a cJSON object you can
+ * interrogate.
  */
 pika_cJSON_PUBLIC(cJSON*) pika_cJSON_Parse(const char* value);
 pika_cJSON_PUBLIC(cJSON*)
@@ -184,18 +186,19 @@ pika_cJSON_PUBLIC(cJSON*)
 
 /* Render a cJSON entity to text for transfer/storage. */
 pika_cJSON_PUBLIC(char*) pika_cJSON_Print(const cJSON* item);
-/* Render a cJSON entity to text for transfer/storage without any formatting. */
+/* Render a cJSON entity to text for transfer/storage without any
+ * formatting. */
 pika_cJSON_PUBLIC(char*) pika_cJSON_PrintUnformatted(const cJSON* item);
-/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess
- * at the final size. guessing well reduces reallocation. fmt=0 gives
+/* Render a cJSON entity to text using a buffered strategy. prebuffer is a
+ * guess at the final size. guessing well reduces reallocation. fmt=0 gives
  * unformatted, =1 gives formatted */
 pika_cJSON_PUBLIC(char*) pika_cJSON_PrintBuffered(const cJSON* item,
                                                   int prebuffer,
                                                   pika_cJSON_bool fmt);
-/* Render a cJSON entity to text using a buffer already allocated in memory with
- * given length. Returns 1 on success and 0 on failure. */
-/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will
- * use, so to be safe allocate 5 bytes more than you actually need */
+/* Render a cJSON entity to text using a buffer already allocated in memory
+ * with given length. Returns 1 on success and 0 on failure. */
+/* NOTE: cJSON is not always 100% accurate in estimating how much memory it
+ * will use, so to be safe allocate 5 bytes more than you actually need */
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_PrintPreallocated(cJSON* item,
                                  char* buffer,
@@ -219,8 +222,9 @@ pika_cJSON_PUBLIC(cJSON*)
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_HasObjectItem(const cJSON* object, const char* string);
 /* For analysing failed parses. This returns a pointer to the parse error.
- * You'll probably need to look a few chars back to make sense of it. Defined
- * when pika_cJSON_Parse() returns 0. 0 when pika_cJSON_Parse() succeeds. */
+ * You'll probably need to look a few chars back to make sense of it.
+ * Defined when pika_cJSON_Parse() returns 0. 0 when pika_cJSON_Parse()
+ * succeeds. */
 pika_cJSON_PUBLIC(const char*) pika_cJSON_GetErrorPtr(void);
 
 /* Check item type and return its value */
@@ -277,17 +281,17 @@ pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_AddItemToArray(cJSON* array, cJSON* item);
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item);
-/* Use this when string is definitely const (i.e. a literal, or as good as), and
- * will definitely survive the cJSON object. WARNING: When this function was
- * used, make sure to always check that (item->type & pika_cJSON_StringIsConst)
- * is zero before writing to `item->string` */
+/* Use this when string is definitely const (i.e. a literal, or as good as),
+ * and will definitely survive the cJSON object. WARNING: When this function
+ * was used, make sure to always check that (item->type &
+ * pika_cJSON_StringIsConst) is zero before writing to `item->string` */
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_AddItemToObjectCS(cJSON* object,
                                  const char* string,
                                  cJSON* item);
 /* Append reference to item to the specified array/object. Use this when you
- * want to add an existing cJSON to a new cJSON, but don't want to corrupt your
- * existing cJSON. */
+ * want to add an existing cJSON to a new cJSON, but don't want to corrupt
+ * your existing cJSON. */
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
 pika_cJSON_PUBLIC(pika_cJSON_bool)
@@ -335,26 +339,27 @@ pika_cJSON_PUBLIC(pika_cJSON_bool)
 /* Duplicate a cJSON item */
 pika_cJSON_PUBLIC(cJSON*)
     pika_cJSON_Duplicate(const cJSON* item, pika_cJSON_bool recurse);
-/* Duplicate will create a new, identical cJSON item to the one you pass, in new
- * memory that will need to be released. With recurse!=0, it will duplicate any
- * children connected to the item. The item->next and ->prev pointers are always
- * zero on return from Duplicate. */
-/* Recursively compare two cJSON items for equality. If either a or b is NULL or
- * invalid, they will be considered unequal. case_sensitive determines if object
- * keys are treated case sensitive (1) or case insensitive (0) */
+/* Duplicate will create a new, identical cJSON item to the one you pass, in
+ * new memory that will need to be released. With recurse!=0, it will
+ * duplicate any children connected to the item. The item->next and ->prev
+ * pointers are always zero on return from Duplicate. */
+/* Recursively compare two cJSON items for equality. If either a or b is
+ * NULL or invalid, they will be considered unequal. case_sensitive
+ * determines if object keys are treated case sensitive (1) or case
+ * insensitive (0) */
 pika_cJSON_PUBLIC(pika_cJSON_bool)
     pika_cJSON_Compare(const cJSON* const a,
                        const cJSON* const b,
                        const pika_cJSON_bool case_sensitive);
 
-/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from
- * strings. The input pointer json cannot point to a read-only address area,
- * such as a string constant, but should point to a readable and writable
- * address area. */
+/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n')
+ * from strings. The input pointer json cannot point to a read-only address
+ * area, such as a string constant, but should point to a readable and
+ * writable address area. */
 pika_cJSON_PUBLIC(void) pika_cJSON_Minify(char* json);
 
-/* Helper functions for creating and adding items to an object at the same time.
- * They return the added item or NULL on failure. */
+/* Helper functions for creating and adding items to an object at the same
+ * time. They return the added item or NULL on failure. */
 pika_cJSON_PUBLIC(cJSON*)
     pika_cJSON_AddNullToObject(cJSON* const object, const char* const name);
 pika_cJSON_PUBLIC(cJSON*)
@@ -391,8 +396,8 @@ pika_cJSON_PUBLIC(double)
 #define pika_cJSON_SetNumberValue(object, number)                          \
     ((object != NULL) ? pika_cJSON_SetNumberHelper(object, (double)number) \
                       : (number))
-/* Change the valuestring of a pika_cJSON_String object, only takes effect when
- * type of object is pika_cJSON_String */
+/* Change the valuestring of a pika_cJSON_String object, only takes effect
+ * when type of object is pika_cJSON_String */
 pika_cJSON_PUBLIC(char*)
     pika_cJSON_SetValuestring(cJSON* object, const char* valuestring);
 
@@ -401,8 +406,8 @@ pika_cJSON_PUBLIC(char*)
     for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \
          element = element->next)
 
-/* malloc/free objects using the malloc/free functions that have been set with
- * pika_cJSON_InitHooks */
+/* malloc/free objects using the malloc/free functions that have been set
+ * with pika_cJSON_InitHooks */
 pika_cJSON_PUBLIC(void*) pika_cJSON_malloc(size_t size);
 pika_cJSON_PUBLIC(void) pika_cJSON_free(void* object);
 

+ 17 - 16
port/linux/package/pikascript/pikascript-lib/json/jsmn.h

@@ -3,23 +3,23 @@
  *
  * Copyright (c) 2010 Serge Zaitsev
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 #ifndef JSMN_H
 #define JSMN_H
@@ -94,9 +94,8 @@ typedef struct jsmn_parser {
 JSMN_API void jsmn_init(jsmn_parser* parser);
 
 /**
- * Run JSON parser. It parses a JSON data string into and array of tokens, each
- * describing
- * a single JSON object.
+ * Run JSON parser. It parses a JSON data string into and array of tokens,
+ * each describing a single JSON object.
  */
 JSMN_API int jsmn_parse(jsmn_parser* parser,
                         const char* js,
@@ -153,7 +152,8 @@ static int jsmn_parse_primitive(jsmn_parser* parser,
     for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
         switch (js[parser->pos]) {
 #ifndef JSMN_STRICT
-            /* In strict mode primitive must be followed by "," or "}" or "]" */
+            /* In strict mode primitive must be followed by "," or "}" or
+             * "]" */
             case ':':
 #endif
             case '\t':
@@ -310,7 +310,8 @@ JSMN_API int jsmn_parse(jsmn_parser* parser,
                 if (parser->toksuper != -1) {
                     jsmntok_t* t = &tokens[parser->toksuper];
 #ifdef JSMN_STRICT
-                    /* In strict mode an object or array can't become a key */
+                    /* In strict mode an object or array can't become a key
+                     */
                     if (t->type == JSMN_OBJECT) {
                         return JSMN_ERROR_INVAL;
                     }

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/math/_math.c

@@ -3,7 +3,6 @@
 
 #define PI (3.141592653589793115997963468544185161590576171875l)
 #define E (2.718281828459045090795598298427648842334747314453125l)
-//初始化,填入π和e的值
 void _math___init__(PikaObj* self) {
     obj_setFloat(self, "pi", PI);
     obj_setFloat(self, "e", E);

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus.c

@@ -38,7 +38,6 @@
  * All rights reserved.</center></h2>
  *
  */
-
 #include "agile_modbus.h"
 #include <string.h>
 

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus.h

@@ -10,7 +10,6 @@
  * All rights reserved.</center></h2>
  *
  */
-
 #ifndef __PKG_AGILE_MODBUS_H
 #define __PKG_AGILE_MODBUS_H
 

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_rtu.h

@@ -10,7 +10,6 @@
  * All rights reserved.</center></h2>
  *
  */
-
 #ifndef __PKG_AGILE_MODBUS_RTU_H
 #define __PKG_AGILE_MODBUS_RTU_H
 

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_tcp.c

@@ -10,7 +10,6 @@
  * All rights reserved.</center></h2>
  *
  */
-
 #include "agile_modbus.h"
 #include "agile_modbus_tcp.h"
 

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/modbus/agile_modbus_tcp.h

@@ -10,7 +10,6 @@
  * All rights reserved.</center></h2>
  *
  */
-
 #ifndef __PKG_AGILE_MODBUS_TCP_H
 #define __PKG_AGILE_MODBUS_TCP_H
 

+ 4 - 4
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnect.h

@@ -11,10 +11,10 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Ian Craggs - add connack return code definitions
- *    Xiang Rong - 442039 Add makefile to Embedded C client
- *    Ian Craggs - fix for issue #64, bit order in connack response
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Ian Craggs - add connack return code definitions Xiang Rong -
+ *442039 Add makefile to Embedded C client Ian Craggs - fix for issue #64,
+ *bit order in connack response
  *******************************************************************************/
 
 #ifndef MQTTCONNECT_H_

+ 6 - 6
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnectClient.c

@@ -11,20 +11,20 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
 #include <string.h>
 
 /**
- * Determines the length of the MQTT connect packet that would be produced using
- * the supplied connect options.
+ * Determines the length of the MQTT connect packet that would be produced
+ * using the supplied connect options.
  * @param options the options to be used to build the connect packet
- * @return the length of buffer needed to contain the serialized version of the
- * packet
+ * @return the length of buffer needed to contain the serialized version of
+ * the packet
  */
 int MQTTSerialize_connectLength(MQTTPacket_connectData* options) {
     int len = 0;

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTConnectServer.c

@@ -11,9 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include <string.h>
 #include "MQTTPacket.h"
 #include "StackTrace.h"

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTDeserializePublish.c

@@ -11,9 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include <string.h>
 #include "MQTTPacket.h"
 #include "StackTrace.h"

+ 2 - 1
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTFormat.c

@@ -11,7 +11,8 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
 
 #include "MQTTPacket.h"

+ 2 - 1
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTFormat.h

@@ -11,7 +11,8 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
 
 #if !defined(MQTTFORMAT_H)

+ 3 - 4
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPacket.c

@@ -11,11 +11,10 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Sergio R. Caprile - non-blocking packet read functions for stream
- *transport
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Sergio R. Caprile - non-blocking packet read functions for
+ *stream transport
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 

+ 2 - 3
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPacket.h

@@ -11,10 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Xiang Rong - 442039 Add makefile to Embedded C client
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Xiang Rong - 442039 Add makefile to Embedded C client
  *******************************************************************************/
-
 #ifndef MQTTPACKET_H_
 #define MQTTPACKET_H_
 

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTPublish.h

@@ -11,8 +11,8 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Xiang Rong - 442039 Add makefile to Embedded C client
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Xiang Rong - 442039 Add makefile to Embedded C client
  *******************************************************************************/
 
 #ifndef MQTTPUBLISH_H_

+ 7 - 7
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSerializePublish.c

@@ -11,23 +11,23 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Ian Craggs - fix for
+ *https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
 #include <string.h>
 
 /**
- * Determines the length of the MQTT publish packet that would be produced using
- * the supplied parameters
+ * Determines the length of the MQTT publish packet that would be produced
+ * using the supplied parameters
  * @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0)
  * @param topicName the topic name to be used in the publish
  * @param payloadlen the length of the payload to be sent
- * @return the length of buffer needed to contain the serialized version of the
- * packet
+ * @return the length of buffer needed to contain the serialized version of
+ * the packet
  */
 int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen) {
     int len = 0;

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribe.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-09 20:15:32
  * @LastEditTime: 2019-12-20 20:37:31
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 /*******************************************************************************
  * Copyright (c) 2014 IBM Corp.

+ 4 - 4
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribeClient.c

@@ -11,9 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
@@ -25,8 +25,8 @@
  * @param count the number of topic filter strings in topicFilters
  * @param topicFilters the array of topic filter strings to be used in the
  * publish
- * @return the length of buffer needed to contain the serialized version of the
- * packet
+ * @return the length of buffer needed to contain the serialized version of
+ * the packet
  */
 int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[]) {
     int i;

+ 6 - 5
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTSubscribeServer.c

@@ -11,9 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
@@ -23,9 +23,10 @@
  * Deserializes the supplied (wire) buffer into subscribe data
  * @param dup integer returned - the MQTT dup flag
  * @param packetid integer returned - the MQTT packet identifier
- * @param maxcount - the maximum number of members allowed in the topicFilters
- * and requestedQoSs arrays
- * @param count - number of members in the topicFilters and requestedQoSs arrays
+ * @param maxcount - the maximum number of members allowed in the
+ * topicFilters and requestedQoSs arrays
+ * @param count - number of members in the topicFilters and requestedQoSs
+ * arrays
  * @param topicFilters - array of topic filter names
  * @param requestedQoSs - array of requested QoS
  * @param buf the raw buffer data, of the correct length determined by the

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribe.h

@@ -11,8 +11,8 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Xiang Rong - 442039 Add makefile to Embedded C client
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Xiang Rong - 442039 Add makefile to Embedded C client
  *******************************************************************************/
 
 #ifndef MQTTUNSUBSCRIBE_H_

+ 6 - 6
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribeClient.c

@@ -11,22 +11,22 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
 #include <string.h>
 
 /**
- * Determines the length of the MQTT unsubscribe packet that would be produced
- * using the supplied parameters
+ * Determines the length of the MQTT unsubscribe packet that would be
+ * produced using the supplied parameters
  * @param count the number of topic filter strings in topicFilters
  * @param topicFilters the array of topic filter strings to be used in the
  * publish
- * @return the length of buffer needed to contain the serialized version of the
- * packet
+ * @return the length of buffer needed to contain the serialized version of
+ * the packet
  */
 int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[]) {
     int i;

+ 6 - 5
port/linux/package/pikascript/pikascript-lib/mqtt/MQTTUnsubscribeServer.c

@@ -11,9 +11,9 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation
  *******************************************************************************/
-
 #include "MQTTPacket.h"
 #include "StackTrace.h"
 
@@ -23,9 +23,10 @@
  * Deserializes the supplied (wire) buffer into unsubscribe data
  * @param dup integer returned - the MQTT dup flag
  * @param packetid integer returned - the MQTT packet identifier
- * @param maxcount - the maximum number of members allowed in the topicFilters
- * and requestedQoSs arrays
- * @param count - number of members in the topicFilters and requestedQoSs arrays
+ * @param maxcount - the maximum number of members allowed in the
+ * topicFilters and requestedQoSs arrays
+ * @param count - number of members in the topicFilters and requestedQoSs
+ * arrays
  * @param topicFilters - array of topic filter names
  * @param buf the raw buffer data, of the correct length determined by the
  * remaining length field

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/StackTrace.h

@@ -11,8 +11,8 @@
  *   http://www.eclipse.org/org/documents/edl-v10.php.
  *
  * Contributors:
- *    Ian Craggs - initial API and implementation and/or initial documentation
- *    Ian Craggs - fix for bug #434081
+ *    Ian Craggs - initial API and implementation and/or initial
+ *documentation Ian Craggs - fix for bug #434081
  *******************************************************************************/
 
 #ifndef STACKTRACE_H_

+ 7 - 152
port/linux/package/pikascript/pikascript-lib/mqtt/_mqtt__MQTT.c

@@ -14,12 +14,6 @@ void Subscribe_Handler(void* client, message_data_t* msg);
 
 const uint32_t MQTT_RECONNECTION_EVENT_ID = 0xFFAA0088;
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT___init__
-// 功能说明:对象初始化
-// 输入参数:
-// 返 回 值:无
-///////////////////////////////////////////////////////////////////
 void _mqtt__MQTT___init__(PikaObj* self,
                           char* ip,
                           int port,
@@ -92,17 +86,10 @@ void _mqtt__MQTT___init__(PikaObj* self,
 
     mqtt_set_clean_session(_client, 1);
 
-    obj_setPtr(self, "_client",
-               _client);  // 这里要再保存一次mqtt结构体的内容到python环境
+    obj_setPtr(self, "_client", _client);
     // __platform_printf("Mqtt_Lib buildtime:%s-%s\r\n", __DATE__, __TIME__);
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT___del__
-// 功能说明:释放对象资源
-// 输入参数:
-// 返 回 值:无
-///////////////////////////////////////////////////////////////////
 void _mqtt__MQTT___del__(PikaObj* self) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     if (NULL == _client) {
@@ -117,12 +104,6 @@ void _mqtt__MQTT___del__(PikaObj* self) {
     mqtt_release_free(_client);
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_connect
-// 功能说明:连接mqtt的服务端
-// 输入参数:无
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_connect(PikaObj* self) {
     int ret;
     obj_setInt(self, "_connected", 1);
@@ -137,12 +118,6 @@ int _mqtt__MQTT_connect(PikaObj* self) {
     return ret;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_disconnect
-// 功能说明:断开 mqtt的连接
-// 输入参数:无
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_disconnect(PikaObj* self) {
     int ret;
     obj_setInt(self, "_connected", 0);
@@ -157,12 +132,6 @@ int _mqtt__MQTT_disconnect(PikaObj* self) {
     return ret;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_listSubscribeTopic
-// 功能说明:罗列出当前订阅的主题
-// 输入参数:无
-// 返 回 值:对象指针
-///////////////////////////////////////////////////////////////////
 PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     // int i = 0;
@@ -180,9 +149,7 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
         return NULL;
     }
 
-    /* 创建 list 对象 */
     list = newNormalObj(New_PikaStdData_List);
-    /* 初始化 list */
     PikaStdData_List___init__(list);
 
     LIST_FOR_EACH_SAFE(curr, next, &_client->mqtt_msg_handler_list) {
@@ -194,9 +161,7 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
                        __LINE__, __FUNCTION__, ++i, msg_handler->topic_filter);
             // __platform_printf("[%d]subscribe topic: %s\n",++i,
             // msg_handler->topic_filter);
-            /* 用 arg_new<type> 的 api 创建 arg */
             Arg* str_arg1 = arg_newStr((char*)msg_handler->topic_filter);
-            /* 添加到 list 对象 */
             PikaStdData_List_append(list, str_arg1);
             arg_deinit(str_arg1);
         }
@@ -204,12 +169,6 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
     return list;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_publish
-// 功能说明:发布主题消息
-// 输入参数:主题名称,有效数据
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
     int ret;
     mqtt_message_t msg;
@@ -233,8 +192,7 @@ int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
 
     msg.payload = (void*)payload;
     msg.qos = qos;
-    __platform_printf("msg.qos:%d\r\n",
-                      msg.qos);  // 这里为了防止被优化,导致运行异常
+    __platform_printf("msg.qos:%d\r\n", msg.qos);
     ret = mqtt_publish(_client, topic, &msg);
     if (ret == 0) {
         // __platform_printf("MQTT_publish OK\r\n");
@@ -243,12 +201,6 @@ int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
     return ret;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setCa
-// 功能说明:设置ca值
-// 输入参数:ca值
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setCa(PikaObj* self, char* ca) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
@@ -268,12 +220,6 @@ int _mqtt__MQTT_setCa(PikaObj* self, char* ca) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setClientID
-// 功能说明:设置mqtt客户端的id
-// 输入参数:id 字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setClientID(PikaObj* self, char* id) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
@@ -293,12 +239,6 @@ int _mqtt__MQTT_setClientID(PikaObj* self, char* id) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setHost
-// 功能说明:设置mqtt客户端,连接主机的ip或者url
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
@@ -311,23 +251,13 @@ int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) {
         return -2;
     }
 
-    obj_setStr(self, "host_str",
-               host_url);  // python 环境创建一个全局变量存放 host
-    mqtt_set_host(
-        _client,
-        obj_getStr(self,
-                   "host_str"));  // 从python环境中取出 host的指针 赋值给结构体
+    obj_setStr(self, "host_str", host_url);
+    mqtt_set_host(_client, obj_getStr(self, "host_str"));
     // __platform_printf("MQTT_setHost :%s\r\n", host_url);
 
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setKeepAlive
-// 功能说明:设置mqtt客户端的 心跳包发送间隔
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setKeepAlive(PikaObj* self, int time) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     int tmp;
@@ -345,12 +275,6 @@ int _mqtt__MQTT_setKeepAlive(PikaObj* self, int time) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setPassword
-// 功能说明:设置mqtt客户端的 密码
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
@@ -370,12 +294,6 @@ int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setPort
-// 功能说明:设置mqtt客户端,连接主机的端口号
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setPort(PikaObj* self, int port) {
     char port_str[10] = {0};
     mqtt_client_t* _client = obj_getPtr(self, "_client");
@@ -394,12 +312,6 @@ int _mqtt__MQTT_setPort(PikaObj* self, int port) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setUsername
-// 功能说明:设置mqtt客户端的用户名
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setUsername(PikaObj* self, char* name) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
@@ -419,12 +331,6 @@ int _mqtt__MQTT_setUsername(PikaObj* self, char* name) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setVersion
-// 功能说明:设置mqtt 协议版本
-// 输入参数:字符串格式
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setVersion(PikaObj* self, char* version) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     // int tmp;
@@ -447,12 +353,6 @@ int _mqtt__MQTT_setVersion(PikaObj* self, char* version) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setWill
-// 功能说明:设置遗嘱消息,异常断连时会发送这个消息
-// 输入参数:
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setWill(PikaObj* self,
                         char* topic,
                         char* payload,
@@ -488,7 +388,6 @@ int _mqtt__MQTT_setWill(PikaObj* self,
         return -1;
     }
 
-    // 必须转换成python环境的变量,否则函数退出后,topic里的是个空指针
     memset(topic_str, 0, sizeof(topic_str));
     sprintf(topic_str, "%s", topic);
     obj_setStr(self, topic_str, topic);
@@ -513,12 +412,6 @@ int _mqtt__MQTT_setWill(PikaObj* self,
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_subscribe
-// 功能说明:设置mqtt 订阅主题
-// 输入参数:
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     int ret;
@@ -541,7 +434,6 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
         return -3;
     }
 
-    // 必须转换成python环境的变量,否则函数退出后,topic里的是个空指针
     memset(topic_str, 0, sizeof(topic_str));
     sprintf(topic_str, "%s", topic);
     obj_setStr(self, topic_str, topic);
@@ -551,13 +443,11 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
     if (ret == 0) {
         // __platform_printf("MQTT_subscribe Topic :%s Qos:%d OK\r\n",
         // topic,qos);
-        // 注册mqtt订阅主题的 回调函数
         if (cb != NULL) {
             char hash_str[32] = {0};
             memset(hash_str, 0, sizeof(hash_str));
             sprintf(hash_str, "C%d", hash_time33(topic_str));
-            obj_newDirectObj(self, hash_str,
-                             New_TinyObj);  // 新建一个对象来放CB
+            obj_newDirectObj(self, hash_str, New_TinyObj);
             PikaObj* eventHandler = obj_getPtr(self, hash_str);
             obj_setArg(eventHandler, "eventCallBack", cb);
             /* init event_listener for the first time */
@@ -577,12 +467,6 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
     return ret;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_unsubscribe
-// 功能说明:取消mqtt 订阅主题
-// 输入参数:
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
     int ret;
@@ -601,12 +485,6 @@ int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) {
     return 0;
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:Subscribe_Handler
-// 功能说明:mqtt 订阅主题 的回调函数
-// 输入参数:
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 void Subscribe_Handler(void* client, message_data_t* msg) {
     char topic_str[MQTT_TOPIC_LEN_MAX + 24];
 
@@ -624,7 +502,6 @@ void Subscribe_Handler(void* client, message_data_t* msg) {
     obj_setStr(evt_obj, "msg", (char*)msg->message->payload);
     obj_setInt(evt_obj, "qos", msg->message->qos);
 
-    // 存好数据后,再发送事件信号,防止信号收到了但是需要传输的数据没准备好
     pika_eventListener_send(g_mqtt_event_listener, hash_time33(msg->topic_name),
                             evt_obj_arg);
 
@@ -646,59 +523,37 @@ void _mqtt__MQTT__fakeMsg(PikaObj* self, char* topic, int qos, char* msg) {
     Subscribe_Handler(NULL, &msg_data);
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt___del__
-// 功能说明:释放事件处理器
-// 输入参数:
-// 返 回 值:
-///////////////////////////////////////////////////////////////////
 void _mqtt___del__(PikaObj* self) {
     if (NULL != g_mqtt_event_listener) {
         pika_eventListener_deinit(&g_mqtt_event_listener);
     }
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:Reconnect_Handler
-// 功能说明:mqtt 断开连接后
-// 的回调函数,这里使用mqttclient库函数的,断线重连接口,提示发生了mqtt断连的事件
-// 输入参数:
-// 返 回 值:0=成功;非0=错误码
-///////////////////////////////////////////////////////////////////
 void Reconnect_Handler(void* client, void* reconnect_date) {
     // PikaObj* self = ((mqtt_client_t*)client)->user_data;
     // __platform_printf("Reconnect_Handler\r\n");
 
     if (((mqtt_client_t*)client)->mqtt_client_state != CLIENT_STATE_CONNECTED) {
-        // 发送事件信号
         pika_eventListener_sendSignal(g_mqtt_event_listener,
                                       MQTT_RECONNECTION_EVENT_ID, 1);
     }
 }
 
-////////////////////////////////////////////////////////////////////
-// 函 数 名:_mqtt__MQTT_setDisconnectHandler
-// 功能说明:设置断开连接的回调函数
-// 输入参数:
-// 返 回 值:
-///////////////////////////////////////////////////////////////////
 int _mqtt__MQTT_setDisconnectHandler(PikaObj* self, Arg* cb) {
     mqtt_client_t* _client = obj_getPtr(self, "_client");
 
     // __platform_printf("_mqtt__MQTT_setDisconnectHandler\r\n");
 
-    // 注册到c库中
     mqtt_set_reconnect_handler(_client, Reconnect_Handler);
 
     // char hash_str[32] = {0};
     // memset(hash_str,0,sizeof(hash_str));
     // sprintf(hash_str,"C%d",hash_time33(topic_str));
-    // obj_newDirectObj(self,hash_str,New_TinyObj);//新建一个对象来放CB
+    // obj_newDirectObj(self,hash_str,New_TinyObj);
     // PikaObj* eventHandler = obj_getPtr(self,hash_str);
     // obj_setArg(eventHandler, "eventCallBack", cb);
 
-    obj_setArg(self, "eventCallBack",
-               cb);  // 重连回调是唯一的,就直接用self对象
+    obj_setArg(self, "eventCallBack", cb);
     /* init event_listener for the first time */
     if (NULL == g_mqtt_event_listener) {
         pika_eventListener_init(&g_mqtt_event_listener);

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_config.h

@@ -2,8 +2,8 @@
  * @Author: jiejie
  * @Github: https://github.com/jiejieTop
  * @LastEditTime: 2020-06-17 19:31:41
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _MQTT_CONFIG_H_
 #define _MQTT_CONFIG_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_error.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-15 00:42:16
  * @LastEditTime: 2020-10-17 14:16:15
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _MQTT_ERROR_H_
 #define _MQTT_ERROR_H_

+ 2 - 3
port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_list.c

@@ -3,10 +3,9 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-11 22:46:33
  * @LastEditTime: 2020-04-27 23:28:12
- * @Description: the following code references TencentOS tiny, please keep the
- * author information and source code according to the license.
+ * @Description: the following code references TencentOS tiny, please keep
+ * the author information and source code according to the license.
  */
-
 #include "mqtt_list.h"
 
 static void _mqtt_list_add(mqtt_list_t* node,

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_list.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-11 22:47:55
  * @LastEditTime: 2020-10-17 14:18:02
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _MQTT_LIST_H_
 #define _MQTT_LIST_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/mqtt_log.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-27 03:25:58
  * @LastEditTime: 2020-10-17 14:15:55
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _MQTT_LOG_H_
 #define _MQTT_LOG_H_

+ 3 - 3
port/linux/package/pikascript/pikascript-lib/mqtt/mqttclient.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-09 21:31:25
  * @LastEditTime : 2022-06-12 17:39:43
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "mqttclient.h"
 
@@ -1172,7 +1172,7 @@ static uint32_t mqtt_read_buf_malloc(mqtt_client_t* c, uint32_t size) {
                    __LINE__, __FUNCTION__);
         RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
     }
-    memset(c->mqtt_read_buf, 0, c->mqtt_read_buf_size);  // 清空申请的内存
+    memset(c->mqtt_read_buf, 0, c->mqtt_read_buf_size);
     return c->mqtt_read_buf_size;
 }
 

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/mqttclient.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-09 21:31:25
  * @LastEditTime : 2022-06-11 22:45:02
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _MQTTCLIENT_H_
 #define _MQTTCLIENT_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tcp.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-15 13:38:52
  * @LastEditTime: 2020-05-25 10:13:41
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "nettype_tcp.h"
 #include "mqtt_log.h"

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tcp.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-15 13:39:00
  * @LastEditTime: 2020-10-17 14:17:10
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _NETTYPE_TCP_H_
 #define _NETTYPE_TCP_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/nettype_tls.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2020-01-11 19:45:35
  * @LastEditTime: 2020-09-20 14:29:06
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "nettype_tls.h"
 #include "platform_memory.h"

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/network.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-09 21:30:54
  * @LastEditTime: 2020-06-05 17:17:48
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include <string.h>
 #include "nettype_tcp.h"

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/network.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-09 21:31:02
  * @LastEditTime: 2020-10-17 14:14:41
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _NETWORK_H_
 #define _NETWORK_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/platform_memory.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-14 22:02:07
  * @LastEditTime: 2020-02-19 20:26:04
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "platform_memory.h"
 

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/platform_memory.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-14 22:06:35
  * @LastEditTime: 2020-10-17 14:17:24
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _PLATFORM_MEMORY_H_
 #define _PLATFORM_MEMORY_H_

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/platform_net_socket.c

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2020-01-10 23:45:59
  * @LastEditTime: 2020-06-05 17:13:00
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "platform_net_socket.h"
 #include "mqtt_error.h"

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/mqtt/platform_net_socket.h

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-15 13:39:00
  * @LastEditTime: 2020-10-17 14:17:45
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #ifndef _PLATFORM_NET_SOCKET_H_
 #define _PLATFORM_NET_SOCKET_H_

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/mqtt/random.h

@@ -8,7 +8,6 @@
  * Copyright (c) 2022 jiejie, All Rights Reserved. Please keep the author
  * information and source code according to the license.
  */
-
 #ifndef _RANDOM_H_
 #define _RANDOM_H_
 

+ 2 - 26
port/linux/package/pikascript/pikascript-lib/os/os_path.c

@@ -20,49 +20,41 @@
 
 #define IS_PATH_SEP(ch) ((ch) == '/' || (ch) == '\\')
 
-// 返回指定路径的绝对路径
 char* os_path_abspath(PikaObj* self, char* path) {
     char* abs_path = NULL;
 
 #ifdef _WIN32
     DWORD size = GetFullPathNameA(path, 0, NULL, NULL);
     if (size == 0) {
-        // 获取绝对路径失败
         return NULL;
     }
 
     abs_path = (char*)malloc(size * sizeof(char));
     if (abs_path == NULL) {
-        // 内存分配失败
         return NULL;
     }
 
     DWORD ret_size = GetFullPathNameA(path, size, abs_path, NULL);
     if (ret_size == 0 || ret_size > size) {
-        // 获取绝对路径失败
         free(abs_path);
         return NULL;
     }
 #else
     char* cwd = getcwd(NULL, 0);
     if (cwd == NULL) {
-        // 获取当前工作目录失败
         return NULL;
     }
 
     abs_path = realpath(path, NULL);
     if (abs_path == NULL) {
-        // 获取绝对路径失败
         free(cwd);
         return NULL;
     }
 
-    // 如果路径不是绝对路径,则将其转换为绝对路径
     if (abs_path[0] != '/') {
         char* temp_path =
             (char*)malloc((strlen(cwd) + strlen(abs_path) + 2) * sizeof(char));
         if (temp_path == NULL) {
-            // 内存分配失败
             free(cwd);
             free(abs_path);
             return NULL;
@@ -83,12 +75,10 @@ char* os_path_abspath(PikaObj* self, char* path) {
     return res;
 }
 
-// 判断指定路径是否存在
 PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
 #ifdef _WIN32
     DWORD attr = GetFileAttributesA(path);
     if (attr == INVALID_FILE_ATTRIBUTES) {
-        // 获取文件属性失败
         return PIKA_FALSE;
     }
 
@@ -96,7 +86,6 @@ PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
 #else
     struct stat statbuf;
     if (stat(path, &statbuf) == -1) {
-        // 获取文件状态失败
         return PIKA_FALSE;
     }
 
@@ -104,7 +93,6 @@ PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
 #endif
 }
 
-// 判断指定路径是否为绝对路径
 PIKA_BOOL os_path_isabs(PikaObj* self, char* path) {
 #ifdef _WIN32
     if (path[0] == '\\' || path[0] == '/') {
@@ -231,16 +219,13 @@ int _os_path_split(char* path, char** folder, char** file) {
     }
     char* p = strrchr(path, PATH_SEPARATOR);
     if (p) {
-        /* 字符串最后一个路径分隔符的位置 */
         size_t idx = p - path;
-        /* 获取最后一个路径分隔符之前的路径 */
         *folder = pika_platform_malloc(idx + 2);
         if (*folder == NULL) {
             return -1;
         }
         strncpy(*folder, path, idx + 1);
         (*folder)[idx] = '\0';
-        /* 获取最后一个路径分隔符之后的文件名 */
         *file = strdup(p + 1);
         if (*file == NULL) {
             pika_platform_free(*folder);
@@ -249,7 +234,6 @@ int _os_path_split(char* path, char** folder, char** file) {
         }
         return 0;
     } else {
-        /* 如果路径没有分隔符,则返回路径本身和空字符串 */
         *folder = strdup(path);
         if (*folder == NULL) {
             return -1;
@@ -267,35 +251,27 @@ int _os_path_split(char* path, char** folder, char** file) {
 int _os_path_splitext(char* path, char** file, char** ext) {
     char* p = strrchr(path, '.');
     if (p) {
-        /* 字符串最后一个点的位置 */
         size_t idx = p - path;
-        /* 获取点之前的路径 */
         *file = malloc(idx + 1);
         if (!(*file)) {
-            /* 内存分配失败 */
             return -1;
         }
         strncpy(*file, path, idx);
         (*file)[idx] = '\0';
-        /* 获取点之后的扩展名 */
         *ext = strdup(p);
         if (!(*ext)) {
-            /* 内存分配失败 */
             pika_platform_free(*file);
             *file = NULL;
             return -1;
         }
         return 0;
     } else {
-        /* 如果没有扩展名,则返回路径本身和空字符串 */
         *file = strdup(path);
         if (!(*file)) {
-            /* 内存分配失败 */
             return -1;
         }
         *ext = strdup("");
         if (!(*ext)) {
-            /* 内存分配失败 */
             free(*file);
             *file = NULL;
             return -1;
@@ -310,7 +286,7 @@ PikaObj* os_path_split(PikaObj* self, char* path) {
     PikaObj* tuple = NULL;
 
     if (0 != _os_path_split(path, &folder, &file)) {
-        goto __exit;  // 发生错误,跳转到 __exit 处做资源回收
+        goto __exit;
     }
 
     tuple = objTuple_new(arg_newStr(folder), arg_newStr(file));
@@ -339,7 +315,7 @@ PikaObj* os_path_splitext(PikaObj* self, char* path) {
     Arg* aExt = NULL;
 
     if (0 != _os_path_splitext(path, &file, &ext)) {
-        goto __exit;  // 发生错误,跳转到 __exit 处做资源回收
+        goto __exit;
     }
 
     tuple = newNormalObj(New_PikaStdData_Tuple);

+ 0 - 2
port/linux/package/pikascript/pikascript-lib/os/os_platform.c

@@ -58,7 +58,6 @@ char* os_read_platform(PikaObj* self, PikaObj* fd, int len) {
         size = fread(buf, 1, len, fp);
 
         if (size > 0) {
-            //转换成
             obj_setStr(self, "os_file_read", buf);
             free(buf);
             return obj_getStr(self, "os_file_read");
@@ -122,7 +121,6 @@ PikaObj* os_listdir_platform(char* path) {
     PikaStdData_List___init__(list);
 
     handle = _findfirst(dirpath, &fb);
-    //找到第一个匹配的文件
     if (handle != -1L) {
         if (memcmp(fb.name, ".", 1) != 0) {
             Arg* arg = arg_setStr(NULL, "", fb.name);

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/pika_cjson/cJSON.c

@@ -19,7 +19,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 /* cJSON */
 /* JSON parser in C. */
 

+ 59 - 54
port/linux/package/pikascript/pikascript-lib/pika_cjson/cJSON.h

@@ -19,7 +19,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 #ifndef cJSON__h
 #define cJSON__h
 
@@ -34,14 +33,14 @@ extern "C" {
 
 #ifdef __WINDOWS__
 
-/* When compiling for windows, we specify a specific calling convention to avoid
-issues where we are being called from a project with a different default calling
-convention.  For windows you have 3 define options:
+/* When compiling for windows, we specify a specific calling convention to
+avoid issues where we are being called from a project with a different
+default calling convention.  For windows you have 3 define options:
 
 CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever
-dllexport symbols CJSON_EXPORT_SYMBOLS - Define this on library build when you
-want to dllexport symbols (default) CJSON_IMPORT_SYMBOLS - Define this if you
-want to dllimport symbol
+dllexport symbols CJSON_EXPORT_SYMBOLS - Define this on library build when
+you want to dllexport symbols (default) CJSON_IMPORT_SYMBOLS - Define this
+if you want to dllimport symbol
 
 For *nix builds that support visibility attribute, you can define similar
 behavior by
@@ -52,8 +51,8 @@ or
 -xldscope=hidden (for sun cc)
 to CFLAGS
 
-then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way
-CJSON_EXPORT_SYMBOLS does
+then using the CJSON_API_VISIBILITY flag to "export" the same symbols the
+way CJSON_EXPORT_SYMBOLS does
 
 */
 
@@ -113,8 +112,8 @@ typedef struct cJSON {
      * GetArraySize/GetArrayItem/GetObjectItem */
     struct cJSON* next;
     struct cJSON* prev;
-    /* An array or object item will have a child pointer pointing to a chain of
-     * the items in the array/object. */
+    /* An array or object item will have a child pointer pointing to a chain
+     * of the items in the array/object. */
     struct cJSON* child;
 
     /* The type of the item, as above. */
@@ -122,13 +121,14 @@ typedef struct cJSON {
 
     /* The item's string, if type==cJSON_String  and type == cJSON_Raw */
     char* valuestring;
-    /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
+    /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead
+     */
     int valueint;
     /* The item's number, if type==cJSON_Number */
     double valuedouble;
 
-    /* The item's name string, if this item is the child of, or is in the list
-     * of subitems of an object. */
+    /* The item's name string, if this item is the child of, or is in the
+     * list of subitems of an object. */
     char* string;
 } cJSON;
 
@@ -154,12 +154,13 @@ CJSON_PUBLIC(const char*) cJSON_Version(void);
 /* Supply malloc, realloc and free functions to cJSON */
 CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
 
-/* Memory Management: the caller is always responsible to free the results from
- * all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib
- * free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is
- * cJSON_PrintPreallocated, where the caller has full responsibility of the
- * buffer. */
-/* Supply a block of JSON, and this returns a cJSON object you can interrogate.
+/* Memory Management: the caller is always responsible to free the results
+ * from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print
+ * (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate).
+ * The exception is cJSON_PrintPreallocated, where the caller has full
+ * responsibility of the buffer. */
+/* Supply a block of JSON, and this returns a cJSON object you can
+ * interrogate.
  */
 CJSON_PUBLIC(cJSON*) cJSON_Parse(const char* value);
 CJSON_PUBLIC(cJSON*)
@@ -181,17 +182,18 @@ cJSON_ParseWithLengthOpts(const char* value,
 
 /* Render a cJSON entity to text for transfer/storage. */
 CJSON_PUBLIC(char*) cJSON_Print(const cJSON* item);
-/* Render a cJSON entity to text for transfer/storage without any formatting. */
+/* Render a cJSON entity to text for transfer/storage without any
+ * formatting. */
 CJSON_PUBLIC(char*) cJSON_PrintUnformatted(const cJSON* item);
-/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess
- * at the final size. guessing well reduces reallocation. fmt=0 gives
+/* Render a cJSON entity to text using a buffered strategy. prebuffer is a
+ * guess at the final size. guessing well reduces reallocation. fmt=0 gives
  * unformatted, =1 gives formatted */
 CJSON_PUBLIC(char*)
 cJSON_PrintBuffered(const cJSON* item, int prebuffer, cJSON_bool fmt);
-/* Render a cJSON entity to text using a buffer already allocated in memory with
- * given length. Returns 1 on success and 0 on failure. */
-/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will
- * use, so to be safe allocate 5 bytes more than you actually need */
+/* Render a cJSON entity to text using a buffer already allocated in memory
+ * with given length. Returns 1 on success and 0 on failure. */
+/* NOTE: cJSON is not always 100% accurate in estimating how much memory it
+ * will use, so to be safe allocate 5 bytes more than you actually need */
 CJSON_PUBLIC(cJSON_bool)
 cJSON_PrintPreallocated(cJSON* item,
                         char* buffer,
@@ -214,8 +216,8 @@ cJSON_GetObjectItemCaseSensitive(const cJSON* const object,
 CJSON_PUBLIC(cJSON_bool)
 cJSON_HasObjectItem(const cJSON* object, const char* string);
 /* For analysing failed parses. This returns a pointer to the parse error.
- * You'll probably need to look a few chars back to make sense of it. Defined
- * when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
+ * You'll probably need to look a few chars back to make sense of it.
+ * Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
 CJSON_PUBLIC(const char*) cJSON_GetErrorPtr(void);
 
 /* Check item type and return its value */
@@ -258,8 +260,10 @@ CJSON_PUBLIC(cJSON*) cJSON_CreateArrayReference(const cJSON* child);
  * The parameter count cannot be greater than the number of elements in the
  * number array, otherwise array access will be out of bounds.*/
 CJSON_PUBLIC(cJSON*) cJSON_CreateIntArray(const int* numbers, int count);
-CJSON_PUBLIC(cJSON*) cJSON_CreateFloatArray(const double* numbers, int count);
-CJSON_PUBLIC(cJSON*) cJSON_CreateDoubleArray(const double* numbers, int count);
+CJSON_PUBLIC(cJSON*)
+cJSON_CreateFloatArray(const double* numbers, int count);
+CJSON_PUBLIC(cJSON*)
+cJSON_CreateDoubleArray(const double* numbers, int count);
 CJSON_PUBLIC(cJSON*)
 cJSON_CreateStringArray(const char* const* strings, int count);
 
@@ -267,15 +271,15 @@ cJSON_CreateStringArray(const char* const* strings, int count);
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON* array, cJSON* item);
 CJSON_PUBLIC(cJSON_bool)
 cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item);
-/* Use this when string is definitely const (i.e. a literal, or as good as), and
- * will definitely survive the cJSON object. WARNING: When this function was
- * used, make sure to always check that (item->type & cJSON_StringIsConst) is
- * zero before writing to `item->string` */
+/* Use this when string is definitely const (i.e. a literal, or as good as),
+ * and will definitely survive the cJSON object. WARNING: When this function
+ * was used, make sure to always check that (item->type &
+ * cJSON_StringIsConst) is zero before writing to `item->string` */
 CJSON_PUBLIC(cJSON_bool)
 cJSON_AddItemToObjectCS(cJSON* object, const char* string, cJSON* item);
 /* Append reference to item to the specified array/object. Use this when you
- * want to add an existing cJSON to a new cJSON, but don't want to corrupt your
- * existing cJSON. */
+ * want to add an existing cJSON to a new cJSON, but don't want to corrupt
+ * your existing cJSON. */
 CJSON_PUBLIC(cJSON_bool)
 cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
 CJSON_PUBLIC(cJSON_bool)
@@ -316,26 +320,27 @@ cJSON_ReplaceItemInObjectCaseSensitive(cJSON* object,
 
 /* Duplicate a cJSON item */
 CJSON_PUBLIC(cJSON*) cJSON_Duplicate(const cJSON* item, cJSON_bool recurse);
-/* Duplicate will create a new, identical cJSON item to the one you pass, in new
- * memory that will need to be released. With recurse!=0, it will duplicate any
- * children connected to the item. The item->next and ->prev pointers are always
- * zero on return from Duplicate. */
-/* Recursively compare two cJSON items for equality. If either a or b is NULL or
- * invalid, they will be considered unequal. case_sensitive determines if object
- * keys are treated case sensitive (1) or case insensitive (0) */
+/* Duplicate will create a new, identical cJSON item to the one you pass, in
+ * new memory that will need to be released. With recurse!=0, it will
+ * duplicate any children connected to the item. The item->next and ->prev
+ * pointers are always zero on return from Duplicate. */
+/* Recursively compare two cJSON items for equality. If either a or b is
+ * NULL or invalid, they will be considered unequal. case_sensitive
+ * determines if object keys are treated case sensitive (1) or case
+ * insensitive (0) */
 CJSON_PUBLIC(cJSON_bool)
 cJSON_Compare(const cJSON* const a,
               const cJSON* const b,
               const cJSON_bool case_sensitive);
 
-/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from
- * strings. The input pointer json cannot point to a read-only address area,
- * such as a string constant, but should point to a readable and writable
- * address area. */
+/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n')
+ * from strings. The input pointer json cannot point to a read-only address
+ * area, such as a string constant, but should point to a readable and
+ * writable address area. */
 CJSON_PUBLIC(void) cJSON_Minify(char* json);
 
-/* Helper functions for creating and adding items to an object at the same time.
- * They return the added item or NULL on failure. */
+/* Helper functions for creating and adding items to an object at the same
+ * time. They return the added item or NULL on failure. */
 CJSON_PUBLIC(cJSON*)
 cJSON_AddNullToObject(cJSON* const object, const char* const name);
 CJSON_PUBLIC(cJSON*)
@@ -373,8 +378,8 @@ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON* object, double number);
 #define cJSON_SetNumberValue(object, number)                          \
     ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) \
                       : (number))
-/* Change the valuestring of a cJSON_String object, only takes effect when type
- * of object is cJSON_String */
+/* Change the valuestring of a cJSON_String object, only takes effect when
+ * type of object is cJSON_String */
 CJSON_PUBLIC(char*)
 cJSON_SetValuestring(cJSON* object, const char* valuestring);
 
@@ -383,8 +388,8 @@ cJSON_SetValuestring(cJSON* object, const char* valuestring);
     for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \
          element = element->next)
 
-/* malloc/free objects using the malloc/free functions that have been set with
- * cJSON_InitHooks */
+/* malloc/free objects using the malloc/free functions that have been set
+ * with cJSON_InitHooks */
 CJSON_PUBLIC(void*) cJSON_malloc(size_t size);
 CJSON_PUBLIC(void) cJSON_free(void* object);
 

+ 0 - 1270
port/linux/package/pikascript/pikascript-lib/pika_libc/pika_vsnprintf.c

@@ -1,1270 +0,0 @@
-/*
- * Copyright (c) 2021, Meco Jianting Man <jiantingman@foxmail.com>
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- * 2021-11-27     Meco Man     porting for rt_vsnprintf as the fully functional
- * version
- */
-
-/**
- * @author (c) Eyal Rozenberg <eyalroz1@gmx.com>
- *             2021, Haifa, Palestine/Israel
- * @author (c) Marco Paland (info@paland.com)
- *             2014-2019, PALANDesign Hannover, Germany
- *
- * @note Others have made smaller contributions to this file: see the
- * contributors page at https://github.com/eyalroz/printf/graphs/contributors
- * or ask one of the authors.
- *
- * @brief Small stand-alone implementation of the printf family of functions
- * (`(v)printf`, `(v)s(n)printf` etc., geared towards use on embedded systems
- * with a very limited resources.
- *
- * @note the implementations are thread-safe; re-entrant; use no functions from
- * the standard library; and do not dynamically allocate any memory.
- *
- * @license The MIT License (MIT)
- *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include "PikaObj.h"
-#include "pika_adapter_rtt.h"
-
-#if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 12, 0)
-#error "pika_vsnprintf.c requires at least PikaScript 1.12.0"
-#endif
-
-// 'ntoa' conversion buffer size, this must be big enough to hold one converted
-// numeric number including padded zeros (dynamically created on stack)
-#ifndef PRINTF_INTEGER_BUFFER_SIZE
-#define PRINTF_INTEGER_BUFFER_SIZE 32
-#endif
-
-// 'ftoa' conversion buffer size, this must be big enough to hold one converted
-// float number including padded zeros (dynamically created on stack)
-#ifndef PRINTF_FTOA_BUFFER_SIZE
-#define PRINTF_FTOA_BUFFER_SIZE 32
-#endif
-
-// Support for the decimal notation floating point conversion specifiers (%f,
-// %F)
-#ifndef PRINTF_SUPPORT_DECIMAL_SPECIFIERS
-#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 1
-#endif
-
-// Support for the exponential notatin floating point conversion specifiers (%e,
-// %g, %E, %G)
-#ifndef PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 1
-#endif
-
-// Default precision for the floating point conversion specifiers (the C
-// standard sets this at 6)
-#ifndef PRINTF_DEFAULT_FLOAT_PRECISION
-#define PRINTF_DEFAULT_FLOAT_PRECISION 6
-#endif
-
-// According to the C languages standard, printf() and related functions must be
-// able to print any integral number in floating-point notation, regardless of
-// length, when using the %f specifier - possibly hundreds of characters,
-// potentially overflowing your buffers. In this implementation, all values
-// beyond this threshold are switched to exponential notation.
-#ifndef PRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL
-#define PRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL 9
-#endif
-
-// Support for the long long integral types (with the ll, z and t length
-// modifiers for specifiers %d,%i,%o,%x,%X,%u, and with the %p specifier). Note:
-// 'L' (long double) is not supported.
-#ifndef PRINTF_SUPPORT_LONG_LONG
-#define PRINTF_SUPPORT_LONG_LONG 1
-#endif
-
-#if PRINTF_SUPPORT_LONG_LONG
-typedef unsigned long long printf_unsigned_value_t;
-typedef long long printf_signed_value_t;
-#else
-typedef unsigned long printf_unsigned_value_t;
-typedef long printf_signed_value_t;
-#endif
-
-#define PRINTF_PREFER_DECIMAL false
-#define PRINTF_PREFER_EXPONENTIAL true
-
-///////////////////////////////////////////////////////////////////////////////
-
-// The following will convert the number-of-digits into an exponential-notation
-// literal
-#define PRINTF_CONCATENATE(s1, s2) s1##s2
-#define PRINTF_EXPAND_THEN_CONCATENATE(s1, s2) PRINTF_CONCATENATE(s1, s2)
-#define PRINTF_FLOAT_NOTATION_THRESHOLD \
-    PRINTF_EXPAND_THEN_CONCATENATE(1e, PRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL)
-
-// internal flag definitions
-#define FLAGS_ZEROPAD (1U << 0U)
-#define FLAGS_LEFT (1U << 1U)
-#define FLAGS_PLUS (1U << 2U)
-#define FLAGS_SPACE (1U << 3U)
-#define FLAGS_HASH (1U << 4U)
-#define FLAGS_UPPERCASE (1U << 5U)
-#define FLAGS_CHAR (1U << 6U)
-#define FLAGS_SHORT (1U << 7U)
-#define FLAGS_LONG (1U << 8U)
-#define FLAGS_LONG_LONG (1U << 9U)
-#define FLAGS_PRECISION (1U << 10U)
-#define FLAGS_ADAPT_EXP (1U << 11U)
-#define FLAGS_POINTER (1U << 12U)
-// Note: Similar, but not identical, effect as FLAGS_HASH
-
-#define BASE_BINARY 2
-#define BASE_OCTAL 8
-#define BASE_DECIMAL 10
-#define BASE_HEX 16
-
-typedef uint8_t numeric_base_t;
-
-#if (PRINTF_SUPPORT_DECIMAL_SPECIFIERS || PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS)
-#include <float.h>
-#if FLT_RADIX != 2
-#error "Non-binary-radix floating-point types are unsupported."
-#endif
-
-#if DBL_MANT_DIG == 24
-
-#define DOUBLE_SIZE_IN_BITS 32
-typedef uint32_t double_uint_t;
-#define DOUBLE_EXPONENT_MASK 0xFFU
-#define DOUBLE_BASE_EXPONENT 127
-
-#elif DBL_MANT_DIG == 53
-
-#define DOUBLE_SIZE_IN_BITS 64
-typedef uint64_t double_uint_t;
-#define DOUBLE_EXPONENT_MASK 0x7FFU
-#define DOUBLE_BASE_EXPONENT 1023
-
-#else
-#error "Unsupported double type configuration"
-#endif
-#define DOUBLE_STORED_MANTISSA_BITS (DBL_MANT_DIG - 1)
-
-typedef union {
-    double_uint_t U;
-    double F;
-} double_with_bit_access;
-
-// This is unnecessary in C99, since compound initializers can be used,
-// but: 1. Some compilers are finicky about this; 2. Some people may want to
-// convert this to C89;
-// 3. If you try to use it as C++, only C++20 supports compound literals
-static inline double_with_bit_access get_bit_access(double x) {
-    double_with_bit_access dwba;
-    dwba.F = x;
-    return dwba;
-}
-
-static inline int get_sign(double x) {
-    // The sign is stored in the highest bit
-    return get_bit_access(x).U >> (DOUBLE_SIZE_IN_BITS - 1);
-}
-
-static inline int get_exp2(double_with_bit_access x) {
-    // The exponent in an IEEE-754 floating-point number occupies a contiguous
-    // sequence of bits (e.g. 52..62 for 64-bit doubles), but with a non-trivial
-    // representation: An unsigned offset from some negative value (with the
-    // extremal offset values reserved for special use).
-    return (int)((x.U >> DOUBLE_STORED_MANTISSA_BITS) & DOUBLE_EXPONENT_MASK) -
-           DOUBLE_BASE_EXPONENT;
-}
-#define PRINTF_ABS(_x) ((_x) > 0 ? (_x) : -(_x))
-
-#endif  // (PRINTF_SUPPORT_DECIMAL_SPECIFIERS ||
-        // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS)
-
-// Note in particular the behavior here on LONG_MIN or LLONG_MIN; it is valid
-// and well-defined, but if you're not careful you can easily trigger undefined
-// behavior with -LONG_MIN or -LLONG_MIN
-#define ABS_FOR_PRINTING(_x) \
-    ((printf_unsigned_value_t)((_x) > 0 ? (_x) : -((printf_signed_value_t)_x)))
-
-// output function type
-typedef void (*out_fct_type)(char character,
-                             void* buffer,
-                             size_t idx,
-                             size_t maxlen);
-
-// wrapper (used as buffer) for output function type
-typedef struct {
-    void (*fct)(char character, void* arg);
-    void* arg;
-} out_function_wrapper_type;
-
-// internal buffer output
-static inline void out_buffer(char character,
-                              void* buffer,
-                              size_t idx,
-                              size_t maxlen) {
-    if (idx < maxlen) {
-        ((char*)buffer)[idx] = character;
-    }
-}
-
-// internal null output
-static inline void out_discard(char character,
-                               void* buffer,
-                               size_t idx,
-                               size_t maxlen) {
-    (void)character;
-    (void)buffer;
-    (void)idx;
-    (void)maxlen;
-}
-
-// internal secure strlen
-// @return The length of the string (excluding the terminating 0) limited by
-// 'maxsize'
-static inline unsigned int strnlen_s_(const char* str, size_t maxsize) {
-    const char* s;
-    for (s = str; *s && maxsize--; ++s)
-        ;
-    return (unsigned int)(s - str);
-}
-
-// internal test if char is a digit (0-9)
-// @return true if char is a digit
-static inline bool is_digit_(char ch) {
-    return (ch >= '0') && (ch <= '9');
-}
-
-// internal ASCII string to unsigned int conversion
-static unsigned int atoi_(const char** str) {
-    unsigned int i = 0U;
-    while (is_digit_(**str)) {
-        i = i * 10U + (unsigned int)(*((*str)++) - '0');
-    }
-    return i;
-}
-
-// output the specified string in reverse, taking care of any zero-padding
-static size_t out_rev_(out_fct_type out,
-                       char* buffer,
-                       size_t idx,
-                       size_t maxlen,
-                       const char* buf,
-                       size_t len,
-                       unsigned int width,
-                       unsigned int flags) {
-    const size_t start_idx = idx;
-
-    // pad spaces up to given width
-    if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD)) {
-        for (size_t i = len; i < width; i++) {
-            out(' ', buffer, idx++, maxlen);
-        }
-    }
-
-    // reverse string
-    while (len) {
-        out(buf[--len], buffer, idx++, maxlen);
-    }
-
-    // append pad spaces up to given width
-    if (flags & FLAGS_LEFT) {
-        while (idx - start_idx < width) {
-            out(' ', buffer, idx++, maxlen);
-        }
-    }
-
-    return idx;
-}
-
-// Invoked by print_integer after the actual number has been printed, performing
-// necessary work on the number's prefix (as the number is initially printed in
-// reverse order)
-static size_t print_integer_finalization(out_fct_type out,
-                                         char* buffer,
-                                         size_t idx,
-                                         size_t maxlen,
-                                         char* buf,
-                                         size_t len,
-                                         bool negative,
-                                         numeric_base_t base,
-                                         unsigned int precision,
-                                         unsigned int width,
-                                         unsigned int flags) {
-    size_t unpadded_len = len;
-
-    // pad with leading zeros
-    {
-        if (!(flags & FLAGS_LEFT)) {
-            if (width && (flags & FLAGS_ZEROPAD) &&
-                (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) {
-                width--;
-            }
-            while ((flags & FLAGS_ZEROPAD) && (len < width) &&
-                   (len < PRINTF_INTEGER_BUFFER_SIZE)) {
-                buf[len++] = '0';
-            }
-        }
-
-        while ((len < precision) && (len < PRINTF_INTEGER_BUFFER_SIZE)) {
-            buf[len++] = '0';
-        }
-
-        if (base == BASE_OCTAL && (len > unpadded_len)) {
-            // Since we've written some zeros, we've satisfied the alternative
-            // format leading space requirement
-            flags &= ~FLAGS_HASH;
-        }
-    }
-
-    // handle hash
-    if (flags & (FLAGS_HASH | FLAGS_POINTER)) {
-        if (!(flags & FLAGS_PRECISION) && len &&
-            ((len == precision) || (len == width))) {
-            // Let's take back some padding digits to fit in what will
-            // eventually be the format-specific prefix
-            if (unpadded_len < len) {
-                len--;
-            }
-            if (len && (base == BASE_HEX)) {
-                if (unpadded_len < len) {
-                    len--;
-                }
-            }
-        }
-        if ((base == BASE_HEX) && !(flags & FLAGS_UPPERCASE) &&
-            (len < PRINTF_INTEGER_BUFFER_SIZE)) {
-            buf[len++] = 'x';
-        } else if ((base == BASE_HEX) && (flags & FLAGS_UPPERCASE) &&
-                   (len < PRINTF_INTEGER_BUFFER_SIZE)) {
-            buf[len++] = 'X';
-        } else if ((base == BASE_BINARY) &&
-                   (len < PRINTF_INTEGER_BUFFER_SIZE)) {
-            buf[len++] = 'b';
-        }
-        if (len < PRINTF_INTEGER_BUFFER_SIZE) {
-            buf[len++] = '0';
-        }
-    }
-
-    if (len < PRINTF_INTEGER_BUFFER_SIZE) {
-        if (negative) {
-            buf[len++] = '-';
-        } else if (flags & FLAGS_PLUS) {
-            buf[len++] = '+';  // ignore the space if the '+' exists
-        } else if (flags & FLAGS_SPACE) {
-            buf[len++] = ' ';
-        }
-    }
-
-    return out_rev_(out, buffer, idx, maxlen, buf, len, width, flags);
-}
-
-// An internal itoa-like function
-static size_t print_integer(out_fct_type out,
-                            char* buffer,
-                            size_t idx,
-                            size_t maxlen,
-                            printf_unsigned_value_t value,
-                            bool negative,
-                            numeric_base_t base,
-                            unsigned int precision,
-                            unsigned int width,
-                            unsigned int flags) {
-    char buf[PRINTF_INTEGER_BUFFER_SIZE];
-    size_t len = 0U;
-
-    if (!value) {
-        if (!(flags & FLAGS_PRECISION)) {
-            buf[len++] = '0';
-            flags &= ~FLAGS_HASH;
-            // We drop this flag this since either the alternative and regular
-            // modes of the specifier don't differ on 0 values, or (in the case
-            // of octal) we've already provided the special handling for this
-            // mode.
-        } else if (base == BASE_HEX) {
-            flags &= ~FLAGS_HASH;
-            // We drop this flag this since either the alternative and regular
-            // modes of the specifier don't differ on 0 values
-        }
-    } else {
-        do {
-            const char digit = (char)(value % base);
-            buf[len++] =
-                (char)(digit < 10 ? '0' + digit
-                                  : (flags & FLAGS_UPPERCASE ? 'A' : 'a') +
-                                        digit - 10);
-            value /= base;
-        } while (value && (len < PRINTF_INTEGER_BUFFER_SIZE));
-    }
-
-    return print_integer_finalization(out, buffer, idx, maxlen, buf, len,
-                                      negative, base, precision, width, flags);
-}
-
-#if (PRINTF_SUPPORT_DECIMAL_SPECIFIERS || PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS)
-
-struct double_components {
-    int_fast64_t integral;
-    int_fast64_t fractional;
-    bool is_negative;
-};
-
-#define NUM_DECIMAL_DIGITS_IN_INT64_T 18
-#define PRINTF_MAX_PRECOMPUTED_POWER_OF_10 NUM_DECIMAL_DIGITS_IN_INT64_T
-static const double powers_of_10[NUM_DECIMAL_DIGITS_IN_INT64_T] = {
-    1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08,
-    1e09, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17};
-
-#define PRINTF_MAX_SUPPORTED_PRECISION NUM_DECIMAL_DIGITS_IN_INT64_T - 1
-
-// Break up a double number - which is known to be a finite non-negative number
-// - into its base-10 parts: integral - before the decimal point, and fractional
-// - after it. Taken the precision into account, but does not change it even
-// internally.
-static struct double_components get_components(double number,
-                                               unsigned int precision) {
-    struct double_components number_;
-    number_.is_negative = get_sign(number);
-    double abs_number = (number_.is_negative) ? -number : number;
-    number_.integral = (int_fast64_t)abs_number;
-    double remainder =
-        (abs_number - number_.integral) * powers_of_10[precision];
-    number_.fractional = (int_fast64_t)remainder;
-
-    remainder -= (double)number_.fractional;
-
-    if (remainder > 0.5) {
-        ++number_.fractional;
-        // handle rollover, e.g. case 0.99 with precision 1 is 1.0
-        if ((double)number_.fractional >= powers_of_10[precision]) {
-            number_.fractional = 0;
-            ++number_.integral;
-        }
-    } else if (remainder == 0.5) {
-        if ((number_.fractional == 0U) || (number_.fractional & 1U)) {
-            // if halfway, round up if odd OR if last digit is 0
-            ++number_.fractional;
-        }
-    }
-
-    if (precision == 0U) {
-        remainder = abs_number - (double)number_.integral;
-        if ((!(remainder < 0.5) || (remainder > 0.5)) &&
-            (number_.integral & 1)) {
-            // exactly 0.5 and ODD, then round up
-            // 1.5 -> 2, but 2.5 -> 2
-            ++number_.integral;
-        }
-    }
-    return number_;
-}
-
-struct scaling_factor {
-    double raw_factor;
-    bool multiply;  // if true, need to multiply by raw_factor; otherwise need
-                    // to divide by it
-};
-
-double apply_scaling(double num, struct scaling_factor normalization) {
-    return normalization.multiply ? num * normalization.raw_factor
-                                  : num / normalization.raw_factor;
-}
-
-double unapply_scaling(double normalized, struct scaling_factor normalization) {
-    return normalization.multiply ? normalized / normalization.raw_factor
-                                  : normalized * normalization.raw_factor;
-}
-
-struct scaling_factor update_normalization(struct scaling_factor sf,
-                                           double extra_multiplicative_factor) {
-    struct scaling_factor result;
-    if (sf.multiply) {
-        result.multiply = true;
-        result.raw_factor = sf.raw_factor * extra_multiplicative_factor;
-    } else {
-        int factor_exp2 = get_exp2(get_bit_access(sf.raw_factor));
-        int extra_factor_exp2 =
-            get_exp2(get_bit_access(extra_multiplicative_factor));
-
-        // Divide the larger-exponent raw raw_factor by the smaller
-        if (PRINTF_ABS(factor_exp2) > PRINTF_ABS(extra_factor_exp2)) {
-            result.multiply = false;
-            result.raw_factor = sf.raw_factor / extra_multiplicative_factor;
-        } else {
-            result.multiply = true;
-            result.raw_factor = extra_multiplicative_factor / sf.raw_factor;
-        }
-    }
-    return result;
-}
-
-#if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-static struct double_components get_normalized_components(
-    bool negative,
-    unsigned int precision,
-    double non_normalized,
-    struct scaling_factor normalization) {
-    struct double_components components;
-    components.is_negative = negative;
-    components.integral =
-        (int_fast64_t)apply_scaling(non_normalized, normalization);
-    double remainder =
-        non_normalized -
-        unapply_scaling((double)components.integral, normalization);
-    double prec_power_of_10 = powers_of_10[precision];
-    struct scaling_factor account_for_precision =
-        update_normalization(normalization, prec_power_of_10);
-    double scaled_remainder = apply_scaling(remainder, account_for_precision);
-    double rounding_threshold = 0.5;
-
-    if (precision == 0U) {
-        components.fractional = 0;
-        components.integral += (scaled_remainder >= rounding_threshold);
-        if (scaled_remainder == rounding_threshold) {
-            // banker's rounding: Round towards the even number (making the mean
-            // error 0)
-            components.integral &= ~((int_fast64_t)0x1);
-        }
-    } else {
-        components.fractional = (int_fast64_t)scaled_remainder;
-        scaled_remainder -= components.fractional;
-
-        components.fractional += (scaled_remainder >= rounding_threshold);
-        if (scaled_remainder == rounding_threshold) {
-            // banker's rounding: Round towards the even number (making the mean
-            // error 0)
-            components.fractional &= ~((int_fast64_t)0x1);
-        }
-        // handle rollover, e.g. the case of 0.99 with precision 1 becoming
-        // (0,100), and must then be corrected into (1, 0).
-        if ((double)components.fractional >= prec_power_of_10) {
-            components.fractional = 0;
-            ++components.integral;
-        }
-    }
-    return components;
-}
-#endif
-
-static size_t print_broken_up_decimal(struct double_components number_,
-                                      out_fct_type out,
-                                      char* buffer,
-                                      size_t idx,
-                                      size_t maxlen,
-                                      unsigned int precision,
-                                      unsigned int width,
-                                      unsigned int flags,
-                                      char* buf,
-                                      size_t len) {
-    if (precision != 0U) {
-        // do fractional part, as an unsigned number
-
-        unsigned int count = precision;
-
-        if (flags & FLAGS_ADAPT_EXP && !(flags & FLAGS_HASH)) {
-            // %g/%G mandates we skip the trailing 0 digits...
-            if (number_.fractional > 0) {
-                while (true) {
-                    int_fast64_t digit = number_.fractional % 10U;
-                    if (digit != 0) {
-                        break;
-                    }
-                    --count;
-                    number_.fractional /= 10U;
-                }
-            }
-            // ... and even the decimal point if there are no
-            // non-zero fractional part digits (see below)
-        }
-
-        if (number_.fractional > 0 || !(flags & FLAGS_ADAPT_EXP) ||
-            (flags & FLAGS_HASH)) {
-            while (len < PRINTF_FTOA_BUFFER_SIZE) {
-                --count;
-                buf[len++] = (char)('0' + number_.fractional % 10U);
-                if (!(number_.fractional /= 10U)) {
-                    break;
-                }
-            }
-            // add extra 0s
-            while ((len < PRINTF_FTOA_BUFFER_SIZE) && (count-- > 0U)) {
-                buf[len++] = '0';
-            }
-            if (len < PRINTF_FTOA_BUFFER_SIZE) {
-                buf[len++] = '.';
-            }
-        }
-    } else {
-        if (flags & FLAGS_HASH) {
-            if (len < PRINTF_FTOA_BUFFER_SIZE) {
-                buf[len++] = '.';
-            }
-        }
-    }
-
-    // Write the integer part of the number (it comes after the fractional
-    // since the character order is reversed)
-    while (len < PRINTF_FTOA_BUFFER_SIZE) {
-        buf[len++] = (char)('0' + (number_.integral % 10));
-        if (!(number_.integral /= 10)) {
-            break;
-        }
-    }
-
-    // pad leading zeros
-    if (!(flags & FLAGS_LEFT) && (flags & FLAGS_ZEROPAD)) {
-        if (width &&
-            (number_.is_negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) {
-            width--;
-        }
-        while ((len < width) && (len < PRINTF_FTOA_BUFFER_SIZE)) {
-            buf[len++] = '0';
-        }
-    }
-
-    if (len < PRINTF_FTOA_BUFFER_SIZE) {
-        if (number_.is_negative) {
-            buf[len++] = '-';
-        } else if (flags & FLAGS_PLUS) {
-            buf[len++] = '+';  // ignore the space if the '+' exists
-        } else if (flags & FLAGS_SPACE) {
-            buf[len++] = ' ';
-        }
-    }
-
-    return out_rev_(out, buffer, idx, maxlen, buf, len, width, flags);
-}
-
-// internal ftoa for fixed decimal floating point
-static size_t print_decimal_number(out_fct_type out,
-                                   char* buffer,
-                                   size_t idx,
-                                   size_t maxlen,
-                                   double number,
-                                   unsigned int precision,
-                                   unsigned int width,
-                                   unsigned int flags,
-                                   char* buf,
-                                   size_t len) {
-    struct double_components value_ = get_components(number, precision);
-    return print_broken_up_decimal(value_, out, buffer, idx, maxlen, precision,
-                                   width, flags, buf, len);
-}
-
-#if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-// internal ftoa variant for exponential floating-point type, contributed by
-// Martijn Jasperse <m.jasperse@gmail.com>
-static size_t print_exponential_number(out_fct_type out,
-                                       char* buffer,
-                                       size_t idx,
-                                       size_t maxlen,
-                                       double number,
-                                       unsigned int precision,
-                                       unsigned int width,
-                                       unsigned int flags,
-                                       char* buf,
-                                       size_t len) {
-    const bool negative = get_sign(number);
-    // This number will decrease gradually (by factors of 10) as we "extract"
-    // the exponent out of it
-    double abs_number = negative ? -number : number;
-
-    int exp10;
-    bool abs_exp10_covered_by_powers_table;
-    struct scaling_factor normalization;
-
-    // Determine the decimal exponent
-    if (abs_number == 0.0) {
-        // TODO: This is a special-case for 0.0 (and -0.0); but proper handling
-        // is required for denormals more generally.
-        exp10 = 0;  // ... and no need to set a normalization factor or check
-                    // the powers table
-    } else {
-        double_with_bit_access conv = get_bit_access(abs_number);
-        {
-            // based on the algorithm by David Gay
-            // (https://www.ampl.com/netlib/fp/dtoa.c)
-            int exp2 = get_exp2(conv);
-            // drop the exponent, so conv.F comes into the range [1,2)
-            conv.U =
-                (conv.U &
-                 (((double_uint_t)(1) << DOUBLE_STORED_MANTISSA_BITS) - 1U)) |
-                ((double_uint_t)DOUBLE_BASE_EXPONENT
-                 << DOUBLE_STORED_MANTISSA_BITS);
-            // now approximate log10 from the log2 integer part and an expansion
-            // of ln around 1.5
-            exp10 = (int)(0.1760912590558 + exp2 * 0.301029995663981 +
-                          (conv.F - 1.5) * 0.289529654602168);
-            // now we want to compute 10^exp10 but we want to be sure it won't
-            // overflow
-            exp2 = (int)(exp10 * 3.321928094887362 + 0.5);
-            const double z =
-                exp10 * 2.302585092994046 - exp2 * 0.6931471805599453;
-            const double z2 = z * z;
-            conv.U = ((double_uint_t)(exp2) + DOUBLE_BASE_EXPONENT)
-                     << DOUBLE_STORED_MANTISSA_BITS;
-            // compute exp(z) using continued fractions, see
-            // https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex
-            conv.F *= 1 + 2 * z / (2 - z + (z2 / (6 + (z2 / (10 + z2 / 14)))));
-            // correct for rounding errors
-            if (abs_number < conv.F) {
-                exp10--;
-                conv.F /= 10;
-            }
-        }
-        abs_exp10_covered_by_powers_table =
-            PRINTF_ABS(exp10) < PRINTF_MAX_PRECOMPUTED_POWER_OF_10;
-        normalization.raw_factor = abs_exp10_covered_by_powers_table
-                                       ? powers_of_10[PRINTF_ABS(exp10)]
-                                       : conv.F;
-    }
-
-    // We now begin accounting for the widths of the two parts of our printed
-    // field: the decimal part after decimal exponent extraction, and the
-    // base-10 exponent part. For both of these, the value of 0 has a special
-    // meaning, but not the same one: a 0 exponent-part width means "don't print
-    // the exponent"; a 0 decimal-part width means "use as many characters as
-    // necessary".
-
-    bool fall_back_to_decimal_only_mode = false;
-    if (flags & FLAGS_ADAPT_EXP) {
-        int required_significant_digits = (precision == 0) ? 1 : (int)precision;
-        // Should we want to fall-back to "%f" mode, and only print the decimal
-        // part?
-        fall_back_to_decimal_only_mode =
-            (exp10 >= -4 && exp10 < required_significant_digits);
-        // Now, let's adjust the precision
-        // This also decided how we adjust the precision value - as in "%g"
-        // mode, "precision" is the number of _significant digits_, and this is
-        // when we "translate" the precision value to an actual number of
-        // decimal digits.
-        int precision_ =
-            (fall_back_to_decimal_only_mode)
-                ? (int)precision - 1 - exp10
-                : (int)precision -
-                      1;  // the presence of the exponent ensures only one
-                          // significant digit comes before the decimal point
-        precision = (precision_ > 0 ? (unsigned)precision_ : 0U);
-        flags |= FLAGS_PRECISION;  // make sure print_broken_up_decimal respects
-                                   // our choice above
-    }
-
-    normalization.multiply = (exp10 < 0 && abs_exp10_covered_by_powers_table);
-    bool should_skip_normalization =
-        (fall_back_to_decimal_only_mode || exp10 == 0);
-    struct double_components decimal_part_components =
-        should_skip_normalization
-            ? get_components(negative ? -abs_number : abs_number, precision)
-            : get_normalized_components(negative, precision, abs_number,
-                                        normalization);
-
-    // Account for roll-over, e.g. rounding from 9.99 to 100.0 - which effects
-    // the exponent and may require additional tweaking of the parts
-    if (fall_back_to_decimal_only_mode) {
-        if ((flags & FLAGS_ADAPT_EXP) && exp10 >= -1 &&
-            decimal_part_components.integral == powers_of_10[exp10 + 1]) {
-            exp10++;  // Not strictly necessary, since exp10 is no longer really
-                      // used
-            precision--;
-            // ... and it should already be the case that
-            // decimal_part_components.fractional == 0
-        }
-        // TODO: What about rollover strictly within the fractional part?
-    } else {
-        if (decimal_part_components.integral >= 10) {
-            exp10++;
-            decimal_part_components.integral = 1;
-            decimal_part_components.fractional = 0;
-        }
-    }
-
-    // the exp10 format is "E%+03d" and largest possible exp10 value for a
-    // 64-bit double is "307" (for 2^1023), so we set aside 4-5 characters
-    // overall
-    unsigned int exp10_part_width = fall_back_to_decimal_only_mode ? 0U
-                                    : (PRINTF_ABS(exp10) < 100)    ? 4U
-                                                                   : 5U;
-
-    unsigned int decimal_part_width =
-        ((flags & FLAGS_LEFT) && exp10_part_width)
-            ?
-            // We're padding on the right, so the width constraint is the
-            // exponent part's problem, not the decimal part's, so we'll use as
-            // many characters as we need:
-            0U
-            :
-            // We're padding on the left; so the width constraint is the decimal
-            // part's problem. Well, can both the decimal part and the exponent
-            // part fit within our overall width?
-            ((width > exp10_part_width)
-                 ?
-                 // Yes, so we limit our decimal part's width.
-                 // (Note this is trivially valid even if we've fallen back to
-                 // "%f" mode)
-                 width - exp10_part_width
-                 :
-                 // No; we just give up on any restriction on the decimal part
-                 // and use as many characters as we need
-                 0U);
-
-    const size_t start_idx = idx;
-    idx = print_broken_up_decimal(decimal_part_components, out, buffer, idx,
-                                  maxlen, precision, decimal_part_width, flags,
-                                  buf, len);
-
-    if (!fall_back_to_decimal_only_mode) {
-        out((flags & FLAGS_UPPERCASE) ? 'E' : 'e', buffer, idx++, maxlen);
-        idx = print_integer(out, buffer, idx, maxlen, ABS_FOR_PRINTING(exp10),
-                            exp10 < 0, 10, 0, exp10_part_width - 1,
-                            FLAGS_ZEROPAD | FLAGS_PLUS);
-        if (flags & FLAGS_LEFT) {
-            // We need to right-pad with spaces to meet the width requirement
-            while (idx - start_idx < width)
-                out(' ', buffer, idx++, maxlen);
-        }
-    }
-    return idx;
-}
-#endif  // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-
-static size_t print_floating_point(out_fct_type out,
-                                   char* buffer,
-                                   size_t idx,
-                                   size_t maxlen,
-                                   double value,
-                                   unsigned int precision,
-                                   unsigned int width,
-                                   unsigned int flags,
-                                   bool prefer_exponential) {
-    char buf[PRINTF_FTOA_BUFFER_SIZE];
-    size_t len = 0U;
-
-    // test for special values
-    if (value != value)
-        return out_rev_(out, buffer, idx, maxlen, "nan", 3, width, flags);
-    if (value < -DBL_MAX)
-        return out_rev_(out, buffer, idx, maxlen, "fni-", 4, width, flags);
-    if (value > DBL_MAX)
-        return out_rev_(out, buffer, idx, maxlen,
-                        (flags & FLAGS_PLUS) ? "fni+" : "fni",
-                        (flags & FLAGS_PLUS) ? 4U : 3U, width, flags);
-
-    if (!prefer_exponential && ((value > PRINTF_FLOAT_NOTATION_THRESHOLD) ||
-                                (value < -PRINTF_FLOAT_NOTATION_THRESHOLD))) {
-        // The required behavior of standard printf is to print _every_
-        // integral-part digit -- which could mean printing hundreds of
-        // characters, overflowing any fixed internal buffer and necessitating a
-        // more complicated implementation.
-#if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-        return print_exponential_number(out, buffer, idx, maxlen, value,
-                                        precision, width, flags, buf, len);
-#else
-        return 0U;
-#endif
-    }
-
-    // set default precision, if not set explicitly
-    if (!(flags & FLAGS_PRECISION)) {
-        precision = PRINTF_DEFAULT_FLOAT_PRECISION;
-    }
-
-    // limit precision so that our integer holding the fractional part does not
-    // overflow
-    while ((len < PRINTF_FTOA_BUFFER_SIZE) &&
-           (precision > PRINTF_MAX_SUPPORTED_PRECISION)) {
-        buf[len++] =
-            '0';  // This respects the precision in terms of result length only
-        precision--;
-    }
-
-    return
-#if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-        prefer_exponential
-            ? print_exponential_number(out, buffer, idx, maxlen, value,
-                                       precision, width, flags, buf, len)
-            :
-#endif
-            print_decimal_number(out, buffer, idx, maxlen, value, precision,
-                                 width, flags, buf, len);
-}
-
-#endif  // (PRINTF_SUPPORT_DECIMAL_SPECIFIERS ||
-        // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS)
-
-// internal vsnprintf
-static int __vsnprintf(out_fct_type out,
-                       char* buffer,
-                       const size_t maxlen,
-                       const char* format,
-                       va_list va) {
-    unsigned int flags, width, precision, n;
-    size_t idx = 0U;
-
-    if (!buffer) {
-        // use null output function
-        out = out_discard;
-    }
-
-    while (*format) {
-        // format specifier?  %[flags][width][.precision][length]
-        if (*format != '%') {
-            // no
-            out(*format, buffer, idx++, maxlen);
-            format++;
-            continue;
-        } else {
-            // yes, evaluate it
-            format++;
-        }
-
-        // evaluate flags
-        flags = 0U;
-        do {
-            switch (*format) {
-                case '0':
-                    flags |= FLAGS_ZEROPAD;
-                    format++;
-                    n = 1U;
-                    break;
-                case '-':
-                    flags |= FLAGS_LEFT;
-                    format++;
-                    n = 1U;
-                    break;
-                case '+':
-                    flags |= FLAGS_PLUS;
-                    format++;
-                    n = 1U;
-                    break;
-                case ' ':
-                    flags |= FLAGS_SPACE;
-                    format++;
-                    n = 1U;
-                    break;
-                case '#':
-                    flags |= FLAGS_HASH;
-                    format++;
-                    n = 1U;
-                    break;
-                default:
-                    n = 0U;
-                    break;
-            }
-        } while (n);
-
-        // evaluate width field
-        width = 0U;
-        if (is_digit_(*format)) {
-            width = atoi_(&format);
-        } else if (*format == '*') {
-            const int w = va_arg(va, int);
-            if (w < 0) {
-                flags |= FLAGS_LEFT;  // reverse padding
-                width = (unsigned int)-w;
-            } else {
-                width = (unsigned int)w;
-            }
-            format++;
-        }
-
-        // evaluate precision field
-        precision = 0U;
-        if (*format == '.') {
-            flags |= FLAGS_PRECISION;
-            format++;
-            if (is_digit_(*format)) {
-                precision = atoi_(&format);
-            } else if (*format == '*') {
-                const int precision_ = (int)va_arg(va, int);
-                precision = precision_ > 0 ? (unsigned int)precision_ : 0U;
-                format++;
-            }
-        }
-
-        // evaluate length field
-        switch (*format) {
-            case 'l':
-                flags |= FLAGS_LONG;
-                format++;
-                if (*format == 'l') {
-                    flags |= FLAGS_LONG_LONG;
-                    format++;
-                }
-                break;
-            case 'h':
-                flags |= FLAGS_SHORT;
-                format++;
-                if (*format == 'h') {
-                    flags |= FLAGS_CHAR;
-                    format++;
-                }
-                break;
-            case 't':
-                flags |= (sizeof(ptrdiff_t) == sizeof(long) ? FLAGS_LONG
-                                                            : FLAGS_LONG_LONG);
-                format++;
-                break;
-            case 'j':
-                flags |= (sizeof(intmax_t) == sizeof(long) ? FLAGS_LONG
-                                                           : FLAGS_LONG_LONG);
-                format++;
-                break;
-            case 'z':
-                flags |= (sizeof(size_t) == sizeof(long) ? FLAGS_LONG
-                                                         : FLAGS_LONG_LONG);
-                format++;
-                break;
-            default:
-                break;
-        }
-
-        // evaluate specifier
-        switch (*format) {
-            case 'd':
-            case 'i':
-            case 'u':
-            case 'x':
-            case 'X':
-            case 'o':
-            case 'b': {
-                // set the base
-                numeric_base_t base;
-                if (*format == 'x' || *format == 'X') {
-                    base = BASE_HEX;
-                } else if (*format == 'o') {
-                    base = BASE_OCTAL;
-                } else if (*format == 'b') {
-                    base = BASE_BINARY;
-                } else {
-                    base = BASE_DECIMAL;
-                    flags &= ~FLAGS_HASH;  // no hash for dec format
-                }
-                // uppercase
-                if (*format == 'X') {
-                    flags |= FLAGS_UPPERCASE;
-                }
-
-                // no plus or space flag for u, x, X, o, b
-                if ((*format != 'i') && (*format != 'd')) {
-                    flags &= ~(FLAGS_PLUS | FLAGS_SPACE);
-                }
-
-                // ignore '0' flag when precision is given
-                if (flags & FLAGS_PRECISION) {
-                    flags &= ~FLAGS_ZEROPAD;
-                }
-
-                // convert the integer
-                if ((*format == 'i') || (*format == 'd')) {
-                    // signed
-                    if (flags & FLAGS_LONG_LONG) {
-#if PRINTF_SUPPORT_LONG_LONG
-                        const long long value = va_arg(va, long long);
-                        idx = print_integer(out, buffer, idx, maxlen,
-                                            ABS_FOR_PRINTING(value), value < 0,
-                                            base, precision, width, flags);
-#endif
-                    } else if (flags & FLAGS_LONG) {
-                        const long value = va_arg(va, long);
-                        idx = print_integer(out, buffer, idx, maxlen,
-                                            ABS_FOR_PRINTING(value), value < 0,
-                                            base, precision, width, flags);
-                    } else {
-                        const int value =
-                            (flags & FLAGS_CHAR) ? (signed char)va_arg(va, int)
-                            : (flags & FLAGS_SHORT) ? (short int)va_arg(va, int)
-                                                    : va_arg(va, int);
-                        idx = print_integer(out, buffer, idx, maxlen,
-                                            ABS_FOR_PRINTING(value), value < 0,
-                                            base, precision, width, flags);
-                    }
-                } else {
-                    // unsigned
-                    if (flags & FLAGS_LONG_LONG) {
-#if PRINTF_SUPPORT_LONG_LONG
-                        idx =
-                            print_integer(out, buffer, idx, maxlen,
-                                          (printf_unsigned_value_t)va_arg(
-                                              va, unsigned long long),
-                                          false, base, precision, width, flags);
-#endif
-                    } else if (flags & FLAGS_LONG) {
-                        idx = print_integer(
-                            out, buffer, idx, maxlen,
-                            (printf_unsigned_value_t)va_arg(va, unsigned long),
-                            false, base, precision, width, flags);
-                    } else {
-                        const unsigned int value =
-                            (flags & FLAGS_CHAR)
-                                ? (unsigned char)va_arg(va, unsigned int)
-                            : (flags & FLAGS_SHORT)
-                                ? (unsigned short int)va_arg(va, unsigned int)
-                                : va_arg(va, unsigned int);
-                        idx =
-                            print_integer(out, buffer, idx, maxlen,
-                                          (printf_unsigned_value_t)value, false,
-                                          base, precision, width, flags);
-                    }
-                }
-                format++;
-                break;
-            }
-#if PRINTF_SUPPORT_DECIMAL_SPECIFIERS
-            case 'f':
-            case 'F':
-                if (*format == 'F')
-                    flags |= FLAGS_UPPERCASE;
-                idx = print_floating_point(out, buffer, idx, maxlen,
-                                           va_arg(va, double), precision, width,
-                                           flags, PRINTF_PREFER_DECIMAL);
-                format++;
-                break;
-#endif
-#if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-            case 'e':
-            case 'E':
-            case 'g':
-            case 'G':
-                if ((*format == 'g') || (*format == 'G'))
-                    flags |= FLAGS_ADAPT_EXP;
-                if ((*format == 'E') || (*format == 'G'))
-                    flags |= FLAGS_UPPERCASE;
-                idx = print_floating_point(out, buffer, idx, maxlen,
-                                           va_arg(va, double), precision, width,
-                                           flags, PRINTF_PREFER_EXPONENTIAL);
-                format++;
-                break;
-#endif  // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
-            case 'c': {
-                unsigned int l = 1U;
-                // pre padding
-                if (!(flags & FLAGS_LEFT)) {
-                    while (l++ < width) {
-                        out(' ', buffer, idx++, maxlen);
-                    }
-                }
-                // char output
-                out((char)va_arg(va, int), buffer, idx++, maxlen);
-                // post padding
-                if (flags & FLAGS_LEFT) {
-                    while (l++ < width) {
-                        out(' ', buffer, idx++, maxlen);
-                    }
-                }
-                format++;
-                break;
-            }
-
-            case 's': {
-                const char* p = va_arg(va, char*);
-                if (p == NULL) {
-                    idx = out_rev_(out, buffer, idx, maxlen, ")llun(", 6, width,
-                                   flags);
-                } else {
-                    unsigned int l =
-                        strnlen_s_(p, precision ? precision : (size_t)-1);
-                    // pre padding
-                    if (flags & FLAGS_PRECISION) {
-                        l = (l < precision ? l : precision);
-                    }
-                    if (!(flags & FLAGS_LEFT)) {
-                        while (l++ < width) {
-                            out(' ', buffer, idx++, maxlen);
-                        }
-                    }
-                    // string output
-                    while ((*p != 0) &&
-                           (!(flags & FLAGS_PRECISION) || precision--)) {
-                        out(*(p++), buffer, idx++, maxlen);
-                    }
-                    // post padding
-                    if (flags & FLAGS_LEFT) {
-                        while (l++ < width) {
-                            out(' ', buffer, idx++, maxlen);
-                        }
-                    }
-                }
-                format++;
-                break;
-            }
-
-            case 'p': {
-                width = sizeof(void*) * 2U +
-                        2;  // 2 hex chars per byte + the "0x" prefix
-                flags |= FLAGS_ZEROPAD | FLAGS_POINTER;
-                uintptr_t value = (uintptr_t)va_arg(va, void*);
-                idx = (value == (uintptr_t)NULL)
-                          ? out_rev_(out, buffer, idx, maxlen, ")lin(", 5,
-                                     width, flags)
-                          : print_integer(out, buffer, idx, maxlen,
-                                          (printf_unsigned_value_t)value, false,
-                                          BASE_HEX, precision, width, flags);
-                format++;
-                break;
-            }
-
-            case '%':
-                out('%', buffer, idx++, maxlen);
-                format++;
-                break;
-
-            default:
-                out(*format, buffer, idx++, maxlen);
-                format++;
-                break;
-        }
-    }
-
-    // termination
-    out((char)0, buffer, idx < maxlen ? idx : maxlen - 1U, maxlen);
-
-    // return written chars without terminating \0
-    return (int)idx;
-}
-
-/**
- * This function will fill a formatted string to buffer.
- *
- * @param  buf is the buffer to save formatted string.
- *
- * @param  size is the size of buffer.
- *
- * @param  fmt is the format parameters.
- *
- * @param  args is a list of variable parameters.
- *
- * @return The number of characters actually written to buffer.
- */
-
-int pika_platform_vsnprintf(char* buff,
-                            size_t size,
-                            const char* fmt,
-                            va_list args) {
-    return __vsnprintf(out_buffer, buff, size, fmt, args);
-}

+ 1 - 1
port/linux/package/pikascript/pikascript-lib/pika_lua/_pika_lua.c

@@ -112,6 +112,6 @@ __exit:
 
 void _pika_lua___del__(PikaObj* self) {
     pika_debug("lua close!\r\n");
-    lua_close(g_pika_L);  // 关闭 Lua 状态机,释放所有关联的资源
+    lua_close(g_pika_L);
     g_pika_L = NULL;
 }

+ 1 - 1
port/linux/package/pikascript/pikascript-lib/socket/PikaPlatform_socket.c

@@ -1,4 +1,4 @@
-#include "PikaPlatform_socket.h"
+#include "PikaPlatform_socket.h"
 /*
     The functinos start with PIKA_WEAK are weak functions,
     you need to override them in your platform.

+ 1 - 1
port/linux/package/pikascript/pikascript-lib/socket/PikaPlatform_socket.h

@@ -1,4 +1,4 @@
-#include "PikaObj.h"
+#include "PikaObj.h"
 #ifdef __linux__
 #include <arpa/inet.h>
 #include <errno.h>

+ 1 - 1
port/linux/package/pikascript/pikascript-lib/socket/_socket.c

@@ -1,4 +1,4 @@
-#include "PikaPlatform_socket.h"
+#include "PikaPlatform_socket.h"
 #include "_socket_socket.h"
 
 #if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 12, 0)

+ 11 - 12
port/linux/package/pikascript/pikascript-lib/struct/_struct.c

@@ -7,25 +7,24 @@
  * Copyright (c) 2014 Paul Sokolovsky
  * Copyright (c) 2023 Lyon
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
-
 #include "_struct.h"
 #include "pika_adapter_mpy.h"
 

+ 20 - 158
port/linux/package/pikascript/pikascript-lib/time/_time.c

@@ -42,8 +42,6 @@ void _time_platformGetTick(PikaObj* self) {
 #include "stdint.h"
 #include "stdio.h"
 
-// 结构体时间类型定义(来源c标准库corect_wtime.h)
-// 无论是16位整数还是32位整数都满足需求
 typedef struct _tm {
     int tm_sec;    // seconds after the minute - [0, 60] including leap second
     int tm_min;    // minutes after the hour - [0, 59]
@@ -56,16 +54,11 @@ typedef struct _tm {
     int tm_isdst;  // daylight savings time flag
 } _tm;
 
-// 时间戳时间类型定义(来源c标准库time.h)
-// 直接支持64位秒数时间,附加时间精度为ns,根据设备决定,需要1GHz及以上时钟频率才能支持1ns级别时间精度
-// 内部时间比对数据类型,传递给外界的时候会使用浮点数,所以精度会降低
-// 但内部使用复合数据类型比对,以实现平台支持的最小时间精度比较
 typedef struct {
     int64_t tv_sec;   // Seconds - >= 0
     int32_t tv_nsec;  // Nanoseconds - [0, 999999999]
 } _timespec;
 
-// 错误处理
 typedef int status;
 
 #define TIME_OK 0
@@ -77,9 +70,7 @@ typedef int status;
 #define TIME_LESS_THAN_1970 5
 #define TIME_ERROR_STRUCT_TIME 6
 
-// 错误状态处理函数
 void status_deal(status s) {
-// 输出异常信息
 #define time_printf(...) __platform_printf(__VA_ARGS__)
 
     time_printf("\n[Error-info]Checking a exception : ");
@@ -111,59 +102,46 @@ void status_deal(status s) {
     time_printf("\n");
 }
 
-// 获取硬件平台的Unix时间戳,时间精度为1s级别,
 status time_get_unix_time(PikaObj* self, _timespec* this_timespec) {
     this_timespec->tv_sec = (int64_t)(obj_getInt(self, "tick") / 1000);
     return TIME_OK;
 }
 
-// 获取硬件平台的Tick时间,时间精度为1s级别以下
-// 即1s的小数部分
 status time_get_tick_ns(PikaObj* self, _timespec* this_timespec) {
     this_timespec->tv_nsec = (obj_getInt(self, "tick") % 1000) * 1000000;
     return TIME_OK;
 }
 
-// 标准time()方法,返回以浮点数表示的从 epoch 开始的秒数的时间值。
-//  epoch 是 1970 年 1 月 1 日 00:00:00 (UTC),
 pika_float time_time(PikaObj* self) {
-    status res = 0;  // 状态响应
+    status res = 0;
     _timespec temp_timespec = {0};
-    // 调用硬件平台函数,获取当前时间
     res = time_get_unix_time(self, &temp_timespec);
     if (res) {
         status_deal(res);
-    }  // 异常处理
+    }
     res = time_get_tick_ns(self, &temp_timespec);
     if (res) {
         status_deal(res);
-    }  // 异常处理
-    // 以浮点数返回时间,float
+    }
     return temp_timespec.tv_sec +
            (pika_float)temp_timespec.tv_nsec / 1000000000;
 }
 
-// 标准time_ns()方法,返回以整数表示的从 epoch 开始的纳秒数的时间值。
-//  epoch 是 1970 年 1 月 1 日 00:00:00 (UTC),
 int64_t time_time_ns(PikaObj* self) {
-    status res = 0;  // 状态响应
+    status res = 0;
     _timespec temp_timespec = {0};
-    // 调用硬件平台函数,获取当前时间
     res = time_get_unix_time(self, &temp_timespec);
     if (res) {
         status_deal(res);
-    }  // 异常处理
+    }
     res = time_get_tick_ns(self, &temp_timespec);
     if (res) {
         status_deal(res);
-    }  // 异常处理
-    // 以浮点数返回时间,float
+    }
     return temp_timespec.tv_sec * 1000000000 + temp_timespec.tv_nsec;
 }
 
-// 利用基姆拉尔森计算公式计算星期
 int time_get_week(const _tm* this_tm) {
-    // 月份要+1
     int month = this_tm->tm_mon + 1;
     int year = this_tm->tm_year;
     int day = this_tm->tm_mday;
@@ -172,195 +150,131 @@ int time_get_week(const _tm* this_tm) {
         month += 12;
         year -= 1;
         w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 -
-            year / 100 + year / 400 + 1;  // 0~6,星期日 ~ 星期六
+            year / 100 + year / 400 + 1;  //
         w = w % 7;
     } else {
         w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 -
-            year / 100 + year / 400 + 1;  // 0~6,星期日 ~ 星期六
+            year / 100 + year / 400 + 1;  //
         w = w % 7;
     }
     return w;
 }
 
-// 由Unix时间戳计算标准UTC时间
 status unix_time_to_utc_struct_time(_tm* this_tm, int64_t unix_time) {
     int32_t total_day;
     int32_t extra_second;
     int year_400, year_100, year_4, year_1;
-    int february_offset, temp;  // 二月偏移量,零时变量
+    int february_offset, temp;
 
-    // 判断是否输入小于0的时间戳
     if (unix_time < 0) {
-        // 暂不支持小于0的时间戳
         return TIME_LESS_THAN_ZERO;
     }
 
-// Unix时间戳每天秒数是固定的 62*60*24
 #define DAY_SECOND (86400)
 
     total_day = unix_time / DAY_SECOND;
     extra_second = unix_time - total_day * DAY_SECOND;
 
-// 为了减少额外闰年判断,把时间往前推到1600年,即闰年最大的一次公倍数开始计算判断
-//  1970-1600 = 370 年 ,370/4 -(370/100-1)=90 个闰年
-//  1600 DAY_OFFSET 365*(1970-1600)+90 = 135140,7为修正天数
-#define YEAR_START (1600)    // 初始年份
-#define DAY_OFFSET (135140)  // 时间偏移量
+#define YEAR_START (1600)
+#define DAY_OFFSET (135140)
 
     total_day += DAY_OFFSET;
 
-// 从1600年到3200年有1600/4-(1600/100-1600/400)=388个闰年
-// 即 MAX_DAY  1600*365+388=584388 day
-#define MAX_DAY (584388)  // 最大可判断时间天数
+#define MAX_DAY (584388)
 
     if (total_day > MAX_DAY) {
-        // 超过3200年的换算暂不支持
         return TIME_OVER_3200;
     } else {
-// 从1600年开始,天数都要多减一天,因为1600年是闰年
-// 但是由于日期不包含当天时间,即2月2号,实际是2月1号+时:分:秒
-// 所以算出来的日期要加上一天
-// 两者配合,无需加减
-
-// 从400年,100年,4年逐渐缩小范围
-//  400个公历年天数为365*400+97=146097天
-//  400年内的100个公历年天数为365*100+24=36524天
-//  100年内的4年365*4+1=1461天
 #define DAY_OF_400Y (146097)
 #define DAY_OF_100Y (36524)
 #define DAY_OF_4Y (1461)
 #define DAY_OF_1Y (365)
-        // 400年也要注意,要实际401年才可
         year_400 = (total_day - 366) / DAY_OF_400Y;
         total_day -= year_400 * DAY_OF_400Y;
-        // 计算400年内的情况
         year_100 = (total_day - 1) / DAY_OF_100Y;
         total_day -= year_100 * DAY_OF_100Y;
-        // 计算100年内的情况,要到第二年的第一天才算,即365+1
         year_4 = (total_day - 366) / DAY_OF_4Y;
-        // 计算4年,需要格外注意0-5-8年,才会计算一个闰年,因为它才包含了4这个闰年,但并不包含8
         total_day -= year_4 * DAY_OF_4Y;
-        // 计算4年内的情况
-        // 需要减去1天,因为当天是不存在的
-        // 需要注意闰年会多一天
-        // 所有闰年都放在这里来考虑,即只要当前是闰年,那么这里就会剩下第一年闰年和第四年闰年两种情况
         if (year_100 == 4) {
-            // 第一年是闰年,此时为400*n+1年内
             year_1 = 0;
             february_offset = 1;
         } else if (total_day <= DAY_OF_1Y * 4) {
-            // 100*n+(4,8,...96)+1年,都是从第二年算起,非闰年
-            // 非闰年,需要减去1天,因为当天是不存在的
             year_1 = (total_day - 1) / DAY_OF_1Y;
             total_day -= year_1 * DAY_OF_1Y;
             february_offset = 0;
         } else {
-            // 第四年是闰年
             year_1 = 4;
             total_day -= year_1 * DAY_OF_1Y;
             february_offset = 1;
         }
 
-        // 计算出当前年份
         this_tm->tm_year =
             (year_400 * 400 + year_100 * 100 + year_4 * 4 + year_1) +
             YEAR_START;
-        // 保存一年的天数
         this_tm->tm_yday = total_day;
 
-        // 剩下的天数为1年内的天数,直接计算月和日
-        // 根据当前是否为闰年设置二月偏移量是否为1
-        // 能被4整除且不被100整除或者能被400整除
-
-        // 闰年需要减去一天再计算
         total_day -= february_offset;
-        // 使用二分法快速定位月份,使用平年计算,在月份确定到2月时,再考虑闰年
-        // 判断是否在1-6月里面
-        //  31, 28, 31, 30, 31, 30,    31, 31, 30, 31, 30, 31
         if (total_day <= 181) {
-            // 判断是否在1-3月里面
             if (total_day <= 90) {
-                // 判断是否在1-2月里面
                 if (total_day <= 59) {
-                    total_day += february_offset;  // 去掉二月的偏置
+                    total_day += february_offset;
                     if (total_day <= 31) {
-                        // 1月
                         temp = 0;
                     } else {
                         total_day -= 31;
-                        // 2月
                         temp = 1;
                     }
                 } else {
                     total_day -= 59;
-                    // 3月
                     temp = 2;
                 }
             } else {
-                // 4-6月
                 total_day -= 90;
-                // 是否在4月里面
                 if (total_day <= 30) {
-                    // 4月
                     temp = 3;
                 } else {
-                    // 5-6月
                     total_day -= 30;
                     if (total_day <= 31) {
-                        // 5月
                         temp = 4;
                     } else {
                         total_day -= 31;
-                        // 6月
                         temp = 5;
                     }
                 }
             }
         } else {
             total_day -= 181;
-            // 判断是否在7-9月里面
             if (total_day <= 92) {
-                // 是否在7-8月
                 if (total_day <= 62) {
                     if (total_day <= 31) {
-                        // 7月
                         temp = 6;
                     } else {
                         total_day -= 31;
-                        // 8月
                         temp = 7;
                     }
                 } else {
-                    // 9月
                     total_day -= 62;
                     temp = 8;
                 }
             } else {
-                // 10-12月
                 total_day -= 92;
-                // 是否在10-11月
                 if (total_day <= 61) {
                     if (total_day <= 31) {
-                        // 10月
                         temp = 9;
                     } else {
-                        // 11 月
                         total_day -= 31;
                         temp = 10;
                     }
                 } else {
-                    // 12月
                     total_day -= 61;
                     temp = 11;
                 }
             }
         }
 
-        // 记录当前月份和天数
-        this_tm->tm_mon = temp;        // 月份 [0,11]
-        this_tm->tm_mday = total_day;  // 天数
+        this_tm->tm_mon = temp;
+        this_tm->tm_mday = total_day;
 
-        // 利用额外秒数计算时-分-秒
         temp = extra_second / 3600;
         this_tm->tm_hour = temp;
         extra_second = extra_second - temp * 3600;
@@ -371,70 +285,47 @@ status unix_time_to_utc_struct_time(_tm* this_tm, int64_t unix_time) {
 
         this_tm->tm_sec = extra_second;
 
-        // 计算出当前日期的星期数
         this_tm->tm_wday = time_get_week(this_tm);
 
-        // 夏令时不明
         this_tm->tm_isdst = -1;
     }
     return TIME_OK;
 }
 
-// 由标准UTC时间生成Unix时间戳
 status utc_struct_time_to_unix_time(const _tm* this_tm, int64_t* unix_time) {
     int32_t total_day, total_leap_year, dyear;
-    int february_offset;  // 二月偏移量,零时变量
+    int february_offset;
     // 31, 28, 31, 30, 31, 30,    31, 31, 30, 31, 30, 31
-    // 每个月份对应前面所有月的天数
     const int month_day[] = {0,   31,  59,  90,  120, 151,
                              181, 212, 243, 273, 304, 334};
 
-    // 每天总秒数一定,将UTC时间(年月)转换成天数
-    // 为了减少额外闰年判断,把时间往前推到1600年,即闰年最大的一次公倍数开始计算判断
-    //  1970-1600 = 370 年 ,370/4 -(370/100-1)=90 个闰年
-    //  1600 DAY_OFFSET 365*(1970-1600)+90 = 135140,7为修正天数
-
     if (this_tm->tm_year < 1970) {
-        // 暂不支持1970之前的时间
         *unix_time = 0;
         return TIME_LESS_THAN_1970;
     }
     if (this_tm->tm_year >= 3200) {
-        // 暂不支持3200及以后的时间
         *unix_time = 0;
         return TIME_OVER_3200;
     }
 
-    // 计算总年数要去掉尾巴,如年数20年,那么实际应该4个闰年,因为20这一年没有包含在里面
-    // 要减去一年来算闰年次数
-    // 先计算到相对1600年的天数,再转换到1970年
     dyear = this_tm->tm_year - YEAR_START - 1;
     total_leap_year = dyear / 4 - (dyear / 100 - dyear / 400 - 1);
-    // 恢复减去的一年
     dyear += 1;
     total_day = dyear * 365 + total_leap_year;
 
-    // 减去1970到1600的总天数
     total_day -= DAY_OFFSET;
 
-    // 增加月和日的总天数
-    // 判断是否是闰年
-    // 能被4整除且不被100整除或者能被400整除
     if (((dyear % 4 == 0) && (dyear % 100 != 0)) || (dyear % 400 == 0)) {
-        // 闰年
         february_offset = 1;
     } else {
         february_offset = 0;
     }
 
-    // 计算含月和日的总天数,日期要减去当天
     total_day += month_day[this_tm->tm_mon] + this_tm->tm_mday - 1;
-    // 二月以上需要加上偏移量
     if (this_tm->tm_mon > 1) {
         total_day += february_offset;
     }
 
-    // 根据天数以及时分秒计算Unix时间戳
     *unix_time = (int64_t)total_day * DAY_SECOND + this_tm->tm_hour * 3600 +
                  this_tm->tm_min * 60 + this_tm->tm_sec;
 
@@ -450,41 +341,30 @@ void time_struct_format(const _tm* this_tm, char* str) {
             this_tm->tm_wday, this_tm->tm_yday, this_tm->tm_isdst);
 }
 
-// 标准库函数gmtime,将以自 epoch 开始的秒数表示的时间转换为 UTC 的 struct_time
 void time_gmtime(pika_float unix_time, _tm* this_tm) {
     status res;
-    // 转化时间
     res = unix_time_to_utc_struct_time(this_tm, (int64_t)unix_time);
     if (res) {
-        status_deal(res);  // 异常情况处理
-        // 返回默认值
-        //  note: 异常情况返回默认时间起始点
+        status_deal(res);
         unix_time_to_utc_struct_time(this_tm, (int64_t)0);
     }
 }
 
-// 标准库函数localtime,将以自 epoch 开始的秒数表示的时间转换为当地时间的
 //  struct_time
 void time_localtime(pika_float unix_time, _tm* this_tm, int locale) {
     status res;
     int local_offset;
 
-    // 获取本地时间偏移量(小时)
     local_offset = locale * 60 * 60;
 
-    // 转化时间
     res = unix_time_to_utc_struct_time(this_tm,
                                        (int64_t)unix_time + local_offset);
     if (res) {
-        status_deal(res);  // 异常情况处理
-        // 这里处理的策略和标准库不同,标准库最初始的时间是1970-1-1,00:00:00,对于不同时区来说,其值是不一样的
-        // 但本函数是要求各时区的起始时间不超过1970-1-1,00:00:00,实际上UTC时间可以更前,可靠的最早时间可到1600年
-        // 对于西时区来说,时间会缺失
+        status_deal(res);
         unix_time_to_utc_struct_time(this_tm, (int64_t)0);
     }
 }
 
-// 检测结构体时间是否在合适的范围内,但不检查它的正确性
 status time_check_struct_time(const _tm* this_tm) {
     if (this_tm->tm_sec < 0 || this_tm->tm_sec > 60) {
         return TIME_ERROR_STRUCT_TIME;
@@ -510,47 +390,33 @@ status time_check_struct_time(const _tm* this_tm) {
     return TIME_OK;
 }
 
-// 标准库函数mktime(t),将当地时间的
-//  struct_time转换为以自epoch开始的秒数表示的时间
 int64_t time_mktime(const _tm* this_tm, int locale) {
     status res;
     int local_offset;
     int64_t unix_time;
 
-    // 获取本地时间偏移量(小时)
     local_offset = locale * 60 * 60;
 
-    // 检测时间结构体范围正确性
     res = time_check_struct_time(this_tm);
     if (res) {
         status_deal(res);
         return 0;
-    }  // 异常情况返回时间零点
+    }
 
-    // 转化时间
     res = utc_struct_time_to_unix_time(this_tm, &unix_time);
     if (res) {
         status_deal(res);
         return 0;
-    }  // 异常情况返回时间零点
-    // 减去本地偏移时间
-    // 可能出现负数,严格来说,这不影响什么!
+    }
     unix_time -= local_offset;
 
-    // 显示出来
     //  time_printf("%I64d\n",unix_time);
 
-    // 返回数据
     return unix_time;
 }
 
-// 标准库函数asctime()
-// 把结构化时间struct_time元组表示为以下形式的字符串: `'Sun Jun 20 23:21:05
-//  1993'`。
 void time_asctime(const _tm* this_tm) {
-    // 星期缩写,python标准库是三个字母,这里并不相同
     const char* week[] = {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"};
-    // 月份缩写
     const char* month[] = {"Jan", "Feb", "Mar",  "Apr", "May", "Jun",
                            "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"};
 
@@ -616,9 +482,7 @@ void _time_gmtime(PikaObj* self, pika_float unix_time) {
     char str[200];
     time_gmtime(unix_time, &this_tm);
     time_set_tm_value(self, &this_tm);
-    // 格式化字符
     time_struct_format(&this_tm, str);
-    // 显示出来
     time_printf("%s\n", str);
 #endif
 }
@@ -634,9 +498,7 @@ void _time_localtime(PikaObj* self, pika_float unix_time) {
     int locale = g_pika_local_timezone;
     time_localtime(unix_time, &this_tm, locale);
     time_set_tm_value(self, &this_tm);
-    // 格式化字符
     time_struct_format(&this_tm, str);
-    // 显示出来
     time_printf("%s\n", str);
 #endif
 }

+ 0 - 1
port/linux/package/pikascript/pikascript-lib/zlib/fastlz.c

@@ -20,7 +20,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 #include "fastlz.h"
 #include "PikaObj.h"
 #include <stdint.h>

+ 2 - 3
port/linux/package/pikascript/pikascript-lib/zlib/fastlz.h

@@ -20,7 +20,6 @@
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
-
 #ifndef FASTLZ_H
 #define FASTLZ_H
 
@@ -87,8 +86,8 @@ int fastlz_decompress(const void* input, int length, void* output, int maxout);
   This is similar to fastlz_compress_level above, but with the level
   automatically chosen.
 
-  This function is deprecated and it will be completely removed in some future
-  version.
+  This function is deprecated and it will be completely removed in some
+  future version.
 */
 
 int fastlz_compress(const void* input, int length, void* output);

+ 0 - 1
port/linux/test/PikaCV-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE)
 TEST(PikaCV, test1) {
     /* init */

+ 0 - 1
port/linux/test/PikaNN-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE)
 
 TEST(PikaNN, test1) {

+ 0 - 1
port/linux/test/ctypes-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_SYNTAX_SLICE_ENABLE
 TEST(ctypes, test1) {
     /* init */

+ 0 - 1
port/linux/test/json-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if !PIKA_NANO_ENABLE
 TEST_RUN_SINGLE_FILE_PASS(json, loads, "test/python/json/json_loads.py")
 

+ 0 - 1
port/linux/test/mem_test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_POOL_ENABLE
 TEST(bitmap, init) {
     uint8_t* bitmap = bitmap_init(10);

+ 0 - 1
port/linux/test/module-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_SYNTAX_IMPORT_EX_ENABLE
 TEST(module, cmodule_import) {
     /* init */

+ 6 - 4
port/linux/test/mqtt-test.cpp

@@ -3,8 +3,8 @@
  * @Github: https://github.com/jiejieTop
  * @Date: 2019-12-11 21:53:07
  * @LastEditTime: 2020-06-08 20:38:41
- * @Description: the code belongs to jiejie, please keep the author information
- * and source code according to the license.
+ * @Description: the code belongs to jiejie, please keep the author
+ * information and source code according to the license.
  */
 #include "test_common.h"
 extern "C" {
@@ -46,12 +46,14 @@ static const char* test_baidu_ca_crt = {
 static void topic1_handler(void* client, message_data_t* msg) {
     (void)client;
     MQTT_LOG_I(
-        "----------------------------------------------------------------------"
+        "------------------------------------------------------------------"
+        "----"
         "-------------");
     MQTT_LOG_I("%s:%d %s()...\ntopic: %s\nmessage:%s", __FILE__, __LINE__,
                __FUNCTION__, msg->topic_name, (char*)msg->message->payload);
     MQTT_LOG_I(
-        "----------------------------------------------------------------------"
+        "------------------------------------------------------------------"
+        "----"
         "-------------");
 }
 

+ 0 - 1
port/linux/test/packtool-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #include "PikaCompiler.h"
 // TEST(packtool, unpack) {
 

+ 0 - 1
port/linux/test/pikaui-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_GC_MARK_SWEEP_ENABLE
 
 TEST(pikaui, page) {

+ 369 - 52
port/linux/test/py-test.cpp

@@ -4,89 +4,406 @@ TEST_START
 #if !PIKA_NANO_ENABLE
 TEST_RUN_SINGLE_FILE(thread, test2, "test/python/_thread/test2.py")
 TEST_RUN_SINGLE_FILE(eventloop, test1, "test/python/eventloop/test1.py")
-TEST_RUN_SINGLE_FILE(eventloop, test2, "test/python/eventloop/test2.py")
+TEST_RUN_SINGLE_FILE(eventloop,
+                     test2,
+                     "test/python/"
+                     "eventloop/"
+                     "test2.py")
 TEST_RUN_SINGLE_FILE(eventloop, test3, "test/python/eventloop/test3.py")
 TEST_RUN_SINGLE_FILE(eventloop, delay1, "test/python/eventloop/delay1.py")
-TEST_RUN_SINGLE_FILE(eventloop, once1, "test/python/eventloop/once1.py")
-TEST_RUN_SINGLE_FILE(eventloop, once2, "test/python/eventloop/once2.py")
-TEST_RUN_SINGLE_FILE(fsm, test1, "test/python/fsm/test1.py")
+TEST_RUN_SINGLE_FILE(eventloop,
+                     once1,
+                     "test/"
+                     "python/"
+                     "eventloop/"
+                     "once1.py")
+TEST_RUN_SINGLE_FILE(eventloop,
+                     once2,
+                     "test/python/eventloop/"
+                     "once2.py")
+TEST_RUN_SINGLE_FILE(fsm,
+                     test1,
+                     "test/"
+                     "python/"
+                     "fsm/"
+                     "test1."
+                     "py")
 
 TEST_RUN_SINGLE_FILE_PASS(builtin,
                           list_tuple_equ,
                           "test/python/builtins/list_tuple_equ.py")
 TEST_RUN_SINGLE_FILE_PASS(builtin,
                           fn_default1,
-                          "test/python/builtins/fn_default1.py")
+                          "te"
+                          "st"
+                          "/p"
+                          "yt"
+                          "ho"
+                          "n/"
+                          "bu"
+                          "il"
+                          "ti"
+                          "ns"
+                          "/f"
+                          "n_"
+                          "de"
+                          "fa"
+                          "ul"
+                          "t1"
+                          ".p"
+                          "y")
 TEST_RUN_SINGLE_FILE_PASS(builtin,
                           fn_default_tuple,
                           "test/python/builtins/fn_default_tuple.py")
-TEST_RUN_SINGLE_FILE_PASS(builtin, max_min, "test/python/builtins/max_min.py")
-TEST_RUN_SINGLE_FILE_PASS(builtin, split, "test/python/builtins/split.py")
+TEST_RUN_SINGLE_FILE_PASS(builtin,
+                          max_min,
+                          "test"
+                          "/pyt"
+                          "hon/"
+                          "buil"
+                          "tins"
+                          "/max"
+                          "_min"
+                          ".py")
+TEST_RUN_SINGLE_FILE_PASS(builtin,
+                          split,
+                          "test/"
+                          "python/"
+                          "builtins/"
+                          "split.py")
 TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
                              split_slice,
                              "'test'.split('e')[0]",
                              "'t'\r\n")
 TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
                              split_slice_1,
-                             "'test'.split('e')[1]",
-                             "'st'\r\n")
+                             "'test'"
+                             ".split"
+                             "('e')["
+                             "1]",
+                             "'st'"
+                             "\r\n")
 TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
                              replace_split_0,
-                             "'a b c d'.replace(' ', ',').split(',')[0]",
+                             "'a b c "
+                             "d'.replace(' ', "
+                             "',').split(',')["
+                             "0]",
                              "'a'\r\n")
 TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin,
                                    class_script,
-                                   "test/python/builtins/class_script.py",
-                                   "Obj1.test\r\n")
+                                   "test"
+                                   "/pyt"
+                                   "hon/"
+                                   "buil"
+                                   "tins"
+                                   "/cla"
+                                   "ss_"
+                                   "scri"
+                                   "pt."
+                                   "py",
+                                   "Obj1"
+                                   ".tes"
+                                   "t\r"
+                                   "\n")
 TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin,
                                    class_hint,
-                                   "test/python/builtins/class_hint.py",
+                                   "test/"
+                                   "python/"
+                                   "builtins/"
+                                   "class_"
+                                   "hint.py",
                                    "1\r\n")
 TEST_RUN_SINGLE_FILE_PASS(builtin,
                           isinstance,
-                          "test/python/builtins/isinstance.py")
-TEST_RUN_SINGLE_FILE_PASS(builtin, getitem, "test/python/builtins/getitem.py")
-TEST_RUN_SINGLE_FILE_PASS(lua, eval, "test/python/pika_lua/eval.py")
-TEST_RUN_SINGLE_FILE_PASS(lua, require, "test/python/pika_lua/require.py")
+                          "tes"
+                          "t/"
+                          "pyt"
+                          "hon"
+                          "/bu"
+                          "ilt"
+                          "ins"
+                          "/is"
+                          "ins"
+                          "tan"
+                          "ce."
+                          "py")
+TEST_RUN_SINGLE_FILE_PASS(builtin,
+                          getitem,
+                          "test/python/"
+                          "builtins/"
+                          "getitem.py")
+TEST_RUN_SINGLE_FILE_PASS(lua,
+                          eval,
+                          "te"
+                          "st"
+                          "/p"
+                          "yt"
+                          "ho"
+                          "n/"
+                          "pi"
+                          "ka"
+                          "_l"
+                          "ua"
+                          "/e"
+                          "va"
+                          "l."
+                          "p"
+                          "y")
+TEST_RUN_SINGLE_FILE_PASS(lua,
+                          require,
+                          "test/python/"
+                          "pika_lua/"
+                          "require.py")
 
 TEST_RUN_LINES(vm, dot_issue, ".")
 TEST_RUN_LINES(vm, char_issue1, "~")
-TEST_RUN_LINES(vm, char_issue2, "/")
-TEST_RUN_LINES(vm, char_issue3, "%")
-TEST_RUN_LINES(vm, char_issue4, "=")
-TEST_RUN_SINGLE_FILE(vm,
-                     issue_star_dict,
-                     "test/python/issue/issue_star_dict.py")
-TEST_RUN_SINGLE_FILE_PASS(vm, proxy2, "test/python/proxy/proxy2.py")
-TEST_RUN_LINES(vm, abs_none, "abs(None)")
-TEST_RUN_LINES(vm, abs_str, "abs('test')")
-TEST_RUN_SINGLE_FILE_PASS(datastruct,
-                          circlequeue,
-                          "test/python/datastruct/circlequeue.py")
+TEST_RUN_LINES(vm, char_issue2, "/") TEST_RUN_LINES(vm, char_issue3, "%")
+    TEST_RUN_LINES(vm, char_issue4, "=") TEST_RUN_SINGLE_FILE(
+        vm,
+        issue_star_dict,
+        "test/"
+        "python/"
+        "issue/"
+        "issue_"
+        "star_"
+        "dict.py") TEST_RUN_SINGLE_FILE_PASS(vm,
+                                             proxy2,
+                                             "t"
+                                             "e"
+                                             "s"
+                                             "t"
+                                             "/"
+                                             "p"
+                                             "y"
+                                             "t"
+                                             "h"
+                                             "o"
+                                             "n"
+                                             "/"
+                                             "p"
+                                             "r"
+                                             "o"
+                                             "x"
+                                             "y"
+                                             "/"
+                                             "p"
+                                             "r"
+                                             "o"
+                                             "x"
+                                             "y"
+                                             "2"
+                                             "."
+                                             "p"
+                                             "y") TEST_RUN_LINES(vm,
+                                                                 abs_none,
+                                                                 "ab"
+                                                                 "s("
+                                                                 "No"
+                                                                 "ne"
+                                                                 ")")
+        TEST_RUN_LINES(vm,
+                       abs_str,
+                       "ab"
+                       "s("
+                       "'t"
+                       "es"
+                       "t'"
+                       ")") TEST_RUN_SINGLE_FILE_PASS(datastruct,
+                                                      circlequeue,
+                                                      "test/python/datastruct/"
+                                                      "circlequeue.py")
 
-TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple, "(1,)", "(1,)\r\n")
-TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple_str, "('test',)", "('test',)\r\n")
-TEST_RUN_SINGLE_FILE_PASS(vm, is_not, "test/python/builtins/is_not.py")
-TEST_RUN_LINES(vm,
-               var_global,
-               "import PikaStdLib\n"
-               "mem = PikaStdLib.MemChecker()\n"
-               "mem.clear\n")
-TEST_RUN_LINES(vm,
-               var_global_run,
-               "import PikaStdLib\n"
-               "mem = PikaStdLib.MemChecker()\n"
-               "mem.clear()\n")
-TEST_RUN_LINES(vm,
-               var_global_module,
-               "import configparser\n"
-               "configparser.clear\n")
-TEST_RUN_LINES(vm, import_void, "import \n")
-TEST_RUN_SINGLE_FILE_PASS(vm, fn_fn, "test/python/builtins/fn_fn.py")
-TEST_RUN_LINES_EXCEPT_OUTPUT(vm, isinstance, "isinstance(1, int)\n", "True\r\n")
-TEST_RUN_SINGLE_FILE_PASS(except,
-                          try_while_return,
-                          "test/python/except/try_while_return.py");
+            TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple, "(1,)", "(1,)\r\n")
+                TEST_RUN_LINES_EXCEPT_OUTPUT(
+                    vm,
+                    single_tuple_str,
+                    "('test',)",
+                    "('test',)"
+                    "\r\n") TEST_RUN_SINGLE_FILE_PASS(vm,
+                                                      is_not,
+                                                      "test"
+                                                      "/pyt"
+                                                      "hon/"
+                                                      "buil"
+                                                      "tins"
+                                                      "/"
+                                                      "is_"
+                                                      "not."
+                                                      "py")
+                    TEST_RUN_LINES(vm,
+                                   var_global,
+                                   "im"
+                                   "po"
+                                   "rt"
+                                   " P"
+                                   "ik"
+                                   "aS"
+                                   "td"
+                                   "Li"
+                                   "b"
+                                   "\n"
+                                   "me"
+                                   "m "
+                                   "= "
+                                   "Pi"
+                                   "ka"
+                                   "St"
+                                   "dL"
+                                   "ib"
+                                   "."
+                                   "Me"
+                                   "mC"
+                                   "he"
+                                   "ck"
+                                   "er"
+                                   "()"
+                                   "\n"
+                                   "me"
+                                   "m."
+                                   "cl"
+                                   "ea"
+                                   "r"
+                                   "\n") TEST_RUN_LINES(vm,
+                                                        var_global_run,
+                                                        "i"
+                                                        "m"
+                                                        "p"
+                                                        "o"
+                                                        "r"
+                                                        "t"
+                                                        " "
+                                                        "P"
+                                                        "i"
+                                                        "k"
+                                                        "a"
+                                                        "S"
+                                                        "t"
+                                                        "d"
+                                                        "L"
+                                                        "i"
+                                                        "b"
+                                                        "\n"
+                                                        "m"
+                                                        "e"
+                                                        "m"
+                                                        " "
+                                                        "="
+                                                        " "
+                                                        "P"
+                                                        "i"
+                                                        "k"
+                                                        "a"
+                                                        "S"
+                                                        "t"
+                                                        "d"
+                                                        "L"
+                                                        "i"
+                                                        "b"
+                                                        "."
+                                                        "M"
+                                                        "e"
+                                                        "m"
+                                                        "C"
+                                                        "h"
+                                                        "e"
+                                                        "c"
+                                                        "k"
+                                                        "e"
+                                                        "r"
+                                                        "("
+                                                        ")"
+                                                        "\n"
+                                                        "m"
+                                                        "e"
+                                                        "m"
+                                                        "."
+                                                        "c"
+                                                        "l"
+                                                        "e"
+                                                        "a"
+                                                        "r"
+                                                        "("
+                                                        ")"
+                                                        "\n")
+                        TEST_RUN_LINES(vm,
+                                       var_global_module,
+                                       "im"
+                                       "po"
+                                       "rt"
+                                       " c"
+                                       "on"
+                                       "fi"
+                                       "gp"
+                                       "ar"
+                                       "se"
+                                       "r"
+                                       "\n"
+                                       "co"
+                                       "nf"
+                                       "ig"
+                                       "pa"
+                                       "rs"
+                                       "er"
+                                       ".c"
+                                       "le"
+                                       "ar"
+                                       "\n") TEST_RUN_LINES(vm,
+                                                            import_void,
+                                                            "i"
+                                                            "m"
+                                                            "p"
+                                                            "o"
+                                                            "r"
+                                                            "t"
+                                                            " "
+                                                            "\n")
+                            TEST_RUN_SINGLE_FILE_PASS(vm,
+                                                      fn_fn,
+                                                      "test/"
+                                                      "python"
+                                                      "/built"
+                                                      "ins/"
+                                                      "fn_fn."
+                                                      "py")
+                                TEST_RUN_LINES_EXCEPT_OUTPUT(vm,
+                                                             isinstance,
+                                                             "is"
+                                                             "in"
+                                                             "st"
+                                                             "an"
+                                                             "ce"
+                                                             "(1"
+                                                             ", "
+                                                             "in"
+                                                             "t)"
+                                                             "\n",
+                                                             "Tr"
+                                                             "ue"
+                                                             "\r"
+                                                             "\n")
+                                    TEST_RUN_SINGLE_FILE_PASS(except,
+                                                              try_while_return,
+                                                              "te"
+                                                              "st"
+                                                              "/p"
+                                                              "yt"
+                                                              "ho"
+                                                              "n/"
+                                                              "ex"
+                                                              "ce"
+                                                              "pt"
+                                                              "/t"
+                                                              "ry"
+                                                              "_w"
+                                                              "hi"
+                                                              "le"
+                                                              "_r"
+                                                              "et"
+                                                              "ur"
+                                                              "n."
+                                                              "p"
+                                                              "y");
 TEST_RUN_SINGLE_FILE_PASS(except,
                           isinstance,
                           "test/python/except/except_isinstance.py");

+ 4 - 4
port/linux/test/requests-test.cpp

@@ -10,7 +10,6 @@
  */
 
 extern "C" {
-
 #include "../pikascript-lib/requests/webclient.h"
 
 #define GET_HEADER_BUFSZ 1024
@@ -18,8 +17,8 @@ extern "C" {
 
 #define GET_LOCAL_URI "http://www.rt-thread.com/service/rt-thread.txt"
 
-/* send HTTP GET request by common request interface, it used to receive longer
- * data */
+/* send HTTP GET request by common request interface, it used to receive
+ * longer data */
 static int webclient_get_comm(const char* uri) {
     struct webclient_session* session = RT_NULL;
     unsigned char* buffer = RT_NULL;
@@ -175,7 +174,8 @@ int webclient_get_test(int argc, char** argv) {
     } else {
         rt_kprintf("web_get_test [URI]     - webclient GET request test.\n");
         rt_kprintf(
-            "web_get_test -s [URI]  - webclient simplify GET request test.\n");
+            "web_get_test -s [URI]  - webclient simplify GET request "
+            "test.\n");
         return -RT_ERROR;
     }
 

+ 0 - 1
port/linux/test/stddata-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_SYNTAX_SLICE_ENABLE
 TEST(stddata, test1) {
     /* init */

+ 0 - 1
port/linux/test/string-test.cpp

@@ -1,6 +1,5 @@
 #include "test_common.h"
 TEST_START
-
 #if PIKA_SYNTAX_FORMAT_ENABLE
 TEST(string, cformat) {
     /* init */

+ 12 - 12
src/BaseObj.c

@@ -4,25 +4,25 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "BaseObj.h"

+ 12 - 13
src/BaseObj.h

@@ -4,27 +4,26 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
-
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 23 - 45
src/PikaCompiler.c

@@ -4,25 +4,25 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 #include "PikaCompiler.h"
 #include "BaseObj.h"
@@ -311,8 +311,7 @@ int LibObj_staticLinkFile_New(LibObj* self, char* input_file_name, char* path) {
         pika_platform_printf("error: can't open file %s\r\n", input_file_name);
         return -1;
     }
-    char* module_name = strsGetLastToken(
-        &buffs, input_file_name, '/'); /*找到最后一个 / 出现的位置的下一个地址*/
+    char* module_name = strsGetLastToken(&buffs, input_file_name, '/');
 
     size_t module_name_len = strlen(module_name);
 
@@ -437,10 +436,6 @@ static int32_t __foreach_handler_selectBlockSize(Arg* argEach,
     return 0;
 }
 
-/* 这里包括文件内容大小,文件信息所占的大小(文件名和文件大小)
- * 一个unit 的组成包括: Namelen(4 bytes)+ Name (strlen("namelen") + 1) \
- * + fileSize (4 bytes)
- */
 static int32_t __foreach_handler_libSumSize(Arg* argEach, PikaLinker* linker) {
     if (arg_isObject(argEach)) {
         PikaObj* module_obj = arg_getPtr(argEach);
@@ -566,14 +561,10 @@ static PIKA_RES _loadModuleDataWithIndex(uint8_t* library_bytes,
                                          char** name_p,
                                          uint8_t** addr_p,
                                          size_t* size) {
-    /*两个指针,一个指向文件信息部分,一个指向文件内容部分  */
-    uint32_t block_size =
-        *(uint32_t*)(library_bytes +
-                     4 * sizeof(uint32_t)); /* 每个文件信息大小的总和 */
+    uint32_t block_size = *(uint32_t*)(library_bytes + 4 * sizeof(uint32_t));
     uint8_t* file_info_block_start = library_bytes + block_size;
     uint8_t* bytecode_ptr = file_info_block_start + block_size * module_num;
     uint8_t* bytecode_ptr_next = bytecode_ptr;
-    /* 每一个模块的信息 */
     uint32_t module_size = 0;
     char* module_name = NULL;
     uintptr_t offset = 0;
@@ -624,8 +615,7 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
         size_t size = 0;
         _loadModuleDataWithIndex(library_bytes, module_num, i, &name, &addr,
                                  &size);
-        name = strsGetLastToken(&buffs, name,
-                                '/'); /*找到最后一个 / 出现的位置的下一个地址*/
+        name = strsGetLastToken(&buffs, name, '/');
 
         if (strEqu(module_name, name)) {
             *addr_p = addr;
@@ -638,16 +628,6 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
     return PIKA_RES_ERR_ARG_NO_FOUND;
 }
 
-/**
- * @brief 打开 .pack 文件,并返回Arg 对象,里面包含这个pack 文件的library_bytes
- *
- * @param
- * @param char* pack_name pack 文件的名字
- * @return  Arg* arg, a pointer to an Arg object, which point to the
- * library_bytes of the pack file.
- * @note
- *
- */
 Arg* _getPack_libraryBytes(char* pack_name) {
     if (NULL == pack_name) {
         pika_platform_printf(
@@ -728,7 +708,7 @@ int LibObj_loadLibraryFile(LibObj* self, char* lib_file_name) {
  */
 PIKA_RES pikafs_unpack_files(char* pack_name, char* out_path) {
     PIKA_RES stat = PIKA_RES_OK;
-    Arg* file_arg = NULL; /* file_arg 存在的意义就是获取文件的 library_bytes*/
+    Arg* file_arg = NULL;
     uint8_t* library_bytes = NULL;
     pikafs_FILE* fptr = NULL;
     if (NULL == out_path) {
@@ -758,8 +738,7 @@ PIKA_RES pikafs_unpack_files(char* pack_name, char* out_path) {
         size = 0;
         stat = _loadModuleDataWithIndex(library_bytes, module_num, i, &name,
                                         &addr, &size);
-        name = strsGetLastToken(&buffs, name,
-                                '/'); /*找到最后一个 / 出现的位置的下一个地址*/
+        name = strsGetLastToken(&buffs, name, '/');
         output_file_path = strsPathJoin(&buffs, out_path, name);
         pika_platform_printf("output_file_path: %s\r\n", output_file_path);
         new_fp = pika_platform_fopen(output_file_path, "wb+");
@@ -1189,7 +1168,7 @@ PIKA_RES pikaMaker_linkRaw(PikaMaker* self, char* file_path) {
 PIKA_RES pikaMaker_linkRaw_New(PikaMaker* self,
                                char* file_path,
                                char* pack_path) {
-    LibObj* lib = obj_getPtr(self, "lib"); /* self 下面的lib 对象 */
+    LibObj* lib = obj_getPtr(self, "lib");
     PIKA_RES ret = LibObj_staticLinkFile_New(lib, file_path, pack_path);
     return ret;
 }
@@ -1203,22 +1182,22 @@ PIKA_RES pikaMaker_linkRaw_New(PikaMaker* self,
 pikafs_FILE* pikafs_fopen(char* file_name, char* mode) {
     pikafs_FILE* f = (pikafs_FILE*)pikaMalloc(sizeof(pikafs_FILE));
     if (NULL == f) {
-        return NULL;  // 避免空指针
+        return NULL;
     }
     memset(f, 0, sizeof(pikafs_FILE));
     extern volatile PikaObj* __pikaMain;
     uint8_t* library_bytes = obj_getPtr((PikaObj*)__pikaMain, "@libraw");
     if (NULL == library_bytes) {
-        goto __error;  // 如果library_bytes为NULL,则跳转到__error
+        goto __error;
     }
     if (PIKA_RES_OK !=
         _loadModuleDataWithName(library_bytes, file_name, &f->addr, &f->size)) {
-        goto __error;  // 如果_loadModuleDataWithName的结果不是PIKA_RES_OK,则跳转到__error
+        goto __error;
     }
     return f;
 
 __error:
-    pikaFree(f, sizeof(pikafs_FILE));  // 释放内存
+    pikaFree(f, sizeof(pikafs_FILE));
     return NULL;
 }
 
@@ -1249,8 +1228,7 @@ pikafs_FILE* pikafs_fopen_pack(char* pack_name, char* file_name) {
     }
 
     f->farg = file_arg;
-    // arg_deinit(file_arg); /* file_arg 被释放以后,library_bytes
-    // 就是个野指针了 */
+    // arg_deinit(file_arg); /* file_arg
     return f;
 
 __exit:

+ 19 - 22
src/PikaObj.c

@@ -4,26 +4,26 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  * Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "PikaObj.h"
@@ -677,8 +677,6 @@ PikaObj* newNormalObj(NewFun newObjFun) {
 #include <termios.h>
 #include <unistd.h>
 #define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)
-// 函数set_disp_mode用于控制是否开启输入回显功能
-// 如果option为0,则关闭回显,为1则打开回显
 static int set_disp_mode(int fd, int option) {
     int err;
     struct termios term;
@@ -707,14 +705,14 @@ struct termios original_termios;
 static void enable_raw_mode(void) {
     struct termios raw;
 
-    tcgetattr(STDIN_FILENO, &original_termios);  // 获取当前终端属性
+    tcgetattr(STDIN_FILENO, &original_termios);
     raw = original_termios;
-    raw.c_lflag &= ~(ECHO | ICANON);           // 禁用回显和规范模式
-    tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);  // 设置终端属性
+    raw.c_lflag &= ~(ECHO | ICANON);
+    tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
 }
 
 static void disable_raw_mode(void) {
-    tcsetattr(STDIN_FILENO, TCSAFLUSH, &original_termios);  // 恢复原始终端属性
+    tcsetattr(STDIN_FILENO, TCSAFLUSH, &original_termios);
     printf("\n");
 }
 
@@ -743,10 +741,9 @@ PikaObj* newRootObj(char* name, NewFun newObjFun) {
     mem_pool_init();
 #endif
 #ifdef __linux
-    signal(SIGINT, signal_handler);   // 捕获 SIGINT 信号(Ctrl+C)
-    signal(SIGTERM, signal_handler);  // 捕获 SIGTERM 信号
-    signal(SIGHUP, signal_handler);   // 捕获 SIGHUP 信号
-    signal(SIGSEGV, signal_handler);  // 捕获 SIGHUP 信号
+    signal(SIGTERM, signal_handler);
+    signal(SIGHUP, signal_handler);
+    signal(SIGSEGV, signal_handler);
     signal(SIGABRT, signal_handler);
     signal(SIGQUIT, signal_handler);
     signal(SIGTRAP, signal_handler);

+ 16 - 15
src/PikaObj.h

@@ -4,26 +4,26 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  * Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 #include <stdint.h>
 #ifdef __cplusplus
@@ -434,8 +434,8 @@ Arg* obj_newObjInPackage(NewFun newObjFun);
  * arguments (of type Arg*) to it. */
 PikaObj* _pika_tuple_new(int num_args, ...);
 
-/* A helper function to create a new list PikaObj and append the given arguments
- * (of type Arg*) to it. */
+/* A helper function to create a new list PikaObj and append the given
+ * arguments (of type Arg*) to it. */
 PikaObj* _pika_list_new(int num_args, ...);
 PikaObj* _pika_dict_new(int num_args, ...);
 
@@ -449,7 +449,8 @@ PikaObj* _pika_dict_new(int num_args, ...);
 #define objList_new(...) \
     _pika_list_new(sizeof((Arg*[]){__VA_ARGS__}) / sizeof(Arg*), __VA_ARGS__)
 
-/* Macro to create a new dict PikaObj with the given arguments (of type Arg*).
+/* Macro to create a new dict PikaObj with the given arguments (of type
+ * Arg*).
  */
 
 #define objDict_new(...)                                                   \

+ 12 - 12
src/PikaParser.c

@@ -4,25 +4,25 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "PikaParser.h"

+ 12 - 12
src/PikaParser.h

@@ -4,25 +4,25 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 #ifdef __cplusplus
 extern "C" {

+ 13 - 13
src/PikaPlatform.c

@@ -1,28 +1,28 @@
-/*
+/*
  * This file is part of the PikaPython project.
  * http://github.com/pikastech/pikapython
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "PikaPlatform.h"

+ 15 - 16
src/PikaPlatform.h

@@ -1,28 +1,28 @@
-/*
+/*
  * This file is part of the PikaPython project.
  * http://github.com/pikastech/pikapython
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 #ifdef __cplusplus
 extern "C" {
@@ -143,9 +143,8 @@ typedef enum {
 
 /*
     [Note]:
-    Create a pika_config.c to override the following weak functions to config
-   PikaScript. [Example]:
-    1.
+    Create a pika_config.c to override the following weak functions to
+   config PikaScript. [Example]: 1.
    https://gitee.com/Lyon1998/pikascript/blob/master/package/STM32G030Booter/pika_config.c
     2.
    https://gitee.com/Lyon1998/pikascript/blob/master/package/pikaRTBooter/pika_config.c

+ 12 - 12
src/PikaVM.c

@@ -4,25 +4,25 @@
  *
  * MIT License
  *
- * Copyright (c) 2021 lyon 李昂 liang6516@outlook.com
+ * Copyright (c) 2021 lyon liang6516@outlook.com
  *
- * 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 the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * 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 the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "PikaVM.h"

Some files were not shown because too many files changed in this diff