From owner-freebsd-questions@FreeBSD.ORG Tue Jun 16 02:57:48 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B23E106564A for ; Tue, 16 Jun 2009 02:57:48 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id EFFEA8FC13 for ; Tue, 16 Jun 2009 02:57:47 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from smoochies.rachie.is-a-geek.net (mailhub.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id D71E77E83F; Mon, 15 Jun 2009 18:57:46 -0800 (AKDT) From: Mel Flynn To: freebsd-questions@freebsd.org Date: Mon, 15 Jun 2009 18:57:45 -0800 User-Agent: KMail/1.11.4 (FreeBSD/8.0-CURRENT; KDE/4.2.4; i386; ; ) References: <20090616012114.GA38011@thought.org> In-Reply-To: <20090616012114.GA38011@thought.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906151857.45945.mel.flynn+fbsd.questions@mailing.thruhere.net> Cc: Gary Kline Subject: Re: feedback, comments on this php-delimiter scrubbing program? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2009 02:57:48 -0000 On Monday 15 June 2009 17:21:16 Gary Kline wrote: > Encl: dephp.c, test case '?': ch = getchar(); while (1) { if (ch == '?' && (ch = getchar()) == '>') { break; } else { ch = getchar(); } } break; As has been hinted before you're not handling the EOF case. Files like: , because one can start filling the output by trailing whitespace before EOF and thus not set any header() anymore. The above code will wait indefinitely for the next char or spin like mad if you're using non-blocking IO. You should really take the pointers from Jeffrey Goldberg and record states and decide based on the state, rather then inlined switch statements, if only for readability. You're also in trouble with