Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
efc6f014
Commit
efc6f014
authored
Aug 05, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move GNU readline interface to ../Modules/readline.c.
Add Py_input_hook (used by _tkinter and perhaps Gist).
parent
e59c3ba8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
78 deletions
+3
-78
Parser/myreadline.c
Parser/myreadline.c
+3
-78
No files found.
Parser/myreadline.c
View file @
efc6f014
...
@@ -51,79 +51,7 @@ PERFORMANCE OF THIS SOFTWARE.
...
@@ -51,79 +51,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "mymalloc.h"
#include "mymalloc.h"
#include "intrcheck.h"
#include "intrcheck.h"
int
(
*
Py_input_hook
)()
=
NULL
;
#ifdef WITH_READLINE
extern
char
*
readline
();
extern
int
rl_initialize
();
extern
int
rl_insert
();
extern
int
rl_bind_key
();
extern
void
add_history
();
extern
char
*
rl_readline_name
;
#include <setjmp.h>
#include <signal.h>
static
jmp_buf
jbuf
;
/* ARGSUSED */
static
RETSIGTYPE
onintr
(
sig
)
int
sig
;
{
longjmp
(
jbuf
,
1
);
}
void
PyOS_ReadlineInit
()
{
static
int
been_here
;
if
(
!
been_here
)
{
/* Force rebind of TAB to insert-tab */
rl_readline_name
=
"python"
;
rl_initialize
();
rl_bind_key
(
'\t'
,
rl_insert
);
been_here
++
;
}
}
char
*
PyOS_GnuReadline
(
prompt
)
char
*
prompt
;
{
int
n
;
char
*
p
;
RETSIGTYPE
(
*
old_inthandler
)();
PyOS_ReadlineInit
();
old_inthandler
=
signal
(
SIGINT
,
onintr
);
if
(
setjmp
(
jbuf
))
{
#ifdef HAVE_SIGRELSE
/* This seems necessary on SunOS 4.1 (Rasmus Hahn) */
sigrelse
(
SIGINT
);
#endif
signal
(
SIGINT
,
old_inthandler
);
return
NULL
;
}
p
=
readline
(
prompt
);
signal
(
SIGINT
,
old_inthandler
);
if
(
p
==
NULL
)
{
p
=
malloc
(
1
);
if
(
p
!=
NULL
)
*
p
=
'\0'
;
return
p
;
}
n
=
strlen
(
p
);
if
(
n
>
0
)
add_history
(
p
);
if
((
p
=
realloc
(
p
,
n
+
2
))
!=
NULL
)
{
p
[
n
]
=
'\n'
;
p
[
n
+
1
]
=
'\0'
;
}
return
p
;
}
#endif
/* !WITH_READLINE */
/* This function restarts a fgets() after an EINTR error occurred
/* This function restarts a fgets() after an EINTR error occurred
except if PyOS_InterruptOccurred() returns true. */
except if PyOS_InterruptOccurred() returns true. */
...
@@ -136,6 +64,8 @@ my_fgets(buf, len, fp)
...
@@ -136,6 +64,8 @@ my_fgets(buf, len, fp)
{
{
char
*
p
;
char
*
p
;
for
(;;)
{
for
(;;)
{
if
(
Py_input_hook
!=
NULL
)
(
void
)(
Py_input_hook
)();
errno
=
0
;
errno
=
0
;
p
=
fgets
(
buf
,
len
,
fp
);
p
=
fgets
(
buf
,
len
,
fp
);
if
(
p
!=
NULL
)
if
(
p
!=
NULL
)
...
@@ -221,11 +151,6 @@ PyOS_Readline(prompt)
...
@@ -221,11 +151,6 @@ PyOS_Readline(prompt)
char
*
prompt
;
char
*
prompt
;
{
{
if
(
PyOS_ReadlineFunctionPointer
==
NULL
)
{
if
(
PyOS_ReadlineFunctionPointer
==
NULL
)
{
#ifdef WITH_READLINE
if
(
isatty
(
fileno
(
stdin
)))
PyOS_ReadlineFunctionPointer
=
PyOS_GnuReadline
;
else
#endif
PyOS_ReadlineFunctionPointer
=
PyOS_StdioReadline
;
PyOS_ReadlineFunctionPointer
=
PyOS_StdioReadline
;
}
}
return
(
*
PyOS_ReadlineFunctionPointer
)(
prompt
);
return
(
*
PyOS_ReadlineFunctionPointer
)(
prompt
);
...
...
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