Author: timbo
Date: Sun Nov 14 12:42:21 2004
New Revision: 579
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/lib/DBD/File.pm
dbi/trunk/lib/DBI/PurePerl.pm
Log:
Changed DBD::File to enable ShowErrorStatement by default.
Fixed DBI::PurePerl neat() to use double quotes for utf8.
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Sun Nov 14 12:42:21 2004
@@ -6,16 +6,20 @@
=head2 Changes in DBI 1.46 (svn rev XXX), 5th November 2004
- Fixed space-parsing bug in DBI::SQL::Nano thanks to Jeff Zucker.
+ Fixed parsing bugs in DBI::SQL::Nano thanks to Jeff Zucker.
Fixed a couple of bad links in docs thanks to Graham Barr.
Fixed test.pl Win32 undef warning thanks to H.Merijn Brand & David Repko.
Fixed minor issues in DBI::DBD::Metadata thanks to Steffen Goeldner.
+ Fixed DBI::PurePerl neat() to use double quotes for utf8.
- Changed use DBI qw(:utils) export tag to include $neat_maxlen.
+ Changed DBD::File to enable ShowErrorStatement by default,
+ which affects DBD::File subclasses such as DBD::CSV and DBD::DBM.
+ Changed use DBI qw(:utils) tag to include $neat_maxlen.
Updated Roadmap and ToDo.
Added data_string_diff() data_string_desc() and data_diff()
utility functions to help diagnose Unicode issues.
+ All can be imported via the use DBI qw(:utils) tag.
=head2 Changes in DBI 1.45 (svn rev 480), 6th October 2004
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Sun Nov 14 12:42:21 2004
@@ -1011,13 +1011,6 @@
sub data_diff {
my ($a, $b, $logical) = @_;
- require utf8;
-
- # hacks to cater for perl 5.6 for data_string_diff() & data_string_desc()
- *utf8::is_utf8 = sub {
- return (DBI::neat(shift) =~ /^"/); # XXX ugly hack, sufficient here
- } unless defined &utf8::is_utf8;
- *utf8::valid = sub { 1 } unless defined &utf8::valid;
my $diff = data_string_diff($a, $b);
return "" if $logical and !$diff;
@@ -1046,6 +1039,11 @@
return "String b is undef, string a has ".length($a)." characters"
if !defined $b;
}
+
+ require utf8;
+ # hack to cater for perl 5.6
+ *utf8::is_utf8 = sub { (DBI::neat(shift)=~/^"/) } unless defined
&utf8::is_utf8;
+
my @a_chars = (utf8::is_utf8($a)) ? unpack("U*", $a) : unpack("C*", $a);
my @b_chars = (utf8::is_utf8($b)) ? unpack("U*", $b) : unpack("C*", $b);
my $i = 0;
@@ -1071,10 +1069,16 @@
return "";
}
+
sub data_string_desc { # describe a data string
my ($a) = @_;
- require utf8;
require bytes;
+ require utf8;
+
+ # hacks to cater for perl 5.6
+ *utf8::is_utf8 = sub { (DBI::neat(shift)=~/^"/) } unless defined
&utf8::is_utf8;
+ *utf8::valid = sub { 1 } unless defined
&utf8::valid;
+
# Give sufficient info to help diagnose at least these kinds of situations:
# - valid UTF8 byte sequence but UTF8 flag not set
# (might be ascii so also need to check for hibit to make it worthwhile)
Modified: dbi/trunk/lib/DBD/File.pm
==============================================================================
--- dbi/trunk/lib/DBD/File.pm (original)
+++ dbi/trunk/lib/DBD/File.pm Sun Nov 14 12:42:21 2004
@@ -49,6 +49,7 @@
$attr->{Version} ||= ${$class . '::VERSION'};
($attr->{Name} = $class) =~ s/^DBD\:\:// unless $attr->{Name};
$drh = DBI::_new_drh($class . "::dr", $attr);
+ $drh->STORE(ShowErrorStatement => 1);
return $drh;
}
Modified: dbi/trunk/lib/DBI/PurePerl.pm
==============================================================================
--- dbi/trunk/lib/DBI/PurePerl.pm (original)
+++ dbi/trunk/lib/DBI/PurePerl.pm Sun Nov 14 12:42:21 2004
@@ -23,6 +23,13 @@
use Carp;
require Symbol;
+require utf8;
+*utf8::is_utf8 = sub { # hack for perl 5.6
+ require bytes;
+ return unless defined $_[0];
+ return !(length($_[0]) == bytes::length($_[0]))
+} unless defined &utf8::is_utf8;
+
$DBI::PurePerl = $ENV{DBI_PUREPERL} || 1;
$DBI::PurePerl::VERSION = sprintf "%d.%02d", '$Revision: 1.96 $ ' =~
/(\d+)\.(\d+)/;
$DBI::neat_maxlen ||= 400;
@@ -551,16 +558,18 @@
}
return (@_ >1) ? @new : $new[0];
}
+
sub neat {
my $v = shift;
return "undef" unless defined $v;
return $v if (($v & ~ $v) eq "0"); # is SvNIOK
+ my $quote = utf8::is_utf8($v) ? '"' : "'";
my $maxlen = shift || $DBI::neat_maxlen;
if ($maxlen && $maxlen < length($v) + 2) {
$v = substr($v,0,$maxlen-5);
$v .= '...';
}
- return "'$v'";
+ return "$quote$v$quote";
}
package