1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

returning an array should be better

This commit is contained in:
Kenichi Ishigaki 2010-05-21 03:58:11 +00:00
parent 937f856f37
commit 1c50bae61b
4 changed files with 22 additions and 16 deletions

View file

@ -205,11 +205,20 @@ MODULE = DBD::SQLite PACKAGE = DBD::SQLite
PROTOTYPES: ENABLE PROTOTYPES: ENABLE
SV * static int
compile_options() compile_options()
CODE: CODE:
ST(0) = (SV*)sqlite_compile_options(); int n = 0;
XSRETURN(1); AV* av = (AV*)sqlite_compile_options();
if (av) {
int i;
n = AvFILL(av) + 1;
EXTEND(sp, n);
for (i = 0; i < n; i++) {
PUSHs(AvARRAY(av)[i]);
}
}
XSRETURN(n);
static int static int
OK() OK()

View file

@ -990,26 +990,23 @@ sqlite_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *
* Driver Private Methods * Driver Private Methods
*-----------------------------------------------------*/ *-----------------------------------------------------*/
SV * AV *
sqlite_compile_options() sqlite_compile_options()
{ {
dTHX; dTHX;
int i = 0; int i = 0;
const char *option; const char *option;
#if SQLITE_VERSION_NUMBER < 3006023
return &PL_sv_undef;
#endif
#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
return &PL_sv_undef;
#endif
AV *av = newAV(); AV *av = newAV();
#if SQLITE_VERSION_NUMBER >= 3006023
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
while(option = sqlite3_compileoption_get(i++)) { while(option = sqlite3_compileoption_get(i++)) {
av_push(av, newSVpv(option, 0)); av_push(av, newSVpv(option, 0));
} }
#endif
#endif
return sv_2mortal(newRV_noinc((SV*)av)); return (AV*)sv_2mortal((SV*)av);
} }
int int

View file

@ -1442,7 +1442,7 @@ sqlite3 extensions. After the call, you can load extensions like this:
=head2 DBD::SQLite::compile_options() =head2 DBD::SQLite::compile_options()
Returns an array reference of compile options (available since sqlite 3.6.23, Returns an array of compile options (available since sqlite 3.6.23,
bundled in DBD::SQLite 1.30_01), or undef if the bundled library is old or bundled in DBD::SQLite 1.30_01), or undef if the bundled library is old or
compiled with SQLITE_OMIT_COMPILEOPTION_DIAGS. compiled with SQLITE_OMIT_COMPILEOPTION_DIAGS.

View file

@ -17,7 +17,7 @@ use_ok('t::lib::Test');
diag("\$DBI::VERSION=$DBI::VERSION"); diag("\$DBI::VERSION=$DBI::VERSION");
if (my $compile_options = DBD::SQLite::compile_options()) { if (my @compile_options = DBD::SQLite::compile_options()) {
diag("Compile Options:"); diag("Compile Options:");
diag(join "", map { " $_\n" } @$compile_options); diag(join "", map { " $_\n" } @compile_options);
} }