From: phil@miracle.com (Phil Hill)
Newsgroups: comp.bbs.waffle
Subject: Re: The woes of ^Z
Date: 30 Dec 92 12:19:14 GMT
Article-I.D.: miracle.30Dec92081914
Organization: Miracle Computer Consultants

barr@pop.psu.edu (David Barr) writes:
>In article <miXLwB1w165w@1776.COM> bob@1776.COM (Robert Coe) writes:
>>phil@miracle.com (Phil Hill) writes:
>>> The most important argument is that **WAFFLE** doesn't treat ^Z's the same
>>> when run on a UNIX system.  It is important that Waffle remain compatible
>>> with itself.  Or to at least document the difference.
>>
>>But *UNIX* doesn't treat ^Zs the same way as MD-DOS does.  (It doesn't treat
>>file names the same either.  Should Unix Waffle refuse to respond to file
>>names that would be illegal in MS-DOS?)  Should Waffle be "compatible with 
>>itself" or should it try to blend in as much as possible with the environment 
>>in which it's run?
>
>	I agree whole-heartedly.  Phil, you're off your rocker.  Waffle
>should not have to "be compatable with itself".  Such a philosophy forces
>you to stoop to the lowest common denomenator of features for an application.
>It's just plain dumb.
>
>	The solution for the ^Z problem in Waffle is to not put a ^Z in
>DOS text file.  You're asking for trouble anyway.  Tom, it's not worth fixing
>in Waffle unless you have some spare time to write your own DOS text I/O
>routines.

Oh come on here!  If I were in charge of Waffle, one of my major concerns would
be that the UNIX and the DOS versions worked the same.  I can't make DOS
take UNIX filenames (I wish I could), so that's not an issue.  But I could
change the way ^Z is treated.

For all of you that think that this is so hard, I'll give you an example...

*** LAZY ***

	char	buff[256];
	int	len;	
	FILE	*fd = fopen("foo.bar", "r");

	while(fgets(buff, 256, fd))
	{	len = strlen(buff);
		if(buff[len-1] = '\n') { buff[len-1] = '\0'; len--; }

		/* Do something useful with the buffer */
	}

*** NOT SO LAZY ***

	_fmode = O_BINARY;

	/* ... */

	char	buff[256];
	int	len;	
	FILE	*fd = fopen("foo.bar", "r");

	while(fgets(buff, 256, fd))
	{	len = strlen(buff);
		if(buff[len-1] = '\n') { buff[len-1] = '\0'; len--; }
		if(buff[len-1] = '\r') { buff[len-1] = '\0'; len--; }

		/* Do something useful with the buffer */
	}

 - - - - - -

Gee, TWO WHOLE LINES OF CODE!  That was so difficult.  (I don't have Waffle
Source, so I can't tell you what the actual code is.  But this example is
close to the WORST case.  If Waffle doesn't use fgets, it is already scanning
for newlines.  The only change that needs to be made is to ignore CR's)

I hope you now see my point.  THIS IS A SIMPLE FIX.  It's not hard!  It
doesn't involve "Writing your own DOS I/O routines."

As for "stooping to the lowest common denomenator," this is a choice that
a designer has to make.  But whenever you make the decision not to stoop,
it is important to put it in the documentation.


-------------------------------------------------------------------------
| Phil Hill                     | "All you people in TV land,           |
| Miracle Computer Consultants  |   I will wake up your empty shells.   |
|                               |  Peak time viewing blown in a flash,  |
|                               |   as I burn into your memory cells.   |
| Email: phil@miracle.com       |  'cause I'm alive." - Peter Gabriel   |
Newsgroups: comp.bbs.waffle