home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 2.5 KB | 102 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriStr.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FWPRISTR_H
- #include "FWPriStr.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #include <Memory.h>
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWCommon
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_PrimitiveStringLength
- //----------------------------------------------------------------------------------------
-
- size_t FW_FUNC_ATTR FW_PrimitiveStringLength(const char * p)
- {
- size_t i = 0;
- for (; *p; p++, i++) ;
-
- return i;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrimitiveStringEqual
- //----------------------------------------------------------------------------------------
-
- int FW_FUNC_ATTR FW_PrimitiveStringEqual(const char *p1, const char *p2)
- {
- while (1)
- {
- char c1 = *p1++;
- char c2 = *p2++;
-
- if (c1 != c2) return 0;
-
- if (!c1) return 1;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrimitiveStringCopy
- //----------------------------------------------------------------------------------------
-
- void FW_FUNC_ATTR FW_PrimitiveStringCopy(const char *source, char *destination)
- {
- char c;
-
- while ((c = *source++) != '\0')
- *destination++ = c;
-
- *destination = '\0';
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrimitiveStringCatenate
- //----------------------------------------------------------------------------------------
-
- void FW_FUNC_ATTR FW_PrimitiveStringCatenate(const char *source, char *destination)
- {
- size_t len = FW_PrimitiveStringLength(destination);
- FW_PrimitiveStringCopy(source, destination+len);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrimitiveStringFindCharacter
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR char * FW_PrimitiveStringFindCharacter(const char *source, char c)
- {
- while (1)
- {
- char cc;
- if (c == (cc = *source))
- {
- return (char *) source;
- }
- else if (!cc)
- {
- return NULL;
- }
- else
- source++;
- }
- }
-