[PHP-DEV] Re: VC6 Win32 Build

2005-04-19 Thread Alexander Valyalkin
"Terry R. Lacey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm also trying to Build php5ts using the VC6 Build Tools as recommended in > the file README.WIN32-BUILD-SYSTEM because I seem to be getting absolutely > nowhere using the GUI. When I open the Tools Command Prompt, th

[PHP-DEV] crc32, md5 & sha1 functions

2005-03-21 Thread Alexander Valyalkin
crc32, md5 and sha1 functions, implemented in PHP, are widely used for computing "fingerprint" of any data. But current implementation has not very good limitation - there is no way to get/set current state vector of these functions. So, we have to pass whole amount of data as argument of these fun

[PHP-DEV] Re: implode() speedup in PHP4

2005-03-21 Thread Alexander Valyalkin
> After applying the change to ext/standard/string.c in PHP4 the following > Test failed: > Bug #4 (implode changes object references in array) > [ext/standard/tests/strings/bug4.phpt] > > Regards, > Christian Stadler I understood my fault. I didn't notice condition if (!(*ppzv)->is_ref)

[PHP-DEV] about mt_srand() function

2005-03-18 Thread Alexander Valyalkin
mt_srand() is used to seed initialisation vector (IV) for Mersenne Twister pseudorandom generator. But there is a "little" problem: the actual length of IV is 19968 bits, but mt_srand() accepts only 32-bit integers, which even reduced to 31 bit in function php_mt_srand() at /ext/standard/rand.c a

[PHP-DEV] implode() speedup in PHP4

2005-03-18 Thread Alexander Valyalkin
I've posted patch last summer http://www.zend.com/zend/week/pat/pat5.txt which imporves performance of implode() function in PHP4, but nobody doesn't commit it yet. Can anybody explain the reason? -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP Internals - PHP Runti

[PHP-DEV] small patch for implode() function

2004-07-02 Thread Alexander Valyalkin
there is such code in the php_implode() function: [snip] while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) &tmp, &pos) == SUCCESS) { SEPARATE_ZVAL(tmp); convert_to_string(*tmp); [snip

[PHP-DEV] Re: 64-bit bugsquash

2004-06-18 Thread Alexander Valyalkin
There is a header file with PHP type's definition: /Zend/zend_types.h It consists following types: --- typedef unsigned char zend_bool; typedef unsigned char zend_uchar; typedef unsigned int zend_uint; typedef unsigned long zend_ulong; typedef unsigned short zend_ushort;

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Wed, 16 Jun 2004 07:05:32 -0700 (Pacific Standard Time), Rasmus Lerdorf <[EMAIL PROTECTED]> wrote: As Alexander's initial re-implementation of crc32() was broken on 64-bit architectures, I think this is a very good point. And his stripslashes() "improvement" actually broke backward compatib

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Wed, 16 Jun 2004 16:35:04 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote: Alexander Valyalkin wrote: On Wed, 16 Jun 2004 12:03:36 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote: Have you tested my initial re-implementation of crc32() on 64-bit architectures? No, but I d

[PHP-DEV] strrchr() bugs

2004-06-16 Thread Alexander Valyalkin
Today I've revised strrchr() function in PHP4.3.7 sources. It wasn't binary-safe. For example: 1) strrpos('abcd', '') returns 4. Expected FALSE 2) strrpos("a\0abcde", 'a') returns 6. Expected 2 3) strrpos("a\0bcde", "\0") returns 6. Expected 1 4) strrpos('', '\0') returns 0. Expected FALSE My versi

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Wed, 16 Jun 2004 12:03:36 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote: As Alexander's initial re-implementation of crc32() was broken on 64-bit architectures, I think this is a very good point. Have you tested my initial re-implementation of crc32() on 64-bit architectures? -- Using Opera

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Wed, 16 Jun 2004 12:11:07 +0400, Antony Dovgal <[EMAIL PROTECTED]> wrote: On Wed, 16 Jun 2004 11:06:31 +0300 "Alexander Valyalkin" <[EMAIL PROTECTED]> wrote: I can't find any serious reason to apply the pathes into the current PHP4 and PHP5 versions. Yup. Me too.

Re: [PHP-DEV] strspn() & strcspn() speed improvements

2004-06-16 Thread Alexander Valyalkin
On Wed, 16 Jun 2004 00:41:19 +0300, Andrey Hristov <[EMAIL PROTECTED]> wrote: Privet Alex, is it possible to show some results from benchmarking? Thanks a lot, Andrey Just compile my standalone test & view results :) -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP In

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Tue, 15 Jun 2004 21:56:37 +0100, Lester Caine <[EMAIL PROTECTED]> wrote: Once PHP5 is out - THEN the sorts of fixes Alexander is suggesting could be looked at - but not until then. Once PHP5 is out - THEN all of my fixes will safely forgotten, on my opinion :) I can't find any serious reaso

Re: [PHP-DEV] The open letter to Derick Rethans

2004-06-16 Thread Alexander Valyalkin
On Tue, 15 Jun 2004 22:48:35 +0200, Bert Slagter <[EMAIL PROTECTED]> wrote: Thomas Goyne wrote: As a user, I personally see placing new features over making old features work better a large mistake. Perhaps that was necessary back in the days of PHP3, but its been a very long time since I've

[PHP-DEV] The open letter to Derick Rethans

2004-06-15 Thread Alexander Valyalkin
On Tue, 15 Jun 2004 12:47:29 +0200 (CEST), Derick Rethans <[EMAIL PROTECTED]> wrote: On Tue, 15 Jun 2004, Alexander Valyalkin wrote: Today I checked file /win32/readdir.c Below you can view its source with my comments. Just a little notice that you succesfully made it into my killfilter.

[PHP-DEV] strspn() & strcspn() speed improvements

2004-06-15 Thread Alexander Valyalkin
My versions of strspn() & strcspn() use faster and clear algorithm. Below I provide simple test application, which compares speed and results of old strspn() with new one & unified diff in the bottom. ===cut== #include #include #include /* for _rdtsc() */ #define S1_L

[PHP-DEV] Re: /win32/readdir.c review

2004-06-15 Thread Alexander Valyalkin
Below I provide my version of readdir.c file unified diff cut=== --- readdir.c Tue Jan 28 04:51:26 2003 +++ readdir_new.c Tue Jun 15 13:35:43 2004 @@ -22,40 +22,80 @@ DIR *opendir(const char *dir) { DIR *dp; - char *filespec; +char *filespec, *tmp_ptr; long h

[PHP-DEV] /win32/readdir.c review

2004-06-15 Thread Alexander Valyalkin
Today I checked file /win32/readdir.c Below you can view its source with my comments. begin of /win32/readdir.c source=== DIR *opendir(const char *dir) { DIR *dp; char *filespec; long handle; /* - [index] must have (size_t) type (see it usage below) *

[PHP-DEV] basename() memory access violation

2004-06-14 Thread Alexander Valyalkin
Here is patch for basename() function, which prevents possible memory access violation: =cut= --- string.cThu May 13 20:44:32 2004 +++ string_basename.c Mon Jun 14 20:43:33 2004 @@ -1079,9 +1079,9 @@ /* strip trailing slashes */ - while (*c == '/' +while (c >= s && *

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Mon, 14 Jun 2004 13:49:16 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote: Alexander Valyalkin wrote: :) Are you sure? I'm not. Look on declaration of [nr] variable: int nr; And answer, please, which value will be assigned to nr, if length of a string will be greater than 0x7ff

[PHP-DEV] Re: implode() speedup

2004-06-14 Thread Alexander Valyalkin
I've read CODING_STANDARDS (thanks to Christian Schneider) and corrected my code according to your standards. Also I've improved speed of algorithm. Now it is not duplicate the string value of array item, if it is has string type already: if (Z_TYPE_PP(tmp) != IS_STRING) { /* create new ins

[PHP-DEV] implode() speedup

2004-06-14 Thread Alexander Valyalkin
The implode() function uses very bad algorithm, which uses memory reallocation very often. The speed of functions falls quickly with increase of length of imploded array & data in it. My version of implode() uses much better algorithm: 1) counts the amount of memory needed to result string 2) alloc

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Mon, 14 Jun 2004 11:00:33 +0200 (CEST), Derick Rethans <[EMAIL PROTECTED]> wrote: if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == FAILURE) { return; } /* !!! there is no error check nr < 0 */ Of course not, that's pointless as a string can never

Re: [PHP-DEV] crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Sun, 13 Jun 2004 23:10:04 +, Curt Zirzow <[EMAIL PROTECTED]> wrote: * Thus wrote Alexander Valyalkin ([EMAIL PROTECTED]): Here is improved version of crc32() function. Features: 1) Automatic initialization of crc32tab[] at first call. So, the file crc32.h with definition of this

[PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Sun, 13 Jun 2004 11:24:12 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote: First of all, crc32tab is no longer in the .text segment, so it will not be shared between forked processes, taking more memory space than necessary. Each process will have to initialise it as well, so the init loop

Re: [PHP-DEV] str_repeat() patch

2004-06-12 Thread Alexander Valyalkin
On Fri, 11 Jun 2004 10:55:20 -0400, Ilia Alshanetsky <[EMAIL PROTECTED]> wrote: Read your memcpy manpages "The memcpy() function copies n bytes from memory area src to memory area dest. The memory areas may not overlap." Well, I've read my manpages: The memcpy() function copies n bytes

[PHP-DEV] crc32() improvements

2004-06-12 Thread Alexander Valyalkin
Here is improved version of crc32() function. Features: 1) Automatic initialization of crc32tab[] at first call. So, the file crc32.h with definition of this tab is not nessesary any more now. 2) Speed is improved on large amount of data. 3) Less source size. Current verison has near 6.5Kb le

Re: [PHP-DEV] str_repeat() patch

2004-06-12 Thread Alexander Valyalkin
On Fri, 11 Jun 2004 17:00:03 +0200 (CEST), Derick Rethans <[EMAIL PROTECTED]> wrote: On Fri, 11 Jun 2004, Alexander Valyalkin wrote: Read it: void *memmove(void *s1, const void *s2, size_t n); If s1 and s2 overlap, all bytes are copied in a preserving manner (unlike memcpy()) And anw

[PHP-DEV] str_repeat() patch

2004-06-11 Thread Alexander Valyalkin
Read it: void *memmove(void *s1, const void *s2, size_t n); If s1 and s2 overlap, all bytes are copied in a preserving manner (unlike memcpy()) And anwer the question: are s1 and s2 overlap in the str_repeat() ? Why don't use memcpy() instead of memmove() ? ===cut= --- string

[PHP-DEV] my strip_tags() v2

2004-06-11 Thread Alexander Valyalkin
Some bugs have been fixed in this version: 1) All [#include] directives moved to the top. Just copy'n'compile sources to test it :) 2) Renamed php_strip_all_tags() to php_strip_tags() with the same interface as in the current version. 3) Fixed php_tag_find(). Allowable tags is case and or

[PHP-DEV] the new version of strip_tag()

2004-06-10 Thread Alexander Valyalkin
On Thu, 10 Jun 2004 16:33:13 +0300, Alexander Valyalkin <[EMAIL PROTECTED]> wrote: Today I wrote the new version of strip_tags(). Yes, it is not ideal, but it is much better than current version. Below is my complete version of strip_tags() with testcases. You can add / change any tes

[PHP-DEV] strip_tags() discussion

2004-06-10 Thread Alexander Valyalkin
What sense of the [allowable_tags] parameter in strip_tags()? According docs, "You can use the optional second parameter to specify tags which should not be stripped". Ok. Suppose, I have a PHP-guestbook and use strip_tags() to filter all tags, excepting ,, in users' messages. Then a "cool-hacker"

Re: [PHP-DEV] stripslashes() improvements

2004-06-10 Thread Alexander Valyalkin
On Thu, 10 Jun 2004 11:56:26 +0400, Antony Dovgal <[EMAIL PROTECTED]> wrote: Ok, my version of stripslashes() is faster, clearer, works correctly with old tests and solves mentioned bugs. Are you still doubt? Try to compare the old (current) code to new one. Faster is ok, but you'd better read

Re: [PHP-DEV] stripslashes() improvements

2004-06-10 Thread Alexander Valyalkin
On Wed, 9 Jun 2004 14:20:01 +0200, Moshe Doron <[EMAIL PROTECTED]> wrote: in addition, i want to remind that when magic mode is on, this function been used by each script to manipulate the $_REQUEST vars so playing with this peace of code have 1. big codes breaking potential. 2. big security p

Re: [PHP-DEV] stripslashes() improvements

2004-06-10 Thread Alexander Valyalkin
On Thu, 10 Jun 2004 00:47:09 -0700 (PDT), Rasmus Lerdorf <[EMAIL PROTECTED]> wrote: Uh, what are you guys talking about? That test case is bogus. $s = 'c:\\windows\\system32'; This means that the base string we are working with is c:\windows\system32 here before any sort of stripslashes. If

Re: [PHP-DEV] stripslashes() improvements

2004-06-10 Thread Alexander Valyalkin
On Wed, 9 Jun 2004 15:56:10 +0400, Antony Dovgal <[EMAIL PROTECTED]> wrote: If you think it's wrong - prove it. There are quite detailed reasons why those bugs were considered to be bogus. I'm ok if you're going to improve stripslashes() efficiency and/or to make it just faster, this could be ve

Re: [PHP-DEV] stripslashes() improvements

2004-06-09 Thread Alexander Valyalkin
On Thu, 10 Jun 2004 00:50:46 +1200, Jevon Wright <[EMAIL PROTECTED]> wrote: 'c:\\windows\\system32' becomes 'c:\windows\system32' in memory (the slashes are stripped). I know it :) stripslashes() will make it 'c:windowssystem32'. Thus the above tests will fail. Yes. The current version of stri

Re: [PHP-DEV] stripslashes() improvements

2004-06-09 Thread Alexander Valyalkin
On Wed, 9 Jun 2004 15:00:30 +0400, Antony Dovgal <[EMAIL PROTECTED]> wrote: On Wed, 09 Jun 2004 13:52:42 +0300 "Alexander Valyalkin" <[EMAIL PROTECTED]> wrote: On Tue, 8 Jun 2004 16:03:19 +0200 (CEST), Derick Rethans <[EMAIL PROTECTED]> wrote: Ok. First of all, my

Re: [PHP-DEV] stripslashes() improvements

2004-06-09 Thread Alexander Valyalkin
On Tue, 8 Jun 2004 16:03:19 +0200 (CEST), Derick Rethans <[EMAIL PROTECTED]> wrote: You'll have to proof that by writing testcases, for example try it with the test cases in the current source and write new ones for things that we don't have a test case for yet. -PHPAPI void php_stripslashes(cha

Re: [PHP-DEV] readfile() improvements

2004-06-09 Thread Alexander Valyalkin
On Tue, 08 Jun 2004 12:51:33 +0200, Morten K. Poulsen <[EMAIL PROTECTED]> wrote: On Tue, 2004-06-08 at 11:32, Alexander Valyalkin wrote: +/* get the length of local file connected to descriptor fd */ fstat(fd, &sbuf); [snip] +if (errno) { Oh-oh! You need to

[PHP-DEV] stripslashes() improvements

2004-06-08 Thread Alexander Valyalkin
Today I checked stripslashes() function. My version of the function if faster, more clearer and bugs free (I hope :)) Below you can see the source and unified diff: source= PHPAPI void php_stripslashes(char *str, size_t *len TSRMLS_DC) { char *s, *t; size_t l;

Re: [PHP-DEV] readfile() improvements

2004-06-08 Thread Alexander Valyalkin
On Mon, 7 Jun 2004 20:02:54 +0400, Antony Dovgal <[EMAIL PROTECTED]> wrote: On Mon, 07 Jun 2004 18:55:52 +0300 "Alexander Valyalkin" <[EMAIL PROTECTED]> wrote: On Mon, 07 Jun 2004 17:07:06 +0300, Andi Gutmans <[EMAIL PROTECTED]> wrote: > Can you send a unifie

Re: [PHP-DEV] readfile() improvements

2004-06-07 Thread Alexander Valyalkin
On Mon, 07 Jun 2004 17:07:06 +0300, Andi Gutmans <[EMAIL PROTECTED]> wrote: Can you send a unified diff? ==cut= 1065,1066c1065,1066 < size_t bcount = 0; < int ready = 0; --- size_t bcount = 0; /* counter of printed out bytes */ int is_mapped = 0; 1067a106

Re: [PHP-DEV] readfile() improvements

2004-06-07 Thread Alexander Valyalkin
On Mon, 7 Jun 2004 10:19:09 -0400, Ilia Alshanetsky <[EMAIL PROTECTED]> wrote: IMO Adding additional error reporting is a good idea, but we should keep MAP_SHARED as the mmap mode. In Apache environment if the file is mapped by more then one process the memory needed to map the file is shared,

Re: [PHP-DEV] readfile() improvements

2004-06-07 Thread Alexander Valyalkin
On Mon, 07 Jun 2004 17:07:06 +0300, Andi Gutmans <[EMAIL PROTECTED]> wrote: Can you send a unified diff? At 02:08 PM 6/7/2004 +0300, Alexander Valyalkin wrote: No, because I dont know how create it :) Please, explain how can I create unified diff under windows. I'm newbie in PHP source

[PHP-DEV] readfile() improvements

2004-06-07 Thread Alexander Valyalkin
When I try to print huge files (greate than 500Mb) using readfile() function, my computer crashes. Why? I found in the PHP 4.3.7 sources the file /main/strems.c and function _php_stream_passthru() in it. The readfile() uses this function to print content of the file. Below you can see source