Files
neovim/src/nvim/charset.h
Sean Dewar 90a4cf92d2 vim-patch:8.2.0886: cannot use octal numbers in scriptversion 4
Problem:    Cannot use octal numbers in scriptversion 4.
Solution:   Add the "0o" notation. (Ken Takata, closes vim/vim#5304)
c17e66c5c0

:scriptversion is N/A.

Cherry-pick latest str2nr() doc changes from v8.1.2035.
Cherry-pick various mentions of the 0o prefix from:
 - v8.2.2324
 - 2346a63784
 - 11e3c5ba82
 - 82be4849ee

Patch used ascii_isbdigit() by mistake, which was fixed in v8.2.2309.

Make STR2NR_OOCT work the same as STR2NR_OCT when forcing.
In Vim, STR2NR_FORCE | STR2NR_OOCT isn't handled, and doesn't actually
force anything. Rather than abort(), make it work as STR2NR_OCT.

This means STR2NR_FORCE | STR2NR_OCT works the same as
STR2NR_FORCE | STR2NR_OOCT and STR2NR_FORCE | STR2NR_OCT | STR2NR_OOCT.
2021-09-11 15:36:03 +01:00

57 lines
1.7 KiB
C

#ifndef NVIM_CHARSET_H
#define NVIM_CHARSET_H
#include "nvim/types.h"
#include "nvim/pos.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval/typval.h"
#include "nvim/option_defs.h"
/// Return the folded-case equivalent of the given character
///
/// @param[in] c Character to transform.
///
/// @return Folded variant.
#define CH_FOLD(c) \
utf_fold((sizeof(c) == sizeof(char)) \
?((int)(uint8_t)(c)) \
:((int)(c)))
/// Flags for vim_str2nr()
typedef enum {
STR2NR_DEC = 0,
STR2NR_BIN = (1 << 0), ///< Allow binary numbers.
STR2NR_OCT = (1 << 1), ///< Allow octal numbers.
STR2NR_HEX = (1 << 2), ///< Allow hexadecimal numbers.
STR2NR_OOCT = (1 << 3), ///< Octal with prefix "0o": 0o777
/// Force one of the above variants.
///
/// STR2NR_FORCE|STR2NR_DEC is actually not different from supplying zero
/// as flags, but still present for completeness.
///
/// STR2NR_FORCE|STR2NR_OCT|STR2NR_OOCT is the same as STR2NR_FORCE|STR2NR_OCT
/// or STR2NR_FORCE|STR2NR_OOCT.
STR2NR_FORCE = (1 << 7),
/// Recognize all formats vim_str2nr() can recognize.
STR2NR_ALL = STR2NR_BIN | STR2NR_OCT | STR2NR_HEX | STR2NR_OOCT,
/// Disallow octals numbers without the 0o prefix.
STR2NR_NO_OCT = STR2NR_BIN | STR2NR_HEX | STR2NR_OOCT,
STR2NR_QUOTE = (1 << 4), ///< Ignore embedded single quotes.
} ChStr2NrFlags;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "charset.h.generated.h"
#endif
static inline bool vim_isbreak(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
/// Check if `c` is one of the characters in 'breakat'.
/// Used very often if 'linebreak' is set
static inline bool vim_isbreak(int c)
{
return breakat_flags[(char_u)c];
}
#endif // NVIM_CHARSET_H