Port hsbcolor filter.

Piotr Pawłow [2016-09-23 03:13:24]
Port hsbcolor filter.
Filename
filters/php_hsbcolor.c
diff --git a/filters/php_hsbcolor.c b/filters/php_hsbcolor.c
index 577afc2..954bd67 100644
--- a/filters/php_hsbcolor.c
+++ b/filters/php_hsbcolor.c
@@ -101,7 +101,9 @@ static void _php_hsbcolor_hsb2rgb(double hue, double saturation, double brightne
 static int
 _php_hsbcolor_exec(Imlib_Image im, HashTable* params)
 {
-      HashPosition pos;
+      ulong num_index;
+      zend_string *str_index;
+      zval *data;

       double h_add = 0, s_add = 0, b_add = 0;
       double h_mul = 1.0, s_mul = 1.0, b_mul = 1.0;
@@ -111,33 +113,23 @@ _php_hsbcolor_exec(Imlib_Image im, HashTable* params)
       w = imgw = imlib_image_get_width();
       h = imgh = imlib_image_get_height();

-      zend_hash_internal_pointer_reset_ex(params,&pos);
-      while (pos)
+      ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data)
       {
-        char *str_index;
-        ulong num_index;
-        int retval;
-
-        retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos);
-        if (retval==HASH_KEY_IS_STRING)
+        if (str_index)
         {
-          zval **data;
-          zend_hash_get_current_data_ex(params,(void*)&data,&pos);
-
-          if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); };
-          if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); };
-          if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); };
-          if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); };
-
-          if (!strcmp(str_index,"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_PP(data); };
-          if (!strcmp(str_index,"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_PP(data); };
-          if (!strcmp(str_index,"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_PP(data); };
-          if (!strcmp(str_index,"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_PP(data); };
-          if (!strcmp(str_index,"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_PP(data); };
-          if (!strcmp(str_index,"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_PP(data); };
+          if (!strcmp(str_index->val,"x")) { convert_to_long_ex(data); x=Z_LVAL_P(data); };
+          if (!strcmp(str_index->val,"y")) { convert_to_long_ex(data); y=Z_LVAL_P(data); };
+          if (!strcmp(str_index->val,"w")) { convert_to_long_ex(data); w=Z_LVAL_P(data); };
+          if (!strcmp(str_index->val,"h")) { convert_to_long_ex(data); h=Z_LVAL_P(data); };
+
+          if (!strcmp(str_index->val,"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_P(data); };
+          if (!strcmp(str_index->val,"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_P(data); };
+          if (!strcmp(str_index->val,"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_P(data); };
+          if (!strcmp(str_index->val,"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_P(data); };
+          if (!strcmp(str_index->val,"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_P(data); };
+          if (!strcmp(str_index->val,"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_P(data); };
         }
-      zend_hash_move_forward_ex(params,&pos);
-      }
+      } ZEND_HASH_FOREACH_END();

       if (x<0) x=0;
       if (y<0) y=0;
ViewGit