1
0
perl-Text-CSV_XS/perl-Text-CSV_XS.spec
Stephan Kulow 76d2dfa66d - update to 0.81
* Add is_missing ()
   * Doc overhaul
   * Fix Build on OpenVMS (RT#65654, Martin P.J. Zinser)
   * Fix SetDiag () leak (RT#66453, Sven Sch366ling)
   * Implement getline_all () and getaline_hr_all ()
   * Fixed another parsing for eol = \r (RT#61525)
   * Use correct type for STRLEN (HP-UX/PA-RISC/32)
   * More code coverage
   * EOF unreliable when line-end missing at eof
   * Internals now use warn () instead of (void)fprintf (stderr, ...)
     Now the test in t/80_diag also passes on Windows
   * Better parsing for eol = \r and set as such (RT#61525)
   * Workaround for AIX cpp bug (RT#62388, Jan Dubois)
   * Spelling fixes
   * Real eol support for parsing streams (beyond \n, \r and \r\n)
   * Clarify doc for always_quote to not quote undef fields
   * Clarify UTF8 process for print () and combine ()

OBS-URL: https://build.opensuse.org/package/show/devel:languages:perl/perl-Text-CSV_XS?expand=0&rev=14
2011-03-31 08:52:47 +00:00

133 lines
4.9 KiB
RPMSpec

#
# spec file for package perl-Text-CSV_XS (Version 0.81)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: perl-Text-CSV_XS
Version: 0.81
Release: 1
License: GPL+ or Artistic
%define cpan_name Text-CSV_XS
Summary: comma-separated values manipulation routines
Url: http://search.cpan.org/dist/Text-CSV_XS/
Group: Development/Libraries/Perl
#Source: http://www.cpan.org/authors/id/H/HM/HMBRAND/Text-CSV_XS-%{version}.tgz
Source: %{cpan_name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Config)
BuildRequires: perl(DynaLoader)
BuildRequires: perl(IO::Handle)
Requires: perl(DynaLoader)
Requires: perl(IO::Handle)
%{perl_requires}
%description
Text::CSV_XS provides facilities for the composition and decomposition of
comma-separated values. An instance of the Text::CSV_XS class can combine
fields into a CSV string and parse a CSV string into fields.
The module accepts either strings or files as input and can utilize any
user-specified characters as delimiters, separators, and escapes so it is
perhaps better called ASV (anything separated values) rather than just CSV.
Embedded newlines
*Important Note*: The default behavior is to only accept ASCII
characters. This means that fields can not contain newlines. If your
data contains newlines embedded in fields, or characters above 0x7e
(tilde), or binary data, you *must* set 'binary => 1' in the call to
'new'. To cover the widest range of parsing options, you will always
want to set binary.
But you still have the problem that you have to pass a correct line to
the 'parse' method, which is more complicated from the usual point of
usage:
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
while (<>) { # WRONG!
$csv->parse ($_);
my @fields = $csv->fields ();
will break, as the while might read broken lines, as that does not care
about the quoting. If you need to support embedded newlines, the way to
go is either
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
while (my $row = $csv->getline (*ARGV)) {
my @fields = @$row;
or, more safely in perl 5.6 and up
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
open my $io, "<", $file or die "$file: $!";
while (my $row = $csv->getline ($io)) {
my @fields = @$row;
Unicode (UTF8)
On parsing (both for 'getline' and 'parse'), if the source is marked
being UTF8, then all fields that are marked binary will also be be
marked UTF8.
For complete control over encoding, please use Text::CSV::Encoded:
use Text::CSV::Encoded;
my $csv = Text::CSV::Encoded->new ({
encoding_in => "iso-8859-1", # the encoding comes into Perl
encoding_out => "cp1252", # the encoding comes out of Perl
});
$csv = Text::CSV::Encoded->new ({ encoding => "utf8" });
# combine () and print () accept *literally* utf8 encoded data
# parse () and getline () return *literally* utf8 encoded data
$csv = Text::CSV::Encoded->new ({ encoding => undef }); # default
# combine () and print () accept UTF8 marked data
# parse () and getline () return UTF8 marked data
On combining ('print' and 'combine'), if any of the combining fields
was marked UTF8, the resulting string will be marked UTF8. Note however
that all fields 'before' the first field that was marked UTF8 and
contained 8-bit characters that were not upgraded to UTF8, these will
be bytes in the resulting string too, causing errors. If you pass data
of different encoding, or you don't know if there is different
encoding, force it to be upgraded before you pass them on:
$csv->print ($fh, [ map { utf8::upgrade (my $x = $_); $x } @data ]);
%prep
%setup -q -n %{cpan_name}-%{version}
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
%{__make} %{?_smp_mflags}
%check
%{__make} test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%clean
%{__rm} -rf %{buildroot}
%files -f %{name}.files
%defattr(644,root,root,755)
%doc ChangeLog README
%changelog