home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWCommon / Sources / FWPriStr.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  1.9 KB  |  85 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPriStr.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/25/94
  7. //
  8. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWPRISTR_H
  13. #include "FWPriStr.h"
  14. #endif
  15.  
  16. #ifdef FW_BUILD_MAC
  17. #include <Memory.h>
  18. #endif
  19.  
  20.  
  21. //----------------------------------------------------------------------------------------
  22. // FW_PrimitiveStringLength
  23. //----------------------------------------------------------------------------------------
  24.  
  25. size_t FW_PrimitiveStringLength(const char * p)
  26. {
  27.     size_t i = 0;
  28.     for (; *p; p++, i++) ;
  29.  
  30.     return i;
  31. }
  32.  
  33. //----------------------------------------------------------------------------------------
  34. // FW_PrimitiveStringEqual
  35. //----------------------------------------------------------------------------------------
  36.  
  37. int FW_PrimitiveStringEqual(const char *p1, const char *p2)
  38. {
  39.     while (1)
  40.     {
  41.         char c1 = *p1++;
  42.         char c2 = *p2++;
  43.         
  44.         if (c1 != c2) return 0;
  45.         
  46.         if (!c1) return 1;
  47.     }
  48. }
  49.  
  50. //----------------------------------------------------------------------------------------
  51. // FW_PrimitiveStringCopy
  52. //----------------------------------------------------------------------------------------
  53.  
  54. char * FW_PrimitiveStringCopy(char *destination, char *source)
  55. {
  56.     char c;
  57.     
  58.     while ((c = *source++) != 0)
  59.         *destination++ = c;
  60.         
  61.     return source;
  62. }
  63.  
  64. //----------------------------------------------------------------------------------------
  65. // FW_PrimitiveStringFindCharacter
  66. //----------------------------------------------------------------------------------------
  67.  
  68. char * FW_PrimitiveStringFindCharacter(const char *source, char c)
  69. {
  70.     while (1)
  71.     {
  72.         char cc;
  73.         if (c == (cc = *source))
  74.         {
  75.             return (char *) source;
  76.         }
  77.         else if (!cc)
  78.         {
  79.             return NULL;
  80.         }
  81.         else
  82.             source++;
  83.     }
  84. }
  85.