--- gcc/cp/input.c 2018/04/24 18:20:20 1.1.1.1 +++ gcc/cp/input.c 2018/04/24 18:27:00 1.1.1.2 @@ -1,5 +1,5 @@ /* Input handling for G++. - Copyright (C) 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. This file is part of GNU CC. @@ -16,7 +16,8 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ /* G++ needs to do enough saving and re-parsing of text that it is necessary to abandon the simple FILE* model and use a mechanism where @@ -128,8 +129,8 @@ feed_input (str, len, delete) struct pending_input *to_be_restored; /* XXX */ extern int end_of_file; -int -getch () +static inline int +sub_getch () { if (putback_char != -1) { @@ -172,8 +173,25 @@ void put_back (ch) int ch; { - my_friendly_assert (putback_char == -1, 224); - putback_char = ch; + if (ch != EOF) + { + my_friendly_assert (putback_char == -1, 224); + putback_char = ch; + } +} + +extern int linemode; + +int +getch () +{ + int ch = sub_getch (); + if (linemode && ch == '\n') + { + put_back (ch); + ch = EOF; + } + return ch; } inline