/ChangeLog 2019-09-26 Lewis Hyatt PR preprocessor/49973 * contrib/gen_wcwidth.cpp: New standalone utility to generate libcpp/generated_cpp_wcwidth.h. libcpp/ChangeLog 2019-09-26 Lewis Hyatt PR preprocessor/49973 * generated_cpp_wcwidth.h: New file generated by contrib/gen_wcwidth.cpp, 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-09-26 Lewis Hyatt 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.c (diagnostic_get_location_text): Use it to output the correct column number on diagnostics for source lines containing multibyte characters. * diagnostic-show-locus.c: Pervasive changes to add multibyte awareness to all classes and functions. (class exploc_with_display_col): New class. (class layout_point): Add m_display_col member. (layout_point::get_col): New function. (layout_range::contains_point): Add use_display 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 use_display argument. (class layout): m_exploc changed to exploc_with_display_col from expanded_location. (layout::layout): Add multibyte awareness. (layout::print_source_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. (get_affected_columns): Rename to... (get_affected_range): ...this; add use_display argument and multibyte awareness. (class correction): Add m_affected_bytes and m_display_cols members. Rename m_len to m_bytes for clarity. Add multibyte awareness. (correction::insertion_p): Add multibyte awareness. (correction::compute_display_cols): New function. (correction::ensure_terminated): m_len renamed to m_bytes. (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. (diagnostic_show_locus_c_tests): Call new tests.