emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sqlite3 b6868d2437 27/62: sqlite3-finalize accepts multipl


From: ELPA Syncer
Subject: [nongnu] elpa/sqlite3 b6868d2437 27/62: sqlite3-finalize accepts multiple params
Date: Tue, 14 Mar 2023 11:01:46 -0400 (EDT)

branch: elpa/sqlite3
commit b6868d2437dc23a7c335aa863b30945d6732fc8c
Author: Y. N. Lo <gordonynlo@yahoo.com>
Commit: Y. N. Lo <gordonynlo@yahoo.com>

    sqlite3-finalize accepts multiple params
---
 Makefile      |  8 +++++++-
 README-in.md  | 13 ++++++++-----
 README.md     | 13 ++++++++-----
 sqlite3-api.c | 25 +++++++++++++++----------
 4 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index ac979abd22..c32f088469 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ CFLAGS=-g3 -Wall -std=c99 $(INC)
 
 EMACS252=$(HOME)/test-emacs/bin/emacs
 EMACS251=$(HOME)/test-emacs-251/bin/emacs
+EMACS253=$(HOME)/test-emacs-253/bin/emacs
+
 SQLITE3_H=$(shell tools/find-sqlite3-h.sh $(INC))
 
 # Melpa package
@@ -12,7 +14,7 @@ PKG=sqlite3-api
 
 # dynamic module package
 MODULE=$(PKG)
-MODULE_VERSION=0.1
+MODULE_VERSION=0.11
 MODULE_BASENAME=$(MODULE)-$(MODULE_VERSION)
 MODULE_PKG_EL=$(MODULE_BASENAME)/$(MODULE)-pkg.el
 MODULE_TAR=$(MODULE_BASENAME).tar
@@ -49,3 +51,7 @@ test:
 # Emacs 25.1
 t251:
        $(EMACS251) -batch -Q -L . -l tests/regression.el
+
+# Emacs 25.1
+t253:
+       $(EMACS253) -batch -Q -L . -l tests/regression.el
diff --git a/README-in.md b/README-in.md
index 6ebdc8f24d..40c6af38cb 100644
--- a/README-in.md
+++ b/README-in.md
@@ -1,4 +1,4 @@
-# SQLite3 API v0.1 for Emacs 25+
+# SQLite3 API v0.11 for Emacs 25+
 `sqlite3-api` is a dynamic module for GNU Emacs 25+ that provides 
 direct access to the core SQLite3 C API from Emacs Lisp.
 ~~~el
@@ -12,7 +12,7 @@ direct access to the core SQLite3 C API from Emacs Lisp.
          ;; execute the SQL
         (sqlite3-step stmt)
         ;; call reset if you want to bind the SQL to a new set of variables
-        (sqlite3-reset stmt) )
+        (sqlite3-reset stmt))
 (sqlite3-finalize stmt)
 
 (setq stmt (sqlite3-prepare dbh "select * from temp"))
@@ -25,7 +25,7 @@ direct access to the core SQLite3 C API from Emacs Lisp.
 While this module provides only 14 functions (vs [200+ in the C 
API](https://sqlite.org/c3ref/funclist.html)), it should satisfy most
 users' needs.
 
-The current version is 0.1.
+The current version is v0.11.
 
 This is an alpha release so it might crash your Emacs. Save your work before 
you try it out!
 
@@ -108,9 +108,9 @@ Compile the supplied SQL statement and return a statement 
handle.
 This function calls 
[`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html) internally 
and raises 'sql-error in case of error.
 ### sqlite3-finalize
 ~~~el
-(sqlite3-finalize statement-handle)
+(sqlite3-finalize statement-handle1 statement-handle2 ...)
 ~~~
-Destroy a prepared statement.
+Destroy prepared statements.
 ### sqlite3-step
 ~~~el
 (sqlite3-step statement-handle)
@@ -293,6 +293,9 @@ For integers > 61 bits you can retrieve them as text as a 
workaround.
 The code is licensed under the [GNU GPL 
v3](https://www.gnu.org/licenses/gpl-3.0.html).
 
 ## Changelog
+*v0.11 - 2017-09-14*
+- `sqlite3-finalize` now accepts multiple handles.
+
 *v0.1 - 2017-09-04*
 - Emacs Lisp code removed. The package is now pure C.
 
diff --git a/README.md b/README.md
index eb0a4befb1..1fd2a8f298 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# SQLite3 API v0.1 for Emacs 25+
+# SQLite3 API v0.11 for Emacs 25+
 `sqlite3-api` is a dynamic module for GNU Emacs 25+ that provides 
 direct access to the core SQLite3 C API from Emacs Lisp.
 ~~~el
@@ -12,7 +12,7 @@ direct access to the core SQLite3 C API from Emacs Lisp.
          ;; execute the SQL
         (sqlite3-step stmt)
         ;; call reset if you want to bind the SQL to a new set of variables
-        (sqlite3-reset stmt) )
+        (sqlite3-reset stmt))
 (sqlite3-finalize stmt)
 
 (setq stmt (sqlite3-prepare dbh "select * from temp"))
@@ -25,7 +25,7 @@ direct access to the core SQLite3 C API from Emacs Lisp.
 While this module provides only 14 functions (vs [200+ in the C 
API](https://sqlite.org/c3ref/funclist.html)), it should satisfy most
 users' needs.
 
-The current version is 0.1.
+The current version is v0.11.
 
 This is an alpha release so it might crash your Emacs. Save your work before 
you try it out!
 
@@ -133,9 +133,9 @@ Compile the supplied SQL statement and return a statement 
handle.
 This function calls 
[`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html) internally 
and raises 'sql-error in case of error.
 ### <a name="3-4"/> sqlite3-finalize
 ~~~el
-(sqlite3-finalize statement-handle)
+(sqlite3-finalize statement-handle1 statement-handle2 ...)
 ~~~
-Destroy a prepared statement.
+Destroy prepared statements.
 ### <a name="3-5"/> sqlite3-step
 ~~~el
 (sqlite3-step statement-handle)
@@ -318,6 +318,9 @@ For integers > 61 bits you can retrieve them as text as a 
workaround.
 The code is licensed under the [GNU GPL 
v3](https://www.gnu.org/licenses/gpl-3.0.html).
 
 ## <a name="9"/> Changelog
+*v0.11 - 2017-09-14*
+- `sqlite3-finalize` now accepts multiple handles.
+
 *v0.1 - 2017-09-04*
 - Emacs Lisp code removed. The package is now pure C.
 
diff --git a/sqlite3-api.c b/sqlite3-api.c
index 27718e143a..11ac7a7b7e 100644
--- a/sqlite3-api.c
+++ b/sqlite3-api.c
@@ -764,18 +764,23 @@ static emacs_value sqlite3_api_finalize(
     emacs_value *args,
     void *ptr) {
   (void)ptr;
-  (void)n;
 
-  /* User passed a nil stmt */
-  if (!env->is_not_nil(env, args[0]))
-    return SYM(env, "nil");
+  INFO(env, "%s: entered", __func__);
 
-  sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]);
-  NON_LOCAL_EXIT_CHECK(env);
+  for (int i = 0; i < n; i++) {
+    /* User passed a nil stmt */
+    if (!env->is_not_nil(env, args[i]))
+      /* return SYM(env, "nil"); */
+      continue;
+
+    sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[i]);
+    NON_LOCAL_EXIT_CHECK(env);
+
+    sqlite3_finalize(stmt);
+    env->set_user_ptr(env, args[i], 0);
+    DEBUG(env, "%s: #%d finalized", __func__, i);
+  }
 
-  INFO(env, "%s: entered", __func__);
-  sqlite3_finalize(stmt);
-  env->set_user_ptr(env, args[0], 0);
   return SYM(env, "nil");
 }
 
@@ -965,7 +970,7 @@ int emacs_module_init(struct emacs_runtime *ert) {
         "Close a SQLite3 database." },
       { "sqlite3-prepare", 2, 2, sqlite3_api_prepare,
         "Prepare (compile) a SQL statement." },
-      { "sqlite3-finalize", 1, 1, sqlite3_api_finalize,
+      { "sqlite3-finalize", 1, 127, sqlite3_api_finalize,
         "Destroy a prepared statement." },
       { "sqlite3-changes", 1, 1, sqlite3_api_changes,
         "Count the number of rows modified." },



reply via email to

[Prev in Thread] Current Thread [Next in Thread]