aboutsummaryrefslogtreecommitdiff
path: root/contrib/unicode
AgeCommit message (Collapse)AuthorFilesLines
2023-11-14libcpp, contrib: Update to Unicode 15.1Jakub Jelinek8-2614/+9011
The following patch (in plaintext just a pseudo-patch where I've left out the too big parts of either wget downloaded or regenerated files out with ..., full patch attached compressed) updates to Unicode 15.1 from 15.0 we had last year. Apparently Unicode forgot to add a new range to 4-8 Table we are using, but from the other files it is clear what should have been added; I've filed a bugreport against Unicode. 2023-11-14 Jakub Jelinek <jakub@redhat.com> contrib/ * unicode/README: Adjust glibc git commit hash, number of Unicode data files to be updated and latest Unicode version. * unicode/from_glibc/utf8_gen.py: Update from glibc. * unicode/UnicodeData.txt: Update from Unicode 15.1. * unicode/EastAsianWidth.txt: Likewise. * unicode/DerivedNormalizationProps.txt: Likewise. * unicode/NameAliases.txt: Likewise. * unicode/DerivedCoreProperties.txt: Likewise. * unicode/PropList.txt: Likewise. libcpp/ * makeucnid.cc (write_copyright): Update copyright year. * makeuname2c.cc (write_copyright): Likewise. (struct generated): Update latest Unicode version. (generated_ranges): Add 2ebf0-2ee5d CJK UNIFIED IDEOGRAPH range which was forgotten to be added to 4-8 table, but clearly is expected to be there from the 15.1 additions. * ucnid.h: Regenerated. * uname2c.h: Regenerated. * generated_cpp_wcwidth.h: Regenerated.
2023-06-21diagnostics: add support for "text art" diagramsDavid Malcolm3-0/+246
Existing text output in GCC has to be implemented by writing sequentially to a pretty_printer instance. This makes it hard to implement some kinds of diagnostic output (see e.g. diagnostic-show-locus.cc). This patch adds more flexible ways of creating text output: - a canvas class, which can be "painted" to via random-access (rather that sequentially) - a table class for 2D grid layout, supporting items that span multiple rows/columns - a widget class for organizing diagrams hierarchically. The patch also expands GCC's diagnostics subsystem so that diagnostics can have "text art" diagrams - think ASCII art, but potentially including some Unicode characters, such as box-drawing chars. The new code is in a new "gcc/text-art" subdirectory and "text_art" namespace. The patch adds a new "-fdiagnostics-text-art-charset=VAL" option, with values: - "none": don't emit diagrams (added to -fdiagnostics-plain-output) - "ascii": use pure ASCII in diagrams - "unicode": allow for conservative use of unicode drawing characters (such as box-drawing characters). - "emoji" (the default): as "unicode", but potentially allow for conservative use of emoji in the output (such as U+26A0 WARNING SIGN). I made it possible to disable emoji separately from unicode as I believe there's a generation gap in acceptance of these characters (some older programmers have a visceral reaction against them, whereas younger programmers may have no problem with them). Diagrams are emitted to stderr by default. With SARIF output they are captured as a location in "relatedLocations", with the diagram as a code block in Markdown within a "markdown" property of a message. This patch doesn't add any such diagram usage to GCC, saving that for followups, apart from adding a plugin to the test suite to exercise the functionality. contrib/ChangeLog: * unicode/gen-box-drawing-chars.py: New file. * unicode/gen-combining-chars.py: New file. * unicode/gen-printable-chars.py: New file. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Add text-art/box-drawing.o, text-art/canvas.o, text-art/ruler.o, text-art/selftests.o, text-art/style.o, text-art/styled-string.o, text-art/table.o, text-art/theme.o, and text-art/widget.o. * color-macros.h (COLOR_FG_BRIGHT_BLACK): New. (COLOR_FG_BRIGHT_RED): New. (COLOR_FG_BRIGHT_GREEN): New. (COLOR_FG_BRIGHT_YELLOW): New. (COLOR_FG_BRIGHT_BLUE): New. (COLOR_FG_BRIGHT_MAGENTA): New. (COLOR_FG_BRIGHT_CYAN): New. (COLOR_FG_BRIGHT_WHITE): New. (COLOR_BG_BRIGHT_BLACK): New. (COLOR_BG_BRIGHT_RED): New. (COLOR_BG_BRIGHT_GREEN): New. (COLOR_BG_BRIGHT_YELLOW): New. (COLOR_BG_BRIGHT_BLUE): New. (COLOR_BG_BRIGHT_MAGENTA): New. (COLOR_BG_BRIGHT_CYAN): New. (COLOR_BG_BRIGHT_WHITE): New. * common.opt (fdiagnostics-text-art-charset=): New option. (diagnostic-text-art.h): New SourceInclude. (diagnostic_text_art_charset) New Enum and EnumValues. * configure: Regenerate. * configure.ac (gccdepdir): Add text-art to loop. * diagnostic-diagram.h: New file. * diagnostic-format-json.cc (json_emit_diagram): New. (diagnostic_output_format_init_json): Wire it up to context->m_diagrams.m_emission_cb. * diagnostic-format-sarif.cc: Include "diagnostic-diagram.h" and "text-art/canvas.h". (sarif_result::on_nested_diagnostic): Move code to... (sarif_result::add_related_location): ...this new function. (sarif_result::on_diagram): New. (sarif_builder::emit_diagram): New. (sarif_builder::make_message_object_for_diagram): New. (sarif_emit_diagram): New. (diagnostic_output_format_init_sarif): Set context->m_diagrams.m_emission_cb to sarif_emit_diagram. * diagnostic-text-art.h: New file. * diagnostic.cc: Include "diagnostic-text-art.h", "diagnostic-diagram.h", and "text-art/theme.h". (diagnostic_initialize): Initialize context->m_diagrams and call diagnostics_text_art_charset_init. (diagnostic_finish): Clean up context->m_diagrams.m_theme. (diagnostic_emit_diagram): New. (diagnostics_text_art_charset_init): New. * diagnostic.h (text_art::theme): New forward decl. (class diagnostic_diagram): Likewise. (diagnostic_context::m_diagrams): New field. (diagnostic_emit_diagram): New decl. * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-text-art-charset=. (-fdiagnostics-plain-output): Add -fdiagnostics-text-art-charset=none. * gcc.cc: Include "diagnostic-text-art.h". (driver_handle_option): Handle OPT_fdiagnostics_text_art_charset_. * opts-common.cc (decode_cmdline_options_to_array): Add "-fdiagnostics-text-art-charset=none" to expanded_args for -fdiagnostics-plain-output. * opts.cc: Include "diagnostic-text-art.h". (common_handle_option): Handle OPT_fdiagnostics_text_art_charset_. * pretty-print.cc (pp_unicode_character): New. * pretty-print.h (pp_unicode_character): New decl. * selftest-run-tests.cc: Include "text-art/selftests.h". (selftest::run_tests): Call text_art_tests. * text-art/box-drawing-chars.inc: New file, generated by contrib/unicode/gen-box-drawing-chars.py. * text-art/box-drawing.cc: New file. * text-art/box-drawing.h: New file. * text-art/canvas.cc: New file. * text-art/canvas.h: New file. * text-art/ruler.cc: New file. * text-art/ruler.h: New file. * text-art/selftests.cc: New file. * text-art/selftests.h: New file. * text-art/style.cc: New file. * text-art/styled-string.cc: New file. * text-art/table.cc: New file. * text-art/table.h: New file. * text-art/theme.cc: New file. * text-art/theme.h: New file. * text-art/types.h: New file. * text-art/widget.cc: New file. * text-art/widget.h: New file. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-text-art-ascii-bw.c: New test. * gcc.dg/plugin/diagnostic-test-text-art-ascii-color.c: New test. * gcc.dg/plugin/diagnostic-test-text-art-none.c: New test. * gcc.dg/plugin/diagnostic-test-text-art-unicode-bw.c: New test. * gcc.dg/plugin/diagnostic-test-text-art-unicode-color.c: New test. * gcc.dg/plugin/diagnostic_plugin_test_text_art.c: New test plugin. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add them. libcpp/ChangeLog: * charset.cc (get_cppchar_property): New function template, based on... (cpp_wcwidth): ...this function. Rework to use the above. Include "combining-chars.inc". (cpp_is_combining_char): New function Include "printable-chars.inc". (cpp_is_printable_char): New function * combining-chars.inc: New file, generated by contrib/unicode/gen-combining-chars.py. * include/cpplib.h (cpp_is_combining_char): New function decl. (cpp_is_printable_char): New function decl. * printable-chars.inc: New file, generated by contrib/unicode/gen-printable-chars.py. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-03-16contrib: Update instructions regarding Unicode updatesJakub Jelinek2-7/+595
I've noticed we have instructions on how to update from newer Unicode standard, but it didn't mention uname2c.h regeneration. The following patch mentions that, also mentions that the Copyright years of Unicode should be updated and adds a copy of NameAliases.txt which is used for uname2c.h generation. 2023-03-16 Jakub Jelinek <jakub@redhat.com> * unicode/README: Update to mention also makeuname2c. * unicode/NameAliases.txt: New file.
2023-03-13libcpp: Update cpp_wcwidth() to Unicode 15Lewis Hyatt6-95/+673
Updates cpp_wcwidth() to Unicode 15, following the procedure in contrib/unicode/README mechanically without incident. contrib/ChangeLog: * unicode/DerivedCoreProperties.txt: Update to Unicode 15. * unicode/DerivedNormalizationProps.txt: Likewise. * unicode/EastAsianWidth.txt: Likwise. * unicode/PropList.txt: Likewise. * unicode/README: Likewise. * unicode/UnicodeData.txt: Likewise. libcpp/ChangeLog: * generated_cpp_wcwidth.h: Regenerated for Unicode 15.
2023-01-16Update copyright years.Jakub Jelinek2-2/+2
2022-06-28libcpp: Update ucnid.h to Unicode 14Lewis Hyatt3-10/+22390
This patch updates ucnid.h from Unicode 13 to Unicode 14. Additionally, the procedure detailed in contrib/unicode/README, which updates generated_wcwidth.h, has been expanded with instructions for updating this file as well, so that both may be done at the same time conveniently. Two additional Unicode data files which are needed to create ucnid.h are also added to source control in contrib/unicode. contrib/ChangeLog: * unicode/README: Added instructions for updating ucnid.h. * unicode/DerivedCoreProperties.txt: New file added to source control from Unicode 14.0 release. * unicode/DerivedNormalizationProps.txt: Likewise. libcpp/ChangeLog: * ucnid.h: Regenerated for Unicode 14.0.
2022-06-26libcpp: Update cpp_wcwidth() to Unicode 14.0.0Lewis Hyatt4-74/+1014
The procedure detailed in contrib/unicode/README was followed with nothing notable coming up. The glibc scripts did not require any update, so the only change was retrieving new versions of the Unicode data files and rerunning gen_wcwidth.py. contrib/ChangeLog: * unicode/EastAsianWidth.txt: Update to Unicode 14.0.0. * unicode/PropList.txt: Likewise. * unicode/README: Likewise. * unicode/UnicodeData.txt: Likewise. libcpp/ChangeLog: * generated_cpp_wcwidth.h: Generated from updated Unicode data files.
2021-11-01contrib: add unicode/utf8-dump.pyDavid Malcolm1-0/+69
This script may be useful when debugging issues relating to Unicode encoding (e.g. when investigating source files with bidirectional control characters). It dumps a UTF-8 file as a list of numbered lines (mimicking GCC's diagnostic output format), interleaved with lines per character showing the Unicode codepoints, the UTF-8 encoding bytes, the name of the character, and, where printable, the characters themselves. The lines are printed in logical order, which may help the reader to grok the relationship between visual and logical ordering in bi-di files. For example: $ cat test.c int གྷ; const char *אבג = "ALEF-BET-GIMEL"; $ ./contrib/unicode/utf8-dump.py test.c 1 | int གྷ; | U+0069 0x69 LATIN SMALL LETTER I i | U+006E 0x6e LATIN SMALL LETTER N n | U+0074 0x74 LATIN SMALL LETTER T t | U+0020 0x20 SPACE (separator) | U+0F43 0xe0 0xbd 0x83 TIBETAN LETTER GHA གྷ | U+003B 0x3b SEMICOLON ; | U+000A 0x0a LINE FEED (LF) (control character) 2 | const char *אבג = "ALEF-BET-GIMEL"; | U+0063 0x63 LATIN SMALL LETTER C c | U+006F 0x6f LATIN SMALL LETTER O o | U+006E 0x6e LATIN SMALL LETTER N n | U+0073 0x73 LATIN SMALL LETTER S s | U+0074 0x74 LATIN SMALL LETTER T t | U+0020 0x20 SPACE (separator) | U+0063 0x63 LATIN SMALL LETTER C c | U+0068 0x68 LATIN SMALL LETTER H h | U+0061 0x61 LATIN SMALL LETTER A a | U+0072 0x72 LATIN SMALL LETTER R r | U+0020 0x20 SPACE (separator) | U+002A 0x2a ASTERISK * | U+05D0 0xd7 0x90 HEBREW LETTER ALEF א | U+05D1 0xd7 0x91 HEBREW LETTER BET ב | U+05D2 0xd7 0x92 HEBREW LETTER GIMEL ג | U+0020 0x20 SPACE (separator) | U+003D 0x3d EQUALS SIGN = | U+0020 0x20 SPACE (separator) | U+0022 0x22 QUOTATION MARK " | U+0041 0x41 LATIN CAPITAL LETTER A A | U+004C 0x4c LATIN CAPITAL LETTER L L | U+0045 0x45 LATIN CAPITAL LETTER E E | U+0046 0x46 LATIN CAPITAL LETTER F F | U+002D 0x2d HYPHEN-MINUS - | U+0042 0x42 LATIN CAPITAL LETTER B B | U+0045 0x45 LATIN CAPITAL LETTER E E | U+0054 0x54 LATIN CAPITAL LETTER T T | U+002D 0x2d HYPHEN-MINUS - | U+0047 0x47 LATIN CAPITAL LETTER G G | U+0049 0x49 LATIN CAPITAL LETTER I I | U+004D 0x4d LATIN CAPITAL LETTER M M | U+0045 0x45 LATIN CAPITAL LETTER E E | U+004C 0x4c LATIN CAPITAL LETTER L L | U+0022 0x22 QUOTATION MARK " | U+003B 0x3b SEMICOLON ; | U+000A 0x0a LINE FEED (LF) (control character) Tested with Python 3.8 contrib/ChangeLog: * unicode/utf8-dump.py: New file. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2020-11-07libcpp: Update cpp_wcwidth() to Unicode 13.0.0Lewis Hyatt6-63/+1106
generated_cpp_wcwidth.h was regenerated using Unicode 13.0.0 data files. No material changes to the parsing scripts (either GCC- or glibc-sourced) were necessary; glibc's utf8_gen.py was tweaked slightly by glibc and matched here. contrib/ChangeLog: * unicode/EastAsianWidth.txt: Update to Unicode 13.0.0. * unicode/PropList.txt: Likewise. * unicode/README: Likewise. * unicode/UnicodeData.txt: Likewise. * unicode/from_glibc/unicode_utils.py: Update to latest glibc version. * unicode/from_glibc/utf8_gen.py: Likewise. libcpp/ChangeLog: * generated_cpp_wcwidth.h: Regenerated from Unicode 13.0.0 data.
2019-12-09Byte vs column awareness for diagnostic-show-locus.c (PR 49973)Lewis Hyatt8-0/+38071
contrib/ChangeLog 2019-12-09 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/49973 * unicode/from_glibc/unicode_utils.py: Support script from glibc (commit 464cd3) to extract character widths from Unicode data files. * unicode/from_glibc/utf8_gen.py: Likewise. * unicode/UnicodeData.txt: Unicode v. 12.1.0 data file. * unicode/EastAsianWidth.txt: Likewise. * unicode/PropList.txt: Likewise. * unicode/gen_wcwidth.py: New utility to generate libcpp/generated_cpp_wcwidth.h with help from the glibc support scripts and the Unicode data files. * unicode/unicode-license.txt: Added. * unicode/README: New explanatory file. libcpp/ChangeLog 2019-12-09 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/49973 * generated_cpp_wcwidth.h: New file generated by ../contrib/unicode/gen_wcwidth.py, supports new cpp_wcwidth function. * charset.c (compute_next_display_width): New function to help implement display columns. (cpp_byte_column_to_display_column): Likewise. (cpp_display_column_to_byte_column): Likewise. (cpp_wcwidth): Likewise. * include/cpplib.h (cpp_byte_column_to_display_column): Declare. (cpp_display_column_to_byte_column): Declare. (cpp_wcwidth): Declare. (cpp_display_width): New function. gcc/ChangeLog 2019-12-09 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/49973 * input.c (location_compute_display_column): New function to help with multibyte awareness in diagnostics. (test_cpp_utf8): New self-test. (input_c_tests): Call the new test. * input.h (location_compute_display_column): Declare. * diagnostic-show-locus.c: Pervasive changes to add multibyte awareness to all classes and functions. (enum column_unit): New enum. (class exploc_with_display_col): New class. (class layout_point): Convert m_column member to array m_columns[2]. (layout_range::contains_point): Add col_unit argument. (test_layout_range_for_single_point): Pass new argument. (test_layout_range_for_single_line): Likewise. (test_layout_range_for_multiple_lines): Likewise. (line_bounds::convert_to_display_cols): New function. (layout::get_state_at_point): Add col_unit argument. (make_range): Use empty filename rather than dummy filename. (get_line_width_without_trailing_whitespace): Rename to... (get_line_bytes_without_trailing_whitespace): ...this. (test_get_line_width_without_trailing_whitespace): Rename to... (test_get_line_bytes_without_trailing_whitespace): ...this. (class layout): m_exploc changed to exploc_with_display_col from plain expanded_location. (layout::get_linenum_width): New accessor member function. (layout::get_x_offset_display): Likewise. (layout::calculate_linenum_width): New subroutine for the constuctor. (layout::calculate_x_offset_display): Likewise. (layout::layout): Use the new subroutines. Add multibyte awareness. (layout::print_source_line): Add multibyte awareness. (layout::print_line): Likewise. (layout::print_annotation_line): Likewise. (line_label::line_label): Likewise. (layout::print_any_labels): Likewise. (layout::annotation_line_showed_range_p): Likewise. (get_printed_columns): Likewise. (class line_label): Rename m_length to m_display_width. (get_affected_columns): Rename to... (get_affected_range): ...this; add col_unit argument and multibyte awareness. (class correction): Add m_affected_bytes and m_display_cols members. Rename m_len to m_byte_length for clarity. Add multibyte awareness throughout. (correction::insertion_p): Add multibyte awareness. (correction::compute_display_cols): New function. (correction::ensure_terminated): Use new member name m_byte_length. (line_corrections::add_hint): Add multibyte awareness. (layout::print_trailing_fixits): Likewise. (layout::get_x_bound_for_row): Likewise. (test_one_liner_simple_caret_utf8): New self-test analogous to the one with _utf8 suffix removed, testing multibyte awareness. (test_one_liner_caret_and_range_utf8): Likewise. (test_one_liner_multiple_carets_and_ranges_utf8): Likewise. (test_one_liner_fixit_insert_before_utf8): Likewise. (test_one_liner_fixit_insert_after_utf8): Likewise. (test_one_liner_fixit_remove_utf8): Likewise. (test_one_liner_fixit_replace_utf8): Likewise. (test_one_liner_fixit_replace_non_equal_range_utf8): Likewise. (test_one_liner_fixit_replace_equal_secondary_range_utf8): Likewise. (test_one_liner_fixit_validation_adhoc_locations_utf8): Likewise. (test_one_liner_many_fixits_1_utf8): Likewise. (test_one_liner_many_fixits_2_utf8): Likewise. (test_one_liner_labels_utf8): Likewise. (test_diagnostic_show_locus_one_liner_utf8): Likewise. (test_overlapped_fixit_printing_utf8): Likewise. (test_overlapped_fixit_printing): Adapt for changes to get_affected_columns, get_printed_columns and class corrections. (test_overlapped_fixit_printing_2): Likewise. (test_linenum_sep): New constant. (test_left_margin): Likewise. (test_offset_impl): Helper function for new test. (test_layout_x_offset_display_utf8): New test. (diagnostic_show_locus_c_tests): Call new tests. gcc/testsuite/ChangeLog: 2019-12-09 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/49973 * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Tweak so that expected output is the same as before the diagnostic-show-locus.c changes. * gcc.dg/cpp/pr66415-1.c: Likewise. From-SVN: r279137