home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13143 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  2.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!eos!data.nas.nasa.gov!taligent!keith@taligent.com
  2. From: keith@taligent.com (Keith Rollin)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: PLstrcmp?? Do the right thing!
  5. Message-ID: <Bs56G5.1Jy@taligent.com>
  6. Date: 29 Jul 92 08:33:41 GMT
  7. References: <jpurlia-280792143857@129.46.5.45>
  8. Sender: usenet@taligent.com (More Bytes Than You Can Read)
  9. Organization: Taligent
  10. Lines: 42
  11.  
  12. In article <jpurlia-280792143857@129.46.5.45>, jpurlia@qualcomm.com (John
  13. Purlia) writes:
  14. > Has anyone else noticed the effective weirdness of PLstrcmp in MPW?  I'm
  15. > using qsort to sort a list of pascal style strings in ascending alphabetic
  16. > order.  My comparison function basically uses a PLstrcmp to test equality
  17. > of the list elements.  Here's the weird part:  PLstrcmp thinks that "Public
  18. > Folder" comes before "Public".  If I take the same data, convert each
  19. > element to C style using p2cstr, and use strcmp in my comparison function,
  20. > "Public" comes before "Public Folder" just as you would expect.
  21. > Is there a known bug in PLstrcmp (MPW 3.2) or for that matter any of the
  22. > other Pascal style string routines?  Is there a fix or am I going to have
  23. > to do the convert to C conversion all over the place?  (No, the toolbox
  24. > routine I'm using to get the data does not have a C string equivalent.)
  25.  
  26. I don't know about PLstrcmp. If I were in your position, I'd do one of two
  27. things:
  28.  
  29. - Disassemble PLstrcmp and see WTF was going on.
  30. - Use one of the toolbox routines that compares Pascal strings (RelString,
  31. EqualString, IUCompString, IUMagString, IUEqualString, or IUMagIDString). Here
  32. are some notes I have on the functions (I can never keep them straight!):
  33.  
  34.     Name            Takes   Case    Diac    Returns         Trap used
  35.     --------------  ------- -----   -----   ------------    ----------
  36.     RelString:      Str255  spec    spec    -1, 0, 1        _RelString
  37.     EqualString:    Str255  spec    spec    Boolean         _CmpString
  38.  
  39.     IUCompString:   Str255  TRUE    TRUE    -1, 0, 1        _Pack6,#10
  40.     IUMagString:    Ptr/len TRUE    TRUE    -1, 0, 1        _Pack6,#10
  41.  
  42.     IUEqualString:  Str255  FALSE   FALSE   Inv. Boolean    _Pack6,#12
  43.     IUMagIDString:  Ptr/len FALSE   FALSE   Inv. Boolean    _Pack6,#12
  44.  
  45. The Case and Diac columns refer to whether or not the functions are sensitive to
  46. case or diacriticals. "spec" means that you can specify whether they are or not.
  47.  
  48. --
  49. Keith Rollin
  50. Phantom Programmer
  51. Taligent, Inc.
  52.