From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Rost Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#4616: 23.1.50; empty script files Date: Mon, 5 Oct 2009 05:11:36 +0200 (CEST) Message-ID: <20091005031136.CD61EEFB40@sonic02.math.uni-bielefeld.de> References: <20091002140131.2998D2865C20@xen12.math.uni-bielefeld.de> Reply-To: Markus Rost , 4616@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1254713246 24058 80.91.229.12 (5 Oct 2009 03:27:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Oct 2009 03:27:26 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, 4616@emacsbugs.donarmstrong.com To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 05 05:27:21 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MueEK-0001dE-Oh for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Oct 2009 05:27:21 +0200 Original-Received: from localhost ([127.0.0.1]:36296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MueEK-0000lv-Dq for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Oct 2009 23:27:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MueEF-0000lc-D4 for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2009 23:27:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MueEC-0000ke-06 for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2009 23:27:15 -0400 Original-Received: from [199.232.76.173] (port=43764 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MueEB-0000kS-Fw for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2009 23:27:11 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:34769) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MueEB-0005mo-20 for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2009 23:27:11 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n953R8cb025501; Sun, 4 Oct 2009 20:27:09 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n953K4dA024324; Sun, 4 Oct 2009 20:20:04 -0700 Resent-Date: Sun, 4 Oct 2009 20:20:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Markus Rost Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Mon, 05 Oct 2009 03:20:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4616 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125471230423474 (code B ref -1); Mon, 05 Oct 2009 03:20:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 5 Oct 2009 03:11:44 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n953BgI7023471 for ; Sun, 4 Oct 2009 20:11:44 -0700 Original-Received: from mail.gnu.org ([199.232.76.166]:35812 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1MudzB-0001cQ-M5 for emacs-pretest-bug@gnu.org; Sun, 04 Oct 2009 23:11:41 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Mudz9-0002ha-F4 for emacs-pretest-bug@gnu.org; Sun, 04 Oct 2009 23:11:41 -0400 Original-Received: from xen16.math.uni-bielefeld.de ([129.70.14.14]:42391) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mudz8-0002gw-Rp for emacs-pretest-bug@gnu.org; Sun, 04 Oct 2009 23:11:39 -0400 Original-Received: from sonic02.math.uni-bielefeld.de (sonic02.math.uni-bielefeld.de [129.70.14.134]) by xen16.math.uni-bielefeld.de (Postfix) with ESMTP id E8F8F30072BE; Mon, 5 Oct 2009 05:11:36 +0200 (CEST) Original-Received: by sonic02.math.uni-bielefeld.de (Postfix, from userid 3710) id CD61EEFB40; Mon, 5 Oct 2009 05:11:36 +0200 (CEST) In-reply-to: (message from Andreas Schwab on Sun, 04 Oct 2009 10:13:03 +0200) X-GNU-Emacs-Mailer: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sun, 04 Oct 2009 23:27:15 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:31688 gmane.emacs.pretest.bugs:25095 Archived-At: What about the following tentative patch? It moves the handling of '#!' from read1 up to readevalloop, which then would skip the first line if it starts with '#!'. To achieve this, the patch allows the readchar/unreadchar mechanism to look 2 characters ahead, instead of just 1. Omitting ' && first_sexp' in the patch would skip '#!' + rest of line anywhere as before. Be aware that I just made some guesses after glancing briefly over lread.c (and I am not a C-programmer). *** /home/rost/build/cvs/emacs/src/lread.c.~1.414~ 2009-10-05 01:38:28.000000000 +0200 --- /home/rost/build/cvs/emacs/src/lread.c 2009-10-05 04:31:51.000000000 +0200 *************** *** 271,276 **** --- 271,277 ---- a file stream can't handle multibyte-char unreading. The value -1 means that there's no unread character. */ static int unread_char; + static int unread_char1; static int readchar (readcharfun, multibyte) *************** *** 410,415 **** --- 411,422 ---- return XINT (tem); read_multibyte: + if (unread_char1 >= 0) + { + c = unread_char1; + unread_char1 = -1; + return c; + } if (unread_char >= 0) { c = unread_char; *************** *** 489,499 **** } else if (CONSP (readcharfun)) { ! unread_char = c; } else if (EQ (readcharfun, Qlambda)) { ! unread_char = c; } else if (EQ (readcharfun, Qget_file_char) || EQ (readcharfun, Qget_emacs_mule_file_char)) --- 496,512 ---- } else if (CONSP (readcharfun)) { ! if (unread_char >= 0) ! unread_char1 = c; ! else ! unread_char = c; } else if (EQ (readcharfun, Qlambda)) { ! if (unread_char >= 0) ! unread_char1 = c; ! else ! unread_char = c; } else if (EQ (readcharfun, Qget_file_char) || EQ (readcharfun, Qget_emacs_mule_file_char)) *************** *** 505,511 **** UNBLOCK_INPUT; } else ! unread_char = c; } else call1 (readcharfun, make_number (c)); --- 518,527 ---- UNBLOCK_INPUT; } else ! if (unread_char >= 0) ! unread_char1 = c; ! else ! unread_char = c; } else call1 (readcharfun, make_number (c)); *************** *** 1658,1663 **** --- 1674,1680 ---- Lisp_Object start, end; { register int c; + register int c1; register Lisp_Object val; int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; *************** *** 1747,1752 **** --- 1764,1782 ---- unbind_to (count1, Qnil); break; } + if (c == '#' && first_sexp) + { + c1 = READCHAR; + if (c1 == '!') + { + /* #! appears at the beginning of an executable file. + Skip the first line. */ + while ((c1 = READCHAR) != '\n' && c1 != -1); + goto read_next; + } + else + UNREAD (c1); + } /* Ignore whitespace here, so we can detect eof. */ if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' *************** *** 2607,2620 **** load_each_byte = 0; goto retry; } - if (c == '!') - { - /* #! appears at the beginning of an executable file. - Skip the first line. */ - while (c != '\n' && c >= 0) - c = READCHAR; - goto retry; - } if (c == '$') return Vload_file_name; if (c == '\'') --- 2637,2642 ----