1 #ifndef NVIM_CHARSET_H
2 #define NVIM_CHARSET_H
3 
4 #include "nvim/buffer_defs.h"
5 #include "nvim/eval/typval.h"
6 #include "nvim/option_defs.h"
7 #include "nvim/pos.h"
8 #include "nvim/types.h"
9 
10 /// Return the folded-case equivalent of the given character
11 ///
12 /// @param[in]  c  Character to transform.
13 ///
14 /// @return Folded variant.
15 #define CH_FOLD(c) \
16   utf_fold((sizeof(c) == sizeof(char)) \
17              ?((int)(uint8_t)(c)) \
18              :((int)(c)))
19 
20 /// Flags for vim_str2nr()
21 typedef enum {
22   STR2NR_DEC = 0,
23   STR2NR_BIN = (1 << 0),  ///< Allow binary numbers.
24   STR2NR_OCT = (1 << 1),  ///< Allow octal numbers.
25   STR2NR_HEX = (1 << 2),  ///< Allow hexadecimal numbers.
26   STR2NR_OOCT = (1 << 3),  ///< Octal with prefix "0o": 0o777
27   /// Force one of the above variants.
28   ///
29   /// STR2NR_FORCE|STR2NR_DEC is actually not different from supplying zero
30   /// as flags, but still present for completeness.
31   ///
32   /// STR2NR_FORCE|STR2NR_OCT|STR2NR_OOCT is the same as STR2NR_FORCE|STR2NR_OCT
33   /// or STR2NR_FORCE|STR2NR_OOCT.
34   STR2NR_FORCE = (1 << 7),
35   /// Recognize all formats vim_str2nr() can recognize.
36   STR2NR_ALL = STR2NR_BIN | STR2NR_OCT | STR2NR_HEX | STR2NR_OOCT,
37   /// Disallow octals numbers without the 0o prefix.
38   STR2NR_NO_OCT = STR2NR_BIN | STR2NR_HEX | STR2NR_OOCT,
39   STR2NR_QUOTE = (1 << 4),  ///< Ignore embedded single quotes.
40 } ChStr2NrFlags;
41 
42 #ifdef INCLUDE_GENERATED_DECLARATIONS
43 # include "charset.h.generated.h"
44 #endif
45 
46 static inline bool vim_isbreak(int c)
47   REAL_FATTR_CONST
48   REAL_FATTR_ALWAYS_INLINE;
49 
50 /// Check if `c` is one of the characters in 'breakat'.
51 /// Used very often if 'linebreak' is set
vim_isbreak(int c)52 static inline bool vim_isbreak(int c)
53 {
54   return breakat_flags[(char_u)c];
55 }
56 #endif  // NVIM_CHARSET_H
57