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

Data::Dumper and negative numbers #1784

Closed
p5pRT opened this issue Apr 5, 2000 · 5 comments
Closed

Data::Dumper and negative numbers #1784

p5pRT opened this issue Apr 5, 2000 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 5, 2000

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

Searchable as RT3039$

@p5pRT
Copy link
Author

p5pRT commented Apr 5, 2000

From @eserte


The Data​::Dumper output of negative numbers in FreeBSD's perl seems to
be incorrect.

Consider the following outputs​:

/usr/perl5.00503/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = -12;

/usr/perl5.6.0/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = 4294967284;


Flags​:
  category=library
  severity=critical


Site configuration information for perl v5.6.0​:

Configured by eserte at Wed Apr 5 22​:54​:41 CEST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:
  Platform​:
  osname=freebsd, osvers=3.4-stable, archname=i386-freebsd-64int
  uname='freebsd vran.herceg.de 3.4-stable freebsd 3.4-stable #6​: mon feb 14 02​:34​:10 cet 2000 eserte@​vran.herceg.de​:usrsrcsyscompilevran i386 '
  config_args='-Dprefix=/usr/perl5.6.0 -de -D hintfile=myfreebsd'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
  useperlio=undef d_sfio=undef uselargefiles=define
  use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler​:
  cc='cc', optimize='-O2 -m486', gccversion=2.7.2.3
  cppflags='-I/usr/local/include'
  ccflags ='-I/usr/local/include'
  stdchar='char', d_stdstdio=undef, usevfork=true
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags ='-Wl,-E -L/usr/local/lib'
  libpth=/usr/lib /usr/local/lib
  libs=-lgdbm -lm -lc -lcrypt
  libc=/usr/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-DPIC -fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl v5.6.0​:
  /usr/perl5.6.0/lib/5.6.0/i386-freebsd-64int
  /usr/perl5.6.0/lib/5.6.0
  /usr/perl5.6.0/lib/site_perl/5.6.0/i386-freebsd-64int
  /usr/perl5.6.0/lib/site_perl/5.6.0
  /usr/perl5.6.0/lib/site_perl
  .


Environment for perl v5.6.0​:
  HOME=/home/e/eserte
  LANG (unset)
  LANGUAGE (unset)
  LC_ALL=de_DE.ISO_8859-1
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/X11R6/bin​:/usr/X11/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/gnu/bin​:/usr/TeX/bin​:/usr/sbin​:/sbin​:/usr/local/sbin​:/usr/local/pilot/bin​:/home/e/eserte/bin/FreeBSD​:/home/e/eserte/bin/sh​:/home/e/eserte/bin​:/usr/X386/bin​:/usr/games​:/home/e/eserte/devel
  PERL_BADLANG (unset)
  SHELL=/usr/local/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2000

From @gsar

On Thu, 06 Apr 2000 01​:14​:52 +0200, Slaven Rezic wrote​:

The Data​::Dumper output of negative numbers in FreeBSD's perl seems to
be incorrect.

Consider the following outputs​:

/usr/perl5.00503/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = -12;

/usr/perl5.6.0/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = 4294967284;

Please try this.

Sarathy
gsar@​activestate.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 5970 by gsar@auger on 2000/04/27 18:05:11

	Data::Dumper fumbles negative numbers on 32-bit platforms where
	IV is >32bits

Affected files ...

... //depot/perl/ext/Data/Dumper/Dumper.xs#18 edit
... //depot/perl/t/lib/dumper.t#10 edit

Differences ...

==== //depot/perl/ext/Data/Dumper/Dumper.xs#18 (text) ====
Index: perl/ext/Data/Dumper/Dumper.xs
--- perl/ext/Data/Dumper/Dumper.xs.~1~	Thu Apr 27 11:05:14 2000
+++ perl/ext/Data/Dumper/Dumper.xs	Thu Apr 27 11:05:14 2000
@@ -584,8 +584,7 @@
 
 	if (SvIOK(val)) {
             STRLEN len;
-	    i = SvIV(val);
-            (void) sprintf(tmpbuf, "%"IVdf, (IV)i);
+            (void) sprintf(tmpbuf, "%"IVdf, SvIV(val));
             len = strlen(tmpbuf);
 	    sv_catpvn(retval, tmpbuf, len);
 	}

==== //depot/perl/t/lib/dumper.t#10 (xtext) ====
Index: perl/t/lib/dumper.t
--- perl/t/lib/dumper.t.~1~	Thu Apr 27 11:05:14 2000
+++ perl/t/lib/dumper.t	Thu Apr 27 11:05:14 2000
@@ -287,7 +287,7 @@
   package main;
   use Data::Dumper;
   $foo = 5;
-  @foo = (10,\*foo);
+  @foo = (-10,\*foo);
   %foo = (a=>1,b=>\$foo,c=>\@foo);
   $foo{d} = \%foo;
   $foo[2] = \%foo;
@@ -299,7 +299,7 @@
 #*::foo = \5;
 #*::foo = [
 #           #0
-#           10,
+#           -10,
 #           #1
 #           do{my $o},
 #           #2
@@ -330,7 +330,7 @@
 #$foo = \*::foo;
 #*::foo = \5;
 #*::foo = [
-#  10,
+#  -10,
 #  do{my $o},
 #  {
 #    'a' => 1,
@@ -356,7 +356,7 @@
 ##
   $WANT = <<'EOT';
 #@bar = (
-#  10,
+#  -10,
 #  \*::foo,
 #  {}
 #);
@@ -383,7 +383,7 @@
 ##
   $WANT = <<'EOT';
 #$bar = [
-#  10,
+#  -10,
 #  \*::foo,
 #  {}
 #];
@@ -411,7 +411,7 @@
   $WANT = <<'EOT';
 #$foo = \*::foo;
 #@bar = (
-#  10,
+#  -10,
 #  $foo,
 #  {
 #    a => 1,
@@ -433,7 +433,7 @@
   $WANT = <<'EOT';
 #$foo = \*::foo;
 #$bar = [
-#  10,
+#  -10,
 #  $foo,
 #  {
 #    a => 1,
End of Patch.

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2000

From [Unknown Contact. See original ticket]

Gurusamy Sarathy writes​:

 if \(SvIOK\(val\)\) \{
         STRLEN len;

- i = SvIV(val);
- (void) sprintf(tmpbuf, "%"IVdf, (IV)i);
+ (void) sprintf(tmpbuf, "%"IVdf, SvIV(val));
len = strlen(tmpbuf);
sv_catpvn(retval, tmpbuf, len);
}

Do not see any support for IsUV....

Ilya

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2000

From @gsar

On Thu, 27 Apr 2000 14​:27​:35 EDT, Ilya Zakharevich wrote​:

Gurusamy Sarathy writes​:

 if \(SvIOK\(val\)\) \{
         STRLEN len;

- i = SvIV(val);
- (void) sprintf(tmpbuf, "%"IVdf, (IV)i);
+ (void) sprintf(tmpbuf, "%"IVdf, SvIV(val));
len = strlen(tmpbuf);
sv_catpvn(retval, tmpbuf, len);
}

Do not see any support for IsUV....

True, patch welcome.

Sarathy
gsar@​activestate.com

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2000

From @eserte

Gurusamy Sarathy <gsar@​ActiveState.com> writes​:

On Thu, 06 Apr 2000 01​:14​:52 +0200, Slaven Rezic wrote​:

The Data​::Dumper output of negative numbers in FreeBSD's perl seems to
be incorrect.

Consider the following outputs​:

/usr/perl5.00503/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = -12;

/usr/perl5.6.0/bin/perl -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = 4294967284;

Please try this.

20​:52 eserte@​vran 322 (src/new.perl-5.6.0)​: ./perl -Ilib -MData​::Dumper -e 'print Data​::Dumper->Dump([-12])'
$VAR1 = -12;

Thanks! Seems to work now. The new test also passes.

Regards,
  Slaven

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

No branches or pull requests

1 participant