home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / bbs / waffle / 5734 < prev    next >
Encoding:
Internet Message Format  |  1992-12-31  |  3.4 KB

  1. Path: sparky!uunet!ogicse!das-news.harvard.edu!spdcc!merk!miracle!phil
  2. From: phil@miracle.com (Phil Hill)
  3. Newsgroups: comp.bbs.waffle
  4. Subject: Re: The woes of ^Z
  5. Message-ID: <30Dec92081914@miracle.com>
  6. Date: 30 Dec 92 12:19:14 GMT
  7. Article-I.D.: miracle.30Dec92081914
  8. Organization: Miracle Computer Consultants
  9. Lines: 82
  10.  
  11. barr@pop.psu.edu (David Barr) writes:
  12. >In article <miXLwB1w165w@1776.COM> bob@1776.COM (Robert Coe) writes:
  13. >>phil@miracle.com (Phil Hill) writes:
  14. >>> The most important argument is that **WAFFLE** doesn't treat ^Z's the same
  15. >>> when run on a UNIX system.  It is important that Waffle remain compatible
  16. >>> with itself.  Or to at least document the difference.
  17. >>
  18. >>But *UNIX* doesn't treat ^Zs the same way as MD-DOS does.  (It doesn't treat
  19. >>file names the same either.  Should Unix Waffle refuse to respond to file
  20. >>names that would be illegal in MS-DOS?)  Should Waffle be "compatible with 
  21. >>itself" or should it try to blend in as much as possible with the environment 
  22. >>in which it's run?
  23. >
  24. >    I agree whole-heartedly.  Phil, you're off your rocker.  Waffle
  25. >should not have to "be compatable with itself".  Such a philosophy forces
  26. >you to stoop to the lowest common denomenator of features for an application.
  27. >It's just plain dumb.
  28. >
  29. >    The solution for the ^Z problem in Waffle is to not put a ^Z in
  30. >DOS text file.  You're asking for trouble anyway.  Tom, it's not worth fixing
  31. >in Waffle unless you have some spare time to write your own DOS text I/O
  32. >routines.
  33.  
  34. Oh come on here!  If I were in charge of Waffle, one of my major concerns would
  35. be that the UNIX and the DOS versions worked the same.  I can't make DOS
  36. take UNIX filenames (I wish I could), so that's not an issue.  But I could
  37. change the way ^Z is treated.
  38.  
  39. For all of you that think that this is so hard, I'll give you an example...
  40.  
  41. *** LAZY ***
  42.  
  43.     char    buff[256];
  44.     int    len;    
  45.     FILE    *fd = fopen("foo.bar", "r");
  46.  
  47.     while(fgets(buff, 256, fd))
  48.     {    len = strlen(buff);
  49.         if(buff[len-1] = '\n') { buff[len-1] = '\0'; len--; }
  50.  
  51.         /* Do something useful with the buffer */
  52.     }
  53.  
  54. *** NOT SO LAZY ***
  55.  
  56.     _fmode = O_BINARY;
  57.  
  58.     /* ... */
  59.  
  60.     char    buff[256];
  61.     int    len;    
  62.     FILE    *fd = fopen("foo.bar", "r");
  63.  
  64.     while(fgets(buff, 256, fd))
  65.     {    len = strlen(buff);
  66.         if(buff[len-1] = '\n') { buff[len-1] = '\0'; len--; }
  67.         if(buff[len-1] = '\r') { buff[len-1] = '\0'; len--; }
  68.  
  69.         /* Do something useful with the buffer */
  70.     }
  71.  
  72.  - - - - - -
  73.  
  74. Gee, TWO WHOLE LINES OF CODE!  That was so difficult.  (I don't have Waffle
  75. Source, so I can't tell you what the actual code is.  But this example is
  76. close to the WORST case.  If Waffle doesn't use fgets, it is already scanning
  77. for newlines.  The only change that needs to be made is to ignore CR's)
  78.  
  79. I hope you now see my point.  THIS IS A SIMPLE FIX.  It's not hard!  It
  80. doesn't involve "Writing your own DOS I/O routines."
  81.  
  82. As for "stooping to the lowest common denomenator," this is a choice that
  83. a designer has to make.  But whenever you make the decision not to stoop,
  84. it is important to put it in the documentation.
  85.  
  86.  
  87. -------------------------------------------------------------------------
  88. | Phil Hill                     | "All you people in TV land,           |
  89. | Miracle Computer Consultants  |   I will wake up your empty shells.   |
  90. |                               |  Peak time viewing blown in a flash,  |
  91. |                               |   as I burn into your memory cells.   |
  92. | Email: phil@miracle.com       |  'cause I'm alive." - Peter Gabriel   |
  93.