From patchwork Fri Mar 18 19:18:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 11386 Received: (qmail 81635 invoked by alias); 18 Mar 2016 19:18:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 81497 invoked by uid 89); 18 Mar 2016 19:18:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=283, 7, 2837, 52825 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 18 Mar 2016 19:18:39 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7F21F3D3 for ; Fri, 18 Mar 2016 19:18:37 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2IJIYk0028091 for ; Fri, 18 Mar 2016 15:18:36 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 02/30] Inline command_loop in read_command_line Date: Fri, 18 Mar 2016 19:18:06 +0000 Message-Id: <1458328714-4938-3-git-send-email-palves@redhat.com> In-Reply-To: <1458328714-4938-1-git-send-email-palves@redhat.com> References: <1458328714-4938-1-git-send-email-palves@redhat.com> read_command_line is the only caller, and here we can assume we're reading a regular file, not stdin. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * top.c (read_command_file): Inline command_loop here. (command_loop): Delete. --- gdb/top.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/gdb/top.c b/gdb/top.c index 90a3f48..41ff6b2 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -283,7 +283,21 @@ read_command_file (FILE *stream) cleanups = make_cleanup (do_restore_instream_cleanup, instream); instream = stream; - command_loop (); + + /* Read commands from `instream' and execute them until end of file + or error reading instream. */ + + while (instream != NULL && !feof (instream)) + { + char *command; + + /* Get a command-line. This calls the readline package. */ + command = command_line_input (NULL, 0, NULL); + if (command == NULL) + break; + command_handler (command); + } + do_cleanups (cleanups); } @@ -528,25 +542,6 @@ execute_command_to_string (char *p, int from_tty) return retval; } -/* Read commands from `instream' and execute them - until end of file or error reading instream. */ - -void -command_loop (void) -{ - while (instream && !feof (instream)) - { - char *command; - - /* Get a command-line. This calls the readline package. */ - command = command_line_input (instream == stdin ? - get_prompt () : (char *) NULL, - instream == stdin, "prompt"); - if (command == NULL) - return; - command_handler (command); - } -} /* When nonzero, cause dont_repeat to do nothing. This should only be set via prevent_dont_repeat. */