[PHP-DEV] Bug #14805 Updated: array_unique works opposed to the manual

2002-01-16 Thread pgerzson

ID: 14805
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Assigned
Bug Type: Arrays related
Operating System: MS Windows 98 PWS 4.0
PHP Version: 4.1.1
Assigned To: venaas
New Comment:

Just one question:
What the main goal to stick to preserving the first key
when array_unique() eliminates multiple occurrences.
I think in most cases it's not so important.


Previous Comments:


[2002-01-16 17:43:45] [EMAIL PROTECTED]

array_unique() uses qsort internally. Provided qsort doesn't
change order of items that are equal, array_unique() should
work as documented. Until recently the systems own qsort
was used, giving different behavior on different systems.
With latest PHP (in CVS) we use our own qsort which doesn't
preserve order of equal items either. I'll either get that
qsort changed, or I will write a new slower array_unique()
that doesn't depend on qsort behavior.



[2002-01-09 12:18:16] [EMAIL PROTECTED]

I tested the examples with PHP 4.1.1 on Apache 1.3.9 under debian
stable. array_unique() does preserve the *first* key 
of every related value in this environment.

Simone Cortesi [EMAIL PROTECTED] stated on phpdoc list:
  On my PHP Version 4.0.6 on System Windows 95/98 4.10
  (as it reads with phpinfo), I get...
what I got, but

  On the same machine using Cygwin and PHP/4.0.8-dev 
  I get:
the expected result (returning with the first keys).







[2002-01-02 13:20:30] [EMAIL PROTECTED]

I forgot to mention that there may be something wrong with 
array_unique itself. There are three values of 3 considered equal in
the example above: 
  2 = 3(string), 4 = 3(int), 5 = 3 (string)

[manual]
  Two elements are considered equal if and only if (string)
  $elem1 === (string) $elem2. In words: when the string
  representation is the same.

Why does array_unique use the index 4 in this case?
(It's neither the first nor the latest key of value 3)





[2002-01-02 12:48:29] [EMAIL PROTECTED]

The manual (recent version from cvs) states that :

 array_unique() will keep the first key encountered for  every value,
and ignore all following keys. 

I've tested the two examples in this page and I've found
this statement is not true.

?php
$input = array (4,4,3,4,3,3);
$result = array_unique ($input);
var_dump($result);
?

output: /* PHP 4.0.6 Win'98 PWS */
array(2) {
  [3]=
  int(4)
  [4]=
  int(3)
}

but the manual says it should print:

array(2) {
   [0]=
   int(4)
   [1]=
   string(1) 3
}

As you can recognize the latest keys are preserved
for both value 4 and 3.






Edit this bug report at http://bugs.php.net/?id=14805edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #10002 Updated: sprintf() and floating point

2002-01-15 Thread pgerzson

ID: 10002
Comment by: [EMAIL PROTECTED]
Old Reported By: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Strings related
Operating System: Debian
PHP Version: 4.1.1
New Comment:

I played with ini settings (to be frank remove the
php.ini), and now examples work fine.


Previous Comments:


[2002-01-09 16:43:39] [EMAIL PROTECTED]

I'd like to reopen it. Visit the page: 

http://213.134.22.60/~gerzson/sprintf.php




[2002-01-09 16:36:36] [EMAIL PROTECTED]

I'm sorry to say that I experienced similar misbehaviour
with  PHP 4.0.6 and 4.1.1, too. 

I'm pulling aggregated statistics from database and display
it. I'm currently working on minimize a test case, please wait. Till
then, visit this link:

http://213.134.22.60/~gerzson/sprintf.php

this is a very simple test script with a show_source() and 
phpinfo(). I think this bug should be reopened.



[2001-03-27 12:30:21] [EMAIL PROTECTED]

Patch applied, but it's still a strange thing.



[2001-03-27 08:32:14] [EMAIL PROTECTED]

I can't reproduce it under RH 6.2.  Generally the fix isn't supposed to
do anything (since arg is a double, 10 should be converted to a double
automatically), but the fix can't hurt anything so if it works around a
compiler bug, it's fine.

PHP cannot use sprintf() because sprintf() works with C types with
predefined types for the arguments, whether PHP has its own types, and
autoconverts arguments to match the format string.



[2001-03-26 17:19:30] [EMAIL PROTECTED]

This bug is in 4.0.5RC2 too, just confirmed it



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10002


Edit this bug report at http://bugs.php.net/?id=10002edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #14805 Updated: array_unique works opposed to the manual

2002-01-09 Thread pgerzson

ID: 14805
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Arrays related
Old Operating System: MS Windows 98
Operating System: MS Windows 98 PWS 4.0
Old PHP Version: 4.0.6
PHP Version: 4.1.1
New Comment:

I tested the examples with PHP 4.1.1 on Apache 1.3.9 under debian
stable. array_unique() does preserve the *first* key 
of every related value in this environment.

Simone Cortesi [EMAIL PROTECTED] stated on phpdoc list:
  On my PHP Version 4.0.6 on System Windows 95/98 4.10
  (as it reads with phpinfo), I get...
what I got, but

  On the same machine using Cygwin and PHP/4.0.8-dev 
  I get:
the expected result (returning with the first keys).






Previous Comments:


[2002-01-02 13:20:30] [EMAIL PROTECTED]

I forgot to mention that there may be something wrong with 
array_unique itself. There are three values of 3 considered equal in the
example above: 
  2 = 3(string), 4 = 3(int), 5 = 3 (string)

[manual]
  Two elements are considered equal if and only if (string)
  $elem1 === (string) $elem2. In words: when the string
  representation is the same.

Why does array_unique use the index 4 in this case?
(It's neither the first nor the latest key of value 3)





[2002-01-02 12:48:29] [EMAIL PROTECTED]

The manual (recent version from cvs) states that :

 array_unique() will keep the first key encountered for  every value,
and ignore all following keys. 

I've tested the two examples in this page and I've found
this statement is not true.

?php
$input = array (4,4,3,4,3,3);
$result = array_unique ($input);
var_dump($result);
?

output: /* PHP 4.0.6 Win'98 PWS */
array(2) {
  [3]=
  int(4)
  [4]=
  int(3)
}

but the manual says it should print:

array(2) {
   [0]=
   int(4)
   [1]=
   string(1) 3
}

As you can recognize the latest keys are preserved
for both value 4 and 3.






Edit this bug report at http://bugs.php.net/?id=14805edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #10002 Updated: sprintf() and floating point

2002-01-09 Thread pgerzson

ID: 10002
Comment by: [EMAIL PROTECTED]
Old Reported By: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: Strings related
Operating System: RedHat 7.0
PHP Version: 4.0 Latest CVS (26/03/2001)
New Comment:

I'm sorry to say that I experienced similar misbehaviour
with  PHP 4.0.6 and 4.1.1, too. 

I'm pulling aggregated statistics from database and display
it. I'm currently working on minimize a test case, please wait. Till
then, visit this link:

http://213.134.22.60/~gerzson/sprintf.php

this is a very simple test script with a show_source() and 
phpinfo(). I think this bug should be reopened.


Previous Comments:


[2001-03-27 12:30:21] [EMAIL PROTECTED]

Patch applied, but it's still a strange thing.



[2001-03-27 08:32:14] [EMAIL PROTECTED]

I can't reproduce it under RH 6.2.  Generally the fix isn't supposed to
do anything (since arg is a double, 10 should be converted to a double
automatically), but the fix can't hurt anything so if it works around a
compiler bug, it's fine.

PHP cannot use sprintf() because sprintf() works with C types with
predefined types for the arguments, whether PHP has its own types, and
autoconverts arguments to match the format string.



[2001-03-26 17:19:30] [EMAIL PROTECTED]

This bug is in 4.0.5RC2 too, just confirmed it



[2001-03-26 14:13:27] [EMAIL PROTECTED]

?php
printf('%.2f',0.0167332731531132594682276248931884765625);
?
produces '0.0:' instead of '0.10'

I'm really curious as to why PHP just doesn't use libc's sprintf().

./configure --with-oracle=/usr/local/oracle/product/8.1.7 \
  --with-oci8=/usr/local/oracle/product/8.1.7
--enable-force-cgi-redirect \
  --enable-track-vars --with-posix --enable-sockets --enable-sigchild
\
  --with-gd=/usr/local

gcc version 2.95.2 19991024 (release)


This is not exactly a fix...
--- ext/standard/formatted_print.c  Mon Mar 26 14:01:31 2001
+++ ext/standard/formatted_print.c-fixedMon Mar 26 14:02:26
2001
@@ -92,7 +92,7 @@
while (p1  cvt_buf[NDIG])
*p++ = *p1++;
} else if (arg  0) {
-   while ((fj = arg * 10)  1) {
+   while ((fj = arg * 10.0)  0.999) {
arg = fj;
r2--;
}







Edit this bug report at http://bugs.php.net/?id=10002edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #14805: array_unique works opposed to the manual

2002-01-02 Thread pgerzson

From: [EMAIL PROTECTED]
Operating system: MS Windows 98
PHP version:  4.0.6
PHP Bug Type: Arrays related
Bug description:  array_unique works opposed to the manual

The manual (recent version from cvs) states that :

 array_unique() will keep the first key encountered for  every value, and
ignore all following keys. 

I've tested the two examples in this page and I've found
this statement is not true.

?php
$input = array (4,4,3,4,3,3);
$result = array_unique ($input);
var_dump($result);
?

output: /* PHP 4.0.6 Win'98 PWS */
array(2) {
  [3]=
  int(4)
  [4]=
  int(3)
}

but the manual says it should print:

array(2) {
   [0]=
   int(4)
   [1]=
   string(1) 3
}

As you can recognize the latest keys are preserved
for both value 4 and 3.

-- 
Edit bug report at: http://bugs.php.net/?id=14805edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #14805 Updated: array_unique works opposed to the manual

2002-01-02 Thread pgerzson

ID: 14805
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Arrays related
Operating System: MS Windows 98
PHP Version: 4.0.6
New Comment:

I forgot to mention that there may be something wrong with 
array_unique itself. There are three values of 3 considered equal in the example 
above: 
  2 = 3(string), 4 = 3(int), 5 = 3 (string)

[manual]
  Two elements are considered equal if and only if (string)
  $elem1 === (string) $elem2. In words: when the string
  representation is the same.

Why does array_unique use the index 4 in this case?
(It's neither the first nor the latest key of value 3)



Previous Comments:


[2002-01-02 12:48:29] [EMAIL PROTECTED]

The manual (recent version from cvs) states that :

 array_unique() will keep the first key encountered for  every value, and ignore all 
following keys. 

I've tested the two examples in this page and I've found
this statement is not true.

?php
$input = array (4,4,3,4,3,3);
$result = array_unique ($input);
var_dump($result);
?

output: /* PHP 4.0.6 Win'98 PWS */
array(2) {
  [3]=
  int(4)
  [4]=
  int(3)
}

but the manual says it should print:

array(2) {
   [0]=
   int(4)
   [1]=
   string(1) 3
}

As you can recognize the latest keys are preserved
for both value 4 and 3.






Edit this bug report at http://bugs.php.net/?id=14805edit=1


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]