Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sprintf behavior or documentation bug #14773

Closed
p5pRT opened this issue Jun 24, 2015 · 11 comments
Closed

sprintf behavior or documentation bug #14773

p5pRT opened this issue Jun 24, 2015 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 24, 2015

Migrated from rt.perl.org#125471 (status was 'resolved')

Searchable as RT125471$

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2015

From saint.snit@gmail.com

This is a bug report for perl from saint.snit@​gmail.com,
generated with the help of perlbug 1.40 running under perl 5.20.2.

Hi,

I've found a discrepancy between documentation and behavior. I'm not
sure which is correct.

perldoc -f sprintf says, "When a space and a plus sign are given as
the flags at once, a plus sign is used to prefix a positive number."
This is not accurate. As the documentation notes,

printf '<%+ d>', 12; # prints "<+12>"

However, the plus sign is printed even in the case of one number that
isn't positive​:

printf '<%+ d>', 0; # prints "<+0>" instead of "<0>" or "< 0>"

Is the documentation supposed to say "a plus sign is used to prefix a
nonnegative number"? Or is the combination of space and + supposed to
inhibit the printing of a plus sign before a 0? The latter makes more
sense, since there seems to be no other way to inhibit the illogical
"+0" output while retaining the + for positive numbers. (Why isn't this
simply the default for all uses of the + flag?)

Thank you.


Flags​:
  category=library
  severity=low


Site configuration information for perl 5.20.2​:

Configured by Gentoo at Mon Apr 6 15​:25​:39 CDT 2015.

Summary of my perl5 (revision 5 version 20 subversion 2) configuration​:
 
  Platform​:
  osname=linux, osvers=3.12.13-gentoo-3.12.13-custom,
archname=i686-linux
  uname='linux evo 3.12.13-gentoo-3.12.13-custom #3 smp sat jul 12
18​:05​:24 cdt 2014 i686 intel(r) pentium(r) 4 cpu 1.70ghz genuineintel
gnulinux '
  config_args='-des -Duseshrplib -Darchname=i686-linux
-Dcc=i686-pc-linux-gnu-gcc -Doptimize=-O2 -march=native -pipe
-Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dinstallprefix=/usr
-Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin
-Dprivlib=/usr/lib/perl5/5.20.2 -Darchlib=/usr/lib/perl5/5.20.2/i686-linux
-Dsitelib=/usr/local/lib/perl5/5.20.2
-Dsitearch=/usr/local/lib/perl5/5.20.2/i686-linux
-Dvendorlib=/usr/lib/perl5/vendor_perl/5.20.2
-Dvendorarch=/usr/lib/perl5/vendor_perl/5.20.2/i686-linux
-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3
-Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3
-Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3
-Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.20.2
-Dlocincpth=/usr/include -Dglibpth=/lib /usr/lib -Duselargefiles
-Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost
-Dperladmin=root@​localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm
-Di_gdbm -Di_db -DDEBUGGING=none -Dinc_version_list=5.20.0/i686-linux
5.20.0 5.20.1/i686-linux 5.20.1 -Dnoextensions=ODBM_File'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='i686-pc-linux-gnu-gcc', ccflags ='-fwrapv -fno-strict-aliasing
-pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2 -march=native -pipe',
  cppflags='-fwrapv -fno-strict-aliasing -pipe'
  ccversion='', gccversion='4.8.3', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='i686-pc-linux-gnu-gcc', ldflags ='-Wl,-O1 -Wl,--as-needed'
  libpth=/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include-fixed /usr/lib
/lib/../lib /usr/lib/../lib /lib
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.19.so, so=so, useshrplib=true, libperl=libperl.so.5.20.2
  gnulibc_version='2.19'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -march=native -pipe
-Wl,-O1 -Wl,--as-needed'

Locally applied patches​:
  gentoo/hints_hpux - Fix hpux hints
  gentoo/aix_soname - aix gcc detection and shared library soname
support
  gentoo/EUMM-RUNPATH - https://bugs.gentoo.org/105054
cpan/ExtUtils-MakeMaker​: drop $PORTAGE_TMPDIR from LD_RUN_PATH
  gentoo/config_over - Remove -rpath and append LDFLAGS to lddlflags
  gentoo/opensolaris_headers - [PATCH] Add headers for opensolaris
  gentoo/patchlevel - List packaged patches for perl-5.20.2(#1)
in patchlevel.h
  gentoo/cpanplus_definstalldirs - Configure CPANPLUS to use the site
directories by default.
  gentoo/cleanup-paths - [PATCH] Cleanup PATH and shrpenv
  gentoo/enc2xs - Tweak enc2xs to follow symlinks and ignore missing
@​INC directories.
  gentoo/enc2xs_checksums -
  gentoo/darwin-cc-ld - https://bugs.gentoo.org/297751 [PATCH] darwin​:
Use $CC to link
  gentoo/cpan_definstalldirs - Provide a sensible INSTALLDIRS default
for modules installed from CPAN.
  gentoo/interix - [PATCH] Fix interix hints
  gentoo/create_libperl_soname - https://bugs.gentoo.org/286840 [PATCH]
Set libperl soname
  gentoo/mod_paths - Add /etc/perl to @​INC
  gentoo/EUMM_delete_packlist -
  gentoo/drop_fstack_protector - https://bugs.gentoo.org/348557 [PATCH]
Don't force -fstack-protector on everyone
  gentoo/usr_local - [PATCH] Remove /usr/local paths
  gentoo/D-SHA-CFLAGS - https://bugs.gentoo.org/506818 [PATCH] Do not
set custom CFLAGS in cpan/Digest-SHA
  gentoo/io_socket_ip_tests -
  debian/cpan-missing-site-dirs - Fix CPAN​::FirstTime defaults with
nonexisting site dirs if a parent is writable
  debian/regcomp-mips-optim - Downgrade the optimization of regcomp.c
on mips and mipsel due to a gcc-4.9 bug
  debian/perldoc-less-R - Tell the 'less' pager to allow terminal
escape sequences
  debian/makemaker-pasthru - Pass LD settings through to subdirectories
  fixes/net_smtp_docs - [rt.cpan.org #36038] Document the Net​::SMTP
'Port' option
  fixes/memoize_storable_nstore - [rt.cpan.org #77790]
Memoize​::Storable​: respect 'nstore' option not respected
  fixes/document_makemaker_ccflags - [rt.cpan.org #68613] Document
that CCFLAGS should include $Config{ccflags}


@​INC for perl 5.20.2​:
  /etc/perl
  /usr/local/lib/perl5/5.20.2/i686-linux
  /usr/local/lib/perl5/5.20.2
  /usr/lib/perl5/vendor_perl/5.20.2/i686-linux
  /usr/lib/perl5/vendor_perl/5.20.2
  /usr/local/lib/perl5
  /usr/lib/perl5/vendor_perl/5.20.1/i686-linux
  /usr/lib/perl5/vendor_perl/5.20.1
  /usr/lib/perl5/vendor_perl
  /usr/lib/perl5/5.20.2/i686-linux
  /usr/lib/perl5/5.20.2
  .


Environment for perl 5.20.2​:
  HOME=/home/vax
  LANG=en_US
  LANGUAGE (unset)
  LC_COLLATE=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/vax/bin​:/usr/local/bin​:/usr/bin​:/bin​:/opt/bin​:/usr/i686-pc-linux-gnu/gcc-bin/4.7.3​:/usr/games/bin​:/sbin​:/usr/sbin​:/usr/games/bin​:./bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2015

From @cowens

SUSv3 says "+ The result of a signed conversion shall always begin with a
sign ('+' or '-'). The conversion shall begin with a sign only when a
negative value is converted if this flag is not specified."

This tells me that our documentation incorrectly used the word positive as
the opposite of negative forgetting that 0 is neither. Patch to correct
documentation follows.

Inline Patch
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 650ad0e..a781158 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -7244,10 +7244,15 @@ For example:
   printf '<%#B>',  12;   # prints "<0B1100>"

 When a space and a plus sign are given as the flags at once,
-a plus sign is used to prefix a positive number.
-
-  printf '<%+ d>', 12;   # prints "<+12>"
-  printf '<% +d>', 12;   # prints "<+12>"
+a plus sign is used to prefix a non-negative number in addition
+to the default prefixing of negative numbers.
+
+  printf '<%+ d>', -12; # prints "<-12>"
+  printf '<% +d>', -12; # prints "<-12>"
+  printf '<%+ d>', 0;   # prints "<+0>"
+  printf '<% +d>', 0;   # prints "<+0>"
+  printf '<%+ d>', 12;  # prints "<+12>"
+  printf '<% +d>', 12;  # prints "<+12>"

 When the # flag and a precision are given in the %o conversion,
 the precision is incremented if it's necessary for the leading "0".



On Tue, Jun 23, 2015 at 10:46 PM via RT wrote:

# New Ticket Created by
# Please include the string​: [perl #125471]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=125471 >

This is a bug report for perl from saint.snit@​gmail.com,
generated with the help of perlbug 1.40 running under perl 5.20.2.

Hi,

I've found a discrepancy between documentation and behavior. I'm not
sure which is correct.

perldoc -f sprintf says, "When a space and a plus sign are given as
the flags at once, a plus sign is used to prefix a positive number."
This is not accurate. As the documentation notes,

printf '<%+ d>', 12; # prints "<+12>"

However, the plus sign is printed even in the case of one number that
isn't positive​:

printf '<%+ d>', 0; # prints "<+0>" instead of "<0>" or "< 0>"

Is the documentation supposed to say "a plus sign is used to prefix a
nonnegative number"? Or is the combination of space and + supposed to
inhibit the printing of a plus sign before a 0? The latter makes more
sense, since there seems to be no other way to inhibit the illogical
"+0" output while retaining the + for positive numbers. (Why isn't this
simply the default for all uses of the + flag?)

Thank you.
---
Flags​:
category=library
severity=low
---
Site configuration information for perl 5.20.2​:

Configured by Gentoo at Mon Apr 6 15​:25​:39 CDT 2015.

Summary of my perl5 (revision 5 version 20 subversion 2) configuration​:

Platform​:
osname=linux, osvers=3.12.13-gentoo-3.12.13-custom,
archname=i686-linux
uname='linux evo 3.12.13-gentoo-3.12.13-custom #3 smp sat jul 12
18​:05​:24 cdt 2014 i686 intel(r) pentium(r) 4 cpu 1.70ghz genuineintel
gnulinux '
config_args='-des -Duseshrplib -Darchname=i686-linux
-Dcc=i686-pc-linux-gnu-gcc -Doptimize=-O2 -march=native -pipe
-Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dinstallprefix=/usr
-Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin
-Dprivlib=/usr/lib/perl5/5.20.2 -Darchlib=/usr/lib/perl5/5.20.2/i686-linux
-Dsitelib=/usr/local/lib/perl5/5.20.2
-Dsitearch=/usr/local/lib/perl5/5.20.2/i686-linux
-Dvendorlib=/usr/lib/perl5/vendor_perl/5.20.2
-Dvendorarch=/usr/lib/perl5/vendor_perl/5.20.2/i686-linux
-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3
-Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3
-Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3
-Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.20.2
-Dlocincpth=/usr/include -Dglibpth=/lib /usr/lib -Duselargefiles
-Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost
-Dperladmin=root@​localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm
-Di_gdbm -Di_db -DDEBUGGING=none -Dinc_version_list=5.20.0/i686-linux
5.20.0 5.20.1/i686-linux 5.20.1 -Dnoextensions=ODBM_File'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='i686-pc-linux-gnu-gcc', ccflags ='-fwrapv -fno-strict-aliasing
-pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -march=native -pipe',
cppflags='-fwrapv -fno-strict-aliasing -pipe'
ccversion='', gccversion='4.8.3', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries​:
ld='i686-pc-linux-gnu-gcc', ldflags ='-Wl,-O1 -Wl,--as-needed'
libpth=/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include-fixed /usr/lib
/lib/../lib /usr/lib/../lib /lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.19.so, so=so, useshrplib=true, libperl=libperl.so.5.20.2
gnulibc_version='2.19'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -march=native -pipe
-Wl,-O1 -Wl,--as-needed'

Locally applied patches​:
gentoo/hints_hpux - Fix hpux hints
gentoo/aix_soname - aix gcc detection and shared library soname
support
gentoo/EUMM-RUNPATH - https://bugs.gentoo.org/105054
cpan/ExtUtils-MakeMaker
<https://bugs.gentoo.org/105054cpan/ExtUtils-MakeMaker>: drop
$PORTAGE_TMPDIR from LD_RUN_PATH
gentoo/config_over - Remove -rpath and append LDFLAGS to lddlflags
gentoo/opensolaris_headers - [PATCH] Add headers for opensolaris
gentoo/patchlevel - List packaged patches for perl-5.20.2(#1)
in patchlevel.h
gentoo/cpanplus_definstalldirs - Configure CPANPLUS to use the site
directories by default.
gentoo/cleanup-paths - [PATCH] Cleanup PATH and shrpenv
gentoo/enc2xs - Tweak enc2xs to follow symlinks and ignore missing
@​INC directories.
gentoo/enc2xs_checksums -
gentoo/darwin-cc-ld - https://bugs.gentoo.org/297751 [PATCH] darwin​:
Use $CC to link
gentoo/cpan_definstalldirs - Provide a sensible INSTALLDIRS default
for modules installed from CPAN.
gentoo/interix - [PATCH] Fix interix hints
gentoo/create_libperl_soname - https://bugs.gentoo.org/286840 [PATCH]
Set libperl soname
gentoo/mod_paths - Add /etc/perl to @​INC
gentoo/EUMM_delete_packlist -
gentoo/drop_fstack_protector - https://bugs.gentoo.org/348557 [PATCH]
Don't force -fstack-protector on everyone
gentoo/usr_local - [PATCH] Remove /usr/local paths
gentoo/D-SHA-CFLAGS - https://bugs.gentoo.org/506818 [PATCH] Do not
set custom CFLAGS in cpan/Digest-SHA
gentoo/io_socket_ip_tests -
debian/cpan-missing-site-dirs - Fix CPAN​::FirstTime defaults with
nonexisting site dirs if a parent is writable
debian/regcomp-mips-optim - Downgrade the optimization of regcomp.c
on mips and mipsel due to a gcc-4.9 bug
debian/perldoc-less-R - Tell the 'less' pager to allow terminal
escape sequences
debian/makemaker-pasthru - Pass LD settings through to subdirectories
fixes/net_smtp_docs - [rt.cpan.org #36038] Document the Net​::SMTP
'Port' option
fixes/memoize_storable_nstore - [rt.cpan.org #77790]
Memoize​::Storable​: respect 'nstore' option not respected
fixes/document_makemaker_ccflags - [rt.cpan.org #68613] Document
that CCFLAGS should include $Config{ccflags}

---
@​INC for perl 5.20.2​:
/etc/perl
/usr/local/lib/perl5/5.20.2/i686-linux
/usr/local/lib/perl5/5.20.2
/usr/lib/perl5/vendor_perl/5.20.2/i686-linux
/usr/lib/perl5/vendor_perl/5.20.2
/usr/local/lib/perl5
/usr/lib/perl5/vendor_perl/5.20.1/i686-linux
/usr/lib/perl5/vendor_perl/5.20.1
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.20.2/i686-linux
/usr/lib/perl5/5.20.2
.

---
Environment for perl 5.20.2​:
HOME=/home/vax
LANG=en_US
LANGUAGE (unset)
LC_COLLATE=C
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/home/vax/bin​:/usr/local/bin​:/usr/bin​:/bin​:/opt/bin​:/usr/i686-pc-linux-gnu/gcc-bin/4.7.3​:/usr/games/bin​:/sbin​:/usr/sbin​:/usr/games/bin​:./bin
PERL_BADLANG (unset)
SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2015

From @tonycoz

On Tue Jun 23 19​:46​:09 2015, saint.snit@​gmail.com wrote​:

This is a bug report for perl from saint.snit@​gmail.com,
generated with the help of perlbug 1.40 running under perl 5.20.2.

Hi,

I've found a discrepancy between documentation and behavior. I'm not
sure which is correct.

perldoc -f sprintf says, "When a space and a plus sign are given as
the flags at once, a plus sign is used to prefix a positive number."
This is not accurate. As the documentation notes,

printf '<%+ d>', 12; # prints "<+12>"

However, the plus sign is printed even in the case of one number that
isn't positive​:

printf '<%+ d>', 0; # prints "<+0>" instead of "<0>" or "< 0>"

Is the documentation supposed to say "a plus sign is used to prefix a
nonnegative number"? Or is the combination of space and + supposed to
inhibit the printing of a plus sign before a 0? The latter makes more
sense, since there seems to be no other way to inhibit the illogical
"+0" output while retaining the + for positive numbers. (Why isn't
this
simply the default for all uses of the + flag?)

I expect it's meant to ignore the space flag if the + flag is present, perl's sprintf() formatting mostly follows the C standard where applicable, which states​:

  If the space and + flags both appear, the space flag is ignored.

So it looks like​:

When a space and a plus sign are given as the flags at once,
a plus sign is used to prefix a positive number.

should be​:

When a space and a plus sign are given as the flags at once,
a plus sign is used to prefix a non-negative number.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 25, 2015

From saint.snit@gmail.com

perl's sprintf() formatting mostly follows the C standard where applicable, which states​:

If the space and + flags both appear, the space flag is ignored.

This is a *much* clearer way to explain it than documenting the combined behavior anew.

Even if the second explanation is fixed to say "nonnegative" rather than "positive," repeating the explanation at all only leaves the reader scrutinizing the two behavior descriptions to see what, if anything, is different. On the other hand, if you just say that adding a space has no effect on the +, the user will know immediately what to expect--and there's no chance of getting details wrong in the repeated explanation, because there isn't one.

The benefits of modularization are just as applicable to documentation as to code. :-)

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2015

From @jkeenan

On Thu Jun 25 06​:08​:14 2015, saint.snit@​gmail.com wrote​:

perl's sprintf() formatting mostly follows the C standard where
applicable, which states​:

If the space and + flags both appear, the space flag is ignored.

This is a *much* clearer way to explain it than documenting the
combined behavior anew.

Even if the second explanation is fixed to say "nonnegative" rather
than "positive," repeating the explanation at all only leaves the
reader scrutinizing the two behavior descriptions to see what, if
anything, is different. On the other hand, if you just say that
adding a space has no effect on the +, the user will know immediately
what to expect--and there's no chance of getting details wrong in the
repeated explanation, because there isn't one.

The benefits of modularization are just as applicable to documentation
as to code. :-)

TonyC​: Do you think we should go forward with this documentation change?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2016

From @jkeenan

On Wed Dec 09 15​:39​:04 2015, jkeenan wrote​:

On Thu Jun 25 06​:08​:14 2015, saint.snit@​gmail.com wrote​:

perl's sprintf() formatting mostly follows the C standard where
applicable, which states​:

If the space and + flags both appear, the space flag is ignored.

This is a *much* clearer way to explain it than documenting the
combined behavior anew.

Even if the second explanation is fixed to say "nonnegative" rather
than "positive," repeating the explanation at all only leaves the
reader scrutinizing the two behavior descriptions to see what, if
anything, is different. On the other hand, if you just say that
adding a space has no effect on the +, the user will know immediately
what to expect--and there's no chance of getting details wrong in the
repeated explanation, because there isn't one.

The benefits of modularization are just as applicable to documentation
as to code. :-)

TonyC​: Do you think we should go forward with this documentation change?

Thank you very much.

TonyC​: ping ^^
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Feb 3, 2016

From @tonycoz

On Fri Jan 22 19​:29​:02 2016, jkeenan wrote​:

TonyC​: ping ^^

Here's an actualy patch.

Tony

@p5pRT
Copy link
Author

p5pRT commented Feb 3, 2016

From @tonycoz

0001-perl-125471-clarify-sprintf-handling-of-and-space-fl.patch
From 810a9637b4679691eb50c0b307b951411f23542b Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 3 Feb 2016 11:35:28 +1100
Subject: [perl #125471] clarify sprintf() handling of + and space flags

---
 pod/perlfunc.pod | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 1dba05a..126bcb1 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -7167,7 +7167,11 @@ one or more of:
 For example:
 
   printf '<% d>',  12;   # prints "< 12>"
+  printf '<% d>',   0;   # prints "< 0>"
+  printf '<% d>', -12;   # prints "<-12>"
   printf '<%+d>',  12;   # prints "<+12>"
+  printf '<%+d>',   0;   # prints "<+0>"
+  printf '<%+d>', -12;   # prints "<-12>"
   printf '<%6s>',  12;   # prints "<    12>"
   printf '<%-6s>', 12;   # prints "<12    >"
   printf '<%06s>', 12;   # prints "<000012>"
@@ -7178,7 +7182,7 @@ For example:
   printf '<%#B>',  12;   # prints "<0B1100>"
 
 When a space and a plus sign are given as the flags at once,
-a plus sign is used to prefix a positive number.
+the space is ignored.
 
   printf '<%+ d>', 12;   # prints "<+12>"
   printf '<% +d>', 12;   # prints "<+12>"
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Feb 3, 2016

From @jkeenan

Thanks, applied to blead in commit c95ea68. Marking ticket resolved.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT p5pRT closed this as completed Feb 3, 2016
@p5pRT
Copy link
Author

p5pRT commented Feb 3, 2016

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant