2011-04-14 08:00:59 +00:00
|
|
|
#
|
2015-04-17 11:43:51 +00:00
|
|
|
# spec file for package perl-Convert-Scalar
|
2011-04-14 08:00:59 +00:00
|
|
|
#
|
2024-07-19 22:36:35 +00:00
|
|
|
# Copyright (c) 2024 SUSE LLC
|
2011-04-14 08:00:59 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2024-07-19 22:36:35 +00:00
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
2011-04-14 08:00:59 +00:00
|
|
|
#
|
|
|
|
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2024-07-19 22:36:35 +00:00
|
|
|
%define cpan_name Convert-Scalar
|
2011-04-14 08:00:59 +00:00
|
|
|
Name: perl-Convert-Scalar
|
2024-07-19 22:36:35 +00:00
|
|
|
Version: 1.120.0
|
2015-04-17 11:43:51 +00:00
|
|
|
Release: 0
|
2024-07-19 22:36:35 +00:00
|
|
|
# 1.12 -> normalize -> 1.120.0
|
|
|
|
%define cpan_version 1.12
|
|
|
|
License: CHECK(Artistic-1.0 or GPL-1.0-or-later)
|
|
|
|
Summary: Convert between different representations of perl scalars
|
|
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
|
|
Source0: https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/%{cpan_name}-%{cpan_version}.tar.gz
|
2015-04-17 11:43:51 +00:00
|
|
|
Source1: cpanspec.yml
|
2025-08-12 18:12:43 +02:00
|
|
|
Source100: README.md
|
2011-04-14 08:00:59 +00:00
|
|
|
BuildRequires: perl
|
|
|
|
BuildRequires: perl-macros
|
2015-09-21 04:53:42 +00:00
|
|
|
BuildRequires: perl(Canary::Stability)
|
2024-07-19 22:36:35 +00:00
|
|
|
BuildRequires: perl(ExtUtils::MakeMaker) >= 6.6
|
2017-09-03 08:59:51 +00:00
|
|
|
BuildRequires: perl(ExtUtils::ParseXS) >= 3.28
|
2024-07-19 22:36:35 +00:00
|
|
|
Provides: perl(Convert::Scalar) = %{version}
|
|
|
|
%undefine __perllib_provides
|
2011-04-14 08:00:59 +00:00
|
|
|
%{perl_requires}
|
|
|
|
|
|
|
|
%description
|
|
|
|
This module exports various internal perl methods that change the internal
|
|
|
|
representation or state of a perl scalar. All of these work in-place, that
|
|
|
|
is, they modify their scalar argument. No functions are exported by
|
|
|
|
default.
|
|
|
|
|
|
|
|
The following export tags exist:
|
|
|
|
|
|
|
|
:utf8 all functions with utf8 in their name
|
|
|
|
:taint all functions with taint in their name
|
|
|
|
:refcnt all functions with refcnt in their name
|
|
|
|
:ok all *ok-functions.
|
|
|
|
|
|
|
|
* utf8 scalar[, mode]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns true when the given scalar is marked as utf8, false otherwise. If
|
|
|
|
the optional mode argument is given, also forces the interpretation of the
|
|
|
|
string to utf8 (mode true) or plain bytes (mode false). The actual (byte-)
|
|
|
|
content is not changed. The return value always reflects the state before
|
|
|
|
any modification is done.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
This function is useful when you "import" utf8-data into perl, or when some
|
|
|
|
external function (e.g. storing/retrieving from a database) removes the
|
|
|
|
utf8-flag.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_on scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Similar to 'utf8 scalar, 1', but additionally returns the scalar (the
|
|
|
|
argument is still modified in-place).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_off scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Similar to 'utf8 scalar, 0', but additionally returns the scalar (the
|
|
|
|
argument is still modified in-place).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_valid scalar [Perl 5.7]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns true if the bytes inside the scalar form a valid utf8 string, false
|
|
|
|
otherwise (the check is independent of the actual encoding perl thinks the
|
|
|
|
string is in).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_upgrade scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Convert the string content of the scalar in-place to its UTF8-encoded form
|
|
|
|
(and also returns it).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_downgrade scalar[, fail_ok=0]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Attempt to convert the string content of the scalar from UTF8-encoded to
|
|
|
|
ISO-8859-1. This may not be possible if the string contains characters that
|
|
|
|
cannot be represented in a single byte; if this is the case, it leaves the
|
|
|
|
scalar unchanged and either returns false or, if 'fail_ok' is not true (the
|
|
|
|
default), croaks.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_encode scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Convert the string value of the scalar to UTF8-encoded, but then turn off
|
|
|
|
the 'SvUTF8' flag so that it looks like bytes to perl again. (Might be
|
|
|
|
removed in future versions).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* utf8_length scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns the number of characters in the string, counting wide UTF8
|
|
|
|
characters as a single character, independent of wether the scalar is
|
|
|
|
marked as containing bytes or mulitbyte characters.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
2015-04-17 11:43:51 +00:00
|
|
|
* $old = readonly scalar[, $new]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns whether the scalar is currently readonly, and sets or clears the
|
|
|
|
readonly status if a new status is given.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
|
|
|
* readonly_on scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Sets the readonly flag on the scalar.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
|
|
|
* readonly_off scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Clears the readonly flag on the scalar.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2011-04-14 08:00:59 +00:00
|
|
|
* unmagic scalar, type
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Remove the specified magic from the scalar (DANGEROUS!).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* weaken scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Weaken a reference. (See also WeakRef).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* taint scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Taint the scalar.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* tainted scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
returns true when the scalar is tainted, false otherwise.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* untaint scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Remove the tainted flag from the specified scalar.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
2015-04-17 11:43:51 +00:00
|
|
|
* length = len scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns SvLEN (scalar), that is, the actual number of bytes allocated to
|
|
|
|
the string value, or 'undef', is the scalar has no string value.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
|
|
|
* scalar = grow scalar, newlen
|
2011-04-14 08:00:59 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Sets the memory area used for the scalar to the given length, if the
|
|
|
|
current length is less than the new value. This does not affect the
|
|
|
|
contents of the scalar, but is only useful to "pre-allocate" memory space
|
|
|
|
if you know the scalar will grow. The return value is the modified scalar
|
|
|
|
(the scalar is modified in-place).
|
2011-04-14 08:00:59 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
* scalar = extend scalar, addlen=64
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Reserves enough space in the scalar so that addlen bytes can be appended
|
|
|
|
without reallocating it. The actual contents of the scalar will not be
|
|
|
|
affected. The modified scalar will also be returned.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
This function is meant to make append workloads efficient - if you append a
|
|
|
|
short string to a scalar many times (millions of times), then perl will
|
|
|
|
have to reallocate and copy the scalar basically every time.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
If you instead use 'extend $scalar, length $shortstring', then
|
|
|
|
Convert::Scalar will use a "size to next power of two, roughly" algorithm,
|
|
|
|
so as the scalar grows, perl will have to resize and copy it less and less
|
|
|
|
often.
|
|
|
|
|
|
|
|
* nread = extend_read fh, scalar, addlen=64
|
|
|
|
|
|
|
|
Calls 'extend scalar, addlen' to ensure some space is available, then do
|
|
|
|
the equivalent of 'sysread' to the end, to try to fill the extra space.
|
|
|
|
Returns how many bytes have been read, '0' on EOF or undef> on eror, just
|
|
|
|
like 'sysread'.
|
|
|
|
|
|
|
|
This function is useful to implement many protocols where you read some
|
|
|
|
data, see if it is enough to decode, and if not, read some more, where the
|
|
|
|
naive or easy way of doing this would result in bad performance.
|
|
|
|
|
|
|
|
* nread = read_all fh, scalar, length
|
|
|
|
|
|
|
|
Tries to read 'length' bytes into 'scalar'. Unlike 'read' or 'sysread', it
|
|
|
|
will try to read more bytes if not all bytes could be read in one go (this
|
|
|
|
is often called 'xread' in C).
|
|
|
|
|
|
|
|
Returns the total nunmber of bytes read (normally 'length', unless an error
|
|
|
|
or EOF occured), '0' on EOF and 'undef' on errors.
|
|
|
|
|
|
|
|
* nwritten = write_all fh, scalar
|
|
|
|
|
|
|
|
Like 'readall', but for writes - the equivalent of the 'xwrite' function
|
|
|
|
often seen in C.
|
2015-04-17 11:43:51 +00:00
|
|
|
|
2011-04-14 08:00:59 +00:00
|
|
|
* refcnt scalar[, newrefcnt]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Returns the current reference count of the given scalar and optionally sets
|
|
|
|
it to the given reference count.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* refcnt_inc scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Increments the reference count of the given scalar inplace.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* refcnt_dec scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Decrements the reference count of the given scalar inplace. Use 'weaken'
|
|
|
|
instead if you understand what this function is fore. Better yet: don't use
|
|
|
|
this module in this case.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* refcnt_rv scalar[, newrefcnt]
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Works like 'refcnt', but dereferences the given reference first. This is
|
|
|
|
useful to find the reference count of arrays or hashes, which cannot be
|
|
|
|
passed directly. Remember that taking a reference of some object increases
|
|
|
|
it's reference count, so the reference count used by the '*_rv'-functions
|
|
|
|
tend to be one higher.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* refcnt_inc_rv scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Works like 'refcnt_inc', but dereferences the given reference first.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* refcnt_dec_rv scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Works like 'refcnt_dec', but dereferences the given reference first.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
* ok scalar
|
|
|
|
|
|
|
|
* uok scalar
|
|
|
|
|
|
|
|
* rok scalar
|
|
|
|
|
|
|
|
* pok scalar
|
|
|
|
|
|
|
|
* nok scalar
|
|
|
|
|
|
|
|
* niok scalar
|
|
|
|
|
2017-09-03 08:59:51 +00:00
|
|
|
Calls SvOK, SvUOK, SvROK, SvPOK, SvNOK or SvNIOK on the given scalar,
|
|
|
|
respectively.
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
%prep
|
2024-07-19 22:36:35 +00:00
|
|
|
%autosetup -n %{cpan_name}-%{cpan_version}
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
%build
|
2024-07-19 22:36:35 +00:00
|
|
|
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
|
|
|
|
%make_build
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
%check
|
2024-07-19 22:36:35 +00:00
|
|
|
make test
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
%install
|
|
|
|
%perl_make_install
|
|
|
|
%perl_process_packlist
|
|
|
|
%perl_gen_filelist
|
|
|
|
|
|
|
|
%files -f %{name}.files
|
2017-09-03 08:59:51 +00:00
|
|
|
%doc Changes README
|
|
|
|
%license COPYING
|
2011-04-14 08:00:59 +00:00
|
|
|
|
|
|
|
%changelog
|