diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-10-12 09:46:38 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-10-12 09:46:38 -0700 |
commit | 9cd320ea6572c577cdf17ce1f9ea5230b166af6d (patch) | |
tree | d1c8e7c2e09a91ed75f0e5476c648c2e745aa2de /libcpp/include | |
parent | 4854d721be78358e59367982bdd94461b4be3c5a (diff) | |
parent | 3175d40fc52fb8eb3c3b18cc343d773da24434fb (diff) | |
download | gcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.zip gcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.tar.gz gcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.tar.bz2 |
Merge from trunk revision 3175d40fc52fb8eb3c3b18cc343d773da24434fb.
Diffstat (limited to 'libcpp/include')
-rw-r--r-- | libcpp/include/cpplib.h | 40 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 6 |
2 files changed, 39 insertions, 7 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index e8bb15d..8e39886 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -312,9 +312,6 @@ enum cpp_normalize_level { carries all the options visible to the command line. */ struct cpp_options { - /* Characters between tab stops. */ - unsigned int tabstop; - /* The language we're preprocessing. */ enum c_lang lang; @@ -1335,14 +1332,43 @@ extern const char * cpp_get_userdef_suffix (const cpp_token *); /* In charset.c */ + +/* A class to manage the state while converting a UTF-8 sequence to cppchar_t + and computing the display width one character at a time. */ +class cpp_display_width_computation { + public: + cpp_display_width_computation (const char *data, int data_length, + int tabstop); + const char *next_byte () const { return m_next; } + int bytes_processed () const { return m_next - m_begin; } + int bytes_left () const { return m_bytes_left; } + bool done () const { return !bytes_left (); } + int display_cols_processed () const { return m_display_cols; } + + int process_next_codepoint (); + int advance_display_cols (int n); + + private: + const char *const m_begin; + const char *m_next; + size_t m_bytes_left; + const int m_tabstop; + int m_display_cols; +}; + +/* Convenience functions that are simple use cases for class + cpp_display_width_computation. Tab characters will be expanded to spaces + as determined by TABSTOP. */ int cpp_byte_column_to_display_column (const char *data, int data_length, - int column); -inline int cpp_display_width (const char *data, int data_length) + int column, int tabstop); +inline int cpp_display_width (const char *data, int data_length, + int tabstop) { - return cpp_byte_column_to_display_column (data, data_length, data_length); + return cpp_byte_column_to_display_column (data, data_length, data_length, + tabstop); } int cpp_display_column_to_byte_column (const char *data, int data_length, - int display_col); + int display_col, int tabstop); int cpp_wcwidth (cppchar_t c); #endif /* ! LIBCPP_CPPLIB_H */ diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 217f916..44008be 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1225,6 +1225,12 @@ LINEMAP_SYSP (const line_map_ordinary *ord_map) return ord_map->sysp; } +const struct line_map *first_map_in_common (line_maps *set, + location_t loc0, + location_t loc1, + location_t *res_loc0, + location_t *res_loc1); + /* Return a positive value if PRE denotes the location of a token that comes before the token of POST, 0 if PRE denotes the location of the same token as the token for POST, and a negative value |