]> granicus.if.org Git - php/commitdiff
- Reverted back to old param parsing api (and eliminated a segfault by doing that)
authorTal Peer <tal@php.net>
Thu, 26 Sep 2002 10:43:42 +0000 (10:43 +0000)
committerTal Peer <tal@php.net>
Thu, 26 Sep 2002 10:43:42 +0000 (10:43 +0000)
- Added the CapRTL charset -- should be used for testing on machines without Hebrew/Arabic/Persian
 fonts
- Changed the note about deprecated behaviour from E_WARNING to E_NOTICE

ext/fribidi/README
ext/fribidi/fribidi.c

index 182cdf8b8b81a365ccec60e8297cb6b8871a2e67..173267aee02eb2c49be3440cfa91e0b08b7b9340 100644 (file)
@@ -18,12 +18,13 @@ Usage
                  c) FRIBIDI_AUTO - autodetect the base direction
             3) The char code being used, which can be one of the following
                constants:
-                 a) FRIBIDI_CHARSET_UTF8
-                 b) FRIBIDI_CHARSET_8859_6
-                 c) FRIBIDI_CHARSET_8859_8
-                 d) FRIBIDI_CHARSET_CP1255
-                 e) FRIBIDI_CHARSET_CP1256
-                 f) FRIBIDI_CHARSET_ISIRI_3342
+                 a) FRIBIDI_CHARSET_UTF8       (Unicode)
+                 b) FRIBIDI_CHARSET_8859_6     (Arabic)
+                 c) FRIBIDI_CHARSET_8859_8     (Hebrew)
+                 d) FRIBIDI_CHARSET_CP1255     (Hebrew/Yiddish)
+                 e) FRIBIDI_CHARSET_CP1256     (Arabic)
+                 f) FRIBIDI_CHARSET_ISIRI_3342 (Persian)
+                 g) FRIBIDI_CHARSET_CAP_RTL - Used for test purposes, will treat CAPS as non-English letetrs
 
 Note: Currently, FriBidi supports the above Character Codes alone. 
 
index 708668aebabcfff5b95836bde7813b7dd854a7e7..fa03da8fa1459a07730d3a115fda159256f4711b 100755 (executable)
@@ -64,6 +64,7 @@ PHP_MINIT_FUNCTION(fribidi)
        REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CP1255", FRIBIDI_CHARSET_CP1255, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CP1256", FRIBIDI_CHARSET_CP1256, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_ISIRI_3342", FRIBIDI_CHARSET_ISIRI_3342, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CAP_RTL", FRIBIDI_CHARSET_CAP_RTL, CONST_CS | CONST_PERSISTENT);
        
        /* Directions */
        REGISTER_LONG_CONSTANT("FRIBIDI_AUTO", FRIBIDI_TYPE_ON, CONST_CS | CONST_PERSISTENT);
@@ -102,7 +103,7 @@ PHP_MINFO_FUNCTION(fribidi)
 |             Possible values:                               |
 |             a) FRIBIDI_LTR  - left to right.               |
 |             b) FRIBIDI_RTL  - right to left.               |
-|             c) FRIBIDI_AUTO - autodetected by the BiDi     |
+|             c) FRIBIDI_AUTO - autodetected by the Unicode  |
 |                               BiDi algorithm.              |
 |        3) Character code being used -                      |
 |             Possible values (i.e., charsets supported)     |
@@ -112,31 +113,35 @@ PHP_MINFO_FUNCTION(fribidi)
 |              FRIBIDI_CHARSET_CP1255                        |
 |              FRIBIDI_CHARSET_CP1256                        |
 |              FRIBIDI_CHARSET_ISIRI_3342                    |
+|              FRIBIDI_CHARSET_CAP_RTL                       |
 |                                                            |
 | Output: on success: The visual string.                     |
 |         on failure: FALSE                                  |
 +------------------------------------------------------------+
 */           
 
-/* {{{ proto string fribidi_log2vis(string v_str, long direction, long charset)
+/* {{{ proto string fribidi_log2vis(string logical_str, long direction, long charset)
    Convert a logical string to a visual one */
 PHP_FUNCTION(fribidi_log2vis)
 {
-       zval **direction;
-       long charset;
+       zval **logical_str, **direction, **charset;
        FriBidiChar *u_logical_str, *u_visual_str;  /* unicode strings .... */
-       char *v_str, *in_string, *out_string;
+       char *in_string, *out_string;
        int len, alloc_len;
        FriBidiCharType base_dir;
        FriBidiStrIndex *position_L_to_V_list;
        FriBidiStrIndex *position_V_to_L_list;
        FriBidiLevel    *embedding_level_list;
-                                  
-       /* parse parameters from input */
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szl", &v_str, &len, &direction, &charset) == FAILURE) {
-               return;
+
+       /* get parameters from input */
+       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &logical_str, &direction, &charset) == FAILURE) {
+               WRONG_PARAM_COUNT;
        }
 
+       /* convert argument types */
+       convert_to_string_ex(logical_str);
+       convert_to_long_ex(charset);
+       
        if (Z_TYPE_PP(direction) == IS_LONG) {
                convert_to_long_ex(direction);
                base_dir = Z_LVAL_PP(direction);
@@ -150,11 +155,11 @@ PHP_FUNCTION(fribidi_log2vis)
                        base_dir = FRIBIDI_TYPE_ON;
                }
                        
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "The use of strings to mark the base direction is deprecated, please use the FRIBIDI_LTR, FRIBIDI_RTL and FRIBIDI_AUTO constants");
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The use of strings to mark the base direction is deprecated, please use the FRIBIDI_LTR, FRIBIDI_RTL and FRIBIDI_AUTO constants");
        }
 
        /* allocate space and prepare all local variables */
-       in_string = estrndup(v_str, len);
+       in_string = estrndup(Z_STRVAL_PP(logical_str), len);
        alloc_len = len+1;
 
        u_logical_str = (FriBidiChar*) emalloc(sizeof(FriBidiChar)*alloc_len);
@@ -168,14 +173,15 @@ PHP_FUNCTION(fribidi_log2vis)
                in_string[len-1] = '\0';
        }
 
-       switch(charset) {
+       switch(Z_LVAL_PP(charset)) {
                case FRIBIDI_CHARSET_UTF8:
                case FRIBIDI_CHARSET_ISO8859_6:
                case FRIBIDI_CHARSET_ISO8859_8:
                case FRIBIDI_CHARSET_CP1255:
                case FRIBIDI_CHARSET_CP1256:
                case FRIBIDI_CHARSET_ISIRI_3342:
-                       len = fribidi_charset_to_unicode(charset, in_string, len, u_logical_str);
+               case FRIBIDI_CHARSET_CAP_RTL:
+                       len = fribidi_charset_to_unicode(Z_LVAL_PP(charset), in_string, len, u_logical_str);
                        break;
                default:
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset");
@@ -195,14 +201,15 @@ PHP_FUNCTION(fribidi_log2vis)
        fribidi_log2vis(u_logical_str, len, &base_dir, u_visual_str, position_L_to_V_list, position_V_to_L_list, embedding_level_list);
        
        /* convert back to original char set */
-       switch(charset) {
+       switch(Z_LVAL_PP(charset)) {
                case FRIBIDI_CHARSET_UTF8:
                case FRIBIDI_CHARSET_ISO8859_6:
                case FRIBIDI_CHARSET_ISO8859_8:
                case FRIBIDI_CHARSET_CP1255:
                case FRIBIDI_CHARSET_CP1256:
                case FRIBIDI_CHARSET_ISIRI_3342:
-                       fribidi_unicode_to_charset(charset, u_visual_str, len, out_string);
+               case FRIBIDI_CHARSET_CAP_RTL:
+                       fribidi_unicode_to_charset(Z_LVAL_PP(charset), u_visual_str, len, out_string);
                        break;                                                                  
                default:
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset");