summaryrefslogtreecommitdiffstats
path: root/src/memline.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-01-30 18:51:09 +0100
committerBram Moolenaar <Bram@vim.org>2016-01-30 18:51:09 +0100
commit52ea13da0fe86df1abf34de52841e367035170c0 (patch)
tree0f0b400936dac18cdfae5304c27eaa1eb5e4d5f3 /src/memline.c
parent02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f (diff)
patch 7.4.1210v7.4.1210
Problem: Using old style function declarations. Solution: Change to new style function declarations. (script by Hirohito Higashi)
Diffstat (limited to 'src/memline.c')
-rw-r--r--src/memline.c297
1 files changed, 116 insertions, 181 deletions
diff --git a/src/memline.c b/src/memline.c
index 34887c31f8..15810fdad0 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -278,8 +278,7 @@ static void ml_updatechunk(buf_T *buf, long line, long len, int updtype);
* Return FAIL for failure, OK otherwise.
*/
int
-ml_open(buf)
- buf_T *buf;
+ml_open(buf_T *buf)
{
memfile_T *mfp;
bhdr_T *hp = NULL;
@@ -437,8 +436,7 @@ error:
* Prepare encryption for "buf" for the current key and method.
*/
static void
-ml_set_mfp_crypt(buf)
- buf_T *buf;
+ml_set_mfp_crypt(buf_T *buf)
{
if (*buf->b_p_key != NUL)
{
@@ -456,9 +454,7 @@ ml_set_mfp_crypt(buf)
* Prepare encryption for "buf" with block 0 "b0p".
*/
static void
-ml_set_b0_crypt(buf, b0p)
- buf_T *buf;
- ZERO_BL *b0p;
+ml_set_b0_crypt(buf_T *buf, ZERO_BL *b0p)
{
if (*buf->b_p_key == NUL)
b0p->b0_id[1] = BLOCK0_ID1;
@@ -485,10 +481,10 @@ ml_set_b0_crypt(buf, b0p)
* 'cryptmethod' when 'key' is changed.
*/
void
-ml_set_crypt_key(buf, old_key, old_cm)
- buf_T *buf;
- char_u *old_key;
- char_u *old_cm;
+ml_set_crypt_key(
+ buf_T *buf,
+ char_u *old_key,
+ char_u *old_cm)
{
memfile_T *mfp = buf->b_ml.ml_mfp;
bhdr_T *hp;
@@ -639,8 +635,7 @@ ml_set_crypt_key(buf, old_key, old_cm)
* It may rename the swap file.
*/
void
-ml_setname(buf)
- buf_T *buf;
+ml_setname(buf_T *buf)
{
int success = FALSE;
memfile_T *mfp;
@@ -747,7 +742,7 @@ ml_setname(buf)
* Used when 'updatecount' changes from zero to non-zero.
*/
void
-ml_open_files()
+ml_open_files(void)
{
buf_T *buf;
@@ -762,8 +757,7 @@ ml_open_files()
* and the memfile will be in memory only (no recovery possible).
*/
void
-ml_open_file(buf)
- buf_T *buf;
+ml_open_file(buf_T *buf)
{
memfile_T *mfp;
char_u *fname;
@@ -844,8 +838,8 @@ ml_open_file(buf)
* file, or reading into an existing buffer, create a swap file now.
*/
void
-check_need_swap(newfile)
- int newfile; /* reading file into new buffer */
+check_need_swap(
+ int newfile) /* reading file into new buffer */
{
if (curbuf->b_may_swap && (!curbuf->b_p_ro || !newfile))
ml_open_file(curbuf);
@@ -856,9 +850,7 @@ check_need_swap(newfile)
* If 'del_file' is TRUE, delete the swap file
*/
void
-ml_close(buf, del_file)
- buf_T *buf;
- int del_file;
+ml_close(buf_T *buf, int del_file)
{
if (buf->b_ml.ml_mfp == NULL) /* not open */
return;
@@ -884,8 +876,7 @@ ml_close(buf, del_file)
* But don't delete files that were ":preserve"d when we are POSIX compatible.
*/
void
-ml_close_all(del_file)
- int del_file;
+ml_close_all(int del_file)
{
buf_T *buf;
@@ -905,7 +896,7 @@ ml_close_all(del_file)
* Only use just before exiting!
*/
void
-ml_close_notmod()
+ml_close_notmod(void)
{
buf_T *buf;
@@ -919,8 +910,7 @@ ml_close_notmod()
* Used when the file has been written.
*/
void
-ml_timestamp(buf)
- buf_T *buf;
+ml_timestamp(buf_T *buf)
{
ml_upd_block0(buf, UB_FNAME);
}
@@ -929,8 +919,7 @@ ml_timestamp(buf)
* Return FAIL when the ID of "b0p" is wrong.
*/
static int
-ml_check_b0_id(b0p)
- ZERO_BL *b0p;
+ml_check_b0_id(ZERO_BL *b0p)
{
if (b0p->b0_id[0] != BLOCK0_ID0
|| (b0p->b0_id[1] != BLOCK0_ID1
@@ -946,9 +935,7 @@ ml_check_b0_id(b0p)
* Update the timestamp or the B0_SAME_DIR flag of the .swp file.
*/
static void
-ml_upd_block0(buf, what)
- buf_T *buf;
- upd_block0_T what;
+ml_upd_block0(buf_T *buf, upd_block0_T what)
{
memfile_T *mfp;
bhdr_T *hp;
@@ -991,9 +978,7 @@ ml_upd_block0(buf, what)
* Don't use NameBuff[]!!!
*/
static void
-set_b0_fname(b0p, buf)
- ZERO_BL *b0p;
- buf_T *buf;
+set_b0_fname(ZERO_BL *b0p, buf_T *buf)
{
struct stat st;
@@ -1072,9 +1057,7 @@ set_b0_fname(b0p, buf)
* not set.
*/
static void
-set_b0_dir_flag(b0p, buf)
- ZERO_BL *b0p;
- buf_T *buf;
+set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
{
if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname))
b0p->b0_flags |= B0_SAME_DIR;
@@ -1087,9 +1070,9 @@ set_b0_dir_flag(b0p, buf)
* When there is room, add the 'fileencoding' to block zero.
*/
static void
-add_b0_fenc(b0p, buf)
- ZERO_BL *b0p;
- buf_T *buf;
+add_b0_fenc(
+ ZERO_BL *b0p,
+ buf_T *buf)
{
int n;
int size = B0_FNAME_SIZE_NOCRYPT;
@@ -1120,7 +1103,7 @@ add_b0_fenc(b0p, buf)
* Try to recover curbuf from the .swp file.
*/
void
-ml_recover()
+ml_recover(void)
{
buf_T *buf = NULL;
memfile_T *mfp = NULL;
@@ -1778,11 +1761,11 @@ theend:
* - find the name of the n'th swap file when recovering
*/
int
-recover_names(fname, list, nr, fname_out)
- char_u *fname; /* base for swap file name */
- int list; /* when TRUE, list the swap file names */
- int nr; /* when non-zero, return nr'th swap file name */
- char_u **fname_out; /* result when "nr" > 0 */
+recover_names(
+ char_u *fname, /* base for swap file name */
+ int list, /* when TRUE, list the swap file names */
+ int nr, /* when non-zero, return nr'th swap file name */
+ char_u **fname_out) /* result when "nr" > 0 */
{
int num_names;
char_u *(names[6]);
@@ -2038,9 +2021,7 @@ recover_names(fname, list, nr, fname_out)
* signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
*/
static char_u *
-make_percent_swname(dir, name)
- char_u *dir;
- char_u *name;
+make_percent_swname(char_u *dir, char_u *name)
{
char_u *d, *s, *f;
@@ -2073,8 +2054,7 @@ static int process_still_running;
* Returns timestamp (0 when unknown).
*/
static time_t
-swapfile_info(fname)
- char_u *fname;
+swapfile_info(char_u *fname)
{
struct stat st;
int fd;
@@ -2188,10 +2168,7 @@ swapfile_info(fname)
}
static int
-recov_file_names(names, path, prepend_dot)
- char_u **names;
- char_u *path;
- int prepend_dot;
+recov_file_names(char_u **names, char_u *path, int prepend_dot)
{
int num_names;
@@ -2298,9 +2275,7 @@ end:
* always sync at least one block.
*/
void
-ml_sync_all(check_file, check_char)
- int check_file;
- int check_char;
+ml_sync_all(int check_file, int check_char)
{
buf_T *buf;
struct stat st;
@@ -2350,9 +2325,7 @@ ml_sync_all(check_file, check_char)
* when message is TRUE the success of preserving is reported
*/
void
-ml_preserve(buf, message)
- buf_T *buf;
- int message;
+ml_preserve(buf_T *buf, int message)
{
bhdr_T *hp;
linenr_T lnum;
@@ -2436,8 +2409,7 @@ theend:
* having to check for error everywhere).
*/
char_u *
-ml_get(lnum)
- linenr_T lnum;
+ml_get(linenr_T lnum)
{
return ml_get_buf(curbuf, lnum, FALSE);
}
@@ -2446,8 +2418,7 @@ ml_get(lnum)
* Return pointer to position "pos".
*/
char_u *
-ml_get_pos(pos)
- pos_T *pos;
+ml_get_pos(pos_T *pos)
{
return (ml_get_buf(curbuf, pos->lnum, FALSE) + pos->col);
}
@@ -2456,7 +2427,7 @@ ml_get_pos(pos)
* Return pointer to cursor line.
*/
char_u *
-ml_get_curline()
+ml_get_curline(void)
{
return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE);
}
@@ -2465,7 +2436,7 @@ ml_get_curline()
* Return pointer to cursor position.
*/
char_u *
-ml_get_cursor()
+ml_get_cursor(void)
{
return (ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE) +
curwin->w_cursor.col);
@@ -2478,10 +2449,10 @@ ml_get_cursor()
* changed)
*/
char_u *
-ml_get_buf(buf, lnum, will_change)
- buf_T *buf;
- linenr_T lnum;
- int will_change; /* line will be changed */
+ml_get_buf(
+ buf_T *buf,
+ linenr_T lnum,
+ int will_change) /* line will be changed */
{
bhdr_T *hp;
DATA_BL *dp;
@@ -2554,7 +2525,7 @@ errorret:
* is in allocated memory.
*/
int
-ml_line_alloced()
+ml_line_alloced(void)
{
return (curbuf->b_ml.ml_flags & ML_LINE_DIRTY);
}
@@ -2572,11 +2543,11 @@ ml_line_alloced()
* return FAIL for failure, OK otherwise
*/
int
-ml_append(lnum, line, len, newfile)
- linenr_T lnum; /* append after this line (can be 0) */
- char_u *line; /* text of the new line */
- colnr_T len; /* length of new line, including NUL, or 0 */
- int newfile; /* flag, see above */
+ml_append(
+ linenr_T lnum, /* append after this line (can be 0) */
+ char_u *line, /* text of the new line */
+ colnr_T len, /* length of new line, including NUL, or 0 */
+ int newfile) /* flag, see above */
{
/* When starting up, we might still need to create the memfile */
if (curbuf->b_ml.ml_mfp == NULL && open_buffer(FALSE, NULL, 0) == FAIL)
@@ -2593,12 +2564,12 @@ ml_append(lnum, line, len, newfile)
* a memline.
*/
int
-ml_append_buf(buf, lnum, line, len, newfile)
- buf_T *buf;
- linenr_T lnum; /* append after this line (can be 0) */
- char_u *line; /* text of the new line */
- colnr_T len; /* length of new line, including NUL, or 0 */
- int newfile; /* flag, see above */
+ml_append_buf(
+ buf_T *buf,
+ linenr_T lnum, /* append after this line (can be 0) */
+ char_u *line, /* text of the new line */
+ colnr_T len, /* length of new line, including NUL, or 0 */
+ int newfile) /* flag, see above */
{
if (buf->b_ml.ml_mfp == NULL)
return FAIL;
@@ -2610,13 +2581,13 @@ ml_append_buf(buf, lnum, line, len, newfile)
#endif
static int
-ml_append_int(buf, lnum, line, len, newfile, mark)
- buf_T *buf;
- linenr_T lnum; /* append after this line (can be 0) */
- char_u *line; /* text of the new line */
- colnr_T len; /* length of line, including NUL, or 0 */
- int newfile; /* flag, see above */
- int mark; /* mark the new line */
+ml_append_int(
+ buf_T *buf,
+ linenr_T lnum, /* append after this line (can be 0) */
+ char_u *line, /* text of the new line */
+ colnr_T len, /* length of line, including NUL, or 0 */
+ int newfile, /* flag, see above */
+ int mark) /* mark the new line */
{
int i;
int line_count; /* number of indexes in current block */
@@ -3119,10 +3090,7 @@ ml_append_int(buf, lnum, line, len, newfile, mark)
* return FAIL for failure, OK otherwise
*/
int
-ml_replace(lnum, line, copy)
- linenr_T lnum;
- char_u *line;
- int copy;
+ml_replace(linenr_T lnum, char_u *line, int copy)
{
if (line == NULL) /* just checking... */
return FAIL;
@@ -3160,19 +3128,14 @@ ml_replace(lnum, line, copy)
* return FAIL for failure, OK otherwise
*/
int
-ml_delete(lnum, message)
- linenr_T lnum;
- int message;
+ml_delete(linenr_T lnum, int message)
{
ml_flush_line(curbuf);
return ml_delete_int(curbuf, lnum, message);
}
static int
-ml_delete_int(buf, lnum, message)
- buf_T *buf;
- linenr_T lnum;
- int message;
+ml_delete_int(buf_T *buf, linenr_T lnum, int message)
{
bhdr_T *hp;
memfile_T *mfp;
@@ -3332,8 +3295,7 @@ ml_delete_int(buf, lnum, message)
* set the B_MARKED flag for line 'lnum'
*/
void
-ml_setmarked(lnum)
- linenr_T lnum;
+ml_setmarked(linenr_T lnum)
{
bhdr_T *hp;
DATA_BL *dp;
@@ -3362,7 +3324,7 @@ ml_setmarked(lnum)
* find the first line with its B_MARKED flag set
*/
linenr_T
-ml_firstmarked()
+ml_firstmarked(void)
{
bhdr_T *hp;
DATA_BL *dp;
@@ -3406,7 +3368,7 @@ ml_firstmarked()
* clear all DB_MARKED flags
*/
void
-ml_clearmarked()
+ml_clearmarked(void)
{
bhdr_T *hp;
DATA_BL *dp;
@@ -3448,8 +3410,7 @@ ml_clearmarked()
* flush ml_line if necessary
*/
static void
-ml_flush_line(buf)
- buf_T *buf;
+ml_flush_line(buf_T *buf)
{
bhdr_T *hp;
DATA_BL *dp;
@@ -3554,10 +3515,7 @@ ml_flush_line(buf)
* create a new, empty, data block
*/
static bhdr_T *
-ml_new_data(mfp, negative, page_count)
- memfile_T *mfp;
- int negative;
- int page_count;
+ml_new_data(memfile_T *mfp, int negative, int page_count)
{
bhdr_T *hp;
DATA_BL *dp;
@@ -3578,8 +3536,7 @@ ml_new_data(mfp, negative, page_count)
* create a new, empty, pointer block
*/
static bhdr_T *
-ml_new_ptr(mfp)
- memfile_T *mfp;
+ml_new_ptr(memfile_T *mfp)
{
bhdr_T *hp;
PTR_BL *pp;
@@ -3612,10 +3569,7 @@ ml_new_ptr(mfp)
* return: NULL for failure, pointer to block header otherwise
*/
static bhdr_T *
-ml_find_line(buf, lnum, action)
- buf_T *buf;
- linenr_T lnum;
- int action;
+ml_find_line(buf_T *buf, linenr_T lnum, int action)
{
DATA_BL *dp;
PTR_BL *pp;
@@ -3817,8 +3771,7 @@ error_noblock:
* return -1 for failure, number of the new entry otherwise
*/
static int
-ml_add_stack(buf)
- buf_T *buf;
+ml_add_stack(buf_T *buf)
{
int top;
infoptr_T *newstack;
@@ -3857,9 +3810,7 @@ ml_add_stack(buf)
* Count is the number of lines added, negative if lines have been deleted.
*/
static void
-ml_lineadd(buf, count)
- buf_T *buf;
- int count;
+ml_lineadd(buf_T *buf, int count)
{
int idx;
infoptr_T *ip;
@@ -3894,9 +3845,7 @@ ml_lineadd(buf, count)
* Otherwise returns FAIL.
*/
int
-resolve_symlink(fname, buf)
- char_u *fname;
- char_u *buf;
+resolve_symlink(char_u *fname, char_u *buf)
{
char_u tmp[MAXPATHL];
int ret;
@@ -3970,11 +3919,11 @@ resolve_symlink(fname, buf)
* Returns pointer to allocated memory or NULL.
*/
char_u *
-makeswapname(fname, ffname, buf, dir_name)
- char_u *fname;
- char_u *ffname UNUSED;
- buf_T *buf;
- char_u *dir_name;
+makeswapname(
+ char_u *fname,
+ char_u *ffname UNUSED,
+ buf_T *buf,
+ char_u *dir_name)
{
char_u *r, *s;
char_u *fname_res = fname;
@@ -4044,9 +3993,9 @@ makeswapname(fname, ffname, buf, dir_name)
* The return value is an allocated string and can be NULL.
*/
char_u *
-get_file_in_dir(fname, dname)
- char_u *fname;
- char_u *dname; /* don't use "dirname", it is a global for Alpha */
+get_file_in_dir(
+ char_u *fname,
+ char_u *dname) /* don't use "dirname", it is a global for Alpha */
{
char_u *t;
char_u *tail;
@@ -4095,9 +4044,9 @@ static void attention_message(buf_T *buf, char_u *fname);
* Print the ATTENTION message: info about an existing swap file.
*/
static void
-attention_message(buf, fname)
- buf_T *buf; /* buffer being edited */
- char_u *fname; /* swap file name */
+attention_message(
+ buf_T *buf, /* buffer being edited */
+ char_u *fname) /* swap file name */
{
struct stat st;
time_t x, sx;
@@ -4154,9 +4103,7 @@ static int do_swapexists(buf_T *buf, char_u *fname);
* 6: abort
*/
static int
-do_swapexists(buf, fname)
- buf_T *buf;
- char_u *fname;
+do_swapexists(buf_T *buf, char_u *fname)
{
set_vim_var_string(VV_SWAPNAME, fname, -1);
set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
@@ -4195,10 +4142,10 @@ do_swapexists(buf, fname)
* Note: May trigger SwapExists autocmd, pointers may change!
*/
static char_u *
-findswapname(buf, dirp, old_fname)
- buf_T *buf;
- char_u **dirp; /* pointer to list of directories */
- char_u *old_fname; /* don't give warning for this file name */
+findswapname(
+ buf_T *buf,
+ char_u **dirp, /* pointer to list of directories */
+ char_u *old_fname) /* don't give warning for this file name */
{
char_u *fname;
int n;
@@ -4676,8 +4623,7 @@ findswapname(buf, dirp, old_fname)
}
static int
-b0_magic_wrong(b0p)
- ZERO_BL *b0p;
+b0_magic_wrong(ZERO_BL *b0p)
{
return (b0p->b0_magic_long != (long)B0_MAGIC_LONG
|| b0p->b0_magic_int != (int)B0_MAGIC_INT
@@ -4736,10 +4682,10 @@ b0_magic_wrong(b0p)
*/
static int
-fnamecmp_ino(fname_c, fname_s, ino_block0)
- char_u *fname_c; /* current file name */
- char_u *fname_s; /* file name from swap file */
- long ino_block0;
+fnamecmp_ino(
+ char_u *fname_c, /* current file name */
+ char_u *fname_s, /* file name from swap file */
+ long ino_block0)
{
struct stat st;
ino_t ino_c = 0; /* ino of current file */
@@ -4789,9 +4735,7 @@ fnamecmp_ino(fname_c, fname_s, ino_block0)
* Used for machine independency in block zero.
*/
static void
-long_to_char(n, s)
- long n;
- char_u *s;
+long_to_char(long n, char_u *s)
{
s[0] = (char_u)(n & 0xff);
n = (unsigned)n >> 8;
@@ -4803,8 +4747,7 @@ long_to_char(n, s)
}
static long
-char_to_long(s)
- char_u *s;
+char_to_long(char_u *s)
{
long retval;
@@ -4826,8 +4769,7 @@ char_to_long(s)
* - 'fileencoding'
*/
void
-ml_setflags(buf)
- buf_T *buf;
+ml_setflags(buf_T *buf)
{
bhdr_T *hp;
ZERO_BL *b0p;
@@ -4859,11 +4801,11 @@ ml_setflags(buf)
* Otherwise return "data".
*/
char_u *
-ml_encrypt_data(mfp, data, offset, size)
- memfile_T *mfp;
- char_u *data;
- off_t offset;
- unsigned size;
+ml_encrypt_data(
+ memfile_T *mfp,
+ char_u *data,
+ off_t offset,
+ unsigned size)
{
DATA_BL *dp = (DATA_BL *)data;
char_u *head_end;
@@ -4904,11 +4846,11 @@ ml_encrypt_data(mfp, data, offset, size)
* Decrypt the text in "data" if it points to an encrypted data block.
*/
void
-ml_decrypt_data(mfp, data, offset, size)
- memfile_T *mfp;
- char_u *data;
- off_t offset;
- unsigned size;
+ml_decrypt_data(
+ memfile_T *mfp,
+ char_u *data,
+ off_t offset,
+ unsigned size)
{
DATA_BL *dp = (DATA_BL *)data;
char_u *head_end;
@@ -4941,10 +4883,7 @@ ml_decrypt_data(mfp, data, offset, size)
* Return an allocated cryptstate_T *.
*/
static cryptstate_T *
-ml_crypt_prepare(mfp, offset, reading)
- memfile_T *mfp;
- off_t offset;
- int reading;
+ml_crypt_prepare(memfile_T *mfp, off_t offset, int reading)
{
buf_T *buf = mfp->mf_buffer;
char_u salt[50];
@@ -4999,11 +4938,11 @@ ml_crypt_prepare(mfp, offset, reading)
* ML_CHNK_UPDLINE: Add len to parent chunk, as a signed entity.
*/
static void
-ml_updatechunk(buf, line, len, updtype)
- buf_T *buf;
- linenr_T line;
- long len;
- int updtype;
+ml_updatechunk(
+ buf_T *buf,
+ linenr_T line,
+ long len,
+ int updtype)
{
static buf_T *ml_upd_lastbuf = NULL;
static linenr_T ml_upd_lastline;
@@ -5241,10 +5180,7 @@ ml_updatechunk(buf, line, len, updtype)
* return -1 if information is not available
*/
long
-ml_find_line_or_offset(buf, lnum, offp)
- buf_T *buf;
- linenr_T lnum;
- long *offp;
+ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp)
{
linenr_T curline;
int curix;
@@ -5371,8 +5307,7 @@ ml_find_line_or_offset(buf, lnum, offp)
* Goto byte in buffer with offset 'cnt'.
*/
void
-goto_byte(cnt)
- long cnt;
+goto_byte(long cnt)
{
long boff = cnt;
linenr_T lnum;