diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-10-12 15:45:05 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-10-12 15:45:05 +0000 |
commit | f25189be509e670d3aefc9339fa45683803185f8 (patch) | |
tree | 4dcde7c80d2a3dd58016a18669beab4578094371 /src/pcre2_string_utils.c | |
parent | 7ec57ec64b87520e01ff0d7493821c255d768408 (diff) | |
download | pcre2-f25189be509e670d3aefc9339fa45683803185f8.tar.gz |
Create PRIV(strcpy_c8) for copying config strings.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@107 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src/pcre2_string_utils.c')
-rw-r--r-- | src/pcre2_string_utils.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/pcre2_string_utils.c b/src/pcre2_string_utils.c index 8b0a45d..1a6864b 100644 --- a/src/pcre2_string_utils.c +++ b/src/pcre2_string_utils.c @@ -160,7 +160,6 @@ return 0; } - /************************************************* * Find the length of a PCRE2 string * *************************************************/ @@ -178,4 +177,28 @@ while (*str++ != 0) c++; return c; } + +/************************************************* +* Copy 8-bit 0-terminated string to PCRE2 string * +*************************************************/ + +/* Arguments: + str1 buffer to receive the string + length length of buffer in code units + str2 8-bit string to be copied + +Returns: the number of code units used (excluding trailing zero) + PCRE2_ERROR_BADLENGTH (a negative number) if buffer is too small +*/ + +int +PRIV(strcpy_c8)(PCRE2_UCHAR *str1, size_t length, const char *str2) +{ +PCRE2_UCHAR *t = str1; +if (strlen(str2) >= length) return PCRE2_ERROR_BADLENGTH; +while (*str2 != 0) *t++ = *str2++; +*t = 0; +return t - str1; +} + /* End of pcre2_string_utils.c */ |