2014-05-13 13:20:03 +02:00
|
|
|
/***************************************************
|
|
|
|
* A program for testing the Unicode property table *
|
|
|
|
***************************************************/
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
/* Copyright (c) University of Cambridge 2008-2022 */
|
2014-05-13 13:20:03 +02:00
|
|
|
|
|
|
|
/* Compile thus:
|
2019-07-30 19:59:42 +02:00
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
gcc -DHAVE_CONFIG_H -DPCRE2_CODE_UNIT_WIDTH=8 -o ucptest \
|
|
|
|
ucptest.c ../src/pcre2_ucd.c ../src/pcre2_tables.c
|
2019-07-30 19:59:42 +02:00
|
|
|
|
|
|
|
Add -lreadline or -ledit if PCRE2 was configured with readline or libedit
|
|
|
|
support in pcre2test.
|
2014-05-13 13:20:03 +02:00
|
|
|
*/
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
/* This is a hacked-up program for testing the Unicode properties tables of
|
2022-01-09 15:46:43 +01:00
|
|
|
PCRE2. It can also be used for finding characters with certain properties. I
|
|
|
|
wrote it to help with debugging, and have added things that I found useful, in
|
|
|
|
a rather haphazard way. The code has never been seriously tidied or checked for
|
|
|
|
robustness, but it shouldn't now give compiler warnings.
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
There is only one option: "-s". If given, it applies only to the "findprop"
|
|
|
|
command. It causes the UTF-8 sequence of bytes that encode the character to be
|
|
|
|
output between angle brackets at the end of the line. On a UTF-8 terminal, this
|
2020-04-01 19:00:33 +02:00
|
|
|
will show the appropriate graphic for the code point.
|
|
|
|
|
|
|
|
If the command has arguments, they are concatenated into a buffer, separated by
|
|
|
|
spaces. If the first argument starts "U+" or consists entirely of hexadecimal
|
|
|
|
digits, "findprop" is inserted at the start. The buffer is then processed as a
|
|
|
|
single line file, after which the program exits. If there are no arguments, the
|
2021-12-05 18:44:59 +01:00
|
|
|
program reads commands line by line on stdin and writes output to stdout. The
|
2020-04-01 19:00:33 +02:00
|
|
|
return code is always zero.
|
|
|
|
|
|
|
|
There are three commands:
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
The command "findprop" must be followed by a space-separated list of Unicode
|
|
|
|
code points as hex numbers, either without any prefix or starting with "U+", or
|
|
|
|
as individual UTF-8 characters preceded by '+'. For example:
|
2021-12-08 16:34:27 +01:00
|
|
|
|
|
|
|
findprop U+1234 5Abc +?
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
The output is one long line per character, listing Unicode properties that have
|
|
|
|
values, followed by its other case or cases if one or more exist, followed by
|
|
|
|
its Script Extension list if there is one. This list is in square brackets. A
|
|
|
|
second list in square brackets gives all the Boolean properties of the
|
|
|
|
character. The properties that come first are:
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
Bidi class e.g. NSM (most common is L)
|
|
|
|
General type e.g. Letter
|
|
|
|
Specific type e.g. Upper case letter
|
|
|
|
Script e.g. Medefaidrin
|
|
|
|
Grapheme break type e.g. Extend (most common is Other)
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
Script names and Boolean property names are all in lower case, with underscores
|
|
|
|
and hyphens removed, because that's how they are stored for "loose" matching.
|
2021-12-08 16:34:27 +01:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
The command "find" must be followed by a list of property types and their
|
|
|
|
values. The values are case-sensitive, except for bidi class. This finds
|
|
|
|
characters that have those properties. If multiple properties are listed, they
|
|
|
|
must all be matched. Currently supported:
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
script <name> The character must have this script property. Only one
|
|
|
|
such script may be given.
|
|
|
|
scriptx <name> This script must be in the character's Script Extension
|
|
|
|
property list. If this is used many times, all the given
|
|
|
|
scripts must be present.
|
2020-04-01 19:00:33 +02:00
|
|
|
type <abbrev> The character's specific type (e.g. Lu or Nd) must match.
|
2018-10-14 16:27:16 +02:00
|
|
|
gbreak <name> The grapheme break property must match.
|
2021-12-05 18:44:59 +01:00
|
|
|
bidi <class> The character's bidi class must match.
|
2022-01-09 15:46:43 +01:00
|
|
|
bool <name> The character's Boolean property list must contain this
|
|
|
|
property.
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
If a <name> or <abbrev> is preceded by !, the value must NOT be present. For
|
2022-01-09 15:46:43 +01:00
|
|
|
Script Extensions and Boolean properties, there may be a mixture of positive
|
|
|
|
and negative requirements. All must be satisfied.
|
2018-10-14 16:27:16 +02:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
Sequences of two or more characters are shown as ranges, for example
|
|
|
|
U+0041..U+004A. No more than 100 lines are are output. If there are more
|
2021-12-05 18:44:59 +01:00
|
|
|
characters, the list ends with ...
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
The command "list" must be followed by one of property names script, bool,
|
|
|
|
type, gbreak or bidi. The defined values for that property are listed. */
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../src/config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-09-19 09:43:39 +02:00
|
|
|
#ifndef SUPPORT_UNICODE
|
|
|
|
#define SUPPORT_UNICODE
|
2014-05-13 13:20:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "../src/pcre2_internal.h"
|
|
|
|
#include "../src/pcre2_ucp.h"
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
|
|
|
|
#if defined(SUPPORT_LIBREADLINE)
|
|
|
|
#include <readline/readline.h>
|
|
|
|
#include <readline/history.h>
|
|
|
|
#else
|
|
|
|
#if defined(HAVE_EDITLINE_READLINE_H)
|
|
|
|
#include <editline/readline.h>
|
|
|
|
#else
|
|
|
|
#include <readline/readline.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-05-13 13:20:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#define CS (char *)
|
|
|
|
#define CCS (const char *)
|
|
|
|
#define CSS (char **)
|
|
|
|
#define US (unsigned char *)
|
|
|
|
#define CUS (const unsigned char *)
|
|
|
|
#define USS (unsigned char **)
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------*/
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
static BOOL show_character = FALSE;
|
|
|
|
|
|
|
|
static const unsigned char *type_names[] = {
|
|
|
|
US"Cc", US"Control",
|
|
|
|
US"Cf", US"Format",
|
|
|
|
US"Cn", US"Unassigned",
|
|
|
|
US"Co", US"Private use",
|
|
|
|
US"Cs", US"Surrogate",
|
|
|
|
US"Ll", US"Lower case letter",
|
|
|
|
US"Lm", US"Modifier letter",
|
|
|
|
US"Lo", US"Other letter",
|
|
|
|
US"Lt", US"Title case letter",
|
|
|
|
US"Lu", US"Upper case letter",
|
|
|
|
US"Mc", US"Spacing mark",
|
|
|
|
US"Me", US"Enclosing mark",
|
|
|
|
US"Mn", US"Non-spacing mark",
|
|
|
|
US"Nd", US"Decimal number",
|
|
|
|
US"Nl", US"Letter number",
|
|
|
|
US"No", US"Other number",
|
|
|
|
US"Pc", US"Connector punctuation",
|
|
|
|
US"Pd", US"Dash punctuation",
|
|
|
|
US"Pe", US"Close punctuation",
|
|
|
|
US"Pf", US"Final punctuation",
|
|
|
|
US"Pi", US"Initial punctuation",
|
|
|
|
US"Po", US"Other punctuation",
|
|
|
|
US"Ps", US"Open punctuation",
|
|
|
|
US"Sc", US"Currency symbol",
|
|
|
|
US"Sk", US"Modifier symbol",
|
|
|
|
US"Sm", US"Mathematical symbol",
|
|
|
|
US"So", US"Other symbol",
|
|
|
|
US"Zl", US"Line separator",
|
|
|
|
US"Zp", US"Paragraph separator",
|
2021-12-05 18:44:59 +01:00
|
|
|
US"Zs", US"Space separator"
|
2018-10-14 16:27:16 +02:00
|
|
|
};
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
static const unsigned char *gb_names[] = {
|
|
|
|
US"CR", US"carriage return",
|
|
|
|
US"LF", US"linefeed",
|
|
|
|
US"Control", US"",
|
|
|
|
US"Extend", US"",
|
|
|
|
US"Prepend", US"",
|
|
|
|
US"SpacingMark", US"",
|
|
|
|
US"L", US"Hangul syllable type L",
|
|
|
|
US"V", US"Hangul syllable type V",
|
|
|
|
US"T", US"Hangul syllable type T",
|
|
|
|
US"LV", US"Hangul syllable type LV",
|
|
|
|
US"LVT", US"Hangul syllable type LVT",
|
2021-12-26 18:49:58 +01:00
|
|
|
US"Regional_Indicator", US"",
|
2020-04-01 19:00:33 +02:00
|
|
|
US"Other", US"",
|
|
|
|
US"ZWJ", US"zero width joiner",
|
|
|
|
US"Extended_Pictographic", US""
|
2018-10-14 16:27:16 +02:00
|
|
|
};
|
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
static const unsigned char *bd_names[] = {
|
|
|
|
US"AL", US"Arabic letter",
|
|
|
|
US"AN", US"Arabid number",
|
|
|
|
US"B", US"Paragraph separator",
|
|
|
|
US"BN", US"Boundary neutral",
|
|
|
|
US"CS", US"Common separator",
|
|
|
|
US"EN", US"European number",
|
|
|
|
US"ES", US"European separator",
|
|
|
|
US"ET", US"European terminator",
|
|
|
|
US"FSI", US"First string isolate",
|
|
|
|
US"L", US"Left-to-right",
|
|
|
|
US"LRE", US"Left-to-right embedding",
|
|
|
|
US"LRI", US"Left-to-right isolate",
|
|
|
|
US"LRO", US"Left-to-right override",
|
|
|
|
US"NSM", US"Non-spacing mark",
|
|
|
|
US"ON", US"Other neutral",
|
|
|
|
US"PDF", US"Pop directional format",
|
|
|
|
US"PDI", US"Pop directional isolate",
|
|
|
|
US"R", US"Right-to-left",
|
|
|
|
US"RLE", US"Right-to-left embedding",
|
|
|
|
US"RLI", US"Right-to-left isolate",
|
|
|
|
US"RLO", US"Right-to-left override",
|
|
|
|
US"S", US"Segment separator",
|
|
|
|
US"WS", US"White space"
|
|
|
|
};
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
static const unsigned int utf8_table1[] = {
|
|
|
|
0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff};
|
|
|
|
|
|
|
|
static const int utf8_table2[] = {
|
|
|
|
0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
|
|
|
|
|
2021-12-08 16:34:27 +01:00
|
|
|
/* Macro to pick up the remaining bytes of a UTF-8 character, advancing
|
|
|
|
the pointer. */
|
|
|
|
|
|
|
|
#define GETUTF8INC(c, eptr) \
|
|
|
|
{ \
|
|
|
|
if ((c & 0x20u) == 0) \
|
|
|
|
c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \
|
|
|
|
else if ((c & 0x10u) == 0) \
|
|
|
|
{ \
|
|
|
|
c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \
|
|
|
|
eptr += 2; \
|
|
|
|
} \
|
|
|
|
else if ((c & 0x08u) == 0) \
|
|
|
|
{ \
|
|
|
|
c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \
|
|
|
|
((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
|
|
|
|
eptr += 3; \
|
|
|
|
} \
|
|
|
|
else if ((c & 0x04u) == 0) \
|
|
|
|
{ \
|
|
|
|
c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \
|
|
|
|
((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \
|
|
|
|
(eptr[3] & 0x3fu); \
|
|
|
|
eptr += 4; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \
|
|
|
|
((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \
|
|
|
|
((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \
|
|
|
|
eptr += 5; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Convert character value to UTF-8 *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
/* This function takes an unsigned long integer value in the range 0 -
|
|
|
|
0x7fffffff and encodes it as a UTF-8 character in 1 to 6 bytes.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
cvalue the character value
|
|
|
|
buffer pointer to buffer for result - at least 6 bytes long
|
|
|
|
|
|
|
|
Returns: number of bytes placed in the buffer
|
|
|
|
0 if input code point is too big
|
|
|
|
*/
|
|
|
|
|
|
|
|
static size_t
|
|
|
|
ord2utf8(unsigned int cvalue, unsigned char *buffer)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
for (i = 0; i < sizeof(utf8_table1)/sizeof(int); i++)
|
|
|
|
if (cvalue <= utf8_table1[i]) break;
|
|
|
|
if (i >= sizeof(utf8_table1)/sizeof(int)) return 0;
|
|
|
|
buffer += i;
|
|
|
|
for (j = i; j > 0; j--)
|
|
|
|
{
|
|
|
|
*buffer-- = 0x80 | (cvalue & 0x3f);
|
|
|
|
cvalue >>= 6;
|
|
|
|
}
|
|
|
|
*buffer = utf8_table2[i] | cvalue;
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Test for interaction *
|
|
|
|
*************************************************/
|
2018-10-06 19:39:52 +02:00
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
static BOOL
|
|
|
|
is_stdin_tty(void)
|
|
|
|
{
|
|
|
|
#if defined WIN32
|
|
|
|
return _isatty(_fileno(stdin));
|
|
|
|
#else
|
|
|
|
return isatty(fileno(stdin));
|
|
|
|
#endif
|
|
|
|
}
|
2018-10-06 19:39:52 +02:00
|
|
|
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
/*************************************************
|
2022-01-09 15:46:43 +01:00
|
|
|
* Get name from ucp ident *
|
2020-04-01 19:00:33 +02:00
|
|
|
*************************************************/
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
/* The utt table contains both full names and abbreviations. So search for both
|
|
|
|
and use the longer if two are found, unless the first one is only 3 characters
|
|
|
|
and we are looking for a script (some scripts have 3-character names). If this
|
|
|
|
were not just a test program it might be worth making some kind of reverse
|
2021-12-28 16:10:12 +01:00
|
|
|
index. */
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
static const char *
|
2022-01-09 15:46:43 +01:00
|
|
|
get_propname(int prop, int type)
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
2021-12-28 16:10:12 +01:00
|
|
|
size_t i, j, len;
|
|
|
|
size_t foundlist[2];
|
|
|
|
const char *yield;
|
2022-01-09 15:46:43 +01:00
|
|
|
int typex = (type == PT_SC)? PT_SCX : type;
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2021-12-28 16:10:12 +01:00
|
|
|
j = 0;
|
2020-04-01 19:00:33 +02:00
|
|
|
for (i = 0; i < PRIV(utt_size); i++)
|
|
|
|
{
|
2021-12-28 16:10:12 +01:00
|
|
|
const ucp_type_table *u = PRIV(utt) + i;
|
2022-01-09 15:46:43 +01:00
|
|
|
if ((u->type == type || u->type == typex) && u->value == prop)
|
2021-12-28 16:10:12 +01:00
|
|
|
{
|
|
|
|
foundlist[j++] = i;
|
|
|
|
if (j >= 2) break;
|
2022-01-09 15:46:43 +01:00
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
}
|
2021-12-28 16:10:12 +01:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
if (j == 0) return "??";
|
2021-12-28 16:10:12 +01:00
|
|
|
|
|
|
|
yield = NULL;
|
|
|
|
len = 0;
|
2021-12-08 16:34:27 +01:00
|
|
|
|
2021-12-28 16:10:12 +01:00
|
|
|
for (i = 0; i < j; i++)
|
|
|
|
{
|
|
|
|
const char *s = PRIV(utt_names) + (PRIV(utt) + foundlist[i])->name_offset;
|
|
|
|
size_t sl = strlen(s);
|
2022-01-09 15:46:43 +01:00
|
|
|
|
2021-12-28 16:10:12 +01:00
|
|
|
if (sl > len)
|
|
|
|
{
|
|
|
|
yield = s;
|
2022-01-09 15:46:43 +01:00
|
|
|
if (sl == 3 && type == PT_SC) break;
|
|
|
|
len = sl;
|
|
|
|
}
|
2021-12-28 16:10:12 +01:00
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2021-12-28 16:10:12 +01:00
|
|
|
return yield;
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
/*************************************************
|
|
|
|
* Print Unicode property info for a char *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
static void
|
2020-04-01 19:00:33 +02:00
|
|
|
print_prop(unsigned int c, BOOL is_just_one)
|
2014-05-13 13:20:03 +02:00
|
|
|
{
|
|
|
|
int type = UCD_CATEGORY(c);
|
|
|
|
int fulltype = UCD_CHARTYPE(c);
|
|
|
|
int script = UCD_SCRIPT(c);
|
2018-10-06 19:39:52 +02:00
|
|
|
int scriptx = UCD_SCRIPTX(c);
|
2014-05-13 13:20:03 +02:00
|
|
|
int gbprop = UCD_GRAPHBREAK(c);
|
2021-12-05 18:44:59 +01:00
|
|
|
int bidi = UCD_BIDICLASS(c);
|
2020-04-01 19:00:33 +02:00
|
|
|
unsigned int othercase = UCD_OTHERCASE(c);
|
2014-05-13 13:20:03 +02:00
|
|
|
int caseset = UCD_CASESET(c);
|
2022-01-09 15:46:43 +01:00
|
|
|
int bprops = UCD_BPROPS(c);
|
2014-05-13 13:20:03 +02:00
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
const unsigned char *fulltypename = US"??";
|
|
|
|
const unsigned char *typename = US"??";
|
|
|
|
const unsigned char *graphbreak = US"??";
|
2021-12-05 18:44:59 +01:00
|
|
|
const unsigned char *bidiclass = US"??";
|
2022-01-09 15:46:43 +01:00
|
|
|
const unsigned char *scriptname = CUS get_propname(script, PT_SC);
|
2018-10-06 19:39:52 +02:00
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case ucp_C: typename = US"Control"; break;
|
|
|
|
case ucp_L: typename = US"Letter"; break;
|
|
|
|
case ucp_M: typename = US"Mark"; break;
|
|
|
|
case ucp_N: typename = US"Number"; break;
|
|
|
|
case ucp_P: typename = US"Punctuation"; break;
|
|
|
|
case ucp_S: typename = US"Symbol"; break;
|
|
|
|
case ucp_Z: typename = US"Separator"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (fulltype)
|
|
|
|
{
|
|
|
|
case ucp_Cc: fulltypename = US"Control"; break;
|
|
|
|
case ucp_Cf: fulltypename = US"Format"; break;
|
|
|
|
case ucp_Cn: fulltypename = US"Unassigned"; break;
|
|
|
|
case ucp_Co: fulltypename = US"Private use"; break;
|
|
|
|
case ucp_Cs: fulltypename = US"Surrogate"; break;
|
|
|
|
case ucp_Ll: fulltypename = US"Lower case letter"; break;
|
|
|
|
case ucp_Lm: fulltypename = US"Modifier letter"; break;
|
|
|
|
case ucp_Lo: fulltypename = US"Other letter"; break;
|
|
|
|
case ucp_Lt: fulltypename = US"Title case letter"; break;
|
|
|
|
case ucp_Lu: fulltypename = US"Upper case letter"; break;
|
|
|
|
case ucp_Mc: fulltypename = US"Spacing mark"; break;
|
|
|
|
case ucp_Me: fulltypename = US"Enclosing mark"; break;
|
|
|
|
case ucp_Mn: fulltypename = US"Non-spacing mark"; break;
|
|
|
|
case ucp_Nd: fulltypename = US"Decimal number"; break;
|
|
|
|
case ucp_Nl: fulltypename = US"Letter number"; break;
|
|
|
|
case ucp_No: fulltypename = US"Other number"; break;
|
|
|
|
case ucp_Pc: fulltypename = US"Connector punctuation"; break;
|
|
|
|
case ucp_Pd: fulltypename = US"Dash punctuation"; break;
|
|
|
|
case ucp_Pe: fulltypename = US"Close punctuation"; break;
|
|
|
|
case ucp_Pf: fulltypename = US"Final punctuation"; break;
|
|
|
|
case ucp_Pi: fulltypename = US"Initial punctuation"; break;
|
|
|
|
case ucp_Po: fulltypename = US"Other punctuation"; break;
|
|
|
|
case ucp_Ps: fulltypename = US"Open punctuation"; break;
|
|
|
|
case ucp_Sc: fulltypename = US"Currency symbol"; break;
|
|
|
|
case ucp_Sk: fulltypename = US"Modifier symbol"; break;
|
|
|
|
case ucp_Sm: fulltypename = US"Mathematical symbol"; break;
|
|
|
|
case ucp_So: fulltypename = US"Other symbol"; break;
|
|
|
|
case ucp_Zl: fulltypename = US"Line separator"; break;
|
|
|
|
case ucp_Zp: fulltypename = US"Paragraph separator"; break;
|
|
|
|
case ucp_Zs: fulltypename = US"Space separator"; break;
|
|
|
|
}
|
2018-10-14 16:27:16 +02:00
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
switch(gbprop)
|
|
|
|
{
|
|
|
|
case ucp_gbCR: graphbreak = US"CR"; break;
|
|
|
|
case ucp_gbLF: graphbreak = US"LF"; break;
|
|
|
|
case ucp_gbControl: graphbreak = US"Control"; break;
|
|
|
|
case ucp_gbExtend: graphbreak = US"Extend"; break;
|
|
|
|
case ucp_gbPrepend: graphbreak = US"Prepend"; break;
|
|
|
|
case ucp_gbSpacingMark: graphbreak = US"SpacingMark"; break;
|
|
|
|
case ucp_gbL: graphbreak = US"Hangul syllable type L"; break;
|
|
|
|
case ucp_gbV: graphbreak = US"Hangul syllable type V"; break;
|
|
|
|
case ucp_gbT: graphbreak = US"Hangul syllable type T"; break;
|
|
|
|
case ucp_gbLV: graphbreak = US"Hangul syllable type LV"; break;
|
|
|
|
case ucp_gbLVT: graphbreak = US"Hangul syllable type LVT"; break;
|
2021-12-26 18:49:58 +01:00
|
|
|
case ucp_gbRegional_Indicator:
|
2018-07-07 18:10:29 +02:00
|
|
|
graphbreak = US"Regional Indicator"; break;
|
2014-05-13 13:20:03 +02:00
|
|
|
case ucp_gbOther: graphbreak = US"Other"; break;
|
2018-07-07 18:10:29 +02:00
|
|
|
case ucp_gbZWJ: graphbreak = US"Zero Width Joiner"; break;
|
|
|
|
case ucp_gbExtended_Pictographic:
|
2018-10-14 16:27:16 +02:00
|
|
|
graphbreak = US"Extended Pictographic"; break;
|
|
|
|
default: graphbreak = US"Unknown"; break;
|
2014-05-13 13:20:03 +02:00
|
|
|
}
|
2018-10-14 16:27:16 +02:00
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
switch(bidi)
|
|
|
|
{
|
|
|
|
case ucp_bidiAL: bidiclass = US"AL "; break;
|
|
|
|
case ucp_bidiFSI: bidiclass = US"FSI"; break;
|
|
|
|
case ucp_bidiL: bidiclass = US"L "; break;
|
|
|
|
case ucp_bidiLRE: bidiclass = US"LRE"; break;
|
|
|
|
case ucp_bidiLRI: bidiclass = US"LRI"; break;
|
|
|
|
case ucp_bidiLRO: bidiclass = US"LRO"; break;
|
|
|
|
case ucp_bidiPDF: bidiclass = US"PDF"; break;
|
|
|
|
case ucp_bidiPDI: bidiclass = US"PDI"; break;
|
|
|
|
case ucp_bidiR: bidiclass = US"R "; break;
|
|
|
|
case ucp_bidiRLE: bidiclass = US"RLE"; break;
|
|
|
|
case ucp_bidiRLI: bidiclass = US"RLI"; break;
|
|
|
|
case ucp_bidiRLO: bidiclass = US"RLO"; break;
|
|
|
|
case ucp_bidiAN: bidiclass = US"AN "; break;
|
|
|
|
case ucp_bidiB: bidiclass = US"B "; break;
|
|
|
|
case ucp_bidiBN: bidiclass = US"BN "; break;
|
|
|
|
case ucp_bidiCS: bidiclass = US"CS "; break;
|
|
|
|
case ucp_bidiEN: bidiclass = US"EN "; break;
|
|
|
|
case ucp_bidiES: bidiclass = US"ES "; break;
|
|
|
|
case ucp_bidiET: bidiclass = US"ET "; break;
|
|
|
|
case ucp_bidiNSM: bidiclass = US"NSM"; break;
|
|
|
|
case ucp_bidiON: bidiclass = US"ON "; break;
|
|
|
|
case ucp_bidiS: bidiclass = US"S "; break;
|
|
|
|
case ucp_bidiWS: bidiclass = US"WS "; break;
|
|
|
|
default: bidiclass = US"???"; break;
|
|
|
|
}
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
printf("U+%04X %s %s: %s, %s, %s", c, bidiclass, typename, fulltypename,
|
|
|
|
scriptname, graphbreak);
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (is_just_one && othercase != c)
|
2014-05-13 13:20:03 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf(", U+%04X", othercase);
|
2014-05-13 13:20:03 +02:00
|
|
|
if (caseset != 0)
|
|
|
|
{
|
|
|
|
const uint32_t *p = PRIV(ucd_caseless_sets) + caseset - 1;
|
|
|
|
while (*(++p) < NOTACHAR)
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
unsigned int d = *p;
|
2020-04-01 19:00:33 +02:00
|
|
|
if (d != othercase && d != c) printf(", U+%04X", d);
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-31 17:06:05 +01:00
|
|
|
if (scriptx != 0)
|
2018-10-06 19:39:52 +02:00
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
const char *sep = "";
|
2021-12-31 17:06:05 +01:00
|
|
|
const uint32_t *p = PRIV(ucd_script_sets) + scriptx;
|
2018-10-14 16:27:16 +02:00
|
|
|
printf(", [");
|
2021-12-31 17:06:05 +01:00
|
|
|
for (int i = 0; i < ucp_Unknown; i++)
|
|
|
|
if (MAPBIT(p, i) != 0)
|
2022-01-09 15:46:43 +01:00
|
|
|
{
|
|
|
|
printf("%s%s", sep, get_propname(i, PT_SC));
|
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
printf("]");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bprops != 0)
|
|
|
|
{
|
|
|
|
const char *sep = "";
|
|
|
|
const uint32_t *p = PRIV(ucd_boolprop_sets) +
|
|
|
|
bprops * ucd_boolprop_sets_item_size;
|
|
|
|
printf(", [");
|
|
|
|
for (int i = 0; i < ucp_Bprop_Count; i++)
|
|
|
|
if (MAPBIT(p, i) != 0)
|
|
|
|
{
|
|
|
|
printf("%s%s", sep, get_propname(i, PT_BOOL));
|
2021-12-31 17:06:05 +01:00
|
|
|
sep = ", ";
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
2018-10-06 19:39:52 +02:00
|
|
|
printf("]");
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (show_character && is_just_one)
|
|
|
|
{
|
|
|
|
unsigned char buffer[8];
|
|
|
|
size_t len = ord2utf8(c, buffer);
|
2021-12-05 18:44:59 +01:00
|
|
|
printf(", >%.*s<", (int)len, buffer);
|
|
|
|
}
|
2018-10-14 16:27:16 +02:00
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
/*************************************************
|
|
|
|
* Find character(s) with given property/ies *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
find_chars(unsigned char *s)
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
unsigned char name[128];
|
|
|
|
unsigned char value[128];
|
2018-10-14 16:27:16 +02:00
|
|
|
unsigned char *t;
|
|
|
|
unsigned int count= 0;
|
2022-01-09 15:46:43 +01:00
|
|
|
int scriptx_list[128];
|
2018-10-14 16:27:16 +02:00
|
|
|
unsigned int scriptx_count = 0;
|
2022-01-09 15:46:43 +01:00
|
|
|
int bprop_list[128];
|
|
|
|
unsigned int bprop_count = 0;
|
2018-10-14 16:27:16 +02:00
|
|
|
uint32_t i, c;
|
|
|
|
int script = -1;
|
|
|
|
int type = -1;
|
|
|
|
int gbreak = -1;
|
2021-12-05 18:44:59 +01:00
|
|
|
int bidiclass = -1;
|
|
|
|
BOOL bidicontrol = FALSE;
|
2018-10-14 16:27:16 +02:00
|
|
|
BOOL script_not = FALSE;
|
|
|
|
BOOL type_not = FALSE;
|
|
|
|
BOOL gbreak_not = FALSE;
|
2021-12-05 18:44:59 +01:00
|
|
|
BOOL bidiclass_not = FALSE;
|
2018-10-14 16:27:16 +02:00
|
|
|
BOOL hadrange = FALSE;
|
|
|
|
const ucd_record *ucd, *next_ucd;
|
2020-04-01 19:00:33 +02:00
|
|
|
const char *pad = " ";
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
while (*s != 0)
|
|
|
|
{
|
|
|
|
unsigned int offset = 0;
|
|
|
|
BOOL scriptx_not = FALSE;
|
2021-12-05 18:44:59 +01:00
|
|
|
char *value_start;
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
for (t = name; *s != 0 && !isspace(*s); s++) *t++ = *s;
|
|
|
|
*t = 0;
|
|
|
|
while (isspace(*s)) s++;
|
2021-12-05 18:44:59 +01:00
|
|
|
value_start = s;
|
2018-10-14 16:27:16 +02:00
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
for (t = value; *s != 0 && !isspace(*s); s++)
|
|
|
|
{
|
|
|
|
if (*s != '_' && *s != '-') *t++ = *s;
|
|
|
|
}
|
2018-10-14 16:27:16 +02:00
|
|
|
*t = 0;
|
|
|
|
while (isspace(*s)) s++;
|
|
|
|
|
|
|
|
if (strcmp(CS name, "script") == 0 ||
|
|
|
|
strcmp(CS name, "scriptx") == 0)
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
for (t = value; *t != 0; t++) *t = tolower(*t);
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
if (value[0] == '!')
|
|
|
|
{
|
|
|
|
if (name[6] == 'x') scriptx_not = TRUE;
|
|
|
|
else script_not = TRUE;
|
|
|
|
offset = 1;
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
for (i = 0; i < PRIV(utt_size); i++)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
const ucp_type_table *u = PRIV(utt) + i;
|
2022-01-09 15:46:43 +01:00
|
|
|
if ((u->type == PT_SCX || u->type == PT_SC) && strcmp(CS(value + offset),
|
2020-04-01 19:00:33 +02:00
|
|
|
PRIV(utt_names) + u->name_offset) == 0)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
c = u->value;
|
2018-10-14 16:27:16 +02:00
|
|
|
if (name[6] == 'x')
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
scriptx_list[scriptx_count++] = scriptx_not? (-c):c;
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
if (script < 0) script = c; else
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
|
|
|
printf("** Only 1 script value allowed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (i >= PRIV(utt_size))
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("** Unrecognized script name \"%s\"\n", value);
|
2018-10-14 16:27:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
else if (strcmp(CS name, "bool") == 0)
|
|
|
|
{
|
|
|
|
int not = 1;
|
|
|
|
if (value[0] == '!')
|
|
|
|
{
|
|
|
|
not = -1;
|
|
|
|
offset = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < PRIV(utt_size); i++)
|
|
|
|
{
|
|
|
|
const ucp_type_table *u = PRIV(utt) + i;
|
|
|
|
if (u->type == PT_BOOL && strcmp(CS(value + offset),
|
|
|
|
PRIV(utt_names) + u->name_offset) == 0)
|
|
|
|
{
|
|
|
|
bprop_list[bprop_count++] = u->value * not;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= PRIV(utt_size))
|
|
|
|
{
|
|
|
|
printf("** Unrecognized property name \"%s\"\n", value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
else if (strcmp(CS name, "type") == 0)
|
|
|
|
{
|
|
|
|
if (type >= 0)
|
|
|
|
{
|
|
|
|
printf("** Only 1 type value allowed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (value[0] == '!')
|
|
|
|
{
|
|
|
|
type_not = TRUE;
|
|
|
|
offset = 1;
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
for (i = 0; i < sizeof(type_names)/sizeof(char *); i += 2)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
if (strcmp(CS (value + offset), CS type_names[i]) == 0)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
type = i/2;
|
2018-10-14 16:27:16 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= sizeof(type_names)/sizeof(char *))
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("** Unrecognized type name \"%s\"\n", value);
|
2018-10-14 16:27:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (strcmp(CS name, "gbreak") == 0)
|
|
|
|
{
|
|
|
|
if (gbreak >= 0)
|
|
|
|
{
|
|
|
|
printf("** Only 1 grapheme break value allowed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (value[0] == '!')
|
|
|
|
{
|
|
|
|
gbreak_not = TRUE;
|
|
|
|
offset = 1;
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
for (i = 0; i < sizeof(gb_names)/sizeof(char *); i += 2)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
if (strcmp(CS (value + offset), CS gb_names[i]) == 0)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
gbreak = i/2;
|
2018-10-14 16:27:16 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= sizeof(gb_names)/sizeof(char *))
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("** Unrecognized gbreak name \"%s\"\n", value);
|
2018-10-14 16:27:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
else if (strcmp(CS name, "bidi") == 0 ||
|
|
|
|
strcmp(CS name, "bidiclass") == 0 ||
|
|
|
|
strcmp(CS name, "bidi_class") == 0 )
|
|
|
|
{
|
|
|
|
if (bidiclass >= 0)
|
|
|
|
{
|
|
|
|
printf("** Only 1 bidi class value allowed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (value[0] == '!')
|
|
|
|
{
|
|
|
|
bidiclass_not = TRUE;
|
|
|
|
offset = 1;
|
|
|
|
}
|
|
|
|
for (i = 0; i < sizeof(bd_names)/sizeof(char *); i += 2)
|
|
|
|
{
|
2021-12-08 16:34:27 +01:00
|
|
|
if (strcasecmp(CS (value + offset), CS bd_names[i]) == 0)
|
2021-12-05 18:44:59 +01:00
|
|
|
{
|
|
|
|
bidiclass = i/2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= sizeof(bd_names)/sizeof(char *))
|
|
|
|
{
|
|
|
|
printf("** Unrecognized bidi class name \"%s\"\n", value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
else
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("** Unrecognized property name \"%s\"\n", name);
|
2018-10-14 16:27:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
if (script < 0 && scriptx_count == 0 && bprop_count == 0 && type < 0 &&
|
|
|
|
gbreak < 0 && bidiclass < 0)
|
2018-10-14 16:27:16 +02:00
|
|
|
{
|
|
|
|
printf("** No properties specified\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (c = 0; c <= 0x10ffff; c++)
|
|
|
|
{
|
|
|
|
if (script >= 0 && (script == UCD_SCRIPT(c)) == script_not) continue;
|
|
|
|
|
|
|
|
if (scriptx_count > 0)
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
const uint32_t *bits_scriptx = PRIV(ucd_script_sets) + UCD_SCRIPTX(c);
|
2020-04-01 19:00:33 +02:00
|
|
|
unsigned int found = 0;
|
2018-10-14 16:27:16 +02:00
|
|
|
|
|
|
|
for (i = 0; i < scriptx_count; i++)
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
int x = scriptx_list[i]/32;
|
|
|
|
int y = scriptx_list[i]%32;
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
/* Positive requirment */
|
|
|
|
if (scriptx_list[i] >= 0)
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
if ((bits_scriptx[x] & (1u<<y)) != 0) found++;
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
|
|
|
/* Negative requirement */
|
|
|
|
else
|
|
|
|
{
|
2022-01-09 15:46:43 +01:00
|
|
|
if ((bits_scriptx[x] & (1u<<y)) == 0) found++;
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found != scriptx_count) continue;
|
|
|
|
}
|
|
|
|
|
2022-01-09 15:46:43 +01:00
|
|
|
if (bprop_count > 0)
|
|
|
|
{
|
|
|
|
const uint32_t *bits_bprop = PRIV(ucd_boolprop_sets) +
|
|
|
|
UCD_BPROPS(c) * ucd_boolprop_sets_item_size;
|
|
|
|
unsigned int found = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < bprop_count; i++)
|
|
|
|
{
|
|
|
|
int x = bprop_list[i]/32;
|
|
|
|
int y = bprop_list[i]%32;
|
|
|
|
|
|
|
|
/* Positive requirement */
|
|
|
|
if (bprop_list[i] >= 0)
|
|
|
|
{
|
|
|
|
if ((bits_bprop[x] & (1u<<y)) != 0) found++;
|
|
|
|
}
|
|
|
|
/* Negative requirement */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((bits_bprop[-x] & (1u<<(-y))) == 0) found++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found != bprop_count) continue;
|
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
if (type >= 0)
|
|
|
|
{
|
|
|
|
if (type_not)
|
|
|
|
{
|
|
|
|
if (type == UCD_CHARTYPE(c)) continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (type != UCD_CHARTYPE(c)) continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gbreak >= 0)
|
|
|
|
{
|
|
|
|
if (gbreak_not)
|
|
|
|
{
|
|
|
|
if (gbreak == UCD_GRAPHBREAK(c)) continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gbreak != UCD_GRAPHBREAK(c)) continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
if (bidiclass >= 0)
|
|
|
|
{
|
|
|
|
if (bidiclass_not)
|
|
|
|
{
|
|
|
|
if (bidiclass == UCD_BIDICLASS(c)) continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bidiclass != UCD_BIDICLASS(c)) continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
/* All conditions are met. Look for runs. */
|
|
|
|
|
|
|
|
ucd = GET_UCD(c);
|
|
|
|
|
|
|
|
for (i = c + 1; i < 0x10ffff; i++)
|
|
|
|
{
|
|
|
|
next_ucd = GET_UCD(i);
|
|
|
|
if (memcmp(ucd, next_ucd, sizeof(ucd_record)) != 0) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--i > c)
|
|
|
|
{
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("U+%04X..", c);
|
2018-10-14 16:27:16 +02:00
|
|
|
c = i;
|
|
|
|
hadrange = TRUE;
|
|
|
|
}
|
|
|
|
else if (hadrange) printf("%s", pad);
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
print_prop(c, FALSE);
|
2018-10-14 16:27:16 +02:00
|
|
|
if (c >= 0x100000) pad = " ";
|
|
|
|
else if (c >= 0x10000) pad = " ";
|
|
|
|
count++;
|
|
|
|
if (count >= 100)
|
|
|
|
{
|
|
|
|
printf("...\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 0) printf("No characters found\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
/*************************************************
|
|
|
|
* Process command line *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_command_line(unsigned char *buffer)
|
|
|
|
{
|
|
|
|
unsigned char *s, *t;
|
|
|
|
unsigned char name[24];
|
|
|
|
|
|
|
|
s = buffer;
|
|
|
|
while (isspace(*s)) s++;
|
|
|
|
if (*s == 0) return;
|
|
|
|
|
|
|
|
for (t = name; *s != 0 && !isspace(*s); s++) *t++ = *s;
|
|
|
|
*t = 0;
|
|
|
|
while (isspace(*s)) s++;
|
|
|
|
|
|
|
|
if (strcmp(CS name, "findprop") == 0)
|
|
|
|
{
|
|
|
|
while (*s != 0)
|
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
unsigned int c;
|
2020-04-01 19:00:33 +02:00
|
|
|
unsigned char *endptr;
|
2021-12-05 18:44:59 +01:00
|
|
|
t = s;
|
2021-12-08 16:34:27 +01:00
|
|
|
|
|
|
|
if (*t == '+')
|
|
|
|
{
|
|
|
|
c = *(++t);
|
2022-01-09 15:46:43 +01:00
|
|
|
if (c > 0x7fu)
|
2021-12-08 16:34:27 +01:00
|
|
|
{
|
|
|
|
GETCHARINC(c, t);
|
2022-01-09 15:46:43 +01:00
|
|
|
}
|
2021-12-08 16:34:27 +01:00
|
|
|
endptr = t+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strncmp(CS t, "U+", 2) == 0) t += 2;
|
|
|
|
c = strtoul(CS t, CSS(&endptr), 16);
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (*endptr != 0 && !isspace(*endptr))
|
|
|
|
{
|
|
|
|
while (*endptr != 0 && !isspace(*endptr)) endptr++;
|
2021-12-08 16:34:27 +01:00
|
|
|
printf("** Invalid character specifier: ignored \"%.*s\"\n", (int)(endptr-s), s);
|
2020-04-01 19:00:33 +02:00
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
else
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
if (c > 0x10ffff)
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("** U+%x is too big for a Unicode code point\n", c);
|
2021-12-05 18:44:59 +01:00
|
|
|
else
|
2020-04-01 19:00:33 +02:00
|
|
|
print_prop(c, TRUE);
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
s = endptr;
|
|
|
|
while (isspace(*s)) s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (strcmp(CS name, "find") == 0)
|
|
|
|
{
|
|
|
|
find_chars(s);
|
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
else if (strcmp(CS name, "list") == 0)
|
|
|
|
{
|
|
|
|
while (*s != 0)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (t = name; *s != 0 && !isspace(*s); s++) *t++ = *s;
|
|
|
|
*t = 0;
|
|
|
|
while (isspace(*s)) s++;
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (strcmp(CS name, "script") == 0 || strcmp(CS name, "scripts") == 0)
|
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
for (i = 0; i < PRIV(utt_size); i++)
|
2022-01-09 15:46:43 +01:00
|
|
|
if (PRIV(utt)[i].type == PT_SCX || PRIV(utt)[i].type == PT_SC)
|
|
|
|
printf("%s\n", PRIV(utt_names) + PRIV(utt)[i].name_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (strcmp(CS name, "bool") == 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < PRIV(utt_size); i++)
|
|
|
|
if (PRIV(utt)[i].type == PT_BOOL)
|
2021-12-05 18:44:59 +01:00
|
|
|
printf("%s\n", PRIV(utt_names) + PRIV(utt)[i].name_offset);
|
2020-04-01 19:00:33 +02:00
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
else if (strcmp(CS name, "type") == 0 || strcmp(CS name, "types") == 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < sizeof(type_names)/sizeof(char *); i += 2)
|
2021-12-05 18:44:59 +01:00
|
|
|
printf("%s %s\n", type_names[i], type_names[i+1]);
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
else if (strcmp(CS name, "gbreak") == 0 || strcmp(CS name, "gbreaks") == 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < sizeof(gb_names)/sizeof(char *); i += 2)
|
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
if (gb_names[i+1][0] != 0)
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("%-3s (%s)\n", gb_names[i], gb_names[i+1]);
|
2021-12-05 18:44:59 +01:00
|
|
|
else
|
2020-04-01 19:00:33 +02:00
|
|
|
printf("%s\n", gb_names[i]);
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
|
2021-12-05 18:44:59 +01:00
|
|
|
else if (strcmp(CS name, "bidi") == 0 ||
|
|
|
|
strcmp(CS name, "bidiclasses") == 0)
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
for (i = 0; i < sizeof(bd_names)/sizeof(char *); i += 2)
|
|
|
|
printf("%3s %s\n", bd_names[i], bd_names[i+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("** Unknown property \"%s\"\n", name);
|
2020-04-01 19:00:33 +02:00
|
|
|
break;
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
else printf("** Unknown test command \"%s\"\n", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
/*************************************************
|
|
|
|
* Main program *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
int
|
2018-10-06 19:39:52 +02:00
|
|
|
main(int argc, char **argv)
|
2014-05-13 13:20:03 +02:00
|
|
|
{
|
2018-10-14 16:27:16 +02:00
|
|
|
BOOL interactive;
|
2020-04-01 19:00:33 +02:00
|
|
|
int first_arg = 1;
|
2014-05-13 13:20:03 +02:00
|
|
|
unsigned char buffer[1024];
|
2018-10-06 19:39:52 +02:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
if (argc > 1 && strcmp(argv[1], "-s") == 0)
|
|
|
|
{
|
|
|
|
show_character = TRUE;
|
|
|
|
first_arg++;
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
if (argc > first_arg)
|
2018-10-06 19:39:52 +02:00
|
|
|
{
|
|
|
|
int i;
|
2021-12-08 16:34:27 +01:00
|
|
|
BOOL datafirst = TRUE;
|
2021-12-05 18:44:59 +01:00
|
|
|
char *arg = argv[first_arg];
|
2020-04-01 19:00:33 +02:00
|
|
|
unsigned char *s = buffer;
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2021-12-08 16:34:27 +01:00
|
|
|
if (*arg != '+' && strncmp(arg, "U+", 2) != 0 && !isdigit(*arg))
|
2018-10-06 19:39:52 +02:00
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
while (*arg != 0)
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
2021-12-08 16:34:27 +01:00
|
|
|
if (!isxdigit(*arg++)) { datafirst = FALSE; break; }
|
2021-12-05 18:44:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-08 16:34:27 +01:00
|
|
|
if (datafirst)
|
2020-04-01 19:00:33 +02:00
|
|
|
{
|
|
|
|
strcpy(CS s, "findprop ");
|
|
|
|
s += 9;
|
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
for (i = first_arg; i < argc; i++)
|
|
|
|
{
|
2021-12-05 18:44:59 +01:00
|
|
|
s += sprintf(CS s, "%s ", argv[i]);
|
2018-10-06 19:39:52 +02:00
|
|
|
}
|
2020-04-01 19:00:33 +02:00
|
|
|
|
|
|
|
process_command_line(buffer);
|
2018-10-06 19:39:52 +02:00
|
|
|
return 0;
|
2018-10-14 16:27:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
interactive = is_stdin_tty();
|
2018-10-06 19:39:52 +02:00
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
|
|
|
|
if (interactive) using_history();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for(;;)
|
2014-05-13 13:20:03 +02:00
|
|
|
{
|
2018-10-14 16:27:16 +02:00
|
|
|
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
|
|
|
|
if (interactive)
|
|
|
|
{
|
|
|
|
size_t len;
|
2020-04-01 19:00:33 +02:00
|
|
|
unsigned char *s = US readline("> ");
|
2018-10-14 16:27:16 +02:00
|
|
|
if (s == NULL) break;
|
2020-04-01 19:00:33 +02:00
|
|
|
len = strlen(CS s);
|
|
|
|
if (len > 0) add_history(CS s);
|
2018-10-14 16:27:16 +02:00
|
|
|
memcpy(buffer, s, len);
|
|
|
|
buffer[len] = '\n';
|
|
|
|
buffer[len+1] = 0;
|
|
|
|
free(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
if (interactive) printf("> ");
|
|
|
|
if (fgets(CS buffer, sizeof(buffer), stdin) == NULL) break;
|
|
|
|
if (!interactive) printf("%s", buffer);
|
|
|
|
}
|
2021-12-05 18:44:59 +01:00
|
|
|
|
2020-04-01 19:00:33 +02:00
|
|
|
process_command_line(buffer);
|
2014-05-13 13:20:03 +02:00
|
|
|
}
|
|
|
|
|
2018-10-14 16:27:16 +02:00
|
|
|
if (interactive) printf("\n");
|
|
|
|
|
|
|
|
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
|
|
|
|
if (interactive) clear_history();
|
|
|
|
#endif
|
|
|
|
|
2014-05-13 13:20:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End */
|