From: Hartmut Holzgraefe Date: Thu, 6 Dec 2001 19:02:27 +0000 (+0000) Subject: ported rot13() from php3 X-Git-Tag: ChangeLog~112 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71028d46cf42ebfa95f9f32d643a001d22a6da03;p=php ported rot13() from php3 --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e31138f88d..c7ffbd7a21 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -803,6 +803,7 @@ function_entry basic_functions[] = { PHP_FALIAS(ftok , warn_not_available, NULL) #endif + PHP_FE(rot13, NULL) {NULL, NULL, NULL} }; diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 27d9cf472c..a5d41d1389 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -116,6 +116,8 @@ PHP_FUNCTION(move_uploaded_file); /* From the INI parser */ PHP_FUNCTION(parse_ini_file); +PHP_FUNCTION(rot13); + #ifdef PHP_WIN32 typedef unsigned int php_stat_len; #else diff --git a/ext/standard/string.c b/ext/standard/string.c index f1070e7e43..56fff3bcec 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -398,6 +398,8 @@ PHP_MINIT_FUNCTION(nl_langinfo) } /* }}} */ +/* {{{ proto string nl_langinfo(int item) + Query language and locale information */ PHP_FUNCTION(nl_langinfo) { zval **item; @@ -3861,6 +3863,30 @@ PHP_FUNCTION(sscanf) } /* }}} */ +/* {{{ proto string rot13(string str) + Perform the rot13 transform on a string */ +PHP_FUNCTION(rot13) +{ + char *str; + int str_len; + static char xfrom[] = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static char xto[] = "nopqrstuvwxyzabcdefghijklm" + "NOPQRSTUVWXYZABCDEFGHIJKLM"; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &str, &str_len) == FAILURE) { + return; + } + + php_strtr(str, str_len, xfrom, xto, 52); + RETURN_STRINGL(str, str_len, 1); +} +/* }}} */ + + + + /* * Local variables: * tab-width: 4