Data Structures | Macros | Typedefs | Functions | Variables
spellfile.c File Reference
#include <stdio.h>
#include <stdint.h>
#include <wctype.h>
#include "nvim/vim.h"
#include "nvim/spell_defs.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/ex_cmds2.h"
#include "nvim/fileio.h"
#include "nvim/memory.h"
#include "nvim/memline.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include <time.h>

Data Structures

struct  afffile_S
 
struct  affentry_S
 
struct  affheader_S
 
struct  compitem_S
 
struct  sblock_S
 
struct  wordnode_S
 
struct  spellinfo_S
 

Macros

#define BY_NOFLAGS   0
 
#define BY_INDEX   1
 
#define BY_FLAGS   2
 
#define BY_FLAGS2   3
 
#define BY_SPECIAL   BY_FLAGS2
 
#define ZERO_FLAG   65009
 
#define SAL_F0LLOWUP   1
 
#define SAL_COLLAPSE   2
 
#define SAL_REM_ACCENTS   4
 
#define VIMSPELLMAGIC   "VIMspell"
 
#define VIMSPELLMAGICL   (sizeof(VIMSPELLMAGIC) - 1)
 
#define VIMSPELLVERSION   50
 
#define SN_REGION   0
 
#define SN_CHARFLAGS   1
 
#define SN_MIDWORD   2
 
#define SN_PREFCOND   3
 
#define SN_REP   4
 
#define SN_SAL   5
 
#define SN_SOFO   6
 
#define SN_MAP   7
 
#define SN_COMPOUND   8
 
#define SN_SYLLABLE   9
 
#define SN_NOBREAK   10
 
#define SN_SUGFILE   11
 
#define SN_REPSAL   12
 
#define SN_WORDS   13
 
#define SN_NOSPLITSUGS   14
 
#define SN_INFO   15
 
#define SN_NOCOMPOUNDSUGS   16
 
#define SN_END   255
 
#define SNF_REQUIRED   1
 
#define CF_WORD   0x01
 
#define CF_UPPER   0x02
 
#define MAXLINELEN   500
 
#define AFT_CHAR   0
 
#define AFT_LONG   1
 
#define AFT_CAPLONG   2
 
#define AFT_NUM   3
 
#define AH_KEY_LEN   17
 
#define HI2AH(hi)   ((affheader_T *)(hi)->hi_key)
 
#define HI2CI(hi)   ((compitem_T *)(hi)->hi_key)
 
#define SBLOCKSIZE   16000
 
#define WN_MASK   0xffff
 
#define HI2WN(hi)   (wordnode_T *)((hi)->hi_key)
 
#define SPELL_READ_BYTES(buf, n, fd, exit_code)
 
#define SPELL_READ_NONNUL_BYTES(buf, n, fd, exit_code)
 
#define SHARED_MASK   0x8000000
 
#define PFX_FLAGS   -256
 
#define CONDIT_COMB   1
 
#define CONDIT_CFIX   2
 
#define CONDIT_SUF   4
 
#define CONDIT_AFF   8
 
#define MAXITEMCNT   30
 

Typedefs

typedef struct afffile_S afffile_T
 
typedef struct affentry_S affentry_T
 
typedef struct affheader_S affheader_T
 
typedef struct compitem_S compitem_T
 
typedef struct sblock_S sblock_T
 
typedef struct wordnode_S wordnode_T
 
typedef struct spellinfo_S spellinfo_T
 

Functions

slang_Tspell_load_file (char_u *fname, char_u *lang, slang_T *old_lp, bool silent)
 
void suggest_load_files (void)
 
 if (len< 0)
 
 if ((size_t) len >=SIZE_MAX/sizeof(int))
 
 if (len > 0)
 
int spell_check_msm (void)
 
void ex_mkspell (exarg_T *eap)
 
void ex_spell (exarg_T *eap)
 
void spell_add_word (char_u *word, int len, SpellAddType what, int idx, bool undo)
 

Variables

static int char_ubp
 
idx_Tip
 
long len = get4c(fd)
 
 return
 

Macro Definition Documentation

◆ AFT_CAPLONG

#define AFT_CAPLONG   2

◆ AFT_CHAR

#define AFT_CHAR   0

◆ AFT_LONG

#define AFT_LONG   1

◆ AFT_NUM

#define AFT_NUM   3

◆ AH_KEY_LEN

#define AH_KEY_LEN   17

◆ BY_FLAGS

#define BY_FLAGS   2

◆ BY_FLAGS2

#define BY_FLAGS2   3

◆ BY_INDEX

#define BY_INDEX   1

◆ BY_NOFLAGS

#define BY_NOFLAGS   0

◆ BY_SPECIAL

#define BY_SPECIAL   BY_FLAGS2

◆ CF_UPPER

#define CF_UPPER   0x02

◆ CF_WORD

#define CF_WORD   0x01

◆ CONDIT_AFF

#define CONDIT_AFF   8

◆ CONDIT_CFIX

#define CONDIT_CFIX   2

◆ CONDIT_COMB

#define CONDIT_COMB   1

◆ CONDIT_SUF

#define CONDIT_SUF   4

◆ HI2AH

#define HI2AH (   hi)    ((affheader_T *)(hi)->hi_key)

◆ HI2CI

#define HI2CI (   hi)    ((compitem_T *)(hi)->hi_key)

◆ HI2WN

#define HI2WN (   hi)    (wordnode_T *)((hi)->hi_key)

◆ MAXITEMCNT

#define MAXITEMCNT   30

◆ MAXLINELEN

#define MAXLINELEN   500

◆ PFX_FLAGS

#define PFX_FLAGS   -256

◆ SAL_COLLAPSE

#define SAL_COLLAPSE   2

◆ SAL_F0LLOWUP

#define SAL_F0LLOWUP   1

◆ SAL_REM_ACCENTS

#define SAL_REM_ACCENTS   4

◆ SBLOCKSIZE

#define SBLOCKSIZE   16000

◆ SHARED_MASK

#define SHARED_MASK   0x8000000

◆ SN_CHARFLAGS

#define SN_CHARFLAGS   1

◆ SN_COMPOUND

#define SN_COMPOUND   8

◆ SN_END

#define SN_END   255

◆ SN_INFO

#define SN_INFO   15

◆ SN_MAP

#define SN_MAP   7

◆ SN_MIDWORD

#define SN_MIDWORD   2

◆ SN_NOBREAK

#define SN_NOBREAK   10

◆ SN_NOCOMPOUNDSUGS

#define SN_NOCOMPOUNDSUGS   16

◆ SN_NOSPLITSUGS

#define SN_NOSPLITSUGS   14

◆ SN_PREFCOND

#define SN_PREFCOND   3

◆ SN_REGION

#define SN_REGION   0

◆ SN_REP

#define SN_REP   4

◆ SN_REPSAL

#define SN_REPSAL   12

◆ SN_SAL

#define SN_SAL   5

◆ SN_SOFO

#define SN_SOFO   6

◆ SN_SUGFILE

#define SN_SUGFILE   11

◆ SN_SYLLABLE

#define SN_SYLLABLE   9

◆ SN_WORDS

#define SN_WORDS   13

◆ SNF_REQUIRED

#define SNF_REQUIRED   1

◆ SPELL_READ_BYTES

#define SPELL_READ_BYTES (   buf,
  n,
  fd,
  exit_code 
)
Value:
do { \
const size_t n__SPRB = (n); \
FILE *const fd__SPRB = (fd); \
char *const buf__SPRB = (buf); \
const size_t read_bytes__SPRB = fread(buf__SPRB, 1, n__SPRB, fd__SPRB); \
if (read_bytes__SPRB != n__SPRB) { \
exit_code; \
return feof(fd__SPRB) ? SP_TRUNCERROR : SP_OTHERERROR; \
} \
} while (0)

Read n bytes from fd to buf, returning on errors

Parameters
[out]bufBuffer to read to, must be at least n bytes long.
[in]nAmount of bytes to read.
fdFILE* to read from.
exit_codeCode to run before returning.
Returns
Allows to proceed if everything is OK, returns SP_TRUNCERROR if there are not enough bytes, returns SP_OTHERERROR if reading failed.

◆ SPELL_READ_NONNUL_BYTES

#define SPELL_READ_NONNUL_BYTES (   buf,
  n,
  fd,
  exit_code 
)
Value:
do { \
const size_t n__SPRNB = (n); \
FILE *const fd__SPRNB = (fd); \
char *const buf__SPRNB = (buf); \
SPELL_READ_BYTES(buf__SPRNB, n__SPRNB, fd__SPRNB, exit_code); \
if (memchr(buf__SPRNB, NUL, (size_t)n__SPRNB)) { \
exit_code; \
return SP_FORMERROR; \
} \
} while (0)

Like SPELL_READ_BYTES, but also error out if NUL byte was read

Returns
Allows to proceed if everything is OK, returns SP_TRUNCERROR if there are not enough bytes, returns SP_OTHERERROR if reading failed, returns SP_FORMERROR if read out a NUL byte.

◆ VIMSPELLMAGIC

#define VIMSPELLMAGIC   "VIMspell"

◆ VIMSPELLMAGICL

#define VIMSPELLMAGICL   (sizeof(VIMSPELLMAGIC) - 1)

◆ VIMSPELLVERSION

#define VIMSPELLVERSION   50

◆ WN_MASK

#define WN_MASK   0xffff

◆ ZERO_FLAG

#define ZERO_FLAG   65009

Typedef Documentation

◆ affentry_T

typedef struct affentry_S affentry_T

◆ afffile_T

typedef struct afffile_S afffile_T

◆ affheader_T

typedef struct affheader_S affheader_T

◆ compitem_T

typedef struct compitem_S compitem_T

◆ sblock_T

typedef struct sblock_S sblock_T

◆ spellinfo_T

typedef struct spellinfo_S spellinfo_T

◆ wordnode_T

typedef struct wordnode_S wordnode_T

Function Documentation

◆ ex_mkspell()

void ex_mkspell ( exarg_T eap)

◆ ex_spell()

void ex_spell ( exarg_T eap)

◆ if() [1/3]

if ( (size_t) len >=SIZE_MAX/sizeof(int)  )

◆ if() [2/3]

if ( len  ,
 
)

◆ if() [3/3]

if ( )

◆ spell_add_word()

void spell_add_word ( char_u word,
int  len,
SpellAddType  what,
int  idx,
bool  undo 
)

◆ spell_check_msm()

int spell_check_msm ( void  )

◆ spell_load_file()

slang_T* spell_load_file ( char_u fname,
char_u lang,
slang_T old_lp,
bool  silent 
)

◆ suggest_load_files()

void suggest_load_files ( void  )

Variable Documentation

◆ bp

int char_u* bp
Initial value:
{
int idx

◆ ip

idx_T* ip

◆ len

long len = get4c(fd)

◆ return

return
SP_TRUNCERROR
#define SP_TRUNCERROR
Definition: spell_defs.h:96
SP_OTHERERROR
#define SP_OTHERERROR
Definition: spell_defs.h:98
NUL
#define NUL
Definition: ascii.h:19
fd
int fd
Definition: undo.c:1184
n
int n
Definition: funcs.c:8392
SP_FORMERROR
#define SP_FORMERROR
Definition: spell_defs.h:97
buf
char *const buf
Definition: encode.c:238