Changeset 96045 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Aug 5, 2022 12:26:04 AM (2 years ago)
- Location:
- trunk/src/VBox/Runtime/common/string
- Files:
-
- 4 added
- 1 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strcat.cpp
r96044 r96045 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - CRT Strings, strc py().3 * IPRT - CRT Strings, strcat(). 4 4 */ 5 5 … … 34 34 35 35 /** 36 * Copy a string36 * Append one string to another. 37 37 * 38 38 * @returns Pointer to destination string 39 * @param pszDst Will contain a copy of pszSrc.39 * @param pszDst String to append @a pszSrc to. 40 40 * @param pszSrc Zero terminated string. 41 41 */ 42 #ifdef IPRT_NO_CRT 43 # undef strcpy 44 char *RT_NOCRT(strcpy)(char *pszDst, const char *pszSrc) 45 #else 46 char *strcpy(char *pszDst, const char *pszSrc) 47 #endif 42 #undef strcat 43 char *RT_NOCRT(strcat)(char *pszDst, const char *pszSrc) 48 44 { 49 45 char * const pszRet = pszDst; 46 pszDst = RTStrEnd(pszDst, RTSTR_MAX); 50 47 while ((*pszDst = *pszSrc++) != '\0') 51 48 pszDst++; … … 53 50 return pszRet; 54 51 } 55 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strc py);52 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strcat); 56 53 -
trunk/src/VBox/Runtime/common/string/strlen.cpp
r96043 r96045 41 41 #ifdef IPRT_NO_CRT 42 42 # undef strlen 43 size_t strlen(const char *pszString)43 size_t RT_NOCRT(strlen)(const char *pszString) 44 44 #elif RT_MSC_PREREQ(RT_MSC_VER_VS2005) 45 45 __checkReturn size_t __cdecl strlen(__in_z const char *pszString) -
trunk/src/VBox/Runtime/common/string/strncat.cpp
r96044 r96045 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - CRT Strings, strcpy().3 * IPRT - No-CRT Strings, strncat(). 4 4 */ 5 5 … … 34 34 35 35 /** 36 * Copy a string36 * Append a substring to an existing string. 37 37 * 38 38 * @returns Pointer to destination string 39 * @param pszDst Will contain a copy of pszSrc. 39 * @param pszDst String to append @a cchMaxSrc chars from @a pszSrc to, 40 * plus a zero terminator. 40 41 * @param pszSrc Zero terminated string. 42 * @param cchMaxSrc Maximum number of chars to copy from @a pszSrc. 41 43 */ 42 #ifdef IPRT_NO_CRT 43 # undef strcpy 44 char *RT_NOCRT(strcpy)(char *pszDst, const char *pszSrc) 45 #else 46 char *strcpy(char *pszDst, const char *pszSrc) 47 #endif 44 #undef strncat 45 char *RT_NOCRT(strncat)(char *pszDst, const char *pszSrc, size_t cchMaxSrc) 48 46 { 49 47 char * const pszRet = pszDst; 50 while ((*pszDst = *pszSrc++) != '\0') 51 pszDst++; 48 49 pszDst = RTStrEnd(pszDst, RTSTR_MAX); 50 51 char ch; 52 while (cchMaxSrc-- > 0 && (ch = *pszSrc++) != '\0') 53 *pszDst++ = ch; 54 *pszDst = '\0'; 52 55 53 56 return pszRet; 54 57 } 55 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(str cpy);58 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strncat); 56 59 -
trunk/src/VBox/Runtime/common/string/strnlen.cpp
r96043 r96045 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - CRT Strings, str len().3 * IPRT - CRT Strings, strnlen(). 4 4 */ 5 5 … … 34 34 35 35 /** 36 * Find the length of a zeroterminated byte string. 36 * Find the length of a zeroterminated byte string, but only up to a given 37 * limit. 37 38 * 38 * @returns String length in bytes .39 * @returns String length in bytes, or cchMax if too long. 39 40 * @param pszString Zero terminated string. 41 * @param cchMax Max number of chars to search for the end. 40 42 */ 41 #ifdef IPRT_NO_CRT 42 # undef strlen 43 size_t strlen(const char *pszString) 44 #elif RT_MSC_PREREQ(RT_MSC_VER_VS2005) 45 __checkReturn size_t __cdecl strlen(__in_z const char *pszString) 46 #else 47 size_t strlen(const char *pszString) 48 #endif 43 #undef strnlen 44 size_t RT_NOCRT(strnlen)(const char *pszString, size_t cchMax) 49 45 { 50 const char * psz= pszString;51 while ( *psz)52 psz ++;53 return psz - pszString;46 const char * const pszStart = pszString; 47 while (cchMax-- > 0 && *pszString) 48 pszString++; 49 return pszString - pszStart; 54 50 } 55 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(str len);51 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strnlen); 56 52
Note:
See TracChangeset
for help on using the changeset viewer.