Skip to content

Remove support for EBCDIC #5390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ int main(void) {
ac_cv_ebcdic=no
])])
if test "$ac_cv_ebcdic" = "yes"; then
AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
AC_MSG_ERROR([PHP does not support EBCDIC targets])
fi
])

Expand Down
30 changes: 0 additions & 30 deletions ext/standard/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@

#include "url.h"
#include "file.h"
#ifdef _OSD_POSIX
# ifndef CHARSET_EBCDIC
# define CHARSET_EBCDIC /* this machine uses EBCDIC, not ASCII! */
# endif
# include "ebcdic.h"
#endif /*_OSD_POSIX*/

/* {{{ free_url
*/
Expand Down Expand Up @@ -469,7 +463,6 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len)

if (c == ' ') {
*to++ = '+';
#ifndef CHARSET_EBCDIC
} else if ((c < '0' && c != '-' && c != '.') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
Expand All @@ -478,14 +471,6 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len)
to[1] = hexchars[c >> 4];
to[2] = hexchars[c & 15];
to += 3;
#else /*CHARSET_EBCDIC*/
} else if (!isalnum(c) && strchr("_-.", c) == NULL) {
/* Allow only alphanumeric chars and '_', '-', '.'; escape the rest */
to[0] = '%';
to[1] = hexchars[os_toascii[c] >> 4];
to[2] = hexchars[os_toascii[c] & 15];
to += 3;
#endif /*CHARSET_EBCDIC*/
} else {
*to++ = c;
}
Expand Down Expand Up @@ -542,11 +527,7 @@ PHPAPI size_t php_url_decode(char *str, size_t len)
}
else if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1))
&& isxdigit((int) *(data + 2))) {
#ifndef CHARSET_EBCDIC
*dest = (char) php_htoi(data + 1);
#else
*dest = os_toebcdic[(unsigned char) php_htoi(data + 1)];
#endif
data += 2;
len -= 2;
} else {
Expand Down Expand Up @@ -574,20 +555,13 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
char c = s[x];

ret[y] = c;
#ifndef CHARSET_EBCDIC
if ((c < '0' && c != '-' && c != '.') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
(c > 'z' && c != '~')) {
ret[y++] = '%';
ret[y++] = hexchars[(unsigned char) c >> 4];
ret[y] = hexchars[(unsigned char) c & 15];
#else /*CHARSET_EBCDIC*/
if (!isalnum(c) && strchr("_-.~", c) != NULL) {
ret[y++] = '%';
ret[y++] = hexchars[os_toascii[(unsigned char) c] >> 4];
ret[y] = hexchars[os_toascii[(unsigned char) c] & 15];
#endif /*CHARSET_EBCDIC*/
}
}
ret[y] = '\0';
Expand Down Expand Up @@ -638,11 +612,7 @@ PHPAPI size_t php_raw_url_decode(char *str, size_t len)
while (len--) {
if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1))
&& isxdigit((int) *(data + 2))) {
#ifndef CHARSET_EBCDIC
*dest = (char) php_htoi(data + 1);
#else
*dest = os_toebcdic[(unsigned char) php_htoi(data + 1)];
#endif
data += 2;
len -= 2;
} else {
Expand Down