From owner-svn-src-all@FreeBSD.ORG Sun Sep 14 16:27:50 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1FCE44F1; Sun, 14 Sep 2014 16:27:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00B91995; Sun, 14 Sep 2014 16:27:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8EGRn8q095031; Sun, 14 Sep 2014 16:27:49 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8EGRnNo095030; Sun, 14 Sep 2014 16:27:49 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201409141627.s8EGRnNo095030@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 14 Sep 2014 16:27:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271592 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2014 16:27:50 -0000 Author: jilles Date: Sun Sep 14 16:27:49 2014 New Revision: 271592 URL: http://svnweb.freebsd.org/changeset/base/271592 Log: sh: Make checkend() a real function instead of an emulated nested function. No functional change is intended, but the generated code is slightly different. Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sun Sep 14 16:12:43 2014 (r271591) +++ head/bin/sh/parser.c Sun Sep 14 16:27:49 2014 (r271592) @@ -946,6 +946,42 @@ struct tokenstate /* + * Check to see whether we are at the end of the here document. When this + * is called, c is set to the first character of the next input line. If + * we are at the end of the here document, this routine sets the c to PEOF. + * The new value of c is returned. + */ + +static int +checkend(int c, const char *eofmark, char *line, size_t sizeof_line, + int striptabs) +{ + if (striptabs) { + while (c == '\t') + c = pgetc(); + } + if (c == *eofmark) { + if (pfgets(line, sizeof_line) != NULL) { + const char *p, *q; + + p = line; + for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); + if ((*p == '\0' || *p == '\n') && *q == '\0') { + c = PEOF; + if (*p == '\n') { + plinno++; + needprompt = doprompt; + } + } else { + pushstring(line, strlen(line), NULL); + } + } + } + return (c); +} + + +/* * Called to parse command substitutions. */ @@ -1269,7 +1305,6 @@ readcstyleesc(char *out) * will run code that appears at the end of readtoken1. */ -#define CHECKEND() {goto checkend; checkend_return:;} #define PARSEREDIR() {goto parseredir; parseredir_return:;} #define PARSESUB() {goto parsesub; parsesub_return:;} #define PARSEARITH() {goto parsearith; parsearith_return:;} @@ -1303,7 +1338,9 @@ readtoken1(int firstc, char const *initi STARTSTACKSTR(out); loop: { /* for each line, until end of word */ - CHECKEND(); /* set c to PEOF if at end of here document */ + if (eofmark) + /* set c to PEOF if at end of here document */ + c = checkend(c, eofmark, line, sizeof(line), striptabs); for (;;) { /* until end of line or end of word */ CHECKSTRSPACE(4, out); /* permit 4 calls to USTPUTC */ @@ -1484,40 +1521,6 @@ endword: /* - * Check to see whether we are at the end of the here document. When this - * is called, c is set to the first character of the next input line. If - * we are at the end of the here document, this routine sets the c to PEOF. - */ - -checkend: { - if (eofmark) { - if (striptabs) { - while (c == '\t') - c = pgetc(); - } - if (c == *eofmark) { - if (pfgets(line, sizeof line) != NULL) { - const char *p, *q; - - p = line; - for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); - if ((*p == '\0' || *p == '\n') && *q == '\0') { - c = PEOF; - if (*p == '\n') { - plinno++; - needprompt = doprompt; - } - } else { - pushstring(line, strlen(line), NULL); - } - } - } - } - goto checkend_return; -} - - -/* * Parse a redirection operator. The variable "out" points to a string * specifying the fd to be redirected. The variable "c" contains the * first character of the redirection operator.