home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / text / ExAll.patch < prev    next >
Internet Message Format  |  2014-05-19  |  3KB

  1. Path: zikzak!cbmger!cbmehq!cbmvax!jesup
  2. From: jesup@cbmvax.commodore.com (Randell Jesup)
  3. Newsgroups: adsp.betatips
  4. Subject: Re: ExAll() & ED_COMMENT
  5. Message-ID: <31483@cbmvax.commodore.com>
  6. Date: 29 May 92 20:27:14 GMT
  7. References: <sticht.05ql@edith.deg.sub.org> <31443@cbmvax.commodore.com>
  8. Reply-To: jesup@cbmvax.commodore.com (Randell Jesup)
  9. Distribution: adsp
  10. Organization: Commodore, West Chester, PA
  11. Lines: 77
  12.  
  13. mks@cbmvax.commodore.com (Michael Sinz) writes:
  14. >sticht@edith.deg.sub.org (Stefan Sticht) writes:
  15. >>I'm just using ExAll() (dos.library 37.44) the first time with  ED_COMMENT.
  16. >>Everything works fine except that  the  string  ead->ed_Comment  points  to
  17. >>isn't NULL-terminated.
  18. >>
  19. >>Is this a bug or am I doing something wrong?
  20. >>If it's a bug, is there a more simple work-around than looking at the
  21. >>FileInfoBlock?
  22. >
  23. >This is a bug...  It turns out that the V37 FFS does the comment wrong when
  24. >in ExAll().  It does it as a BSTR rather than a standard C-String.  Other
  25. >filesystems (such as RAM) do it right.  Also, filesystems that do not directly
  26. >support ExAll() but have DOS simulate it do it right too.
  27.  
  28.     A workable but _ugly_ workaround (rough code, modify to suit):
  29.  
  30.     // Assumes you used ED_COMMENT
  31.     if (dosversion <= 37)
  32.     {
  33.         if (ed->ed_Comment)
  34.         {
  35.         // The rom fs and ram: and dos emulation all store name first.
  36.         // If there's no ed_Next, though, we don't know how big it is.
  37.         if (ed->ed_Comment > ed->ed_Name)
  38.             if (ed->ed_Next)
  39.                 size = ed->ed_Next - ed->ed_Comment;
  40.             else
  41.                 size = -1;
  42.         else
  43.             it's a C-string comment.
  44.  
  45.         // We now have the size available for the comment.  does this
  46.         // appear to be a comment?
  47.         // The tests for long-aligned ptrs takes advantage of knowledge
  48.         // that the filesystem with this problem always did that.
  49.         // This _can_ be fooled (for example by a 66-character comment
  50.         // that starts with an 'A').
  51.         // The devicename() != NULL check will kick out NFS volumes.
  52.  
  53.         if (devicename(lock) != NULL &&
  54.             strcmp(devicename(lock),"RAM") != SAME &&
  55.             (!(ed->ed_Comment & 3)) &&
  56.             (!(ed->ed_Name & 3)) &&
  57.             ((UBYTE) (ed->ed_Comment)[0]) < 80 &&
  58.             (size == -1 ||
  59.              (((UBYTE) (ed->ed_Comment)[0]) <= size-1 &&
  60.               ((UBYTE) (ed->ed_Comment)[0]) >= size-5)))
  61.         {
  62.             BtoCStr(ed->ed_Comment);
  63.         } else
  64.             it's a c-string comment.
  65.         }
  66.     }
  67.  
  68.  
  69. devicename() probably should be done before calling exall so you only do it
  70. once (ditto for the RAM compare).  scan the dos device list for a DLT_DEVICE
  71. with the same dol_Task, and if found return BADDR(dol_Name)+1 otherwise NULL.
  72. (Use LockDosList/etc).
  73.  
  74. For pure paranoia, see if any comments don't fit BCPL, and if any don't then
  75. you know that all of them aren't BCPL.  However, the tests above will do
  76. almost as well.
  77.  
  78. Any publicly released system with > V37 dos will have a fixed FS, though
  79. early betas may not.
  80.  
  81. Ugh, what an annoying bug....
  82.  
  83. -- 
  84. "Thus spake the Master Ninjei: If your application does not run correctly,
  85. do not blame the operating system." - The Zen of Programming
  86. -
  87. Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
  88. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
  89. Disclaimer: Nothing I say is anything other than my personal opinion.
  90.