Data Structures | Macros | Typedefs | Functions
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 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)
 
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, int bad, int idx, bool undo)
 

Macro Definition Documentation

#define AFT_CAPLONG   2
#define AFT_CHAR   0
#define AFT_LONG   1
#define AFT_NUM   3
#define AH_KEY_LEN   17
#define BY_FLAGS   2
#define BY_FLAGS2   3
#define BY_INDEX   1
#define BY_NOFLAGS   0
#define BY_SPECIAL   BY_FLAGS2
#define CF_UPPER   0x02
#define CF_WORD   0x01
#define CONDIT_AFF   8
#define CONDIT_CFIX   2
#define CONDIT_COMB   1
#define CONDIT_SUF   4
#define HI2AH (   hi)    ((affheader_T *)(hi)->hi_key)
#define HI2CI (   hi)    ((compitem_T *)(hi)->hi_key)
#define HI2WN (   hi)    (wordnode_T *)((hi)->hi_key)
#define MAXITEMCNT   30
#define MAXLINELEN   500
#define PFX_FLAGS   -256
#define SAL_COLLAPSE   2
#define SAL_F0LLOWUP   1
#define SAL_REM_ACCENTS   4
#define SBLOCKSIZE   16000
#define SHARED_MASK   0x8000000
#define SN_CHARFLAGS   1
#define SN_COMPOUND   8
#define SN_END   255
#define SN_INFO   15
#define SN_MAP   7
#define SN_MIDWORD   2
#define SN_NOBREAK   10
#define SN_NOCOMPOUNDSUGS   16
#define SN_NOSPLITSUGS   14
#define SN_PREFCOND   3
#define SN_REGION   0
#define SN_REP   4
#define SN_REPSAL   12
#define SN_SAL   5
#define SN_SOFO   6
#define SN_SUGFILE   11
#define SN_SYLLABLE   9
#define SN_WORDS   13
#define SNF_REQUIRED   1
#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)
#define SP_TRUNCERROR
Definition: spell_defs.h:96
if(len)
Definition: encode.c:226
char *const buf
Definition: encode.c:235
#define SP_OTHERERROR
Definition: spell_defs.h:98
int fd
Definition: undo.c:1062
static char size_t n
Definition: memline.c:3251
return
Definition: eval.c:14724

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.
#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; \
} \
} while (0)
if(len)
Definition: encode.c:226
#define NUL
Definition: ascii.h:19
char *const buf
Definition: encode.c:235
int fd
Definition: undo.c:1062
static char size_t n
Definition: memline.c:3251
return
Definition: eval.c:14724
#define SPELL_READ_BYTES(buf, n, fd, exit_code)
Definition: spellfile.c:511
#define SP_FORMERROR
Definition: spell_defs.h:97

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.
#define VIMSPELLMAGIC   "VIMspell"
#define VIMSPELLMAGICL   (sizeof(VIMSPELLMAGIC) - 1)
#define VIMSPELLVERSION   50
#define WN_MASK   0xffff

Typedef Documentation

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

Function Documentation

void ex_mkspell ( exarg_T eap)
void ex_spell ( exarg_T eap)
void spell_add_word ( char_u word,
int  len,
int  bad,
int  idx,
bool  undo 
)
int spell_check_msm ( void  )
slang_T* spell_load_file ( char_u fname,
char_u lang,
slang_T old_lp,
bool  silent 
)
void suggest_load_files ( void  )