Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
566f6afe
Kaydet (Commit)
566f6afe
authored
Eki 26, 2002
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #512981: Update readline input stream on sys.stdin/out change.
üst
88afe666
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
22 deletions
+42
-22
pythonrun.h
Include/pythonrun.h
+2
-2
readline.c
Modules/readline.c
+13
-7
myreadline.c
Parser/myreadline.c
+20
-8
tokenizer.c
Parser/tokenizer.c
+2
-2
bltinmodule.c
Python/bltinmodule.c
+5
-3
No files found.
Include/pythonrun.h
Dosyayı görüntüle @
566f6afe
...
@@ -113,9 +113,9 @@ PyAPI_FUNC(void) PyFloat_Fini(void);
...
@@ -113,9 +113,9 @@ PyAPI_FUNC(void) PyFloat_Fini(void);
PyAPI_FUNC
(
void
)
PyOS_FiniInterrupts
(
void
);
PyAPI_FUNC
(
void
)
PyOS_FiniInterrupts
(
void
);
/* Stuff with no proper home (yet) */
/* Stuff with no proper home (yet) */
PyAPI_FUNC
(
char
*
)
PyOS_Readline
(
char
*
);
PyAPI_FUNC
(
char
*
)
PyOS_Readline
(
FILE
*
,
FILE
*
,
char
*
);
PyAPI_DATA
(
int
)
(
*
PyOS_InputHook
)(
void
);
PyAPI_DATA
(
int
)
(
*
PyOS_InputHook
)(
void
);
PyAPI_DATA
(
char
)
*
(
*
PyOS_ReadlineFunctionPointer
)(
char
*
);
PyAPI_DATA
(
char
)
*
(
*
PyOS_ReadlineFunctionPointer
)(
FILE
*
,
FILE
*
,
char
*
);
/* Stack size, in "pointers" (so we get extra safety margins
/* Stack size, in "pointers" (so we get extra safety margins
on 64-bit platforms). On a 32-bit platform, this translates
on 64-bit platforms). On a 32-bit platform, this translates
...
...
Modules/readline.c
Dosyayı görüntüle @
566f6afe
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
/* Pointers needed from outside (but not declared in a header file). */
/* Pointers needed from outside (but not declared in a header file). */
extern
DL_IMPORT
(
int
)
(
*
PyOS_InputHook
)(
void
);
extern
DL_IMPORT
(
int
)
(
*
PyOS_InputHook
)(
void
);
extern
DL_IMPORT
(
char
)
*
(
*
PyOS_ReadlineFunctionPointer
)(
char
*
);
extern
DL_IMPORT
(
char
)
*
(
*
PyOS_ReadlineFunctionPointer
)(
FILE
*
,
FILE
*
,
char
*
);
/* Exported function to send one line to readline's init file parser */
/* Exported function to send one line to readline's init file parser */
...
@@ -606,12 +606,12 @@ onintr(int sig)
...
@@ -606,12 +606,12 @@ onintr(int sig)
/* Wrapper around GNU readline that handles signals differently. */
/* Wrapper around GNU readline that handles signals differently. */
static
char
*
static
char
*
call_readline
(
char
*
prompt
)
call_readline
(
FILE
*
sys_stdin
,
FILE
*
sys_stdout
,
char
*
prompt
)
{
{
size_t
n
;
size_t
n
;
char
*
p
,
*
q
;
char
*
p
,
*
q
;
PyOS_sighandler_t
old_inthandler
;
PyOS_sighandler_t
old_inthandler
;
old_inthandler
=
PyOS_setsig
(
SIGINT
,
onintr
);
old_inthandler
=
PyOS_setsig
(
SIGINT
,
onintr
);
if
(
setjmp
(
jbuf
))
{
if
(
setjmp
(
jbuf
))
{
#ifdef HAVE_SIGRELSE
#ifdef HAVE_SIGRELSE
...
@@ -622,6 +622,13 @@ call_readline(char *prompt)
...
@@ -622,6 +622,13 @@ call_readline(char *prompt)
return
NULL
;
return
NULL
;
}
}
rl_event_hook
=
PyOS_InputHook
;
rl_event_hook
=
PyOS_InputHook
;
if
(
sys_stdin
!=
rl_instream
||
sys_stdout
!=
rl_outstream
)
{
rl_instream
=
sys_stdin
;
rl_outstream
=
sys_stdout
;
rl_prep_terminal
(
1
);
}
p
=
readline
(
prompt
);
p
=
readline
(
prompt
);
PyOS_setsig
(
SIGINT
,
old_inthandler
);
PyOS_setsig
(
SIGINT
,
old_inthandler
);
...
@@ -676,8 +683,7 @@ initreadline(void)
...
@@ -676,8 +683,7 @@ initreadline(void)
m
=
Py_InitModule4
(
"readline"
,
readline_methods
,
doc_module
,
m
=
Py_InitModule4
(
"readline"
,
readline_methods
,
doc_module
,
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
if
(
isatty
(
fileno
(
stdin
)))
{
PyOS_ReadlineFunctionPointer
=
call_readline
;
PyOS_ReadlineFunctionPointer
=
call_readline
;
setup_readline
();
setup_readline
();
}
}
}
Parser/myreadline.c
Dosyayı görüntüle @
566f6afe
...
@@ -87,14 +87,14 @@ my_fgets(char *buf, int len, FILE *fp)
...
@@ -87,14 +87,14 @@ my_fgets(char *buf, int len, FILE *fp)
/* Readline implementation using fgets() */
/* Readline implementation using fgets() */
char
*
char
*
PyOS_StdioReadline
(
char
*
prompt
)
PyOS_StdioReadline
(
FILE
*
sys_stdin
,
FILE
*
sys_stdout
,
char
*
prompt
)
{
{
size_t
n
;
size_t
n
;
char
*
p
;
char
*
p
;
n
=
100
;
n
=
100
;
if
((
p
=
PyMem_MALLOC
(
n
))
==
NULL
)
if
((
p
=
PyMem_MALLOC
(
n
))
==
NULL
)
return
NULL
;
return
NULL
;
fflush
(
stdout
);
fflush
(
s
ys_s
tdout
);
#ifndef RISCOS
#ifndef RISCOS
if
(
prompt
)
if
(
prompt
)
fprintf
(
stderr
,
"%s"
,
prompt
);
fprintf
(
stderr
,
"%s"
,
prompt
);
...
@@ -107,7 +107,7 @@ PyOS_StdioReadline(char *prompt)
...
@@ -107,7 +107,7 @@ PyOS_StdioReadline(char *prompt)
}
}
#endif
#endif
fflush
(
stderr
);
fflush
(
stderr
);
switch
(
my_fgets
(
p
,
(
int
)
n
,
stdin
))
{
switch
(
my_fgets
(
p
,
(
int
)
n
,
s
ys_s
tdin
))
{
case
0
:
/* Normal case */
case
0
:
/* Normal case */
break
;
break
;
case
1
:
/* Interrupt */
case
1
:
/* Interrupt */
...
@@ -135,7 +135,7 @@ PyOS_StdioReadline(char *prompt)
...
@@ -135,7 +135,7 @@ PyOS_StdioReadline(char *prompt)
if
(
incr
>
INT_MAX
)
{
if
(
incr
>
INT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"input line too long"
);
PyErr_SetString
(
PyExc_OverflowError
,
"input line too long"
);
}
}
if
(
my_fgets
(
p
+
n
,
(
int
)
incr
,
stdin
)
!=
0
)
if
(
my_fgets
(
p
+
n
,
(
int
)
incr
,
s
ys_s
tdin
)
!=
0
)
break
;
break
;
n
+=
strlen
(
p
+
n
);
n
+=
strlen
(
p
+
n
);
}
}
...
@@ -148,20 +148,32 @@ PyOS_StdioReadline(char *prompt)
...
@@ -148,20 +148,32 @@ PyOS_StdioReadline(char *prompt)
Note: Python expects in return a buffer allocated with PyMem_Malloc. */
Note: Python expects in return a buffer allocated with PyMem_Malloc. */
char
*
(
*
PyOS_ReadlineFunctionPointer
)(
char
*
);
char
*
(
*
PyOS_ReadlineFunctionPointer
)(
FILE
*
,
FILE
*
,
char
*
);
/* Interface used by tokenizer.c and bltinmodule.c */
/* Interface used by tokenizer.c and bltinmodule.c */
char
*
char
*
PyOS_Readline
(
char
*
prompt
)
PyOS_Readline
(
FILE
*
sys_stdin
,
FILE
*
sys_stdout
,
char
*
prompt
)
{
{
char
*
rv
;
char
*
rv
;
if
(
PyOS_ReadlineFunctionPointer
==
NULL
)
{
if
(
PyOS_ReadlineFunctionPointer
==
NULL
)
{
PyOS_ReadlineFunctionPointer
=
PyOS_StdioReadline
;
PyOS_ReadlineFunctionPointer
=
PyOS_StdioReadline
;
}
}
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
rv
=
(
*
PyOS_ReadlineFunctionPointer
)(
prompt
);
/* This is needed to handle the unlikely case that the
* interpreter is in interactive mode *and* stdin/out are not
* a tty. This can happen, for example if python is run like
* this: python -i < test1.py
*/
if
(
!
isatty
(
fileno
(
sys_stdin
))
||
!
isatty
(
fileno
(
sys_stdout
)))
rv
=
PyOS_StdioReadline
(
sys_stdin
,
sys_stdout
,
prompt
);
else
rv
=
(
*
PyOS_ReadlineFunctionPointer
)(
sys_stdin
,
sys_stdout
,
prompt
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
return
rv
;
return
rv
;
}
}
Parser/tokenizer.c
Dosyayı görüntüle @
566f6afe
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "abstract.h"
#include "abstract.h"
#endif
/* PGEN */
#endif
/* PGEN */
extern
char
*
PyOS_Readline
(
char
*
);
extern
char
*
PyOS_Readline
(
FILE
*
,
FILE
*
,
char
*
);
/* Return malloc'ed string including trailing \n;
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
empty malloc'ed string for EOF;
NULL if interrupted */
NULL if interrupted */
...
@@ -671,7 +671,7 @@ tok_nextc(register struct tok_state *tok)
...
@@ -671,7 +671,7 @@ tok_nextc(register struct tok_state *tok)
return
Py_CHARMASK
(
*
tok
->
cur
++
);
return
Py_CHARMASK
(
*
tok
->
cur
++
);
}
}
if
(
tok
->
prompt
!=
NULL
)
{
if
(
tok
->
prompt
!=
NULL
)
{
char
*
new
=
PyOS_Readline
(
tok
->
prompt
);
char
*
new
=
PyOS_Readline
(
stdin
,
stdout
,
tok
->
prompt
);
if
(
tok
->
nextprompt
!=
NULL
)
if
(
tok
->
nextprompt
!=
NULL
)
tok
->
prompt
=
tok
->
nextprompt
;
tok
->
prompt
=
tok
->
nextprompt
;
if
(
new
==
NULL
)
if
(
new
==
NULL
)
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
566f6afe
...
@@ -1311,8 +1311,9 @@ builtin_raw_input(PyObject *self, PyObject *args)
...
@@ -1311,8 +1311,9 @@ builtin_raw_input(PyObject *self, PyObject *args)
if
(
PyFile_WriteString
(
" "
,
fout
)
!=
0
)
if
(
PyFile_WriteString
(
" "
,
fout
)
!=
0
)
return
NULL
;
return
NULL
;
}
}
if
(
PyFile_AsFile
(
fin
)
==
stdin
&&
PyFile_AsFile
(
fout
)
==
stdout
&&
if
(
PyFile_Check
(
fin
)
&&
PyFile_Check
(
fout
)
isatty
(
fileno
(
stdin
))
&&
isatty
(
fileno
(
stdout
)))
{
&&
isatty
(
fileno
(
PyFile_AsFile
(
fin
)))
&&
isatty
(
fileno
(
PyFile_AsFile
(
fout
))))
{
PyObject
*
po
;
PyObject
*
po
;
char
*
prompt
;
char
*
prompt
;
char
*
s
;
char
*
s
;
...
@@ -1329,7 +1330,8 @@ builtin_raw_input(PyObject *self, PyObject *args)
...
@@ -1329,7 +1330,8 @@ builtin_raw_input(PyObject *self, PyObject *args)
po
=
NULL
;
po
=
NULL
;
prompt
=
""
;
prompt
=
""
;
}
}
s
=
PyOS_Readline
(
prompt
);
s
=
PyOS_Readline
(
PyFile_AsFile
(
fin
),
PyFile_AsFile
(
fout
),
prompt
);
Py_XDECREF
(
po
);
Py_XDECREF
(
po
);
if
(
s
==
NULL
)
{
if
(
s
==
NULL
)
{
PyErr_SetNone
(
PyExc_KeyboardInterrupt
);
PyErr_SetNone
(
PyExc_KeyboardInterrupt
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment