mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(memline): convert function comments to doxygen format
This commit is contained in:
parent
a72f338d76
commit
8b7f818ee7
@ -242,11 +242,9 @@ typedef enum {
|
|||||||
# include "memline.c.generated.h"
|
# include "memline.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/// Open a new memline for "buf".
|
||||||
* Open a new memline for "buf".
|
///
|
||||||
*
|
/// @return FAIL for failure, OK otherwise.
|
||||||
* Return FAIL for failure, OK otherwise.
|
|
||||||
*/
|
|
||||||
int ml_open(buf_T *buf)
|
int ml_open(buf_T *buf)
|
||||||
{
|
{
|
||||||
bhdr_T *hp = NULL;
|
bhdr_T *hp = NULL;
|
||||||
@ -379,10 +377,8 @@ error:
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// ml_setname() is called when the file name of "buf" has been changed.
|
||||||
* ml_setname() is called when the file name of "buf" has been changed.
|
/// It may rename the swap file.
|
||||||
* It may rename the swap file.
|
|
||||||
*/
|
|
||||||
void ml_setname(buf_T *buf)
|
void ml_setname(buf_T *buf)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
@ -458,11 +454,9 @@ void ml_setname(buf_T *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Open a file for the memfile for all buffers that are not readonly or have
|
||||||
* Open a file for the memfile for all buffers that are not readonly or have
|
/// been modified.
|
||||||
* been modified.
|
/// Used when 'updatecount' changes from zero to non-zero.
|
||||||
* Used when 'updatecount' changes from zero to non-zero.
|
|
||||||
*/
|
|
||||||
void ml_open_files(void)
|
void ml_open_files(void)
|
||||||
{
|
{
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
@ -472,11 +466,9 @@ void ml_open_files(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Open a swap file for an existing memfile, if there is no swap file yet.
|
||||||
* Open a swap file for an existing memfile, if there is no swap file yet.
|
/// If we are unable to find a file name, mf_fname will be NULL
|
||||||
* If we are unable to find a file name, mf_fname will be NULL
|
/// and the memfile will be in memory only (no recovery possible).
|
||||||
* and the memfile will be in memory only (no recovery possible).
|
|
||||||
*/
|
|
||||||
void ml_open_file(buf_T *buf)
|
void ml_open_file(buf_T *buf)
|
||||||
{
|
{
|
||||||
memfile_T *mfp;
|
memfile_T *mfp;
|
||||||
@ -563,10 +555,9 @@ void check_need_swap(bool newfile)
|
|||||||
msg_silent = old_msg_silent;
|
msg_silent = old_msg_silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Close memline for buffer 'buf'.
|
||||||
* Close memline for buffer 'buf'.
|
///
|
||||||
* If 'del_file' is TRUE, delete the swap file
|
/// @param del_file if TRUE, delete the swap file
|
||||||
*/
|
|
||||||
void ml_close(buf_T *buf, int del_file)
|
void ml_close(buf_T *buf, int del_file)
|
||||||
{
|
{
|
||||||
if (buf->b_ml.ml_mfp == NULL) { // not open
|
if (buf->b_ml.ml_mfp == NULL) { // not open
|
||||||
@ -598,10 +589,8 @@ void ml_close_all(bool del_file)
|
|||||||
vim_deltempdir(); // delete created temp directory
|
vim_deltempdir(); // delete created temp directory
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Close all memfiles for not modified buffers.
|
||||||
* Close all memfiles for not modified buffers.
|
/// Only use just before exiting!
|
||||||
* Only use just before exiting!
|
|
||||||
*/
|
|
||||||
void ml_close_notmod(void)
|
void ml_close_notmod(void)
|
||||||
{
|
{
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
@ -611,10 +600,8 @@ void ml_close_notmod(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Update the timestamp in the .swp file.
|
||||||
* Update the timestamp in the .swp file.
|
/// Used when the file has been written.
|
||||||
* Used when the file has been written.
|
|
||||||
*/
|
|
||||||
void ml_timestamp(buf_T *buf)
|
void ml_timestamp(buf_T *buf)
|
||||||
{
|
{
|
||||||
ml_upd_block0(buf, UB_FNAME);
|
ml_upd_block0(buf, UB_FNAME);
|
||||||
@ -637,9 +624,7 @@ static bool ml_check_b0_strings(ZERO_BL *b0p)
|
|||||||
&& memchr(b0p->b0_fname, NUL, B0_FNAME_SIZE_CRYPT)); // -V512
|
&& memchr(b0p->b0_fname, NUL, B0_FNAME_SIZE_CRYPT)); // -V512
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Update the timestamp or the B0_SAME_DIR flag of the .swp file.
|
||||||
* Update the timestamp or the B0_SAME_DIR flag of the .swp file.
|
|
||||||
*/
|
|
||||||
static void ml_upd_block0(buf_T *buf, upd_block0_T what)
|
static void ml_upd_block0(buf_T *buf, upd_block0_T what)
|
||||||
{
|
{
|
||||||
memfile_T *mfp;
|
memfile_T *mfp;
|
||||||
@ -663,11 +648,9 @@ static void ml_upd_block0(buf_T *buf, upd_block0_T what)
|
|||||||
mf_put(mfp, hp, true, false);
|
mf_put(mfp, hp, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Write file name and timestamp into block 0 of a swap file.
|
||||||
* Write file name and timestamp into block 0 of a swap file.
|
/// Also set buf->b_mtime.
|
||||||
* Also set buf->b_mtime.
|
/// Don't use NameBuff[]!!!
|
||||||
* Don't use NameBuff[]!!!
|
|
||||||
*/
|
|
||||||
static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
||||||
{
|
{
|
||||||
if (buf->b_ffname == NULL) {
|
if (buf->b_ffname == NULL) {
|
||||||
@ -719,12 +702,10 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
|||||||
add_b0_fenc(b0p, curbuf);
|
add_b0_fenc(b0p, curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Update the B0_SAME_DIR flag of the swap file. It's set if the file and the
|
||||||
* Update the B0_SAME_DIR flag of the swap file. It's set if the file and the
|
/// swapfile for "buf" are in the same directory.
|
||||||
* swapfile for "buf" are in the same directory.
|
/// This is fail safe: if we are not sure the directories are equal the flag is
|
||||||
* This is fail safe: if we are not sure the directories are equal the flag is
|
/// not set.
|
||||||
* not set.
|
|
||||||
*/
|
|
||||||
static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
|
static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
|
||||||
{
|
{
|
||||||
if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname)) {
|
if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname)) {
|
||||||
@ -734,9 +715,7 @@ static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// When there is room, add the 'fileencoding' to block zero.
|
||||||
* When there is room, add the 'fileencoding' to block zero.
|
|
||||||
*/
|
|
||||||
static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf)
|
static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
@ -755,7 +734,8 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf)
|
|||||||
|
|
||||||
|
|
||||||
/// Try to recover curbuf from the .swp file.
|
/// Try to recover curbuf from the .swp file.
|
||||||
/// @param checkext If true, check the extension and detect whether it is a
|
///
|
||||||
|
/// @param checkext if true, check the extension and detect whether it is a
|
||||||
/// swap file.
|
/// swap file.
|
||||||
void ml_recover(bool checkext)
|
void ml_recover(bool checkext)
|
||||||
{
|
{
|
||||||
@ -1463,10 +1443,8 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
|
|||||||
return file_count;
|
return file_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Append the full path to name with path separators made into percent
|
||||||
* Append the full path to name with path separators made into percent
|
/// signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
|
||||||
* signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
|
|
||||||
*/
|
|
||||||
char *make_percent_swname(const char *dir, const char *name)
|
char *make_percent_swname(const char *dir, const char *name)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
@ -1488,8 +1466,9 @@ char *make_percent_swname(const char *dir, const char *name)
|
|||||||
|
|
||||||
static bool process_still_running;
|
static bool process_still_running;
|
||||||
|
|
||||||
/// Return information found in swapfile "fname" in dictionary "d".
|
|
||||||
/// This is used by the swapinfo() function.
|
/// This is used by the swapinfo() function.
|
||||||
|
///
|
||||||
|
/// @return information found in swapfile "fname" in dictionary "d".
|
||||||
void get_b0_dict(const char *fname, dict_T *d)
|
void get_b0_dict(const char *fname, dict_T *d)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -1526,7 +1505,8 @@ void get_b0_dict(const char *fname, dict_T *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Give information about an existing swap file.
|
/// Give information about an existing swap file.
|
||||||
/// Returns timestamp (0 when unknown).
|
///
|
||||||
|
/// @return timestamp (0 when unknown).
|
||||||
static time_t swapfile_info(char_u *fname)
|
static time_t swapfile_info(char_u *fname)
|
||||||
{
|
{
|
||||||
assert(fname != NULL);
|
assert(fname != NULL);
|
||||||
@ -1696,13 +1676,12 @@ static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
|
|||||||
return num_names;
|
return num_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// sync all memlines
|
||||||
* sync all memlines
|
///
|
||||||
*
|
/// @param check_file if TRUE, check if original file exists and was not changed.
|
||||||
* If 'check_file' is TRUE, check if original file exists and was not changed.
|
/// @param check_char if TRUE, stop syncing when character becomes available, but
|
||||||
* If 'check_char' is TRUE, stop syncing when character becomes available, but
|
///
|
||||||
* always sync at least one block.
|
/// always sync at least one block.
|
||||||
*/
|
|
||||||
void ml_sync_all(int check_file, int check_char, bool do_fsync)
|
void ml_sync_all(int check_file, int check_char, bool do_fsync)
|
||||||
{
|
{
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
@ -1738,16 +1717,14 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// sync one buffer, including negative blocks
|
||||||
* sync one buffer, including negative blocks
|
///
|
||||||
*
|
/// after this all the blocks are in the swap file
|
||||||
* after this all the blocks are in the swap file
|
///
|
||||||
*
|
/// Used for the :preserve command and when the original file has been
|
||||||
* Used for the :preserve command and when the original file has been
|
/// changed or deleted.
|
||||||
* changed or deleted.
|
///
|
||||||
*
|
/// @param message if TRUE, the success of preserving is reported.
|
||||||
* when message is TRUE the success of preserving is reported
|
|
||||||
*/
|
|
||||||
void ml_preserve(buf_T *buf, int message, bool do_fsync)
|
void ml_preserve(buf_T *buf, int message, bool do_fsync)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -1823,27 +1800,24 @@ theend:
|
|||||||
* line2 = ml_get(2); // line1 is now invalid!
|
* line2 = ml_get(2); // line1 is now invalid!
|
||||||
* Make a copy of the line if necessary.
|
* Make a copy of the line if necessary.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
* Return a pointer to a (read-only copy of a) line.
|
/// @return a pointer to a (read-only copy of a) line.
|
||||||
*
|
///
|
||||||
* On failure an error message is given and IObuff is returned (to avoid
|
/// On failure an error message is given and IObuff is returned (to avoid
|
||||||
* having to check for error everywhere).
|
/// having to check for error everywhere).
|
||||||
*/
|
|
||||||
char_u *ml_get(linenr_T lnum)
|
char_u *ml_get(linenr_T lnum)
|
||||||
{
|
{
|
||||||
return ml_get_buf(curbuf, lnum, false);
|
return ml_get_buf(curbuf, lnum, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// @return pointer to position "pos".
|
||||||
* Return pointer to position "pos".
|
|
||||||
*/
|
|
||||||
char_u *ml_get_pos(const pos_T *pos)
|
char_u *ml_get_pos(const pos_T *pos)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
return ml_get_buf(curbuf, pos->lnum, false) + pos->col;
|
return ml_get_buf(curbuf, pos->lnum, false) + pos->col;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get codepoint at pos. pos must be either valid or have col set to MAXCOL!
|
/// @return codepoint at pos. pos must be either valid or have col set to MAXCOL!
|
||||||
int gchar_pos(pos_T *pos)
|
int gchar_pos(pos_T *pos)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
@ -1854,9 +1828,9 @@ int gchar_pos(pos_T *pos)
|
|||||||
return utf_ptr2char(ml_get_pos(pos));
|
return utf_ptr2char(ml_get_pos(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a pointer to a line in a specific buffer
|
|
||||||
///
|
|
||||||
/// @param will_change true mark the buffer dirty (chars in the line will be changed)
|
/// @param will_change true mark the buffer dirty (chars in the line will be changed)
|
||||||
|
///
|
||||||
|
/// @return a pointer to a line in a specific buffer
|
||||||
char_u *ml_get_buf(buf_T *buf, linenr_T lnum, bool will_change)
|
char_u *ml_get_buf(buf_T *buf, linenr_T lnum, bool will_change)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
@ -1929,10 +1903,8 @@ errorret:
|
|||||||
return buf->b_ml.ml_line_ptr;
|
return buf->b_ml.ml_line_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Check if a line that was just obtained by a call to ml_get
|
||||||
* Check if a line that was just obtained by a call to ml_get
|
/// is in allocated memory.
|
||||||
* is in allocated memory.
|
|
||||||
*/
|
|
||||||
int ml_line_alloced(void)
|
int ml_line_alloced(void)
|
||||||
{
|
{
|
||||||
return curbuf->b_ml.ml_flags & ML_LINE_DIRTY;
|
return curbuf->b_ml.ml_flags & ML_LINE_DIRTY;
|
||||||
@ -2489,17 +2461,18 @@ int ml_replace(linenr_T lnum, char_u *line, bool copy)
|
|||||||
return ml_replace_buf(curbuf, lnum, line, copy);
|
return ml_replace_buf(curbuf, lnum, line, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace line "lnum", with buffering, in current buffer.
|
/// Replace line "lnum", with buffering, in current buffer.
|
||||||
//
|
///
|
||||||
// If "copy" is true, make a copy of the line, otherwise the line has been
|
/// @param copy if true, make a copy of the line, otherwise the line has been
|
||||||
// copied to allocated memory already.
|
/// copied to allocated memory already.
|
||||||
// If "copy" is false the "line" may be freed to add text properties!
|
/// if false, the "line" may be freed to add text properties!
|
||||||
// Do not use it after calling ml_replace().
|
///
|
||||||
//
|
/// Do not use it after calling ml_replace().
|
||||||
// Check: The caller of this function should probably also call
|
///
|
||||||
// changed_lines(), unless update_screen(NOT_VALID) is used.
|
/// Check: The caller of this function should probably also call
|
||||||
//
|
/// changed_lines(), unless update_screen(NOT_VALID) is used.
|
||||||
// return FAIL for failure, OK otherwise
|
///
|
||||||
|
/// @return FAIL for failure, OK otherwise
|
||||||
int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
|
int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
|
||||||
{
|
{
|
||||||
if (line == NULL) { // just checking...
|
if (line == NULL) { // just checking...
|
||||||
@ -2542,6 +2515,7 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
|
|||||||
/// deleted_lines() after this.
|
/// deleted_lines() after this.
|
||||||
///
|
///
|
||||||
/// @param message Show "--No lines in buffer--" message.
|
/// @param message Show "--No lines in buffer--" message.
|
||||||
|
///
|
||||||
/// @return FAIL for failure, OK otherwise
|
/// @return FAIL for failure, OK otherwise
|
||||||
int ml_delete(linenr_T lnum, bool message)
|
int ml_delete(linenr_T lnum, bool message)
|
||||||
{
|
{
|
||||||
@ -2699,9 +2673,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// set the B_MARKED flag for line 'lnum'
|
||||||
* set the B_MARKED flag for line 'lnum'
|
|
||||||
*/
|
|
||||||
void ml_setmarked(linenr_T lnum)
|
void ml_setmarked(linenr_T lnum)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -2728,9 +2700,7 @@ void ml_setmarked(linenr_T lnum)
|
|||||||
curbuf->b_ml.ml_flags |= ML_LOCKED_DIRTY;
|
curbuf->b_ml.ml_flags |= ML_LOCKED_DIRTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// find the first line with its B_MARKED flag set
|
||||||
* find the first line with its B_MARKED flag set
|
|
||||||
*/
|
|
||||||
linenr_T ml_firstmarked(void)
|
linenr_T ml_firstmarked(void)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -2771,9 +2741,7 @@ linenr_T ml_firstmarked(void)
|
|||||||
return (linenr_T)0;
|
return (linenr_T)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// clear all DB_MARKED flags
|
||||||
* clear all DB_MARKED flags
|
|
||||||
*/
|
|
||||||
void ml_clearmarked(void)
|
void ml_clearmarked(void)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -2822,9 +2790,7 @@ size_t ml_flush_deleted_bytes(buf_T *buf, size_t *codepoints, size_t *codeunits)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// flush ml_line if necessary
|
||||||
* flush ml_line if necessary
|
|
||||||
*/
|
|
||||||
static void ml_flush_line(buf_T *buf)
|
static void ml_flush_line(buf_T *buf)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -2921,9 +2887,7 @@ static void ml_flush_line(buf_T *buf)
|
|||||||
buf->b_ml.ml_line_offset = 0;
|
buf->b_ml.ml_line_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// create a new, empty, data block
|
||||||
* create a new, empty, data block
|
|
||||||
*/
|
|
||||||
static bhdr_T *ml_new_data(memfile_T *mfp, bool negative, int page_count)
|
static bhdr_T *ml_new_data(memfile_T *mfp, bool negative, int page_count)
|
||||||
{
|
{
|
||||||
assert(page_count >= 0);
|
assert(page_count >= 0);
|
||||||
@ -2937,9 +2901,7 @@ static bhdr_T *ml_new_data(memfile_T *mfp, bool negative, int page_count)
|
|||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// create a new, empty, pointer block
|
||||||
* create a new, empty, pointer block
|
|
||||||
*/
|
|
||||||
static bhdr_T *ml_new_ptr(memfile_T *mfp)
|
static bhdr_T *ml_new_ptr(memfile_T *mfp)
|
||||||
{
|
{
|
||||||
bhdr_T *hp = mf_new(mfp, false, 1);
|
bhdr_T *hp = mf_new(mfp, false, 1);
|
||||||
@ -2951,21 +2913,19 @@ static bhdr_T *ml_new_ptr(memfile_T *mfp)
|
|||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// lookup line 'lnum' in a memline
|
||||||
* lookup line 'lnum' in a memline
|
///
|
||||||
*
|
/// @param action: if ML_DELETE or ML_INSERT the line count is updated while searching
|
||||||
* action: if ML_DELETE or ML_INSERT the line count is updated while searching
|
/// if ML_FLUSH only flush a locked block
|
||||||
* if ML_FLUSH only flush a locked block
|
/// if ML_FIND just find the line
|
||||||
* if ML_FIND just find the line
|
///
|
||||||
*
|
/// If the block was found it is locked and put in ml_locked.
|
||||||
* If the block was found it is locked and put in ml_locked.
|
/// The stack is updated to lead to the locked block. The ip_high field in
|
||||||
* The stack is updated to lead to the locked block. The ip_high field in
|
/// the stack is updated to reflect the last line in the block AFTER the
|
||||||
* the stack is updated to reflect the last line in the block AFTER the
|
/// insert or delete, also if the pointer block has not been updated yet. But
|
||||||
* insert or delete, also if the pointer block has not been updated yet. But
|
/// if ml_locked != NULL ml_locked_lineadd must be added to ip_high.
|
||||||
* if ml_locked != NULL ml_locked_lineadd must be added to ip_high.
|
///
|
||||||
*
|
/// @return NULL for failure, pointer to block header otherwise
|
||||||
* return: NULL for failure, pointer to block header otherwise
|
|
||||||
*/
|
|
||||||
static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action)
|
static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action)
|
||||||
{
|
{
|
||||||
DATA_BL *dp;
|
DATA_BL *dp;
|
||||||
@ -3146,11 +3106,9 @@ error_noblock:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// add an entry to the info pointer stack
|
||||||
* add an entry to the info pointer stack
|
///
|
||||||
*
|
/// @return number of the new entry
|
||||||
* return number of the new entry
|
|
||||||
*/
|
|
||||||
static int ml_add_stack(buf_T *buf)
|
static int ml_add_stack(buf_T *buf)
|
||||||
{
|
{
|
||||||
int top = buf->b_ml.ml_stack_top;
|
int top = buf->b_ml.ml_stack_top;
|
||||||
@ -3168,16 +3126,14 @@ static int ml_add_stack(buf_T *buf)
|
|||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Update the pointer blocks on the stack for inserted/deleted lines.
|
||||||
* Update the pointer blocks on the stack for inserted/deleted lines.
|
/// The stack itself is also updated.
|
||||||
* The stack itself is also updated.
|
///
|
||||||
*
|
/// When an insert/delete line action fails, the line is not inserted/deleted,
|
||||||
* When an insert/delete line action fails, the line is not inserted/deleted,
|
/// but the pointer blocks have already been updated. That is fixed here by
|
||||||
* but the pointer blocks have already been updated. That is fixed here by
|
/// walking through the stack.
|
||||||
* walking through the stack.
|
///
|
||||||
*
|
/// Count is the number of lines added, negative if lines have been deleted.
|
||||||
* Count is the number of lines added, negative if lines have been deleted.
|
|
||||||
*/
|
|
||||||
static void ml_lineadd(buf_T *buf, int count)
|
static void ml_lineadd(buf_T *buf, int count)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
@ -3204,13 +3160,13 @@ static void ml_lineadd(buf_T *buf, int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_READLINK)
|
#if defined(HAVE_READLINK)
|
||||||
/*
|
|
||||||
* Resolve a symlink in the last component of a file name.
|
/// Resolve a symlink in the last component of a file name.
|
||||||
* Note that f_resolve() does it for every part of the path, we don't do that
|
/// Note that f_resolve() does it for every part of the path, we don't do that
|
||||||
* here.
|
/// here.
|
||||||
* If it worked returns OK and the resolved link in "buf[MAXPATHL]".
|
///
|
||||||
* Otherwise returns FAIL.
|
/// @return OK if it worked and the resolved link in "buf[MAXPATHL]",
|
||||||
*/
|
/// FAIL otherwise
|
||||||
int resolve_symlink(const char_u *fname, char_u *buf)
|
int resolve_symlink(const char_u *fname, char_u *buf)
|
||||||
{
|
{
|
||||||
char_u tmp[MAXPATHL];
|
char_u tmp[MAXPATHL];
|
||||||
@ -3274,10 +3230,9 @@ int resolve_symlink(const char_u *fname, char_u *buf)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/// Make swap file name out of the file name and a directory name.
|
||||||
* Make swap file name out of the file name and a directory name.
|
///
|
||||||
* Returns pointer to allocated memory or NULL.
|
/// @return pointer to allocated memory or NULL.
|
||||||
*/
|
|
||||||
char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)
|
char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)
|
||||||
{
|
{
|
||||||
char_u *r, *s;
|
char_u *r, *s;
|
||||||
@ -3407,17 +3362,16 @@ static void attention_message(buf_T *buf, char_u *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/// Trigger the SwapExists autocommands.
|
||||||
* Trigger the SwapExists autocommands.
|
///
|
||||||
* Returns a value for equivalent to do_dialog() (see below):
|
/// @return a value for equivalent to do_dialog() (see below):
|
||||||
* 0: still need to ask for a choice
|
/// 0: still need to ask for a choice
|
||||||
* 1: open read-only
|
/// 1: open read-only
|
||||||
* 2: edit anyway
|
/// 2: edit anyway
|
||||||
* 3: recover
|
/// 3: recover
|
||||||
* 4: delete it
|
/// 4: delete it
|
||||||
* 5: quit
|
/// 5: quit
|
||||||
* 6: abort
|
/// 6: abort
|
||||||
*/
|
|
||||||
static int do_swapexists(buf_T *buf, char_u *fname)
|
static int do_swapexists(buf_T *buf, char_u *fname)
|
||||||
{
|
{
|
||||||
set_vim_var_string(VV_SWAPNAME, (char *)fname, -1);
|
set_vim_var_string(VV_SWAPNAME, (char *)fname, -1);
|
||||||
@ -3811,10 +3765,8 @@ static bool fnamecmp_ino(char_u *fname_c, char_u *fname_s, long ino_block0)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Move a long integer into a four byte character array.
|
||||||
* Move a long integer into a four byte character array.
|
/// Used for machine independency in block zero.
|
||||||
* Used for machine independency in block zero.
|
|
||||||
*/
|
|
||||||
static void long_to_char(long n, char_u *s)
|
static void long_to_char(long n, char_u *s)
|
||||||
{
|
{
|
||||||
s[0] = (char_u)(n & 0xff);
|
s[0] = (char_u)(n & 0xff);
|
||||||
@ -3841,12 +3793,10 @@ static long char_to_long(char_u *s)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Set the flags in the first block of the swap file:
|
||||||
* Set the flags in the first block of the swap file:
|
/// - file is modified or not: buf->b_changed
|
||||||
* - file is modified or not: buf->b_changed
|
/// - 'fileformat'
|
||||||
* - 'fileformat'
|
/// - 'fileencoding'
|
||||||
* - 'fileencoding'
|
|
||||||
*/
|
|
||||||
void ml_setflags(buf_T *buf)
|
void ml_setflags(buf_T *buf)
|
||||||
{
|
{
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
@ -3872,13 +3822,13 @@ void ml_setflags(buf_T *buf)
|
|||||||
#define MLCS_MAXL 800 // max no of lines in chunk
|
#define MLCS_MAXL 800 // max no of lines in chunk
|
||||||
#define MLCS_MINL 400 // should be half of MLCS_MAXL
|
#define MLCS_MINL 400 // should be half of MLCS_MAXL
|
||||||
|
|
||||||
/*
|
/// Keep information for finding byte offset of a line
|
||||||
* Keep information for finding byte offset of a line, updtype may be one of:
|
///
|
||||||
* ML_CHNK_ADDLINE: Add len to parent chunk, possibly splitting it
|
/// @param updtype may be one of:
|
||||||
* Careful: ML_CHNK_ADDLINE may cause ml_find_line() to be called.
|
/// ML_CHNK_ADDLINE: Add len to parent chunk, possibly splitting it
|
||||||
* ML_CHNK_DELLINE: Subtract len from parent chunk, possibly deleting it
|
/// Careful: ML_CHNK_ADDLINE may cause ml_find_line() to be called.
|
||||||
* ML_CHNK_UPDLINE: Add len to parent chunk, as a signed entity.
|
/// ML_CHNK_DELLINE: Subtract len from parent chunk, possibly deleting it
|
||||||
*/
|
/// ML_CHNK_UPDLINE: Add len to parent chunk, as a signed entity.
|
||||||
static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
||||||
{
|
{
|
||||||
static buf_T *ml_upd_lastbuf = NULL;
|
static buf_T *ml_upd_lastbuf = NULL;
|
||||||
@ -4256,10 +4206,11 @@ void goto_byte(long cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Increment the line pointer "lp" crossing line boundaries as necessary.
|
/// 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 going to the next line.
|
||||||
/// Return -1 when at the end of file.
|
/// 2 when moving forward onto a NUL at the end of the line).
|
||||||
/// Return 0 otherwise.
|
/// -1 when at the end of file.
|
||||||
|
/// 0 otherwise.
|
||||||
int inc(pos_T *lp)
|
int inc(pos_T *lp)
|
||||||
{
|
{
|
||||||
// when searching position may be set to end of a line
|
// when searching position may be set to end of a line
|
||||||
|
Loading…
Reference in New Issue
Block a user