Re: [PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-19 Thread Dmitry Stogov
On Mon, Mar 18, 2013 at 9:51 PM, Andrey Hristov p...@hristov.com wrote:

 On 03/18/2013 02:40 PM, Dmitry Stogov wrote:

 Hi Andrey,

 I don't think it makes a lot of sense to make it in only this particular
 place.
 We use int in thousands other places (near everywhere across PHP
 sources).


 A journey of a thousand miles begins with a single step Lau-Tzu :)


OK :)

Dmitry.


[PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-18 Thread Dmitry Stogov
Commit:5b0879e7c969e0bd87b0ad6fad03e278a0a46642
Author:Dmitry Stogov dmi...@zend.com Mon, 18 Mar 2013 13:36:31 
+0400
Parents:   a9684532ebda83e2459da4f6f450a37f4ee6ff7b
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=5b0879e7c969e0bd87b0ad6fad03e278a0a46642

Log:
Avoid trailing line break

Changed paths:
  M  ext/opcache/zend_accelerator_module.c


Diff:
diff --git a/ext/opcache/zend_accelerator_module.c 
b/ext/opcache/zend_accelerator_module.c
index 019ce66..dd8eb59 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -403,6 +403,8 @@ static zval* accelerator_get_scripts(TSRMLS_D)
for (i = 0; iZCSG(hash).max_num_entries; i++) {
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; 
cache_entry = cache_entry-next) {
zend_persistent_script *script;
+   char *str;
+   int len;
 
if (cache_entry-indirect) continue;
 
@@ -414,7 +416,10 @@ static zval* accelerator_get_scripts(TSRMLS_D)
add_assoc_long(persistent_script_report, hits, 
script-dynamic_members.hits);
add_assoc_long(persistent_script_report, 
memory_consumption, script-dynamic_members.memory_consumption);
ta = localtime(script-dynamic_members.last_used);
-   add_assoc_string(persistent_script_report, last_used, 
asctime(ta), 1);
+   str = asctime(ta);
+   len = strlen(str);
+   if (len  0  str[len - 1] == '\n') len--;
+   add_assoc_stringl(persistent_script_report, 
last_used, str, len, 1);
add_assoc_long(persistent_script_report, 
last_used_timestamp, script-dynamic_members.last_used);
if (ZCG(accel_directives).validate_timestamps) {
add_assoc_long(persistent_script_report, 
timestamp, (long)script-timestamp);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-18 Thread Andrey Hristov

On 03/18/2013 10:36 AM, Dmitry Stogov wrote:

Commit:5b0879e7c969e0bd87b0ad6fad03e278a0a46642
Author:Dmitry Stogov dmi...@zend.com Mon, 18 Mar 2013 13:36:31 
+0400
Parents:   a9684532ebda83e2459da4f6f450a37f4ee6ff7b
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=5b0879e7c969e0bd87b0ad6fad03e278a0a46642

Log:
Avoid trailing line break

Changed paths:
   M  ext/opcache/zend_accelerator_module.c


Diff:
diff --git a/ext/opcache/zend_accelerator_module.c 
b/ext/opcache/zend_accelerator_module.c
index 019ce66..dd8eb59 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -403,6 +403,8 @@ static zval* accelerator_get_scripts(TSRMLS_D)
for (i = 0; iZCSG(hash).max_num_entries; i++) {
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; 
cache_entry = cache_entry-next) {
zend_persistent_script *script;
+   char *str;
+   int len;


could you use size_t instead of len? (strlen() returns size_t). Thanks :)


if (cache_entry-indirect) continue;

@@ -414,7 +416,10 @@ static zval* accelerator_get_scripts(TSRMLS_D)
add_assoc_long(persistent_script_report, hits, 
script-dynamic_members.hits);
add_assoc_long(persistent_script_report, 
memory_consumption, script-dynamic_members.memory_consumption);
ta = localtime(script-dynamic_members.last_used);
-   add_assoc_string(persistent_script_report, last_used, 
asctime(ta), 1);
+   str = asctime(ta);
+   len = strlen(str);
+   if (len  0  str[len - 1] == '\n') len--;
+   add_assoc_stringl(persistent_script_report, 
last_used, str, len, 1);
add_assoc_long(persistent_script_report, 
last_used_timestamp, script-dynamic_members.last_used);
if (ZCG(accel_directives).validate_timestamps) {
add_assoc_long(persistent_script_report, 
timestamp, (long)script-timestamp);




Andrey

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-18 Thread Dmitry Stogov
Hi Andrey,

I don't think it makes a lot of sense to make it in only this particular
place.
We use int in thousands other places (near everywhere across PHP sources).

Thanks. Dmitry.

On Mon, Mar 18, 2013 at 5:09 PM, Andrey Hristov p...@hristov.com wrote:


 could you use size_t instead of len? (strlen() returns size_t). Thanks :)

 Andrey



Re: [PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-18 Thread Pierre Joye
hi Dmitry,

On Mon, Mar 18, 2013 at 2:40 PM, Dmitry Stogov dmi...@zend.com wrote:
 Hi Andrey,

 I don't think it makes a lot of sense to make it in only this particular
 place.
 We use int in thousands other places (near everywhere across PHP sources).

Well it makes sense and as this code is new, why not make it right in
the 1st place? :)

-- 
Pierre

@pierrejoye

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Avoid trailing line break: ext/opcache/zend_accelerator_module.c

2013-03-18 Thread Andrey Hristov

On 03/18/2013 02:40 PM, Dmitry Stogov wrote:

Hi Andrey,

I don't think it makes a lot of sense to make it in only this particular
place.
We use int in thousands other places (near everywhere across PHP sources).


A journey of a thousand miles begins with a single step Lau-Tzu :)


Thanks. Dmitry.

On Mon, Mar 18, 2013 at 5:09 PM, Andrey Hristov p...@hristov.com wrote:



could you use size_t instead of len? (strlen() returns size_t). Thanks :)

Andrey





Best,
Andrey

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php