mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 02:44:18 +08:00
45ab93d9af
I've tried to build stage3 with -Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank added to STRICT_WARN and that expectably resulted in about 2744 unique trailing whitespace warnings and 124837 leading whitespace warnings when excluding *.md files (which obviously is in big part a generator issue). Others from that are generator related, I think those need to be solved later. The following patch just fixes up the easy case (trailing whitespace), which could be easily automated: for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[ ]$' | grep -v testsuite/`; do sed -i -e 's/[ ]*$//' $i; done I've excluded files which I knew are obviously generated or go FE. Is there anything else we'd want to avoid the changes? Due to patch size, I've split it between gcc/ part and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/; this part). 2024-10-24 Jakub Jelinek <jakub@redhat.com> include/ * dyn-string.h: Remove trailing whitespace. * libiberty.h: Likewise. * xregex.h: Likewise. * splay-tree.h: Likewise. * partition.h: Likewise. * plugin-api.h: Likewise. * demangle.h: Likewise. * vtv-change-permission.h: Likewise. * fibheap.h: Likewise. * hsa_ext_image.h: Likewise. * hashtab.h: Likewise. * libcollector.h: Likewise. * sort.h: Likewise. * symcat.h: Likewise. * hsa_ext_amd.h: Likewise. libcpp/ * directives.cc: Remove trailing whitespace. * mkdeps.cc: Likewise. * line-map.cc: Likewise. * internal.h: Likewise. * files.cc: Likewise. * init.cc: Likewise. * makeucnid.cc: Likewise. * system.h: Likewise. * include/line-map.h: Likewise. * include/symtab.h: Likewise. * include/cpplib.h: Likewise. * expr.cc: Likewise. * charset.cc: Likewise. * macro.cc: Likewise. * errors.cc: Likewise. * lex.cc: Likewise. * traditional.cc: Likewise. libgcc/ * crtstuff.c: Remove trailing whitespace. * libgcov.h: Likewise. * config/alpha/crtfastmath.c: Likewise. * config/alpha/vms-gcc_shell_handler.c: Likewise. * config/alpha/vms-unwind.h: Likewise. * config/pa/linux-atomic.c: Likewise. * config/pa/linux-unwind.h: Likewise. * config/pa/quadlib.c: Likewise. * config/pa/fptr.c: Likewise. * config/s390/32/_fixsfdi.c: Likewise. * config/s390/32/_fixunssfdi.c: Likewise. * config/s390/32/_fixunsdfdi.c: Likewise. * config/c6x/pr-support.c: Likewise. * config/lm32/_udivsi3.c: Likewise. * config/lm32/libgcc_lm32.h: Likewise. * config/lm32/_udivmodsi4.c: Likewise. * config/lm32/_mulsi3.c: Likewise. * config/lm32/_modsi3.c: Likewise. * config/lm32/_umodsi3.c: Likewise. * config/lm32/_divsi3.c: Likewise. * config/darwin-crt3.c: Likewise. * config/msp430/mpy.c: Likewise. * config/ia64/tf-signs.c: Likewise. * config/ia64/fde-vms.c: Likewise. * config/ia64/unwind-ia64.c: Likewise. * config/ia64/vms-unwind.h: Likewise. * config/ia64/sfp-exceptions.c: Likewise. * config/ia64/quadlib.c: Likewise. * config/ia64/unwind-ia64.h: Likewise. * config/rl78/vregs.h: Likewise. * config/arm/bpabi.c: Likewise. * config/arm/unwind-arm.c: Likewise. * config/arm/pr-support.c: Likewise. * config/arm/linux-atomic.c: Likewise. * config/arm/bpabi-lib.h: Likewise. * config/frv/frvend.c: Likewise. * config/frv/cmovw.c: Likewise. * config/frv/frvbegin.c: Likewise. * config/frv/cmovd.c: Likewise. * config/frv/cmovh.c: Likewise. * config/aarch64/cpuinfo.c: Likewise. * config/i386/crtfastmath.c: Likewise. * config/i386/cygming-crtend.c: Likewise. * config/i386/32/tf-signs.c: Likewise. * config/i386/crtprec.c: Likewise. * config/i386/sfp-exceptions.c: Likewise. * config/i386/w32-unwind.h: Likewise. * config/m32r/initfini.c: Likewise. * config/sparc/crtfastmath.c: Likewise. * config/gcn/amdgcn_veclib.h: Likewise. * config/nios2/linux-atomic.c: Likewise. * config/nios2/linux-unwind.h: Likewise. * config/nios2/lib2-mul.c: Likewise. * config/nios2/lib2-nios2.h: Likewise. * config/xtensa/unwind-dw2-xtensa.c: Likewise. * config/rs6000/darwin-fallback.c: Likewise. * config/rs6000/ibm-ldouble.c: Likewise. * config/rs6000/sfp-machine.h: Likewise. * config/rs6000/darwin-asm.h: Likewise. * config/rs6000/darwin-crt2.c: Likewise. * config/rs6000/aix-unwind.h: Likewise. * config/rs6000/sfp-exceptions.c: Likewise. * config/gthr-vxworks.c: Likewise. * config/riscv/atomic.c: Likewise. * config/visium/memcpy.c: Likewise. * config/darwin-crt-tm.c: Likewise. * config/stormy16/lib2funcs.c: Likewise. * config/arc/ieee-754/divtab-arc-sf.c: Likewise. * config/arc/ieee-754/divtab-arc-df.c: Likewise. * config/arc/initfini.c: Likewise. * config/sol2/gmon.c: Likewise. * config/microblaze/divsi3_table.c: Likewise. * config/m68k/fpgnulib.c: Likewise. * libgcov-driver.c: Likewise. * unwind-dw2.c: Likewise. * fp-bit.c: Likewise. * dfp-bit.h: Likewise. * dfp-bit.c: Likewise. * libgcov-driver-system.c: Likewise. libgcc/config/libbid/ * _le_td.c: Remove trailing whitespace. * bid128_compare.c: Likewise. * bid_div_macros.h: Likewise. * bid64_to_bid128.c: Likewise. * bid64_to_uint32.c: Likewise. * bid128_to_uint64.c: Likewise. * bid64_div.c: Likewise. * bid128_round_integral.c: Likewise. * bid_binarydecimal.c: Likewise. * bid128_string.c: Likewise. * bid_flag_operations.c: Likewise. * bid128_to_int64.c: Likewise. * _mul_sd.c: Likewise. * bid64_mul.c: Likewise. * bid128_noncomp.c: Likewise. * _gt_dd.c: Likewise. * bid64_add.c: Likewise. * bid64_string.c: Likewise. * bid_from_int.c: Likewise. * bid128.c: Likewise. * _ge_dd.c: Likewise. * _ne_sd.c: Likewise. * _dd_to_td.c: Likewise. * _unord_sd.c: Likewise. * bid64_to_uint64.c: Likewise. * _gt_sd.c: Likewise. * _sd_to_td.c: Likewise. * _addsub_td.c: Likewise. * _ne_td.c: Likewise. * bid_dpd.c: Likewise. * bid128_add.c: Likewise. * bid128_next.c: Likewise. * _lt_sd.c: Likewise. * bid64_next.c: Likewise. * bid128_mul.c: Likewise. * _lt_dd.c: Likewise. * _ge_td.c: Likewise. * _unord_dd.c: Likewise. * bid64_sqrt.c: Likewise. * bid_sqrt_macros.h: Likewise. * bid64_fma.c: Likewise. * _sd_to_dd.c: Likewise. * bid_conf.h: Likewise. * bid64_noncomp.c: Likewise. * bid_gcc_intrinsics.h: Likewise. * _gt_td.c: Likewise. * _ge_sd.c: Likewise. * bid128_minmax.c: Likewise. * bid128_quantize.c: Likewise. * bid32_to_bid64.c: Likewise. * bid_round.c: Likewise. * _td_to_sd.c: Likewise. * bid_inline_add.h: Likewise. * bid128_fma.c: Likewise. * _eq_td.c: Likewise. * bid32_to_bid128.c: Likewise. * bid64_rem.c: Likewise. * bid128_2_str_tables.c: Likewise. * _mul_dd.c: Likewise. * _dd_to_sd.c: Likewise. * bid128_div.c: Likewise. * _lt_td.c: Likewise. * bid64_compare.c: Likewise. * bid64_to_int32.c: Likewise. * _unord_td.c: Likewise. * bid128_rem.c: Likewise. * bid_internal.h: Likewise. * bid64_to_int64.c: Likewise. * _eq_dd.c: Likewise. * _td_to_dd.c: Likewise. * bid128_to_int32.c: Likewise. * bid128_to_uint32.c: Likewise. * _ne_dd.c: Likewise. * bid64_quantize.c: Likewise. * _le_dd.c: Likewise. * bid64_round_integral.c: Likewise. * _le_sd.c: Likewise. * bid64_minmax.c: Likewise. libgcc/config/avr/libf7/ * f7-renames.h: Remove trailing whitespace. libstdc++-v3/ * include/debug/debug.h: Remove trailing whitespace. * include/parallel/base.h: Likewise. * include/parallel/types.h: Likewise. * include/parallel/settings.h: Likewise. * include/parallel/multiseq_selection.h: Likewise. * include/parallel/partition.h: Likewise. * include/parallel/random_number.h: Likewise. * include/parallel/find_selectors.h: Likewise. * include/parallel/partial_sum.h: Likewise. * include/parallel/list_partition.h: Likewise. * include/parallel/search.h: Likewise. * include/parallel/algorithmfwd.h: Likewise. * include/parallel/random_shuffle.h: Likewise. * include/parallel/multiway_mergesort.h: Likewise. * include/parallel/sort.h: Likewise. * include/parallel/algobase.h: Likewise. * include/parallel/numericfwd.h: Likewise. * include/parallel/multiway_merge.h: Likewise. * include/parallel/losertree.h: Likewise. * include/bits/basic_ios.h: Likewise. * include/bits/stringfwd.h: Likewise. * include/bits/ostream_insert.h: Likewise. * include/bits/stl_heap.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/hashtable_policy.h: Likewise. * include/bits/stl_iterator_base_funcs.h: Likewise. * include/bits/valarray_before.h: Likewise. * include/bits/regex.h: Likewise. * include/bits/postypes.h: Likewise. * include/bits/stl_iterator.h: Likewise. * include/bits/localefwd.h: Likewise. * include/bits/stl_algo.h: Likewise. * include/bits/ios_base.h: Likewise. * include/bits/stl_function.h: Likewise. * include/bits/basic_string.h: Likewise. * include/bits/hashtable.h: Likewise. * include/bits/valarray_after.h: Likewise. * include/bits/char_traits.h: Likewise. * include/bits/gslice.h: Likewise. * include/bits/locale_facets_nonio.h: Likewise. * include/bits/mask_array.h: Likewise. * include/bits/specfun.h: Likewise. * include/bits/random.h: Likewise. * include/bits/slice_array.h: Likewise. * include/bits/valarray_array.h: Likewise. * include/tr1/float.h: Likewise. * include/tr1/functional_hash.h: Likewise. * include/tr1/math.h: Likewise. * include/tr1/hashtable_policy.h: Likewise. * include/tr1/stdio.h: Likewise. * include/tr1/complex.h: Likewise. * include/tr1/stdbool.h: Likewise. * include/tr1/stdarg.h: Likewise. * include/tr1/inttypes.h: Likewise. * include/tr1/fenv.h: Likewise. * include/tr1/stdlib.h: Likewise. * include/tr1/wchar.h: Likewise. * include/tr1/tgmath.h: Likewise. * include/tr1/limits.h: Likewise. * include/tr1/wctype.h: Likewise. * include/tr1/stdint.h: Likewise. * include/tr1/ctype.h: Likewise. * include/tr1/random.h: Likewise. * include/tr1/shared_ptr.h: Likewise. * include/ext/mt_allocator.h: Likewise. * include/ext/sso_string_base.h: Likewise. * include/ext/debug_allocator.h: Likewise. * include/ext/vstring_fwd.h: Likewise. * include/ext/pointer.h: Likewise. * include/ext/pod_char_traits.h: Likewise. * include/ext/malloc_allocator.h: Likewise. * include/ext/vstring.h: Likewise. * include/ext/bitmap_allocator.h: Likewise. * include/ext/pool_allocator.h: Likewise. * include/ext/type_traits.h: Likewise. * include/ext/ropeimpl.h: Likewise. * include/ext/codecvt_specializations.h: Likewise. * include/ext/throw_allocator.h: Likewise. * include/ext/extptr_allocator.h: Likewise. * include/ext/atomicity.h: Likewise. * include/ext/concurrence.h: Likewise. * include/c_compatibility/wchar.h: Likewise. * include/c_compatibility/stdint.h: Likewise. * include/backward/hash_fun.h: Likewise. * include/backward/binders.h: Likewise. * include/backward/hashtable.h: Likewise. * include/backward/auto_ptr.h: Likewise. * libsupc++/eh_arm.cc: Likewise. * libsupc++/unwind-cxx.h: Likewise. * libsupc++/si_class_type_info.cc: Likewise. * libsupc++/vec.cc: Likewise. * libsupc++/class_type_info.cc: Likewise. * libsupc++/vmi_class_type_info.cc: Likewise. * libsupc++/guard_error.cc: Likewise. * libsupc++/bad_typeid.cc: Likewise. * libsupc++/eh_personality.cc: Likewise. * libsupc++/atexit_arm.cc: Likewise. * libsupc++/pmem_type_info.cc: Likewise. * libsupc++/vterminate.cc: Likewise. * libsupc++/eh_terminate.cc: Likewise. * libsupc++/bad_cast.cc: Likewise. * libsupc++/exception_ptr.h: Likewise. * libsupc++/eh_throw.cc: Likewise. * libsupc++/bad_alloc.cc: Likewise. * libsupc++/nested_exception.cc: Likewise. * libsupc++/pointer_type_info.cc: Likewise. * libsupc++/pbase_type_info.cc: Likewise. * libsupc++/bad_array_new.cc: Likewise. * libsupc++/pure.cc: Likewise. * libsupc++/eh_exception.cc: Likewise. * libsupc++/bad_array_length.cc: Likewise. * libsupc++/cxxabi.h: Likewise. * libsupc++/guard.cc: Likewise. * libsupc++/eh_catch.cc: Likewise. * libsupc++/cxxabi_forced.h: Likewise. * libsupc++/tinfo.h: Likewise.
526 lines
15 KiB
C++
526 lines
15 KiB
C++
/* Make ucnid.h from various sources.
|
|
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the
|
|
Free Software Foundation; either version 3, or (at your option) any
|
|
later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* Run this program as
|
|
./makeucnid ucnid.tab UnicodeData.txt DerivedNormalizationProps.txt \
|
|
DerivedCoreProperties.txt > ucnid.h
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
enum {
|
|
C99 = 1,
|
|
CXX = 2,
|
|
N99 = 4,
|
|
C11 = 8,
|
|
N11 = 16,
|
|
CXX23 = 32,
|
|
NXX23 = 64,
|
|
all_languages = C99 | CXX | C11 | CXX23 | NXX23,
|
|
not_NFC = 128,
|
|
not_NFKC = 256,
|
|
maybe_not_NFC = 512
|
|
};
|
|
|
|
#define NUM_CODE_POINTS 0x110000
|
|
#define MAX_CODE_POINT 0x10ffff
|
|
|
|
static unsigned flags[NUM_CODE_POINTS];
|
|
static unsigned int all_decomp[NUM_CODE_POINTS][2];
|
|
static unsigned int decomp[NUM_CODE_POINTS][2];
|
|
static unsigned char combining_value[NUM_CODE_POINTS];
|
|
|
|
/* Die! */
|
|
|
|
static void
|
|
fail (const char *s)
|
|
{
|
|
fprintf (stderr, "%s\n", s);
|
|
exit (1);
|
|
}
|
|
|
|
/* Read ucnid.tab and set the flags for language versions in header[]. */
|
|
|
|
static void
|
|
read_ucnid (const char *fname)
|
|
{
|
|
FILE *f = fopen (fname, "r");
|
|
unsigned fl = 0;
|
|
|
|
if (!f)
|
|
fail ("opening ucnid.tab");
|
|
for (;;)
|
|
{
|
|
char line[256];
|
|
|
|
if (!fgets (line, sizeof (line), f))
|
|
break;
|
|
if (strcmp (line, "[C99]\n") == 0)
|
|
fl = C99;
|
|
else if (strcmp (line, "[C99DIG]\n") == 0)
|
|
fl = C99|N99;
|
|
else if (strcmp (line, "[CXX]\n") == 0)
|
|
fl = CXX;
|
|
else if (strcmp (line, "[C11]\n") == 0)
|
|
fl = C11;
|
|
else if (strcmp (line, "[C11NOSTART]\n") == 0)
|
|
fl = C11|N11;
|
|
else if (isxdigit (line[0]))
|
|
{
|
|
char *l = line;
|
|
while (*l)
|
|
{
|
|
unsigned long start, end;
|
|
char *endptr;
|
|
start = strtoul (l, &endptr, 16);
|
|
if (endptr == l || (*endptr != '-' && ! isspace (*endptr)))
|
|
fail ("parsing ucnid.tab [1]");
|
|
l = endptr;
|
|
if (*l != '-')
|
|
end = start;
|
|
else
|
|
{
|
|
end = strtoul (l + 1, &endptr, 16);
|
|
if (end < start)
|
|
fail ("parsing ucnid.tab, end before start");
|
|
l = endptr;
|
|
if (! isspace (*l))
|
|
fail ("parsing ucnid.tab, junk after range");
|
|
}
|
|
while (isspace (*l))
|
|
l++;
|
|
if (end > MAX_CODE_POINT)
|
|
fail ("parsing ucnid.tab, end too large");
|
|
while (start <= end)
|
|
flags[start++] |= fl;
|
|
}
|
|
}
|
|
}
|
|
if (ferror (f))
|
|
fail ("reading ucnid.tab");
|
|
fclose (f);
|
|
}
|
|
|
|
/* Read UnicodeData.txt and fill in the 'decomp' table to be the
|
|
decompositions of characters for which both the character
|
|
decomposed and all the code points in the decomposition are valid
|
|
for some supported language version, and the 'all_decomp' table to
|
|
be the decompositions of all characters without those
|
|
constraints. */
|
|
|
|
static void
|
|
read_table (char *fname)
|
|
{
|
|
FILE * f = fopen (fname, "r");
|
|
|
|
if (!f)
|
|
fail ("opening UnicodeData.txt");
|
|
for (;;)
|
|
{
|
|
char line[256];
|
|
unsigned long codepoint, this_decomp[4];
|
|
char *l;
|
|
int i, j;
|
|
int decomp_useful;
|
|
|
|
if (!fgets (line, sizeof (line), f))
|
|
break;
|
|
codepoint = strtoul (line, &l, 16);
|
|
if (l == line || *l != ';')
|
|
fail ("parsing UnicodeData.txt, reading code point");
|
|
if (codepoint > MAX_CODE_POINT)
|
|
fail ("parsing UnicodeData.txt, code point too large");
|
|
|
|
do {
|
|
l++;
|
|
} while (*l != ';');
|
|
/* Category value. */
|
|
do {
|
|
l++;
|
|
} while (*l != ';');
|
|
/* Canonical combining class; in NFC/NFKC, they must be increasing
|
|
(or zero). */
|
|
if (! isdigit (*++l))
|
|
fail ("parsing UnicodeData.txt, combining class not number");
|
|
combining_value[codepoint] = strtoul (l, &l, 10);
|
|
if (*l++ != ';')
|
|
fail ("parsing UnicodeData.txt, junk after combining class");
|
|
|
|
/* Skip over bidi value. */
|
|
do {
|
|
l++;
|
|
} while (*l != ';');
|
|
|
|
/* Decomposition mapping. */
|
|
decomp_useful = flags[codepoint];
|
|
if (*++l == '<') /* Compatibility mapping. */
|
|
continue;
|
|
for (i = 0; i < 4; i++)
|
|
{
|
|
if (*l == ';')
|
|
break;
|
|
if (!isxdigit (*l))
|
|
fail ("parsing UnicodeData.txt, decomposition format");
|
|
this_decomp[i] = strtoul (l, &l, 16);
|
|
decomp_useful &= flags[this_decomp[i]];
|
|
while (isspace (*l))
|
|
l++;
|
|
}
|
|
if (i > 2) /* Decomposition too long. */
|
|
fail ("parsing UnicodeData.txt, decomposition too long");
|
|
for (j = 0; j < i; j++)
|
|
all_decomp[codepoint][j] = this_decomp[j];
|
|
if ((flags[codepoint] & all_languages) && decomp_useful)
|
|
while (--i >= 0)
|
|
decomp[codepoint][i] = this_decomp[i];
|
|
}
|
|
if (ferror (f))
|
|
fail ("reading UnicodeData.txt");
|
|
fclose (f);
|
|
}
|
|
|
|
/* Read DerivedNormalizationProps.txt and set the flags that say whether
|
|
a character is in NFC, NFKC, or is context-dependent. */
|
|
|
|
static void
|
|
read_derived (const char *fname)
|
|
{
|
|
FILE * f = fopen (fname, "r");
|
|
|
|
if (!f)
|
|
fail ("opening DerivedNormalizationProps.txt");
|
|
for (;;)
|
|
{
|
|
char line[256];
|
|
unsigned long start, end;
|
|
char *l;
|
|
bool not_NFC_p, not_NFKC_p, maybe_not_NFC_p;
|
|
|
|
if (!fgets (line, sizeof (line), f))
|
|
break;
|
|
not_NFC_p = (strstr (line, "; NFC_QC; N") != NULL);
|
|
not_NFKC_p = (strstr (line, "; NFKC_QC; N") != NULL);
|
|
maybe_not_NFC_p = (strstr (line, "; NFC_QC; M") != NULL);
|
|
if (! not_NFC_p && ! not_NFKC_p && ! maybe_not_NFC_p)
|
|
continue;
|
|
|
|
start = strtoul (line, &l, 16);
|
|
if (l == line)
|
|
fail ("parsing DerivedNormalizationProps.txt, reading start");
|
|
if (start > MAX_CODE_POINT)
|
|
fail ("parsing DerivedNormalizationProps.txt, code point too large");
|
|
if (*l == '.' && l[1] == '.')
|
|
end = strtoul (l + 2, &l, 16);
|
|
else
|
|
end = start;
|
|
|
|
while (start <= end)
|
|
flags[start++] |= ((not_NFC_p ? not_NFC : 0)
|
|
| (not_NFKC_p ? not_NFKC : 0)
|
|
| (maybe_not_NFC_p ? maybe_not_NFC : 0)
|
|
);
|
|
}
|
|
if (ferror (f))
|
|
fail ("reading DerivedNormalizationProps.txt");
|
|
fclose (f);
|
|
}
|
|
|
|
/* Read DerivedCoreProperties.txt and fill in languages version in
|
|
flags from the XID_Start and XID_Continue properties. */
|
|
|
|
static void
|
|
read_derivedcore (char *fname)
|
|
{
|
|
FILE * f = fopen (fname, "r");
|
|
|
|
if (!f)
|
|
fail ("opening DerivedCoreProperties.txt");
|
|
for (;;)
|
|
{
|
|
char line[256];
|
|
unsigned long codepoint_start, codepoint_end;
|
|
char *l;
|
|
int i, j;
|
|
|
|
if (!fgets (line, sizeof (line), f))
|
|
break;
|
|
if (line[0] == '#' || line[0] == '\n' || line[0] == '\r')
|
|
continue;
|
|
codepoint_start = strtoul (line, &l, 16);
|
|
if (l == line)
|
|
fail ("parsing DerivedCoreProperties.txt, reading code point");
|
|
if (codepoint_start > MAX_CODE_POINT)
|
|
fail ("parsing DerivedCoreProperties.txt, code point too large");
|
|
|
|
if (*l == '.' && l[1] == '.')
|
|
{
|
|
char *l2 = l + 2;
|
|
codepoint_end = strtoul (l + 2, &l, 16);
|
|
if (l == l2 || codepoint_end < codepoint_start)
|
|
fail ("parsing DerivedCoreProperties.txt, reading code point");
|
|
if (codepoint_end > MAX_CODE_POINT)
|
|
fail ("parsing DerivedCoreProperties.txt, code point too large");
|
|
}
|
|
else
|
|
codepoint_end = codepoint_start;
|
|
|
|
while (*l == ' ')
|
|
l++;
|
|
if (*l++ != ';')
|
|
fail ("parsing DerivedCoreProperties.txt, reading code point");
|
|
|
|
while (*l == ' ')
|
|
l++;
|
|
|
|
if (codepoint_end < 0x80)
|
|
continue;
|
|
|
|
if (strncmp (l, "XID_Start ", 10) == 0)
|
|
{
|
|
for (; codepoint_start <= codepoint_end; codepoint_start++)
|
|
flags[codepoint_start]
|
|
= (flags[codepoint_start] | CXX23) & ~NXX23;
|
|
}
|
|
else if (strncmp (l, "XID_Continue ", 13) == 0)
|
|
{
|
|
for (; codepoint_start <= codepoint_end; codepoint_start++)
|
|
if ((flags[codepoint_start] & CXX23) == 0)
|
|
flags[codepoint_start] |= CXX23 | NXX23;
|
|
}
|
|
}
|
|
if (ferror (f))
|
|
fail ("reading DerivedCoreProperties.txt");
|
|
fclose (f);
|
|
}
|
|
|
|
/* Write out the table.
|
|
The table consists of two words per entry. The first word is the flags
|
|
for the unicode code points up to and including the second word. */
|
|
|
|
static void
|
|
write_table (void)
|
|
{
|
|
unsigned i;
|
|
unsigned last_flag = flags[0];
|
|
bool really_safe = decomp[0][0] == 0;
|
|
unsigned char last_combine = combining_value[0];
|
|
|
|
printf ("static const struct ucnrange ucnranges[] = {\n");
|
|
|
|
for (i = 1; i <= NUM_CODE_POINTS; i++)
|
|
if (i == NUM_CODE_POINTS
|
|
|| (flags[i] != last_flag && ((flags[i] | last_flag) & all_languages))
|
|
|| really_safe != (decomp[i][0] == 0)
|
|
|| combining_value[i] != last_combine)
|
|
{
|
|
printf ("{ %s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s, %3d, %#06x },\n",
|
|
last_flag & C99 ? "C99" : " 0",
|
|
last_flag & N99 ? "N99" : " 0",
|
|
last_flag & CXX ? "CXX" : " 0",
|
|
last_flag & C11 ? "C11" : " 0",
|
|
last_flag & N11 ? "N11" : " 0",
|
|
last_flag & CXX23 ? "CXX23" : " 0",
|
|
last_flag & NXX23 ? "NXX23" : " 0",
|
|
really_safe ? "CID" : " 0",
|
|
last_flag & not_NFC ? " 0" : "NFC",
|
|
last_flag & not_NFKC ? " 0" : "NKC",
|
|
last_flag & maybe_not_NFC ? "CTX" : " 0",
|
|
combining_value[i - 1],
|
|
i - 1);
|
|
last_flag = flags[i];
|
|
last_combine = combining_value[i];
|
|
really_safe = decomp[i][0] == 0;
|
|
}
|
|
|
|
printf ("};\n");
|
|
}
|
|
|
|
/* Return whether a given character is valid in an identifier for some
|
|
supported language, either as itself or as a UCN. */
|
|
|
|
static bool
|
|
char_id_valid (unsigned int c)
|
|
{
|
|
return ((flags[c] & all_languages)
|
|
|| (c == 0x24)
|
|
|| (c >= 0x30 && c <= 0x39)
|
|
|| (c >= 0x41 && c <= 0x5a)
|
|
|| (c >= 0x61 && c <= 0x7a));
|
|
}
|
|
|
|
/* Write out the switch statement over characters for which it is
|
|
context-dependent whether they are in NFC. */
|
|
|
|
static void
|
|
write_context_switch (void)
|
|
{
|
|
unsigned i;
|
|
printf ("static bool\n"
|
|
"check_nfc (cpp_reader *pfile, cppchar_t c, cppchar_t p)\n"
|
|
"{\n"
|
|
" switch (c)\n"
|
|
" {\n");
|
|
for (i = 0; i < NUM_CODE_POINTS; i++)
|
|
{
|
|
bool found_case = false;
|
|
unsigned j;
|
|
if (!(flags[i] & all_languages) || !(flags[i] & maybe_not_NFC))
|
|
continue;
|
|
if ((i >= 0x1161 && i <= 0x1175) || (i >= 0x11A8 && i <= 0x11C2))
|
|
continue; /* Hangul handled algorithmically. */
|
|
printf (" case %#06x:\n"
|
|
" switch (p)\n"
|
|
"\t{\n", i);
|
|
/* If an NFC starter character decomposes with this character I
|
|
as the second character and an NFC starter character S as the
|
|
first character, that latter character as a previous
|
|
character means this character is not NFC. Furthermore, any
|
|
NFC starter character K made by a series of compositions of S
|
|
with combining characters whose combining class is greater
|
|
than that of I also means this character is not NFC. */
|
|
for (j = 0; j < NUM_CODE_POINTS; j++)
|
|
{
|
|
unsigned s, k;
|
|
if (all_decomp[j][1] != i)
|
|
continue;
|
|
s = all_decomp[j][0];
|
|
if (combining_value[s] != 0 || (flags[s] & not_NFC) != 0)
|
|
continue;
|
|
if (char_id_valid (s))
|
|
{
|
|
found_case = true;
|
|
printf ("\tcase %#06x:\n", s);
|
|
}
|
|
for (k = 0; k < NUM_CODE_POINTS; k++)
|
|
{
|
|
unsigned t = k;
|
|
if (k == s || !char_id_valid (k))
|
|
continue;
|
|
while (all_decomp[t][1] != 0
|
|
&& combining_value[all_decomp[t][1]] > combining_value[i])
|
|
{
|
|
if (combining_value[t] != 0 || (flags[t] & not_NFC) != 0)
|
|
break;
|
|
t = all_decomp[t][0];
|
|
}
|
|
if (t == s)
|
|
{
|
|
found_case = true;
|
|
printf ("\tcase %#06x:\n", k);
|
|
}
|
|
}
|
|
}
|
|
if (found_case)
|
|
printf ("\t return false;\n");
|
|
else
|
|
printf ("\t/* Non-NFC cases not applicable to C/C++. */\n");
|
|
printf ("\tdefault:\n"
|
|
"\t return true;\n"
|
|
"\t}\n\n");
|
|
}
|
|
printf (" default:\n"
|
|
" cpp_error (pfile, CPP_DL_ICE, \"Character %%x might not be NFKC\", c);\n"
|
|
" return true;\n"
|
|
" }\n"
|
|
"}\n");
|
|
}
|
|
|
|
/* Print out the huge copyright notice. */
|
|
|
|
static void
|
|
write_copyright (void)
|
|
{
|
|
static const char copyright[] = "\
|
|
/* Unicode characters and various properties.\n\
|
|
Copyright (C) 2003-2024 Free Software Foundation, Inc.\n\
|
|
\n\
|
|
This program is free software; you can redistribute it and/or modify it\n\
|
|
under the terms of the GNU General Public License as published by the\n\
|
|
Free Software Foundation; either version 3, or (at your option) any\n\
|
|
later version.\n\
|
|
\n\
|
|
This program is distributed in the hope that it will be useful,\n\
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
|
|
GNU General Public License for more details.\n\
|
|
\n\
|
|
You should have received a copy of the GNU General Public License\n\
|
|
along with this program; see the file COPYING3. If not see\n\
|
|
<http://www.gnu.org/licenses/>.\n\
|
|
\n\
|
|
\n\
|
|
Copyright (C) 1991-2024 Unicode, Inc. All rights reserved.\n\
|
|
Distributed under the Terms of Use in\n\
|
|
http://www.unicode.org/copyright.html.\n\
|
|
\n\
|
|
Permission is hereby granted, free of charge, to any person\n\
|
|
obtaining a copy of the Unicode data files and any associated\n\
|
|
documentation (the \"Data Files\") or Unicode software and any\n\
|
|
associated documentation (the \"Software\") to deal in the Data Files\n\
|
|
or Software without restriction, including without limitation the\n\
|
|
rights to use, copy, modify, merge, publish, distribute, and/or\n\
|
|
sell copies of the Data Files or Software, and to permit persons to\n\
|
|
whom the Data Files or Software are furnished to do so, provided\n\
|
|
that (a) the above copyright notice(s) and this permission notice\n\
|
|
appear with all copies of the Data Files or Software, (b) both the\n\
|
|
above copyright notice(s) and this permission notice appear in\n\
|
|
associated documentation, and (c) there is clear notice in each\n\
|
|
modified Data File or in the Software as well as in the\n\
|
|
documentation associated with the Data File(s) or Software that the\n\
|
|
data or software has been modified.\n\
|
|
\n\
|
|
THE DATA FILES AND SOFTWARE ARE PROVIDED \"AS IS\", WITHOUT WARRANTY\n\
|
|
OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n\
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n\
|
|
NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE\n\
|
|
COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR\n\
|
|
ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY\n\
|
|
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\n\
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\n\
|
|
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE\n\
|
|
OF THE DATA FILES OR SOFTWARE.\n\
|
|
\n\
|
|
Except as contained in this notice, the name of a copyright holder\n\
|
|
shall not be used in advertising or otherwise to promote the sale,\n\
|
|
use or other dealings in these Data Files or Software without prior\n\
|
|
written authorization of the copyright holder. */\n";
|
|
|
|
puts (copyright);
|
|
}
|
|
|
|
/* Main program. */
|
|
|
|
int
|
|
main(int argc, char ** argv)
|
|
{
|
|
if (argc != 5)
|
|
fail ("too few arguments to makeucn");
|
|
read_ucnid (argv[1]);
|
|
read_table (argv[2]);
|
|
read_derived (argv[3]);
|
|
read_derivedcore (argv[4]);
|
|
|
|
write_copyright ();
|
|
write_table ();
|
|
write_context_switch ();
|
|
return 0;
|
|
}
|