unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: Problems with guile-sqlite3
Date: Fri, 01 Apr 2011 16:33:02 +0200	[thread overview]
Message-ID: <m239m2f3dt.fsf@ohwell.denx.de> (raw)
In-Reply-To: <m3d3l6urwj.fsf@unquote.localdomain> (Andy Wingo's message of "Fri, 01 Apr 2011 13:34:20 +0200")

[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]

Hi Andy,

> On Thu 31 Mar 2011 18:18, Detlev Zundel <dzu@denx.de> writes:
>
>> Hi Andy,
>>
>>>> Indeed, there's no null-termination on this string.  I guess we need to
>>>> copy into a bytevector that is longer and provide a NUL byte.  Want to
>>>> patch that one too?
>>
>> The attached patches work for me.
>
> Thanks.  Please detabify the first one.  

Sure, no problem.

> Can you resubmit the second one also using the string->pointer
> encoding argument that I just pushed to Guile?  Thanks :-)

Ah, that makes the code a lot easier ;)

>> As a followup I'd really like to put a few statments into tests below
>> test/.  Can anyone point me to what functions (i.e. assert,...) I should
>> use in such tests?
>
> Sigh, it's a good question.  Guile has "(test-suite lib)" internally,
> which is quite nice, but not public.  Externally there are many things
> but none as nice.
>
> I guess I would say to just add some test scripts using the normal
> automake mechanism, and make them (exit 1) if there is an error.  You
> won't get a nice summary but it's better than nothing.

Ok, I needed to read up on the "normal automake mechanism", but I think
I understand.  The third patch prepares for real test cases ;)

Thanks
  Detlev

-- 
1. What is the best thing about Unix?
A: The community.
2. What is the worst thing about Unix?
A: That there are so many communities.         (Rob Pike)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Export-SQLITE_-constants.patch --]
[-- Type: text/x-diff, Size: 1197 bytes --]

From 5eef5b889a1e00b05a424fa27618b76a66a576fe Mon Sep 17 00:00:00 2001
From: Detlev Zundel <dzu@denx.de>
Date: Thu, 31 Mar 2011 18:14:06 +0200
Subject: [PATCH 1/3] Export SQLITE_* constants.

Signed-off-by: Detlev Zundel <dzu@denx.de>
---
 sqlite3.scm |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/sqlite3.scm b/sqlite3.scm
index c326da4..8a1e6f1 100644
--- a/sqlite3.scm
+++ b/sqlite3.scm
@@ -38,7 +38,24 @@
             sqlite-fold
             sqlite-map
             sqlite-reset
-            sqlite-finalize))
+            sqlite-finalize
+
+            SQLITE_OPEN_READONLY
+            SQLITE_OPEN_READWRITE
+            SQLITE_OPEN_CREATE
+            SQLITE_OPEN_DELETEONCLOSE
+            SQLITE_OPEN_EXCLUSIVE
+            SQLITE_OPEN_MAIN_DB
+            SQLITE_OPEN_TEMP_DB
+            SQLITE_OPEN_TRANSIENT_DB
+            SQLITE_OPEN_MAIN_JOURNAL
+            SQLITE_OPEN_TEMP_JOURNAL
+            SQLITE_OPEN_SUBJOURNAL
+            SQLITE_OPEN_MASTER_JOURNAL
+            SQLITE_OPEN_NOMUTEX
+            SQLITE_OPEN_FULLMUTEX
+            SQLITE_OPEN_SHAREDCACHE
+            SQLITE_OPEN_PRIVATECACHE))
 
 ;;
 ;; Utils
-- 
1.7.4.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Fix-and-simplify-foreign-string-conversions.patch --]
[-- Type: text/x-diff, Size: 1055 bytes --]

From 2be1beddc9d52664482d9d3e7f57e0a976baf5de Mon Sep 17 00:00:00 2001
From: Detlev Zundel <dzu@denx.de>
Date: Thu, 31 Mar 2011 18:15:12 +0200
Subject: [PATCH 2/3] Fix and simplify foreign string conversions

Use the versions of string->pointer and pointer->string that accept an
encoding parameter.

The previous version of string->utf8-pointer missed the null termination
of the string.

Signed-off-by: Detlev Zundel <dzu@denx.de>
---
 sqlite3.scm |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/sqlite3.scm b/sqlite3.scm
index 8a1e6f1..3369e02 100644
--- a/sqlite3.scm
+++ b/sqlite3.scm
@@ -61,15 +61,10 @@
 ;; Utils
 ;;
 (define (string->utf8-pointer s)
-  (bytevector->pointer (string->utf8 s)))
-
-(define strlen
-  (pointer->procedure size_t
-                      (dynamic-pointer "strlen" (dynamic-link))
-                      '(*)))
+  (string->pointer s "utf-8"))
 
 (define (utf8-pointer->string p)
-  (utf8->string (pointer->bytevector p (strlen p))))
+  (pointer->string p -1 "utf-8"))
 
 
 ;;
-- 
1.7.4.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Fix-command-line-parameter-for-test-execution.patch --]
[-- Type: text/x-diff, Size: 721 bytes --]

From 00c4543c9844ac584929a16e4d2d44b577b6dea1 Mon Sep 17 00:00:00 2001
From: Detlev Zundel <dzu@denx.de>
Date: Fri, 1 Apr 2011 16:30:44 +0200
Subject: [PATCH 3/3] Fix command line parameter for test execution

Signed-off-by: Detlev Zundel <dzu@denx.de>
---
 Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 509d1be..ae9a6a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,6 @@ SUFFIXES = .scm .go
 
 TESTS = 					\
 	tests/basic.test
-TESTS_ENVIRONMENT = $(abs_top_builddir)/env $(GUILE) --no-autocompile
+TESTS_ENVIRONMENT = $(abs_top_builddir)/env $(GUILE) --no-auto-compile
 
 EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES) $(TESTS)
-- 
1.7.4.1


  reply	other threads:[~2011-04-01 14:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30 22:52 Problems with guile-sqlite3 Detlev Zundel
2011-03-31 10:25 ` Andy Wingo
2011-03-31 14:03   ` Detlev Zundel
2011-03-31 16:18     ` Detlev Zundel
2011-04-01  5:33       ` David Pirotte
2011-04-01  9:12         ` Detlev Zundel
2011-04-01 23:05           ` David Pirotte
2011-04-04 16:22             ` Detlev Zundel
2011-04-04 20:50               ` Andy Wingo
2011-04-04 21:28                 ` Detlev Zundel
2011-04-11 15:05                   ` Detlev Zundel
2011-04-20 15:22               ` David Pirotte
2011-04-20 15:51                 ` Detlev Zundel
2011-04-21 12:17                   ` Andy Wingo
2011-04-21 21:58                     ` David Pirotte
2011-04-01 11:34       ` Andy Wingo
2011-04-01 14:33         ` Detlev Zundel [this message]
2011-04-01 14:49           ` Andy Wingo
2011-03-31 14:28   ` Ludovic Courtès
2011-03-31 14:54     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m239m2f3dt.fsf@ohwell.denx.de \
    --to=dzu@denx.de \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).