From owner-freebsd-questions@FreeBSD.ORG Tue Jun 16 15:30:46 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 1454E106567D for ; Tue, 16 Jun 2009 15:30:46 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (ns1.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id A894C8FC2A for ; Tue, 16 Jun 2009 15:30:45 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id n5GFUf3n025080; Tue, 16 Jun 2009 08:30:41 -0700 (PDT) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Tue, 16 Jun 2009 08:30:41 -0700 (PDT) Date: Tue, 16 Jun 2009 08:30:40 -0700 From: Gary Kline To: Mel Flynn Message-ID: <20090616153040.GA40540@thought.org> References: <20090616012114.GA38011@thought.org> <200906151857.45945.mel.flynn+fbsd.questions@mailing.thruhere.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200906151857.45945.mel.flynn+fbsd.questions@mailing.thruhere.net> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 22++ years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: freebsd-questions@freebsd.org 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 15:30:46 -0000 On Mon, Jun 15, 2009 at 06:57:45PM -0800, Mel Flynn wrote: > 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: > class foo > { > function __construct() { echo 'foo'; }; > }; > > Are perfectly valid php files and actually preferred for included files, > rather then a terminating ?>, 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. YUP. I thought my initial getchar() != EOF would handle that. But then there's that do-forever loop. I remember Jeffrey's post and tried a case 'EOF' or case '-1'; thar gives me compiler errors. Suggestions? > > 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 you might actually be doing the right thing from your usage perspective. > -- > Mel -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org For FBSD list: http://transfinite.thought.org/slicejourney.php The 4.98a release of Jottings: http://jottings.thought.org/index.php