tests: parse idna.h instead of manual decls
authorMichael Wallner <mike@php.net>
Thu, 7 Sep 2017 12:03:45 +0000 (14:03 +0200)
committerMichael Wallner <mike@php.net>
Thu, 7 Sep 2017 12:03:45 +0000 (14:03 +0200)
tests/idn/idn.psi
tests/idn/idn002.phpt
tests/idn/idn003.phpt
tests/idn/idn004.phpt

index b8f3602205127f09558c98358d76e43e100e0706..aaf0f810845f216494cb9a11e5f83409e97367c3 100644 (file)
@@ -1,35 +1,17 @@
 // libidn
 lib "idn";
 
 // libidn
 lib "idn";
 
-// IDNA errors
-const int \IDNA_SUCCESS = 0;
-const int \IDNA_STRINGPREP_ERROR = 1;
-const int \IDNA_PUNYCODE_ERROR = 2;
-const int \IDNA_CONTAINS_NON_LDH = 3;
-const int \IDNA_CONTAINS_LDH = 3;
-const int \IDNA_CONTAINS_MINUS = 4;
-const int \IDNA_INVALID_LENGTH = 5;
-const int \IDNA_NO_ACE_PREFIX = 6;
-const int \IDNA_ROUNDTRIP_VERIFY_ERROR = 7;
-const int \IDNA_CONTAINS_ACE_PREFIX = 8;
-const int \IDNA_ICONV_ERROR = 9;
-const int \IDNA_MALLOC_ERROR = 201;
-const int \IDNA_DLOPEN_ERROR = 202;
-// IDNA flags
-const int \IDNA_ALLOW_UNASSIGNED = 1;
-const int \IDNA_USE_STD3_ASCII_RULES = 2;
+#include <idna.h>
 
 
-
-default int idna_to_ascii_8z(char *host, char **buffer, int flags);
 function idn\utf8_to_ascii(string $host, string &$result, int $flags = 0) : int {
 function idn\utf8_to_ascii(string $host, string &$result, int $flags = 0) : int {
-       let buffer = &NULL;
-       let host = strval($host);
+       let output = &NULL;
+       let input = strval($host);
        let flags = intval($flags);
        let flags = intval($flags);
-       set $result = to_string(*buffer);
+       set $result = to_string(*output);
        return to_int(idna_to_ascii_8z);
        return to_int(idna_to_ascii_8z);
-       free free(*buffer);
+       free free(*output);
 }
 }
-default char *idna_strerror(int rc);
+
 function idn\strerror(int $rc) : string {
        return to_string(idna_strerror);
        let rc = intval($rc);
 function idn\strerror(int $rc) : string {
        return to_string(idna_strerror);
        let rc = intval($rc);
index d3d3375aaaaf421c88e0f22dd3f3978c4807225d..da1d5322b19c3ac6fe78dca6684b90e6b2461dea 100644 (file)
@@ -11,7 +11,7 @@ function_exists("idn\\strerror") or die("skip - need libidn");
 ===TEST===
 <?php
 
 ===TEST===
 <?php
 
-$rc = idn\utf8_to_ascii("…asdf….de", $result, IDNA_USE_STD3_ASCII_RULES);
+$rc = idn\utf8_to_ascii("…asdf….de", $result, psi\IDNA_USE_STD3_ASCII_RULES);
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
index e8a47ff1ae54e3bf337f82d3cf2e6210ae1909c6..73aca3f986a1a90d9807d9bc602dbfa090429744 100644 (file)
@@ -12,7 +12,7 @@ function_exists("idn\\strerror") or die("skip - need libidn");
 <?php
 
 $result = "buecher.de";
 <?php
 
 $result = "buecher.de";
-$rc = idn\utf8_to_ascii("bücher.de", $result, IDNA_USE_STD3_ASCII_RULES);
+$rc = idn\utf8_to_ascii("bücher.de", $result, psi\IDNA_USE_STD3_ASCII_RULES);
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
index 471d0917dbd2951f97c7cf0144436f240e0dc86e..33ed47e978d401936fae9f3e70179e5a579b8d72 100644 (file)
@@ -12,11 +12,11 @@ function_exists("idn\\strerror") or die("skip - need libidn");
 <?php
 
 $result = "buecher.de";
 <?php
 
 $result = "buecher.de";
-$rc = idn\utf8_to_ascii("bücher.de", $result, IDNA_USE_STD3_ASCII_RULES);
+$rc = idn\utf8_to_ascii("bücher.de", $result, psi\IDNA_USE_STD3_ASCII_RULES);
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
-$rc = idn\utf8_to_ascii("bücher2.de", $result, IDNA_USE_STD3_ASCII_RULES);
+$rc = idn\utf8_to_ascii("bücher2.de", $result, psi\IDNA_USE_STD3_ASCII_RULES);
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));
 
 printf("%s\n", $result);
 printf("%s\n", idn\strerror($rc));