Enable UTF8 in gnulib regexp.
* config.h.in (RE_ENABLE_I18N) [!GRUB_UTIL]: New define. * grub-core/lib/posix_wrap/ctype.h (islower): Use grub_islower. (isupper): Use grub_isupper. (isascii): New inline function. * grub-core/lib/posix_wrap/wchar.h: Replace dummy with real contents. * grub-core/lib/posix_wrap/wctype.h: Likewise. * grub-core/normal/charset.c (grub_utf8_process): New function. (grub_utf8_to_utf16): Use grub_utf8_process. (grub_encode_utf8_character): New function. (grub_ucs4_to_utf8): Use grub_encode_utf8_character. * include/grub/charset.h (grub_utf8_process): New declaration. (grub_encode_utf8_character): Likewise. * include/grub/misc.h (grub_islower): New inline function. (grub_isupper): Likewise. (grub_strchrsub): Moved down to fix the definitions.
This commit is contained in:
parent
0af2346fdb
commit
c5fc563aff
8 changed files with 380 additions and 106 deletions
|
@ -126,11 +126,22 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
|||
|
||||
int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
|
||||
/* Process one character from UTF8 sequence.
|
||||
At beginning set *code = 0, *count = 0. Returns 0 on failure and
|
||||
1 on success. *count holds the number of trailing bytes. */
|
||||
int
|
||||
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count);
|
||||
|
||||
void
|
||||
grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
||||
grub_uint8_t *dest, grub_size_t destsize);
|
||||
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
/* Returns -2 if not enough space, -1 on invalid character. */
|
||||
grub_ssize_t
|
||||
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
|
||||
grub_uint32_t code);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -175,6 +175,18 @@ grub_isalpha (int c)
|
|||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_islower (int c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_isupper (int c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_isgraph (int c)
|
||||
{
|
||||
|
@ -250,27 +262,6 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
|
|||
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
||||
}
|
||||
|
||||
/* Replace all `ch' characters of `input' with `with' and copy the
|
||||
result into `output'; return EOS address of `output'. */
|
||||
static inline char *
|
||||
grub_strchrsub (char *output, const char *input, char ch, const char *with)
|
||||
{
|
||||
grub_size_t grub_strlen (const char *s);
|
||||
while (*input)
|
||||
{
|
||||
if (*input == ch)
|
||||
{
|
||||
grub_strcpy (output, with);
|
||||
output += grub_strlen (with);
|
||||
input++;
|
||||
continue;
|
||||
}
|
||||
*output++ = *input++;
|
||||
}
|
||||
*output = '\0';
|
||||
return output;
|
||||
}
|
||||
|
||||
unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
|
||||
unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
|
||||
|
||||
|
@ -317,6 +308,26 @@ grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) __attribute__ ((warn_unused
|
|||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
/* Replace all `ch' characters of `input' with `with' and copy the
|
||||
result into `output'; return EOS address of `output'. */
|
||||
static inline char *
|
||||
grub_strchrsub (char *output, const char *input, char ch, const char *with)
|
||||
{
|
||||
while (*input)
|
||||
{
|
||||
if (*input == ch)
|
||||
{
|
||||
grub_strcpy (output, with);
|
||||
output += grub_strlen (with);
|
||||
input++;
|
||||
continue;
|
||||
}
|
||||
*output++ = *input++;
|
||||
}
|
||||
*output = '\0';
|
||||
return output;
|
||||
}
|
||||
|
||||
extern void (*EXPORT_VAR (grub_xputs)) (const char *str);
|
||||
|
||||
static inline int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue