From a3fdd3589c713678eafe20840a7334de6bed038b Mon Sep 17 00:00:00 2001
From: nancy.liao <huihui.liao@greentest.com.cn>
Date: 周五, 18 4月 2025 10:10:38 +0800
Subject: [PATCH] 修改

---
 libscpi/src/utils.c |   52 ++++++++++++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c
index be7b5d7..e0aa9a0 100644
--- a/libscpi/src/utils.c
+++ b/libscpi/src/utils.c
@@ -1,30 +1,29 @@
 /*-
- * Copyright (c) 2013 Jan Breuer
- *                    Richard.hmm
- * Copyright (c) 2012 Jan Breuer
+ * BSD 2-Clause License
  *
- * All Rights Reserved
+ * Copyright (c) 2012-2018, Jan Breuer, Richard.hmm
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
+ * modification, are permitted provided that the following conditions are met:
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 /**
@@ -676,6 +675,8 @@
  *
  * prev and current should be in the same memory buffer
  */
+
+ //缁勫悎澶嶅悎SCPI鍛戒护
 scpi_bool_t composeCompoundCommand(const scpi_token_t * prev, scpi_token_t * current) {
     size_t i;
 
@@ -688,6 +689,7 @@
         return TRUE;
 
     /* Common command or command root - nothing to do */
+    // 褰撳墠鍛戒护鏄叕鍏卞懡浠�(*)鎴栨牴鍛戒护(:)
     if (current->ptr[0] == '*' || current->ptr[0] == ':')
         return TRUE;
 
@@ -708,6 +710,7 @@
 
     current->ptr -= i;
     current->len += i;
+    //澶嶅悎鍛戒护缁勫悎
     memmove(current->ptr, prev->ptr, i);
     return TRUE;
 }
@@ -752,10 +755,11 @@
 }
 #endif
 
-#if !HAVE_STRNDUP
+#if USE_MEMORY_ALLOCATION_FREE && !HAVE_STRNDUP
 char *OUR_strndup(const char *s, size_t n) {
     size_t len = SCPIDEFINE_strnlen(s, n);
-    char * result = malloc(len + 1);
+    //msvc涓嬮渶瑕佸己杞�
+    char * result =(char*) malloc(len + 1);
     if (!result) {
         return NULL;
     }

--
Gitblit v1.9.1