mirror of
https://github.com/python/cpython.git
synced 2025-11-14 07:49:28 +00:00
Back out #479898.
This commit is contained in:
parent
049cd6b563
commit
a5f0907d79
4 changed files with 24 additions and 90 deletions
|
|
@ -26,20 +26,6 @@ static PyStringObject *nullstring;
|
||||||
static PyObject *interned;
|
static PyObject *interned;
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_MBTOWC) && defined(HAVE_WCHAR_H) && defined(HAVE_WCTYPE_H)
|
|
||||||
# define PRINT_MULTIBYTE_STRING
|
|
||||||
# include <locale.h>
|
|
||||||
# include <wchar.h>
|
|
||||||
# include <wctype.h>
|
|
||||||
# if defined(HAVE_ISWPRINT)
|
|
||||||
# define _isprint iswprint
|
|
||||||
# else
|
|
||||||
# define _isprint isprint
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *hexchars = "0123456789abcdef";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For both PyString_FromString() and PyString_FromStringAndSize(), the
|
For both PyString_FromString() and PyString_FromStringAndSize(), the
|
||||||
parameter `size' denotes number of characters to allocate, not counting any
|
parameter `size' denotes number of characters to allocate, not counting any
|
||||||
|
|
@ -763,14 +749,8 @@ PyString_AsStringAndSize(register PyObject *obj,
|
||||||
static int
|
static int
|
||||||
string_print(PyStringObject *op, FILE *fp, int flags)
|
string_print(PyStringObject *op, FILE *fp, int flags)
|
||||||
{
|
{
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
#else
|
|
||||||
char *scur, *send;
|
|
||||||
wchar_t c;
|
|
||||||
int cr;
|
|
||||||
#endif
|
|
||||||
int quote;
|
int quote;
|
||||||
|
|
||||||
/* XXX Ought to check for interrupts when writing long strings */
|
/* XXX Ought to check for interrupts when writing long strings */
|
||||||
|
|
@ -796,36 +776,20 @@ string_print(PyStringObject *op, FILE *fp, int flags)
|
||||||
quote = '"';
|
quote = '"';
|
||||||
|
|
||||||
fputc(quote, fp);
|
fputc(quote, fp);
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
|
||||||
for (i = 0; i < op->ob_size; i++) {
|
for (i = 0; i < op->ob_size; i++) {
|
||||||
c = op->ob_sval[i];
|
c = op->ob_sval[i];
|
||||||
#else
|
|
||||||
for (scur = op->ob_sval, send = op->ob_sval + op->ob_size;
|
|
||||||
scur < send; scur += cr) {
|
|
||||||
if ((cr = mbtowc(&c, scur, send - scur)) <= 0)
|
|
||||||
goto non_printable;
|
|
||||||
#endif
|
|
||||||
if (c == quote || c == '\\')
|
if (c == quote || c == '\\')
|
||||||
fputc('\\', fp), fputc(c, fp);
|
fprintf(fp, "\\%c", c);
|
||||||
else if (c == '\t')
|
else if (c == '\t')
|
||||||
fputs("\\t", fp);
|
fprintf(fp, "\\t");
|
||||||
else if (c == '\n')
|
else if (c == '\n')
|
||||||
fputs("\\n", fp);
|
fprintf(fp, "\\n");
|
||||||
else if (c == '\r')
|
else if (c == '\r')
|
||||||
fputs("\\r", fp);
|
fprintf(fp, "\\r");
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
else if (c < ' ' || c >= 0x7f)
|
||||||
else if (' ' <= c && c < 0x7f)
|
fprintf(fp, "\\x%02x", c & 0xff);
|
||||||
fputc(c, fp);
|
|
||||||
else
|
else
|
||||||
fprintf(fp, "\\x%02x", c & 0xff);
|
fputc(c, fp);
|
||||||
#else
|
|
||||||
else if (_isprint(c))
|
|
||||||
fwrite(scur, cr, 1, fp);
|
|
||||||
else {
|
|
||||||
non_printable: cr = 1; /* unit to move cursor */
|
|
||||||
fprintf(fp, "\\x%02x", *scur & 0xff);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
fputc(quote, fp);
|
fputc(quote, fp);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -846,14 +810,8 @@ PyString_Repr(PyObject *obj, int smartquotes)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
|
||||||
register int i;
|
register int i;
|
||||||
register char c;
|
register char c;
|
||||||
#else
|
|
||||||
register char *scur, *send;
|
|
||||||
wchar_t c;
|
|
||||||
int cr;
|
|
||||||
#endif
|
|
||||||
register char *p;
|
register char *p;
|
||||||
int quote;
|
int quote;
|
||||||
|
|
||||||
|
|
@ -866,18 +824,11 @@ PyString_Repr(PyObject *obj, int smartquotes)
|
||||||
|
|
||||||
p = PyString_AS_STRING(v);
|
p = PyString_AS_STRING(v);
|
||||||
*p++ = quote;
|
*p++ = quote;
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
|
||||||
for (i = 0; i < op->ob_size; i++) {
|
for (i = 0; i < op->ob_size; i++) {
|
||||||
/* There's at least enough room for a hex escape
|
/* There's at least enough room for a hex escape
|
||||||
and a closing quote. */
|
and a closing quote. */
|
||||||
assert(newsize - (p - PyString_AS_STRING(v)) >= 5);
|
assert(newsize - (p - PyString_AS_STRING(v)) >= 5);
|
||||||
c = op->ob_sval[i];
|
c = op->ob_sval[i];
|
||||||
#else
|
|
||||||
for (scur = op->ob_sval, send = op->ob_sval + op->ob_size;
|
|
||||||
scur < send; scur += cr) {
|
|
||||||
if ((cr = mbtowc(&c, scur, send - scur)) <= 0)
|
|
||||||
goto non_printable;
|
|
||||||
#endif
|
|
||||||
if (c == quote || c == '\\')
|
if (c == quote || c == '\\')
|
||||||
*p++ = '\\', *p++ = c;
|
*p++ = '\\', *p++ = c;
|
||||||
else if (c == '\t')
|
else if (c == '\t')
|
||||||
|
|
@ -886,20 +837,15 @@ PyString_Repr(PyObject *obj, int smartquotes)
|
||||||
*p++ = '\\', *p++ = 'n';
|
*p++ = '\\', *p++ = 'n';
|
||||||
else if (c == '\r')
|
else if (c == '\r')
|
||||||
*p++ = '\\', *p++ = 'r';
|
*p++ = '\\', *p++ = 'r';
|
||||||
#ifndef PRINT_MULTIBYTE_STRING
|
else if (c < ' ' || c >= 0x7f) {
|
||||||
else if (' ' <= c && c < 0x7f)
|
/* For performance, we don't want to call
|
||||||
*p++ = c;
|
PyOS_snprintf here (extra layers of
|
||||||
else {
|
function call). */
|
||||||
#else
|
sprintf(p, "\\x%02x", c & 0xff);
|
||||||
else if (_isprint(c))
|
p += 4;
|
||||||
memcpy(p, scur, cr), p += cr;
|
|
||||||
else {
|
|
||||||
non_printable: cr = 1; c = *scur;
|
|
||||||
#endif
|
|
||||||
*p++ = '\\'; *p++ = 'x';
|
|
||||||
*p++ = hexchars[(c >> 4) & 0x0f];
|
|
||||||
*p++ = hexchars[c & 0x0f];
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
*p++ = c;
|
||||||
}
|
}
|
||||||
assert(newsize - (p - PyString_AS_STRING(v)) >= 1);
|
assert(newsize - (p - PyString_AS_STRING(v)) >= 1);
|
||||||
*p++ = quote;
|
*p++ = quote;
|
||||||
|
|
|
||||||
15
configure
vendored
15
configure
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# From configure.in Revision: 1.355 .
|
# From configure.in Revision: 1.356 .
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.53.
|
# Generated by GNU Autoconf 2.53.
|
||||||
#
|
#
|
||||||
|
|
@ -901,7 +901,7 @@ esac
|
||||||
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
||||||
# absolute.
|
# absolute.
|
||||||
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
||||||
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
|
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
|
||||||
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
||||||
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
||||||
|
|
||||||
|
|
@ -3888,7 +3888,6 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \
|
for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \
|
||||||
|
|
@ -3896,7 +3895,7 @@ libintl.h locale.h ncurses.h poll.h pthread.h \
|
||||||
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
|
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
|
||||||
sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
||||||
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
||||||
sys/un.h sys/utsname.h sys/wait.h pty.h term.h wctype.h libutil.h \
|
sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
|
||||||
sys/resource.h netpacket/packet.h
|
sys/resource.h netpacket/packet.h
|
||||||
do
|
do
|
||||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
|
|
@ -11931,16 +11930,14 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \
|
for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \
|
||||||
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
|
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
|
||||||
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
|
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
|
||||||
hstrerror inet_pton iswprint kill killpg lchown link lstat mbtowc mkfifo \
|
hstrerror inet_pton kill killpg lchown link lstat mkfifo mknod mktime \
|
||||||
mknod mktime mremap nice pathconf pause plock poll pthread_init \
|
mremap nice pathconf pause plock poll pthread_init \
|
||||||
putenv readlink \
|
putenv readlink \
|
||||||
select setegid seteuid setgid setgroups \
|
select setegid seteuid setgid setgroups \
|
||||||
setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
|
setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
|
||||||
|
|
@ -17175,7 +17172,7 @@ esac
|
||||||
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
||||||
# absolute.
|
# absolute.
|
||||||
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
||||||
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
|
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
|
||||||
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
||||||
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ libintl.h locale.h ncurses.h poll.h pthread.h \
|
||||||
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
|
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
|
||||||
sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
||||||
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
||||||
sys/un.h sys/utsname.h sys/wait.h pty.h term.h wctype.h libutil.h \
|
sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
|
||||||
sys/resource.h netpacket/packet.h)
|
sys/resource.h netpacket/packet.h)
|
||||||
AC_HEADER_DIRENT
|
AC_HEADER_DIRENT
|
||||||
AC_HEADER_MAJOR
|
AC_HEADER_MAJOR
|
||||||
|
|
@ -1680,8 +1680,8 @@ AC_MSG_RESULT(MACHDEP_OBJS)
|
||||||
AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
|
AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
|
||||||
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
|
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
|
||||||
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
|
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
|
||||||
hstrerror inet_pton iswprint kill killpg lchown link lstat mbtowc mkfifo \
|
hstrerror inet_pton kill killpg lchown link lstat mkfifo mknod mktime \
|
||||||
mknod mktime mremap nice pathconf pause plock poll pthread_init \
|
mremap nice pathconf pause plock poll pthread_init \
|
||||||
putenv readlink \
|
putenv readlink \
|
||||||
select setegid seteuid setgid setgroups \
|
select setegid seteuid setgid setgroups \
|
||||||
setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
|
setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
|
||||||
|
|
|
||||||
|
|
@ -199,9 +199,6 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
/* Define to 1 if you have the `iswprint' function. */
|
|
||||||
#undef HAVE_ISWPRINT
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `kill' function. */
|
/* Define to 1 if you have the `kill' function. */
|
||||||
#undef HAVE_KILL
|
#undef HAVE_KILL
|
||||||
|
|
||||||
|
|
@ -253,9 +250,6 @@
|
||||||
/* Define this if you have the makedev macro. */
|
/* Define this if you have the makedev macro. */
|
||||||
#undef HAVE_MAKEDEV
|
#undef HAVE_MAKEDEV
|
||||||
|
|
||||||
/* Define to 1 if you have the `mbtowc' function. */
|
|
||||||
#undef HAVE_MBTOWC
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `memmove' function. */
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
#undef HAVE_MEMMOVE
|
#undef HAVE_MEMMOVE
|
||||||
|
|
||||||
|
|
@ -595,9 +589,6 @@
|
||||||
/* Define if the compiler provides a wchar.h header file. */
|
/* Define if the compiler provides a wchar.h header file. */
|
||||||
#undef HAVE_WCHAR_H
|
#undef HAVE_WCHAR_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <wctype.h> header file. */
|
|
||||||
#undef HAVE_WCTYPE_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `_getpty' function. */
|
/* Define to 1 if you have the `_getpty' function. */
|
||||||
#undef HAVE__GETPTY
|
#undef HAVE__GETPTY
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue