Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
memline.c File Reference
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
#include "nvim/ascii.h"
#include "nvim/vim.h"
#include "nvim/memline.h"
#include "nvim/buffer.h"
#include "nvim/cursor.h"
#include "nvim/eval.h"
#include "nvim/getchar.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memfile.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/screen.h"
#include "nvim/sha256.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/version.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/input.h"
#include <time.h>

Data Structures

struct  pointer_entry
 
struct  pointer_block
 
struct  data_block
 
struct  block0
 

Macros

#define CHECK(c, s)
 
#define DATA_ID   (('d' << 8) + 'a') /* data block id */
 
#define PTR_ID   (('p' << 8) + 't') /* pointer block id */
 
#define BLOCK0_ID0   'b' /* block 0 id 0 */
 
#define BLOCK0_ID1   '0' /* block 0 id 1 */
 
#define DB_MARKED   ((unsigned)1 << ((sizeof(unsigned) * 8) - 1))
 
#define DB_INDEX_MASK   (~DB_MARKED)
 
#define INDEX_SIZE   (sizeof(unsigned)) /* size of one db_index entry */
 
#define HEADER_SIZE   (sizeof(DATA_BL) - INDEX_SIZE) /* size of data block header */
 
#define B0_FNAME_SIZE_ORG   900 /* what it was in older versions */
 
#define B0_FNAME_SIZE_NOCRYPT   898 /* 2 bytes used for other things */
 
#define B0_FNAME_SIZE_CRYPT   890 /* 10 bytes used for other things */
 
#define B0_UNAME_SIZE   40
 
#define B0_HNAME_SIZE   40
 
#define B0_MAGIC_LONG   0x30313233L
 
#define B0_MAGIC_INT   0x20212223L
 
#define B0_MAGIC_SHORT   0x10111213L
 
#define B0_MAGIC_CHAR   0x55
 
#define B0_DIRTY   0x55
 
#define b0_dirty   b0_fname[B0_FNAME_SIZE_ORG - 1]
 
#define b0_flags   b0_fname[B0_FNAME_SIZE_ORG - 2]
 
#define B0_FF_MASK   3
 
#define B0_SAME_DIR   4
 
#define B0_HAS_FENC   8
 
#define STACK_INCR   5 /* nr of entries added to ml_stack at a time */
 
#define ML_DELETE   0x11 /* delete line */
 
#define ML_INSERT   0x12 /* insert line */
 
#define ML_FIND   0x13 /* just find the line */
 
#define ML_FLUSH   0x02 /* flush locked block */
 
#define ML_SIMPLE(x)   (x & 0x10) /* DEL, INS or FIND */
 
#define MLCS_MAXL   800 /* max no of lines in chunk */
 
#define MLCS_MINL   400 /* should be half of MLCS_MAXL */
 

Typedefs

typedef struct block0 ZERO_BL
 
typedef struct pointer_block PTR_BL
 
typedef struct data_block DATA_BL
 
typedef struct pointer_entry PTR_EN
 

Enumerations

enum  upd_block0_T { UB_FNAME = 0, UB_SAME_DIR }
 

Functions

int ml_open (buf_T *buf)
 
void ml_setname (buf_T *buf)
 
void ml_open_files (void)
 
void ml_open_file (buf_T *buf)
 
void check_need_swap (int newfile)
 
void ml_close (buf_T *buf, int del_file)
 
void ml_close_all (int del_file)
 
void ml_close_notmod (void)
 
void ml_timestamp (buf_T *buf)
 
void ml_recover (void)
 
int recover_names (char_u *fname, int list, int nr, char_u **fname_out)
 
void ml_sync_all (int check_file, int check_char, bool do_fsync)
 
void ml_preserve (buf_T *buf, int message, bool do_fsync)
 
char_uml_get (linenr_T lnum)
 
char_uml_get_pos (pos_T *pos)
 
char_uml_get_buf (buf_T *buf, linenr_T lnum, int will_change)
 
int ml_line_alloced (void)
 
int ml_append (linenr_T lnum, char_u *line, colnr_T len, int newfile)
 
int ml_append_buf (buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, int newfile)
 
int ml_replace (linenr_T lnum, char_u *line, bool copy)
 
int ml_delete (linenr_T lnum, int message)
 
void ml_setmarked (linenr_T lnum)
 
linenr_T ml_firstmarked (void)
 
void ml_clearmarked (void)
 
char_umakeswapname (char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)
 
char_uget_file_in_dir (char_u *fname, char_u *dname)
 
void copy_option_part ((char_u **) dirp,(char_u *) dir_name, dir_len,",")
 
 for (;;)
 
 if (os_isdir((char_u *) dir_name))
 
else if (!*found_existing_dir &&**dirp==NUL)
 
 xfree (dir_name)
 
void ml_setflags (buf_T *buf)
 
long ml_find_line_or_offset (buf_T *buf, linenr_T lnum, long *offp, bool no_ff)
 
void goto_byte (long cnt)
 Goto byte in buffer with offset 'cnt'. More...
 
int inc (pos_T *lp)
 
int incl (pos_T *lp)
 Same as inc(), but skip NUL at the end of non-empty lines. More...
 
int dec (pos_T *lp)
 
int decl (pos_T *lp)
 Same as dec(), but skip NUL at the end of non-empty lines. More...
 

Variables

static char size_t n
 
char * dir_name = xmalloc(dir_len)
 
char * buf_fname = (char *) buf->b_fname
 
const size_t dir_len = strlen(*dirp) + 1
 
 fname
 

Macro Definition Documentation

#define B0_DIRTY   0x55
#define b0_dirty   b0_fname[B0_FNAME_SIZE_ORG - 1]
#define B0_FF_MASK   3
#define b0_flags   b0_fname[B0_FNAME_SIZE_ORG - 2]
#define B0_FNAME_SIZE_CRYPT   890 /* 10 bytes used for other things */
#define B0_FNAME_SIZE_NOCRYPT   898 /* 2 bytes used for other things */
#define B0_FNAME_SIZE_ORG   900 /* what it was in older versions */
#define B0_HAS_FENC   8
#define B0_HNAME_SIZE   40
#define B0_MAGIC_CHAR   0x55
#define B0_MAGIC_INT   0x20212223L
#define B0_MAGIC_LONG   0x30313233L
#define B0_MAGIC_SHORT   0x10111213L
#define B0_SAME_DIR   4
#define B0_UNAME_SIZE   40
#define BLOCK0_ID0   'b' /* block 0 id 0 */
#define BLOCK0_ID1   '0' /* block 0 id 1 */
#define CHECK (   c,
  s 
)
#define DATA_ID   (('d' << 8) + 'a') /* data block id */
#define DB_INDEX_MASK   (~DB_MARKED)
#define DB_MARKED   ((unsigned)1 << ((sizeof(unsigned) * 8) - 1))
#define HEADER_SIZE   (sizeof(DATA_BL) - INDEX_SIZE) /* size of data block header */
#define INDEX_SIZE   (sizeof(unsigned)) /* size of one db_index entry */
#define ML_DELETE   0x11 /* delete line */
#define ML_FIND   0x13 /* just find the line */
#define ML_FLUSH   0x02 /* flush locked block */
#define ML_INSERT   0x12 /* insert line */
#define ML_SIMPLE (   x)    (x & 0x10) /* DEL, INS or FIND */
#define MLCS_MAXL   800 /* max no of lines in chunk */
#define MLCS_MINL   400 /* should be half of MLCS_MAXL */
#define PTR_ID   (('p' << 8) + 't') /* pointer block id */
#define STACK_INCR   5 /* nr of entries added to ml_stack at a time */

Typedef Documentation

typedef struct data_block DATA_BL
typedef struct pointer_block PTR_BL
typedef struct pointer_entry PTR_EN
typedef struct block0 ZERO_BL

Enumeration Type Documentation

Enumerator
UB_FNAME 
UB_SAME_DIR 

Function Documentation

void check_need_swap ( int  newfile)

If still need to create a swap file, and starting to edit a not-readonly file, or reading into an existing buffer, create a swap file now.

Parameters
newfilereading file into new buffer
void copy_option_part ( (char_u **)  dirp,
(char_u *)  dir_name,
dir_len  ,
,
 
)
int dec ( pos_T lp)
int decl ( pos_T lp)

Same as dec(), but skip NUL at the end of non-empty lines.

for ( ;;  )
char_u* get_file_in_dir ( char_u fname,
char_u dname 
)
void goto_byte ( long  cnt)

Goto byte in buffer with offset 'cnt'.

if ( os_isdir((char_u *) dir_name )
else if ( !*found_existing_dir &&**  dirp = NUL)
int inc ( pos_T lp)

Increment the line pointer "lp" crossing line boundaries as necessary. Return 1 when going to the next line. Return 2 when moving forward onto a NUL at the end of the line). Return -1 when at the end of file. Return 0 otherwise.

int incl ( pos_T lp)

Same as inc(), but skip NUL at the end of non-empty lines.

char_u* makeswapname ( char_u fname,
char_u ffname,
buf_T buf,
char_u dir_name 
)
int ml_append ( linenr_T  lnum,
char_u line,
colnr_T  len,
int  newfile 
)
int ml_append_buf ( buf_T buf,
linenr_T  lnum,
char_u line,
colnr_T  len,
int  newfile 
)
void ml_clearmarked ( void  )
void ml_close ( buf_T buf,
int  del_file 
)
void ml_close_all ( int  del_file)
void ml_close_notmod ( void  )
int ml_delete ( linenr_T  lnum,
int  message 
)

Delete line lnum in the current buffer.

Note
The caller of this function should probably also call deleted_lines() after this.
Parameters
messageShow "--No lines in buffer--" message.
Returns
FAIL for failure, OK otherwise
long ml_find_line_or_offset ( buf_T buf,
linenr_T  lnum,
long *  offp,
bool  no_ff 
)

Find offset for line or line with offset.

Parameters
bufbuffer to use
lnumif > 0, find offset of lnum, store offset in offp if == 0, return line with offset *offp
offpLocation where offset of line is stored, or to read offset to use to find line. In the later case, store remaining offset.
no_ffignore 'fileformat' option, always use one byte for NL.
Returns
-1 if information is not available
linenr_T ml_firstmarked ( void  )
char_u* ml_get ( linenr_T  lnum)
char_u* ml_get_buf ( buf_T buf,
linenr_T  lnum,
int  will_change 
)
char_u* ml_get_pos ( pos_T pos)
int ml_line_alloced ( void  )
int ml_open ( buf_T buf)
void ml_open_file ( buf_T buf)
void ml_open_files ( void  )
void ml_preserve ( buf_T buf,
int  message,
bool  do_fsync 
)
void ml_recover ( void  )
int ml_replace ( linenr_T  lnum,
char_u line,
bool  copy 
)
void ml_setflags ( buf_T buf)
void ml_setmarked ( linenr_T  lnum)
void ml_setname ( buf_T buf)
void ml_sync_all ( int  check_file,
int  check_char,
bool  do_fsync 
)
void ml_timestamp ( buf_T buf)
int recover_names ( char_u fname,
int  list,
int  nr,
char_u **  fname_out 
)
xfree ( dir_name  )

Variable Documentation

char* buf_fname = (char *) buf->b_fname
const size_t dir_len = strlen(*dirp) + 1
dir_name = xmalloc(dir_len)
return fname
Initial value:
= (char *)makeswapname((char_u *)buf_fname, buf->b_ffname, buf,
char * buf_fname
Definition: memline.c:3255
char_u * makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)
Definition: memline.c:3050
char *const buf
Definition: encode.c:231
char * dir_name
Definition: memline.c:3254
unsigned char char_u
Definition: types.h:11
char size_t n
Initial value:
{
char *fname
fname
Definition: memline.c:3268