Create PRIV(strcpy_c8) for copying config strings.
This commit is contained in:
parent
0ec351e95e
commit
3ab47d70b0
|
@ -150,11 +150,7 @@ switch (what)
|
|||
#else
|
||||
const char *v = "Unicode not supported";
|
||||
#endif
|
||||
PCRE2_UCHAR *t = (PCRE2_UCHAR *)where;
|
||||
if (strlen(v) >= BYTES2CU(length) - 1) return PCRE2_ERROR_BADLENGTH;
|
||||
while (*v != 0) *t++ = *v++;
|
||||
*t = 0;
|
||||
return t - (PCRE2_UCHAR *)where;
|
||||
return PRIV(strcpy_c8)((PCRE2_UCHAR *)where, BYTES2CU(length), v);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -187,14 +183,10 @@ switch (what)
|
|||
|
||||
case PCRE2_CONFIG_VERSION:
|
||||
{
|
||||
PCRE2_UCHAR *t = (PCRE2_UCHAR *)where;
|
||||
const char *v = (XSTRING(Z PCRE2_PRERELEASE)[1] == 0)?
|
||||
XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
|
||||
XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
|
||||
if (strlen(v) >= BYTES2CU(length) - 1) return PCRE2_ERROR_BADLENGTH;
|
||||
while (*v != 0) *t++ = *v++;
|
||||
*t = 0;
|
||||
return t - (PCRE2_UCHAR *)where;
|
||||
return PRIV(strcpy_c8)((PCRE2_UCHAR *)where, BYTES2CU(length), v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1865,13 +1865,14 @@ is available. */
|
|||
#define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_)
|
||||
#define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_)
|
||||
#define _pcre2_ord2utf PCRE2_SUFFIX(_pcre2_ord2utf_)
|
||||
#define _pcre2_strcmp PCRE2_SUFFIX(_pcre_strcmp_)
|
||||
#define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre_strcmp_c8_)
|
||||
#define _pcre2_strlen PCRE2_SUFFIX(_pcre_strlen_)
|
||||
#define _pcre2_strncmp PCRE2_SUFFIX(_pcre_strncmp_)
|
||||
#define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre_strncmp_c8_)
|
||||
#define _pcre2_study PCRE2_SUFFIX(_pcre_study_)
|
||||
#define _pcre2_valid_utf PCRE2_SUFFIX(_pcre_valid_utf_)
|
||||
#define _pcre2_strcmp PCRE2_SUFFIX(_pcre2_strcmp_)
|
||||
#define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre2_strcmp_c8_)
|
||||
#define _pcre2_strcpy_c8 PCRE2_SUFFIX(_pcre2_strcpy_c8_)
|
||||
#define _pcre2_strlen PCRE2_SUFFIX(_pcre2_strlen_)
|
||||
#define _pcre2_strncmp PCRE2_SUFFIX(_pcre2_strncmp_)
|
||||
#define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre2_strncmp_c8_)
|
||||
#define _pcre2_study PCRE2_SUFFIX(_pcre2_study_)
|
||||
#define _pcre2_valid_utf PCRE2_SUFFIX(_pcre2_valid_utf_)
|
||||
#define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_)
|
||||
#define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_)
|
||||
|
||||
|
@ -1885,6 +1886,7 @@ extern void *_pcre2_memctl_malloc(size_t, pcre2_memctl *);
|
|||
extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);
|
||||
extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);
|
||||
extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *);
|
||||
extern int _pcre2_strcpy_c8(PCRE2_UCHAR *, size_t, const char *);
|
||||
extern int _pcre2_strlen(PCRE2_SPTR);
|
||||
extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
|
||||
extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue