Date: Tue, 16 Jun 2009 16:02:52 -0500 From: Jeffrey Goldberg <jeffrey@goldmark.org> To: Gary Kline <kline@thought.org> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: feedback, comments on this php-delimiter scrubbing program? Message-ID: <E74D0D2C-3D06-4F3D-9801-DF1EBA513C6D@goldmark.org> In-Reply-To: <20090616153040.GA40540@thought.org> References: <20090616012114.GA38011@thought.org> <200906151857.45945.mel.flynn%2Bfbsd.questions@mailing.thruhere.net> <20090616153040.GA40540@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jun 16, 2009, at 10:30 AM, Gary Kline wrote: > I thought my initial getchar() != EOF would handle that. > But then there's that do-forever loop. As I said, the most common problem people had was failing to check of EOF in all the places it could occur, and so looping forever. Do not rely on the input being well formed. > I remember Jeffrey's > post and tried a case 'EOF' or case '-1'; thar gives me > compiler errors. Look at the man page for getchar() paying close attention to the type of what it returns. >> 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. Even for a very simple task, the logic of your code is very very hard to read. Clarify the logic (using the idea of a "state") and you will find that this can be programmed very simply. -j -- Jeffrey Goldberg http://www.goldmark.org/jeff/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E74D0D2C-3D06-4F3D-9801-DF1EBA513C6D>