feedback, comments on this php-delimiter scrubbing program?
Gary Kline
kline at thought.org
Tue Jun 16 15:30:46 UTC 2009
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:
> <?php
> 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 <?xml, but that's an entirely different beast and
> you might actually be doing the right thing from your usage perspective.
> --
> Mel
--
Gary Kline kline at 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
More information about the freebsd-questions
mailing list