|
Karsten Hopp |
5d2990 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
5d2990 |
Subject: Patch 7.4.803
|
|
Karsten Hopp |
5d2990 |
Fcc: outbox
|
|
Karsten Hopp |
5d2990 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
5d2990 |
Mime-Version: 1.0
|
|
Karsten Hopp |
5d2990 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
5d2990 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
5d2990 |
------------
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
Patch 7.4.803
|
|
Karsten Hopp |
5d2990 |
Problem: C indent does not support C11 raw strings. (Mark Lodato)
|
|
Karsten Hopp |
5d2990 |
Solution: Do not change indent inside the raw string.
|
|
Karsten Hopp |
5d2990 |
Files: src/search.c, src/misc1.c, src/edit.c, src/ops.c,
|
|
Karsten Hopp |
5d2990 |
src/testdir/test3.in, src/testdir/test3.ok
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/search.c 2015-07-21 17:53:11.585527913 +0200
|
|
Karsten Hopp |
5d2990 |
--- src/search.c 2015-07-28 21:14:08.968071627 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 1725,1744 ****
|
|
Karsten Hopp |
5d2990 |
return (col >= 0 && linep[col] == ch) ? TRUE : FALSE;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* findmatchlimit -- find the matching paren or brace, if it exists within
|
|
Karsten Hopp |
5d2990 |
! * maxtravel lines of here. A maxtravel of 0 means search until falling off
|
|
Karsten Hopp |
5d2990 |
! * the edge of the file.
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
* "initc" is the character to find a match for. NUL means to find the
|
|
Karsten Hopp |
5d2990 |
! * character at or after the cursor.
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
* flags: FM_BACKWARD search backwards (when initc is '/', '*' or '#')
|
|
Karsten Hopp |
5d2990 |
* FM_FORWARD search forwards (when initc is '/', '*' or '#')
|
|
Karsten Hopp |
5d2990 |
* FM_BLOCKSTOP stop at start/end of block ({ or } in column 0)
|
|
Karsten Hopp |
5d2990 |
* FM_SKIPCOMM skip comments (not implemented yet!)
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
! * "oap" is only used to set oap->motion_type for a linewise motion, it be
|
|
Karsten Hopp |
5d2990 |
* NULL
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
--- 1725,1795 ----
|
|
Karsten Hopp |
5d2990 |
return (col >= 0 && linep[col] == ch) ? TRUE : FALSE;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
+ static int find_rawstring_end __ARGS((char_u *linep, pos_T *startpos, pos_T *endpos));
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
+ * Raw string start is found at linep[startpos.col - 1].
|
|
Karsten Hopp |
5d2990 |
+ * Return TRUE if the matching end can be found between startpos and endpos.
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
+ static int
|
|
Karsten Hopp |
5d2990 |
+ find_rawstring_end(linep, startpos, endpos)
|
|
Karsten Hopp |
5d2990 |
+ char_u *linep;
|
|
Karsten Hopp |
5d2990 |
+ pos_T *startpos;
|
|
Karsten Hopp |
5d2990 |
+ pos_T *endpos;
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ char_u *p;
|
|
Karsten Hopp |
5d2990 |
+ char_u *delim_copy;
|
|
Karsten Hopp |
5d2990 |
+ size_t delim_len;
|
|
Karsten Hopp |
5d2990 |
+ linenr_T lnum;
|
|
Karsten Hopp |
5d2990 |
+ int found = FALSE;
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ for (p = linep + startpos->col + 1; *p && *p != '('; ++p)
|
|
Karsten Hopp |
5d2990 |
+ ;
|
|
Karsten Hopp |
5d2990 |
+ delim_len = (p - linep) - startpos->col - 1;
|
|
Karsten Hopp |
5d2990 |
+ delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len);
|
|
Karsten Hopp |
5d2990 |
+ if (delim_copy == NULL)
|
|
Karsten Hopp |
5d2990 |
+ return FALSE;
|
|
Karsten Hopp |
5d2990 |
+ for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ char_u *line = ml_get(lnum);
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ for (p = line + (lnum == startpos->lnum
|
|
Karsten Hopp |
5d2990 |
+ ? startpos->col + 1 : 0); *p; ++p)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col)
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+ if (*p == ')' && p[delim_len + 1] == '"'
|
|
Karsten Hopp |
5d2990 |
+ && STRNCMP(delim_copy, p + 1, delim_len) == 0)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ found = TRUE;
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ if (found)
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ vim_free(delim_copy);
|
|
Karsten Hopp |
5d2990 |
+ return found;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* findmatchlimit -- find the matching paren or brace, if it exists within
|
|
Karsten Hopp |
5d2990 |
! * maxtravel lines of the cursor. A maxtravel of 0 means search until falling
|
|
Karsten Hopp |
5d2990 |
! * off the edge of the file.
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
* "initc" is the character to find a match for. NUL means to find the
|
|
Karsten Hopp |
5d2990 |
! * character at or after the cursor. Special values:
|
|
Karsten Hopp |
5d2990 |
! * '*' look for C-style comment / *
|
|
Karsten Hopp |
5d2990 |
! * '/' look for C-style comment / *, ignoring comment-end
|
|
Karsten Hopp |
5d2990 |
! * '#' look for preprocessor directives
|
|
Karsten Hopp |
5d2990 |
! * 'R' look for raw string start: R"delim(text)delim" (only backwards)
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
* flags: FM_BACKWARD search backwards (when initc is '/', '*' or '#')
|
|
Karsten Hopp |
5d2990 |
* FM_FORWARD search forwards (when initc is '/', '*' or '#')
|
|
Karsten Hopp |
5d2990 |
* FM_BLOCKSTOP stop at start/end of block ({ or } in column 0)
|
|
Karsten Hopp |
5d2990 |
* FM_SKIPCOMM skip comments (not implemented yet!)
|
|
Karsten Hopp |
5d2990 |
*
|
|
Karsten Hopp |
5d2990 |
! * "oap" is only used to set oap->motion_type for a linewise motion, it can be
|
|
Karsten Hopp |
5d2990 |
* NULL
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 1754,1759 ****
|
|
Karsten Hopp |
5d2990 |
--- 1805,1811 ----
|
|
Karsten Hopp |
5d2990 |
int c;
|
|
Karsten Hopp |
5d2990 |
int count = 0; /* cumulative number of braces */
|
|
Karsten Hopp |
5d2990 |
int backwards = FALSE; /* init for gcc */
|
|
Karsten Hopp |
5d2990 |
+ int raw_string = FALSE; /* search for raw string */
|
|
Karsten Hopp |
5d2990 |
int inquote = FALSE; /* TRUE when inside quotes */
|
|
Karsten Hopp |
5d2990 |
char_u *linep; /* pointer to current line */
|
|
Karsten Hopp |
5d2990 |
char_u *ptr;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 1798,1809 ****
|
|
Karsten Hopp |
5d2990 |
* When '/' is used, we ignore running backwards into an star-slash, for
|
|
Karsten Hopp |
5d2990 |
* "[*" command, we just want to find any comment.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (initc == '/' || initc == '*')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
comment_dir = dir;
|
|
Karsten Hopp |
5d2990 |
if (initc == '/')
|
|
Karsten Hopp |
5d2990 |
ignore_cend = TRUE;
|
|
Karsten Hopp |
5d2990 |
backwards = (dir == FORWARD) ? FALSE : TRUE;
|
|
Karsten Hopp |
5d2990 |
initc = NUL;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
else if (initc != '#' && initc != NUL)
|
|
Karsten Hopp |
5d2990 |
--- 1850,1862 ----
|
|
Karsten Hopp |
5d2990 |
* When '/' is used, we ignore running backwards into an star-slash, for
|
|
Karsten Hopp |
5d2990 |
* "[*" command, we just want to find any comment.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (initc == '/' || initc == '*' || initc == 'R')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
comment_dir = dir;
|
|
Karsten Hopp |
5d2990 |
if (initc == '/')
|
|
Karsten Hopp |
5d2990 |
ignore_cend = TRUE;
|
|
Karsten Hopp |
5d2990 |
backwards = (dir == FORWARD) ? FALSE : TRUE;
|
|
Karsten Hopp |
5d2990 |
+ raw_string = (initc == 'R');
|
|
Karsten Hopp |
5d2990 |
initc = NUL;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
else if (initc != '#' && initc != NUL)
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 1812,1823 ****
|
|
Karsten Hopp |
5d2990 |
if (findc == NUL)
|
|
Karsten Hopp |
5d2990 |
return NULL;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
- /*
|
|
Karsten Hopp |
5d2990 |
- * Either initc is '#', or no initc was given and we need to look under the
|
|
Karsten Hopp |
5d2990 |
- * cursor.
|
|
Karsten Hopp |
5d2990 |
- */
|
|
Karsten Hopp |
5d2990 |
else
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
if (initc == '#')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
hash_dir = dir;
|
|
Karsten Hopp |
5d2990 |
--- 1865,1876 ----
|
|
Karsten Hopp |
5d2990 |
if (findc == NUL)
|
|
Karsten Hopp |
5d2990 |
return NULL;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
else
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
+ * Either initc is '#', or no initc was given and we need to look
|
|
Karsten Hopp |
5d2990 |
+ * under the cursor.
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
if (initc == '#')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
hash_dir = dir;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 2135,2140 ****
|
|
Karsten Hopp |
5d2990 |
--- 2188,2213 ----
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
if (pos.col == 0)
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
+ else if (raw_string)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ if (linep[pos.col - 1] == 'R'
|
|
Karsten Hopp |
5d2990 |
+ && linep[pos.col] == '"'
|
|
Karsten Hopp |
5d2990 |
+ && vim_strchr(linep + pos.col + 1, '(') != NULL)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ /* Possible start of raw string. Now that we have the
|
|
Karsten Hopp |
5d2990 |
+ * delimiter we can check if it ends before where we
|
|
Karsten Hopp |
5d2990 |
+ * started searching, or before the previously found
|
|
Karsten Hopp |
5d2990 |
+ * raw string start. */
|
|
Karsten Hopp |
5d2990 |
+ if (!find_rawstring_end(linep, &pos,
|
|
Karsten Hopp |
5d2990 |
+ count > 0 ? &match_pos : &curwin->w_cursor))
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ count++;
|
|
Karsten Hopp |
5d2990 |
+ match_pos = pos;
|
|
Karsten Hopp |
5d2990 |
+ match_pos.col--;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ linep = ml_get(pos.lnum); /* may have been released */
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
else if ( linep[pos.col - 1] == '/'
|
|
Karsten Hopp |
5d2990 |
&& linep[pos.col] == '*'
|
|
Karsten Hopp |
5d2990 |
&& (int)pos.col < comment_col)
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/misc1.c 2015-07-21 17:53:11.581527951 +0200
|
|
Karsten Hopp |
5d2990 |
--- src/misc1.c 2015-07-28 21:06:38.908518760 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 5267,5276 ****
|
|
Karsten Hopp |
5d2990 |
--- 5267,5279 ----
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
static char_u *skip_string __ARGS((char_u *p));
|
|
Karsten Hopp |
5d2990 |
static pos_T *ind_find_start_comment __ARGS((void));
|
|
Karsten Hopp |
5d2990 |
+ static pos_T *ind_find_start_CORS __ARGS((void));
|
|
Karsten Hopp |
5d2990 |
+ static pos_T *find_start_rawstring __ARGS((int ind_maxcomment));
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Find the start of a comment, not knowing if we are in a comment right now.
|
|
Karsten Hopp |
5d2990 |
* Search starts at w_cursor.lnum and goes backwards.
|
|
Karsten Hopp |
5d2990 |
+ * Return NULL when not inside a comment.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
static pos_T *
|
|
Karsten Hopp |
5d2990 |
ind_find_start_comment() /* XXX */
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 5313,5318 ****
|
|
Karsten Hopp |
5d2990 |
--- 5316,5380 ----
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
+ * Find the start of a comment or raw string, not knowing if we are in a
|
|
Karsten Hopp |
5d2990 |
+ * comment or raw string right now.
|
|
Karsten Hopp |
5d2990 |
+ * Search starts at w_cursor.lnum and goes backwards.
|
|
Karsten Hopp |
5d2990 |
+ * Return NULL when not inside a comment or raw string.
|
|
Karsten Hopp |
5d2990 |
+ * "CORS" -> Comment Or Raw String
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
+ static pos_T *
|
|
Karsten Hopp |
5d2990 |
+ ind_find_start_CORS() /* XXX */
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
|
|
Karsten Hopp |
5d2990 |
+ pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /* If comment_pos is before rs_pos the raw string is inside the comment.
|
|
Karsten Hopp |
5d2990 |
+ * If rs_pos is before comment_pos the comment is inside the raw string. */
|
|
Karsten Hopp |
5d2990 |
+ if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos)))
|
|
Karsten Hopp |
5d2990 |
+ return rs_pos;
|
|
Karsten Hopp |
5d2990 |
+ return comment_pos;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
+ * Find the start of a raw string, not knowing if we are in one right now.
|
|
Karsten Hopp |
5d2990 |
+ * Search starts at w_cursor.lnum and goes backwards.
|
|
Karsten Hopp |
5d2990 |
+ * Return NULL when not inside a raw string.
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
+ static pos_T *
|
|
Karsten Hopp |
5d2990 |
+ find_start_rawstring(ind_maxcomment) /* XXX */
|
|
Karsten Hopp |
5d2990 |
+ int ind_maxcomment;
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ pos_T *pos;
|
|
Karsten Hopp |
5d2990 |
+ char_u *line;
|
|
Karsten Hopp |
5d2990 |
+ char_u *p;
|
|
Karsten Hopp |
5d2990 |
+ int cur_maxcomment = ind_maxcomment;
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ for (;;)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ pos = findmatchlimit(NULL, 'R', FM_BACKWARD, cur_maxcomment);
|
|
Karsten Hopp |
5d2990 |
+ if (pos == NULL)
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
+ * Check if the raw string start we found is inside a string.
|
|
Karsten Hopp |
5d2990 |
+ * If it is then restrict the search to below this line and try again.
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
+ line = ml_get(pos->lnum);
|
|
Karsten Hopp |
5d2990 |
+ for (p = line; *p && (colnr_T)(p - line) < pos->col; ++p)
|
|
Karsten Hopp |
5d2990 |
+ p = skip_string(p);
|
|
Karsten Hopp |
5d2990 |
+ if ((colnr_T)(p - line) <= pos->col)
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+ cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;
|
|
Karsten Hopp |
5d2990 |
+ if (cur_maxcomment <= 0)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ pos = NULL;
|
|
Karsten Hopp |
5d2990 |
+ break;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ return pos;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
* Skip to the end of a "string" and a 'c' character.
|
|
Karsten Hopp |
5d2990 |
* If there is no string or character, return argument unmodified.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 5354,5360 ****
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
if (p[0] == '"')
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
break; /* no string found */
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
--- 5416,5443 ----
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
if (p[0] == '"')
|
|
Karsten Hopp |
5d2990 |
! continue; /* continue for another string */
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! else if (p[0] == 'R' && p[1] == '"')
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! /* Raw string: R"[delim](...)[delim]" */
|
|
Karsten Hopp |
5d2990 |
! char_u *delim = p + 2;
|
|
Karsten Hopp |
5d2990 |
! char_u *paren = vim_strchr(delim, '(');
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! if (paren != NULL)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! size_t delim_len = paren - delim;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! for (p += 3; *p; ++p)
|
|
Karsten Hopp |
5d2990 |
! if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0
|
|
Karsten Hopp |
5d2990 |
! && p[delim_len + 1] == '"')
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! p += delim_len + 1;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! if (p[0] == '"')
|
|
Karsten Hopp |
5d2990 |
! continue; /* continue for another string */
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
break; /* no string found */
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 5596,5605 ****
|
|
Karsten Hopp |
5d2990 |
--curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment now, skip to the start of the comment.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_comment()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
line = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
--- 5679,5689 ----
|
|
Karsten Hopp |
5d2990 |
--curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment or raw string now, skip to the start of
|
|
Karsten Hopp |
5d2990 |
! * it.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_CORS()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
line = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 6454,6460 ****
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (s[0] == '"')
|
|
Karsten Hopp |
5d2990 |
s = skip_string(s) + 1;
|
|
Karsten Hopp |
5d2990 |
else if (s[0] == ':')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
--- 6538,6544 ----
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (s[0] == '"' || (s[0] == 'R' && s[1] == '"'))
|
|
Karsten Hopp |
5d2990 |
s = skip_string(s) + 1;
|
|
Karsten Hopp |
5d2990 |
else if (s[0] == ':')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 6660,6666 ****
|
|
Karsten Hopp |
5d2990 |
pos = NULL;
|
|
Karsten Hopp |
5d2990 |
/* ignore the { if it's in a // or / * * / comment */
|
|
Karsten Hopp |
5d2990 |
if ((colnr_T)cin_skip2pos(trypos) == trypos->col
|
|
Karsten Hopp |
5d2990 |
! && (pos = ind_find_start_comment()) == NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
if (pos != NULL)
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = pos->lnum;
|
|
Karsten Hopp |
5d2990 |
--- 6744,6750 ----
|
|
Karsten Hopp |
5d2990 |
pos = NULL;
|
|
Karsten Hopp |
5d2990 |
/* ignore the { if it's in a // or / * * / comment */
|
|
Karsten Hopp |
5d2990 |
if ((colnr_T)cin_skip2pos(trypos) == trypos->col
|
|
Karsten Hopp |
5d2990 |
! && (pos = ind_find_start_CORS()) == NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
if (pos != NULL)
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = pos->lnum;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 6714,6720 ****
|
|
Karsten Hopp |
5d2990 |
pos_copy = *trypos; /* copy trypos, findmatch will change it */
|
|
Karsten Hopp |
5d2990 |
trypos = &pos_copy;
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
! if ((trypos_wk = ind_find_start_comment()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum
|
|
Karsten Hopp |
5d2990 |
- trypos_wk->lnum);
|
|
Karsten Hopp |
5d2990 |
--- 6798,6804 ----
|
|
Karsten Hopp |
5d2990 |
pos_copy = *trypos; /* copy trypos, findmatch will change it */
|
|
Karsten Hopp |
5d2990 |
trypos = &pos_copy;
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
! if ((trypos_wk = ind_find_start_CORS()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum
|
|
Karsten Hopp |
5d2990 |
- trypos_wk->lnum);
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7029,7034 ****
|
|
Karsten Hopp |
5d2990 |
--- 7113,7122 ----
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
+ * Return the desired indent for C code.
|
|
Karsten Hopp |
5d2990 |
+ * Return -1 if the indent should be left alone (inside a raw string).
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
int
|
|
Karsten Hopp |
5d2990 |
get_c_indent()
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7040,7047 ****
|
|
Karsten Hopp |
5d2990 |
char_u *theline;
|
|
Karsten Hopp |
5d2990 |
char_u *linecopy;
|
|
Karsten Hopp |
5d2990 |
pos_T *trypos;
|
|
Karsten Hopp |
5d2990 |
pos_T *tryposBrace = NULL;
|
|
Karsten Hopp |
5d2990 |
! pos_T tryposBraceCopy;
|
|
Karsten Hopp |
5d2990 |
pos_T our_paren_pos;
|
|
Karsten Hopp |
5d2990 |
char_u *start;
|
|
Karsten Hopp |
5d2990 |
int start_brace;
|
|
Karsten Hopp |
5d2990 |
--- 7128,7136 ----
|
|
Karsten Hopp |
5d2990 |
char_u *theline;
|
|
Karsten Hopp |
5d2990 |
char_u *linecopy;
|
|
Karsten Hopp |
5d2990 |
pos_T *trypos;
|
|
Karsten Hopp |
5d2990 |
+ pos_T *comment_pos;
|
|
Karsten Hopp |
5d2990 |
pos_T *tryposBrace = NULL;
|
|
Karsten Hopp |
5d2990 |
! pos_T tryposCopy;
|
|
Karsten Hopp |
5d2990 |
pos_T our_paren_pos;
|
|
Karsten Hopp |
5d2990 |
char_u *start;
|
|
Karsten Hopp |
5d2990 |
int start_brace;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7085,7091 ****
|
|
Karsten Hopp |
5d2990 |
/* remember where the cursor was when we started */
|
|
Karsten Hopp |
5d2990 |
cur_curpos = curwin->w_cursor;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* if we are at line 1 0 is fine, right? */
|
|
Karsten Hopp |
5d2990 |
if (cur_curpos.lnum == 1)
|
|
Karsten Hopp |
5d2990 |
return 0;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
--- 7174,7180 ----
|
|
Karsten Hopp |
5d2990 |
/* remember where the cursor was when we started */
|
|
Karsten Hopp |
5d2990 |
cur_curpos = curwin->w_cursor;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* if we are at line 1 zero indent is fine, right? */
|
|
Karsten Hopp |
5d2990 |
if (cur_curpos.lnum == 1)
|
|
Karsten Hopp |
5d2990 |
return 0;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7117,7157 ****
|
|
Karsten Hopp |
5d2990 |
original_line_islabel = cin_islabel(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* #defines and so on always go at the left when included in 'cinkeys'.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE)))
|
|
Karsten Hopp |
5d2990 |
amount = curbuf->b_ind_hash_comment;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Is it a non-case label? Then that goes at the left margin too unless:
|
|
Karsten Hopp |
5d2990 |
* - JS flag is set.
|
|
Karsten Hopp |
5d2990 |
* - 'L' item has a positive value.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! else if (original_line_islabel && !curbuf->b_ind_js
|
|
Karsten Hopp |
5d2990 |
&& curbuf->b_ind_jump_label < 0)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
amount = 0;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* If we're inside a "//" comment and there is a "//" comment in a
|
|
Karsten Hopp |
5d2990 |
* previous line, lineup with that one.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! else if (cin_islinecomment(theline)
|
|
Karsten Hopp |
5d2990 |
&& (trypos = find_line_comment()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* find how indented the line beginning the comment is */
|
|
Karsten Hopp |
5d2990 |
getvcol(curwin, trypos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* If we're inside a comment and not looking at the start of the
|
|
Karsten Hopp |
5d2990 |
* comment, try using the 'comments' option.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! else if (!cin_iscomment(theline)
|
|
Karsten Hopp |
5d2990 |
! && (trypos = ind_find_start_comment()) != NULL)
|
|
Karsten Hopp |
5d2990 |
! /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
int lead_start_len = 2;
|
|
Karsten Hopp |
5d2990 |
int lead_middle_len = 1;
|
|
Karsten Hopp |
5d2990 |
--- 7206,7267 ----
|
|
Karsten Hopp |
5d2990 |
original_line_islabel = cin_islabel(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
+ * If we are inside a raw string don't change the indent.
|
|
Karsten Hopp |
5d2990 |
+ * Ignore a raw string inside a comment.
|
|
Karsten Hopp |
5d2990 |
+ */
|
|
Karsten Hopp |
5d2990 |
+ comment_pos = ind_find_start_comment();
|
|
Karsten Hopp |
5d2990 |
+ if (comment_pos != NULL)
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ /* findmatchlimit() static pos is overwritten, make a copy */
|
|
Karsten Hopp |
5d2990 |
+ tryposCopy = *comment_pos;
|
|
Karsten Hopp |
5d2990 |
+ comment_pos = &tryposCopy;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ trypos = find_start_rawstring(curbuf->b_ind_maxcomment);
|
|
Karsten Hopp |
5d2990 |
+ if (trypos != NULL && (comment_pos == NULL || lt(*trypos, *comment_pos)))
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
+ amount = -1;
|
|
Karsten Hopp |
5d2990 |
+ goto laterend;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ /*
|
|
Karsten Hopp |
5d2990 |
* #defines and so on always go at the left when included in 'cinkeys'.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE)))
|
|
Karsten Hopp |
5d2990 |
+ {
|
|
Karsten Hopp |
5d2990 |
amount = curbuf->b_ind_hash_comment;
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Is it a non-case label? Then that goes at the left margin too unless:
|
|
Karsten Hopp |
5d2990 |
* - JS flag is set.
|
|
Karsten Hopp |
5d2990 |
* - 'L' item has a positive value.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (original_line_islabel && !curbuf->b_ind_js
|
|
Karsten Hopp |
5d2990 |
&& curbuf->b_ind_jump_label < 0)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
amount = 0;
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* If we're inside a "//" comment and there is a "//" comment in a
|
|
Karsten Hopp |
5d2990 |
* previous line, lineup with that one.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (cin_islinecomment(theline)
|
|
Karsten Hopp |
5d2990 |
&& (trypos = find_line_comment()) != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* find how indented the line beginning the comment is */
|
|
Karsten Hopp |
5d2990 |
getvcol(curwin, trypos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* If we're inside a comment and not looking at the start of the
|
|
Karsten Hopp |
5d2990 |
* comment, try using the 'comments' option.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (!cin_iscomment(theline) && comment_pos != NULL) /* XXX */
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
int lead_start_len = 2;
|
|
Karsten Hopp |
5d2990 |
int lead_middle_len = 1;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7164,7170 ****
|
|
Karsten Hopp |
5d2990 |
int done = FALSE;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/* find how indented the line beginning the comment is */
|
|
Karsten Hopp |
5d2990 |
! getvcol(curwin, trypos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
*lead_start = NUL;
|
|
Karsten Hopp |
5d2990 |
*lead_middle = NUL;
|
|
Karsten Hopp |
5d2990 |
--- 7274,7280 ----
|
|
Karsten Hopp |
5d2990 |
int done = FALSE;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/* find how indented the line beginning the comment is */
|
|
Karsten Hopp |
5d2990 |
! getvcol(curwin, comment_pos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
*lead_start = NUL;
|
|
Karsten Hopp |
5d2990 |
*lead_middle = NUL;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7228,7234 ****
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
/* If the start comment string doesn't match with the
|
|
Karsten Hopp |
5d2990 |
* start of the comment, skip this entry. XXX */
|
|
Karsten Hopp |
5d2990 |
! else if (STRNCMP(ml_get(trypos->lnum) + trypos->col,
|
|
Karsten Hopp |
5d2990 |
lead_start, lead_start_len) != 0)
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
--- 7338,7344 ----
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
/* If the start comment string doesn't match with the
|
|
Karsten Hopp |
5d2990 |
* start of the comment, skip this entry. XXX */
|
|
Karsten Hopp |
5d2990 |
! else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col,
|
|
Karsten Hopp |
5d2990 |
lead_start, lead_start_len) != 0)
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7276,7282 ****
|
|
Karsten Hopp |
5d2990 |
* otherwise, add the amount specified by "c" in 'cino'
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
amount = -1;
|
|
Karsten Hopp |
5d2990 |
! for (lnum = cur_curpos.lnum - 1; lnum > trypos->lnum; --lnum)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
if (linewhite(lnum)) /* skip blank lines */
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
--- 7386,7392 ----
|
|
Karsten Hopp |
5d2990 |
* otherwise, add the amount specified by "c" in 'cino'
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
amount = -1;
|
|
Karsten Hopp |
5d2990 |
! for (lnum = cur_curpos.lnum - 1; lnum > comment_pos->lnum; --lnum)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
if (linewhite(lnum)) /* skip blank lines */
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7287,7319 ****
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
if (!curbuf->b_ind_in_comment2)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! start = ml_get(trypos->lnum);
|
|
Karsten Hopp |
5d2990 |
! look = start + trypos->col + 2; /* skip / and * */
|
|
Karsten Hopp |
5d2990 |
if (*look != NUL) /* if something after it */
|
|
Karsten Hopp |
5d2990 |
! trypos->col = (colnr_T)(skipwhite(look) - start);
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
! getvcol(curwin, trypos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
if (curbuf->b_ind_in_comment2 || *look == NUL)
|
|
Karsten Hopp |
5d2990 |
amount += curbuf->b_ind_in_comment;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Are we looking at a ']' that has a match?
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! else if (*skipwhite(theline) == ']'
|
|
Karsten Hopp |
5d2990 |
&& (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* align with the line containing the '['. */
|
|
Karsten Hopp |
5d2990 |
amount = get_indent_lnum(trypos->lnum);
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Are we inside parentheses or braces?
|
|
Karsten Hopp |
5d2990 |
*/ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! else if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL
|
|
Karsten Hopp |
5d2990 |
&& curbuf->b_ind_java == 0)
|
|
Karsten Hopp |
5d2990 |
|| (tryposBrace = find_start_brace()) != NULL
|
|
Karsten Hopp |
5d2990 |
|| trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
--- 7397,7431 ----
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
if (!curbuf->b_ind_in_comment2)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! start = ml_get(comment_pos->lnum);
|
|
Karsten Hopp |
5d2990 |
! look = start + comment_pos->col + 2; /* skip / and * */
|
|
Karsten Hopp |
5d2990 |
if (*look != NUL) /* if something after it */
|
|
Karsten Hopp |
5d2990 |
! comment_pos->col = (colnr_T)(skipwhite(look) - start);
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
! getvcol(curwin, comment_pos, &col, NULL, NULL);
|
|
Karsten Hopp |
5d2990 |
amount = col;
|
|
Karsten Hopp |
5d2990 |
if (curbuf->b_ind_in_comment2 || *look == NUL)
|
|
Karsten Hopp |
5d2990 |
amount += curbuf->b_ind_in_comment;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Are we looking at a ']' that has a match?
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! if (*skipwhite(theline) == ']'
|
|
Karsten Hopp |
5d2990 |
&& (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* align with the line containing the '['. */
|
|
Karsten Hopp |
5d2990 |
amount = get_indent_lnum(trypos->lnum);
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
* Are we inside parentheses or braces?
|
|
Karsten Hopp |
5d2990 |
*/ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL
|
|
Karsten Hopp |
5d2990 |
&& curbuf->b_ind_java == 0)
|
|
Karsten Hopp |
5d2990 |
|| (tryposBrace = find_start_brace()) != NULL
|
|
Karsten Hopp |
5d2990 |
|| trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7354,7361 ****
|
|
Karsten Hopp |
5d2990 |
continue; /* ignore #define, #if, etc. */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = lnum;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* Skip a comment. XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_comment()) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
--- 7466,7473 ----
|
|
Karsten Hopp |
5d2990 |
continue; /* ignore #define, #if, etc. */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = lnum;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* Skip a comment or raw string. XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_CORS()) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
continue;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7583,7590 ****
|
|
Karsten Hopp |
5d2990 |
* Make a copy of tryposBrace, it may point to pos_copy inside
|
|
Karsten Hopp |
5d2990 |
* find_start_brace(), which may be changed somewhere.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! tryposBraceCopy = *tryposBrace;
|
|
Karsten Hopp |
5d2990 |
! tryposBrace = &tryposBraceCopy;
|
|
Karsten Hopp |
5d2990 |
trypos = tryposBrace;
|
|
Karsten Hopp |
5d2990 |
ourscope = trypos->lnum;
|
|
Karsten Hopp |
5d2990 |
start = ml_get(ourscope);
|
|
Karsten Hopp |
5d2990 |
--- 7695,7702 ----
|
|
Karsten Hopp |
5d2990 |
* Make a copy of tryposBrace, it may point to pos_copy inside
|
|
Karsten Hopp |
5d2990 |
* find_start_brace(), which may be changed somewhere.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! tryposCopy = *tryposBrace;
|
|
Karsten Hopp |
5d2990 |
! tryposBrace = &tryposCopy;
|
|
Karsten Hopp |
5d2990 |
trypos = tryposBrace;
|
|
Karsten Hopp |
5d2990 |
ourscope = trypos->lnum;
|
|
Karsten Hopp |
5d2990 |
start = ml_get(ourscope);
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7791,7800 ****
|
|
Karsten Hopp |
5d2990 |
l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment now, skip to the start of the
|
|
Karsten Hopp |
5d2990 |
! * comment.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! trypos = ind_find_start_comment();
|
|
Karsten Hopp |
5d2990 |
if (trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
--- 7903,7912 ----
|
|
Karsten Hopp |
5d2990 |
l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment or raw string now, skip to
|
|
Karsten Hopp |
5d2990 |
! * the start of it.
|
|
Karsten Hopp |
5d2990 |
*/
|
|
Karsten Hopp |
5d2990 |
! trypos = ind_find_start_CORS();
|
|
Karsten Hopp |
5d2990 |
if (trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7911,7919 ****
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* If we're in a comment now, skip to the start of
|
|
Karsten Hopp |
5d2990 |
! * the comment. */
|
|
Karsten Hopp |
5d2990 |
! trypos = ind_find_start_comment();
|
|
Karsten Hopp |
5d2990 |
if (trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
--- 8023,8031 ----
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* If we're in a comment or raw string now, skip
|
|
Karsten Hopp |
5d2990 |
! * to the start of it. */
|
|
Karsten Hopp |
5d2990 |
! trypos = ind_find_start_CORS();
|
|
Karsten Hopp |
5d2990 |
if (trypos != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7941,7949 ****
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment now, skip to the start of the comment.
|
|
Karsten Hopp |
5d2990 |
*/ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_comment()) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
--- 8053,8062 ----
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment or raw string now, skip to the start
|
|
Karsten Hopp |
5d2990 |
! * of it.
|
|
Karsten Hopp |
5d2990 |
*/ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_CORS()) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 8729,9004 ****
|
|
Karsten Hopp |
5d2990 |
/* subtract extra left-shift for jump labels */
|
|
Karsten Hopp |
5d2990 |
if (curbuf->b_ind_jump_label > 0 && original_line_islabel)
|
|
Karsten Hopp |
5d2990 |
amount -= curbuf->b_ind_jump_label;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
! else
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * ok -- we're not inside any sort of structure at all!
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * This means we're at the top level, and everything should
|
|
Karsten Hopp |
5d2990 |
! * basically just match where the previous line is, except
|
|
Karsten Hopp |
5d2990 |
! * for the lines immediately following a function declaration,
|
|
Karsten Hopp |
5d2990 |
! * which are K&R-style parameters and need to be indented.
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * if our line starts with an open brace, forget about any
|
|
Karsten Hopp |
5d2990 |
! * prevailing indent and make sure it looks like the start
|
|
Karsten Hopp |
5d2990 |
! * of a function
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (theline[0] == '{')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_first_open;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * If the NEXT line is a function declaration, the current
|
|
Karsten Hopp |
5d2990 |
! * line needs to be indented as a function type spec.
|
|
Karsten Hopp |
5d2990 |
! * Don't do this if the current line looks like a comment or if the
|
|
Karsten Hopp |
5d2990 |
! * current line is terminated, ie. ends in ';', or if the current line
|
|
Karsten Hopp |
5d2990 |
! * contains { or }: "void f() {\n if (1)"
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! else if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
|
|
Karsten Hopp |
5d2990 |
! && !cin_nocode(theline)
|
|
Karsten Hopp |
5d2990 |
! && vim_strchr(theline, '{') == NULL
|
|
Karsten Hopp |
5d2990 |
! && vim_strchr(theline, '}') == NULL
|
|
Karsten Hopp |
5d2990 |
! && !cin_ends_in(theline, (char_u *)":", NULL)
|
|
Karsten Hopp |
5d2990 |
! && !cin_ends_in(theline, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! && cin_isfuncdecl(NULL, cur_curpos.lnum + 1,
|
|
Karsten Hopp |
5d2990 |
! cur_curpos.lnum + 1)
|
|
Karsten Hopp |
5d2990 |
! && !cin_isterminated(theline, FALSE, TRUE))
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_func_type;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
! else
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! amount = 0;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = cur_curpos;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /* search backwards until we find something we recognize */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! while (curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.lnum--;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment now, skip to the start of the comment.
|
|
Karsten Hopp |
5d2990 |
! */ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_comment()) != NULL)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Are we at the start of a cpp base class declaration or
|
|
Karsten Hopp |
5d2990 |
! * constructor initialization?
|
|
Karsten Hopp |
5d2990 |
! */ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! n = FALSE;
|
|
Karsten Hopp |
5d2990 |
! if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{')
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! if (n)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! /* XXX */
|
|
Karsten Hopp |
5d2990 |
! amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col);
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Skip preprocessor directives and blank lines.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! if (cin_nocode(l))
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends in ',', use one level of
|
|
Karsten Hopp |
5d2990 |
! * indentation:
|
|
Karsten Hopp |
5d2990 |
! * int foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! * do this before checking for '}' in case of eg.
|
|
Karsten Hopp |
5d2990 |
! * enum foobar
|
|
Karsten Hopp |
5d2990 |
! * {
|
|
Karsten Hopp |
5d2990 |
! * ...
|
|
Karsten Hopp |
5d2990 |
! * } foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! n = 0;
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\'))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! /* take us back to opening paren */
|
|
Karsten Hopp |
5d2990 |
! if (find_last_paren(l, '(', ')')
|
|
Karsten Hopp |
5d2990 |
! && (trypos = find_match_paren(
|
|
Karsten Hopp |
5d2990 |
! curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* For a line ending in ',' that is a continuation line go
|
|
Karsten Hopp |
5d2990 |
! * back to the first line with a backslash:
|
|
Karsten Hopp |
5d2990 |
! * char *foo = "bla\
|
|
Karsten Hopp |
5d2990 |
! * bla",
|
|
Karsten Hopp |
5d2990 |
! * here;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! while (n == 0 && curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(curwin->w_cursor.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (*l == NUL || l[STRLEN(l) - 1] != '\\')
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! --curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount = cin_first_id_amount();
|
|
Karsten Hopp |
5d2990 |
! if (amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount = ind_continuation;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the line looks like a function declaration, and we're
|
|
Karsten Hopp |
5d2990 |
! * not in a comment, put it the left margin.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Finding the closing '}' of a previous function. Put
|
|
Karsten Hopp |
5d2990 |
! * current line at the left margin. For when 'cino' has "fs".
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (*skipwhite(l) == '}')
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* (matching {)
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends on '};' (maybe followed by
|
|
Karsten Hopp |
5d2990 |
! * comments) align at column 0. For example:
|
|
Karsten Hopp |
5d2990 |
! * char *string_array[] = { "foo",
|
|
Karsten Hopp |
5d2990 |
! * / * x * / "b};ar" }; / * foobar * /
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)"};", NULL))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends on '[' we are probably in an
|
|
Karsten Hopp |
5d2990 |
! * array constant:
|
|
Karsten Hopp |
5d2990 |
! * something = [
|
|
Karsten Hopp |
5d2990 |
! * 234, <- extra indent
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)"[", NULL))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent() + ind_continuation;
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Find a line only has a semicolon that belongs to a previous
|
|
Karsten Hopp |
5d2990 |
! * line ending in '}', e.g. before an #endif. Don't increase
|
|
Karsten Hopp |
5d2990 |
! * indent then.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! pos_T curpos_save = curwin->w_cursor;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! while (curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! look = ml_get(--curwin->w_cursor.lnum);
|
|
Karsten Hopp |
5d2990 |
! if (!(cin_nocode(look) || cin_ispreproc_cont(
|
|
Karsten Hopp |
5d2990 |
! &look, &curwin->w_cursor.lnum)))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! if (curwin->w_cursor.lnum > 0
|
|
Karsten Hopp |
5d2990 |
! && cin_ends_in(look, (char_u *)"}", NULL))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = curpos_save;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the PREVIOUS line is a function declaration, the current
|
|
Karsten Hopp |
5d2990 |
! * line (and the ones that follow) needs to be indented as
|
|
Karsten Hopp |
5d2990 |
! * parameters.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_param;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends in ';' and the line before the
|
|
Karsten Hopp |
5d2990 |
! * previous line ends in ',' or '\', ident to column zero:
|
|
Karsten Hopp |
5d2990 |
! * int foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! * indent_to_0 here;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)";", NULL))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(curwin->w_cursor.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Doesn't look like anything interesting -- so just
|
|
Karsten Hopp |
5d2990 |
! * use the indent of this line.
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * Position the cursor over the rightmost paren, so that
|
|
Karsten Hopp |
5d2990 |
! * matching it will take us back to the start of the line.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! find_last_paren(l, '(', ')');
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* add extra indent for a comment */
|
|
Karsten Hopp |
5d2990 |
! if (cin_iscomment(theline))
|
|
Karsten Hopp |
5d2990 |
! amount += curbuf->b_ind_comment;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /* add extra indent if the previous line ended in a backslash:
|
|
Karsten Hopp |
5d2990 |
! * "asdfasdf\
|
|
Karsten Hopp |
5d2990 |
! * here";
|
|
Karsten Hopp |
5d2990 |
! * char *foo = "asdf\
|
|
Karsten Hopp |
5d2990 |
! * here";
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cur_curpos.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(cur_curpos.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (*l != NUL && l[STRLEN(l) - 1] == '\\')
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (cur_amount > 0)
|
|
Karsten Hopp |
5d2990 |
! amount = cur_amount;
|
|
Karsten Hopp |
5d2990 |
! else if (cur_amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount += ind_continuation;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
theend:
|
|
Karsten Hopp |
5d2990 |
/* put the cursor back where it belongs */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = cur_curpos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
vim_free(linecopy);
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
- if (amount < 0)
|
|
Karsten Hopp |
5d2990 |
- return 0;
|
|
Karsten Hopp |
5d2990 |
return amount;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
--- 8842,9118 ----
|
|
Karsten Hopp |
5d2990 |
/* subtract extra left-shift for jump labels */
|
|
Karsten Hopp |
5d2990 |
if (curbuf->b_ind_jump_label > 0 && original_line_islabel)
|
|
Karsten Hopp |
5d2990 |
amount -= curbuf->b_ind_jump_label;
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ goto theend;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * ok -- we're not inside any sort of structure at all!
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * This means we're at the top level, and everything should
|
|
Karsten Hopp |
5d2990 |
! * basically just match where the previous line is, except
|
|
Karsten Hopp |
5d2990 |
! * for the lines immediately following a function declaration,
|
|
Karsten Hopp |
5d2990 |
! * which are K&R-style parameters and need to be indented.
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * if our line starts with an open brace, forget about any
|
|
Karsten Hopp |
5d2990 |
! * prevailing indent and make sure it looks like the start
|
|
Karsten Hopp |
5d2990 |
! * of a function
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! if (theline[0] == '{')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_first_open;
|
|
Karsten Hopp |
5d2990 |
! goto theend;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the NEXT line is a function declaration, the current
|
|
Karsten Hopp |
5d2990 |
! * line needs to be indented as a function type spec.
|
|
Karsten Hopp |
5d2990 |
! * Don't do this if the current line looks like a comment or if the
|
|
Karsten Hopp |
5d2990 |
! * current line is terminated, ie. ends in ';', or if the current line
|
|
Karsten Hopp |
5d2990 |
! * contains { or }: "void f() {\n if (1)"
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
|
|
Karsten Hopp |
5d2990 |
! && !cin_nocode(theline)
|
|
Karsten Hopp |
5d2990 |
! && vim_strchr(theline, '{') == NULL
|
|
Karsten Hopp |
5d2990 |
! && vim_strchr(theline, '}') == NULL
|
|
Karsten Hopp |
5d2990 |
! && !cin_ends_in(theline, (char_u *)":", NULL)
|
|
Karsten Hopp |
5d2990 |
! && !cin_ends_in(theline, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! && cin_isfuncdecl(NULL, cur_curpos.lnum + 1,
|
|
Karsten Hopp |
5d2990 |
! cur_curpos.lnum + 1)
|
|
Karsten Hopp |
5d2990 |
! && !cin_isterminated(theline, FALSE, TRUE))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_func_type;
|
|
Karsten Hopp |
5d2990 |
! goto theend;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /* search backwards until we find something we recognize */
|
|
Karsten Hopp |
5d2990 |
! amount = 0;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = cur_curpos;
|
|
Karsten Hopp |
5d2990 |
! while (curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.lnum--;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If we're in a comment or raw string now, skip to the start
|
|
Karsten Hopp |
5d2990 |
! * of it.
|
|
Karsten Hopp |
5d2990 |
! */ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = ind_find_start_CORS()) != NULL)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.lnum = trypos->lnum + 1;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/*
|
|
Karsten Hopp |
5d2990 |
! * Are we at the start of a cpp base class declaration or
|
|
Karsten Hopp |
5d2990 |
! * constructor initialization?
|
|
Karsten Hopp |
5d2990 |
! */ /* XXX */
|
|
Karsten Hopp |
5d2990 |
! n = FALSE;
|
|
Karsten Hopp |
5d2990 |
! if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{')
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
! if (n)
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! /* XXX */
|
|
Karsten Hopp |
5d2990 |
! amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col);
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Skip preprocessor directives and blank lines.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (cin_nocode(l))
|
|
Karsten Hopp |
5d2990 |
! continue;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends in ',', use one level of
|
|
Karsten Hopp |
5d2990 |
! * indentation:
|
|
Karsten Hopp |
5d2990 |
! * int foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! * do this before checking for '}' in case of eg.
|
|
Karsten Hopp |
5d2990 |
! * enum foobar
|
|
Karsten Hopp |
5d2990 |
! * {
|
|
Karsten Hopp |
5d2990 |
! * ...
|
|
Karsten Hopp |
5d2990 |
! * } foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! n = 0;
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\'))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! /* take us back to opening paren */
|
|
Karsten Hopp |
5d2990 |
! if (find_last_paren(l, '(', ')')
|
|
Karsten Hopp |
5d2990 |
! && (trypos = find_match_paren(
|
|
Karsten Hopp |
5d2990 |
! curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* For a line ending in ',' that is a continuation line go
|
|
Karsten Hopp |
5d2990 |
! * back to the first line with a backslash:
|
|
Karsten Hopp |
5d2990 |
! * char *foo = "bla\
|
|
Karsten Hopp |
5d2990 |
! * bla",
|
|
Karsten Hopp |
5d2990 |
! * here;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! while (n == 0 && curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(curwin->w_cursor.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (*l == NUL || l[STRLEN(l) - 1] != '\\')
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
! --curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor.col = 0;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount = cin_first_id_amount();
|
|
Karsten Hopp |
5d2990 |
! if (amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount = ind_continuation;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the line looks like a function declaration, and we're
|
|
Karsten Hopp |
5d2990 |
! * not in a comment, put it the left margin.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Finding the closing '}' of a previous function. Put
|
|
Karsten Hopp |
5d2990 |
! * current line at the left margin. For when 'cino' has "fs".
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (*skipwhite(l) == '}')
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* (matching {)
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends on '};' (maybe followed by
|
|
Karsten Hopp |
5d2990 |
! * comments) align at column 0. For example:
|
|
Karsten Hopp |
5d2990 |
! * char *string_array[] = { "foo",
|
|
Karsten Hopp |
5d2990 |
! * / * x * / "b};ar" }; / * foobar * /
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)"};", NULL))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends on '[' we are probably in an
|
|
Karsten Hopp |
5d2990 |
! * array constant:
|
|
Karsten Hopp |
5d2990 |
! * something = [
|
|
Karsten Hopp |
5d2990 |
! * 234, <- extra indent
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)"[", NULL))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent() + ind_continuation;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Find a line only has a semicolon that belongs to a previous
|
|
Karsten Hopp |
5d2990 |
! * line ending in '}', e.g. before an #endif. Don't increase
|
|
Karsten Hopp |
5d2990 |
! * indent then.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! pos_T curpos_save = curwin->w_cursor;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! while (curwin->w_cursor.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! look = ml_get(--curwin->w_cursor.lnum);
|
|
Karsten Hopp |
5d2990 |
! if (!(cin_nocode(look) || cin_ispreproc_cont(
|
|
Karsten Hopp |
5d2990 |
! &look, &curwin->w_cursor.lnum)))
|
|
Karsten Hopp |
5d2990 |
break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
! if (curwin->w_cursor.lnum > 0
|
|
Karsten Hopp |
5d2990 |
! && cin_ends_in(look, (char_u *)"}", NULL))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = curpos_save;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the PREVIOUS line is a function declaration, the current
|
|
Karsten Hopp |
5d2990 |
! * line (and the ones that follow) needs to be indented as
|
|
Karsten Hopp |
5d2990 |
! * parameters.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! amount = curbuf->b_ind_param;
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * If the previous line ends in ';' and the line before the
|
|
Karsten Hopp |
5d2990 |
! * previous line ends in ',' or '\', ident to column zero:
|
|
Karsten Hopp |
5d2990 |
! * int foo,
|
|
Karsten Hopp |
5d2990 |
! * bar;
|
|
Karsten Hopp |
5d2990 |
! * indent_to_0 here;
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)";", NULL))
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(curwin->w_cursor.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (cin_ends_in(l, (char_u *)",", NULL)
|
|
Karsten Hopp |
5d2990 |
! || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! l = ml_get_curline();
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /*
|
|
Karsten Hopp |
5d2990 |
! * Doesn't look like anything interesting -- so just
|
|
Karsten Hopp |
5d2990 |
! * use the indent of this line.
|
|
Karsten Hopp |
5d2990 |
! *
|
|
Karsten Hopp |
5d2990 |
! * Position the cursor over the rightmost paren, so that
|
|
Karsten Hopp |
5d2990 |
! * matching it will take us back to the start of the line.
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! find_last_paren(l, '(', ')');
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
|
|
Karsten Hopp |
5d2990 |
! curwin->w_cursor = *trypos;
|
|
Karsten Hopp |
5d2990 |
! amount = get_indent(); /* XXX */
|
|
Karsten Hopp |
5d2990 |
! break;
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! /* add extra indent for a comment */
|
|
Karsten Hopp |
5d2990 |
! if (cin_iscomment(theline))
|
|
Karsten Hopp |
5d2990 |
! amount += curbuf->b_ind_comment;
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! /* add extra indent if the previous line ended in a backslash:
|
|
Karsten Hopp |
5d2990 |
! * "asdfasdf\
|
|
Karsten Hopp |
5d2990 |
! * here";
|
|
Karsten Hopp |
5d2990 |
! * char *foo = "asdf\
|
|
Karsten Hopp |
5d2990 |
! * here";
|
|
Karsten Hopp |
5d2990 |
! */
|
|
Karsten Hopp |
5d2990 |
! if (cur_curpos.lnum > 1)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! l = ml_get(cur_curpos.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (*l != NUL && l[STRLEN(l) - 1] == '\\')
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
|
|
Karsten Hopp |
5d2990 |
! if (cur_amount > 0)
|
|
Karsten Hopp |
5d2990 |
! amount = cur_amount;
|
|
Karsten Hopp |
5d2990 |
! else if (cur_amount == 0)
|
|
Karsten Hopp |
5d2990 |
! amount += ind_continuation;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
theend:
|
|
Karsten Hopp |
5d2990 |
+ if (amount < 0)
|
|
Karsten Hopp |
5d2990 |
+ amount = 0;
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ laterend:
|
|
Karsten Hopp |
5d2990 |
/* put the cursor back where it belongs */
|
|
Karsten Hopp |
5d2990 |
curwin->w_cursor = cur_curpos;
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
vim_free(linecopy);
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
return amount;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/edit.c 2015-07-21 17:53:11.577527989 +0200
|
|
Karsten Hopp |
5d2990 |
--- src/edit.c 2015-07-28 19:40:27.771945786 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 7813,7821 ****
|
|
Karsten Hopp |
5d2990 |
fixthisline(get_the_indent)
|
|
Karsten Hopp |
5d2990 |
int (*get_the_indent) __ARGS((void));
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! change_indent(INDENT_SET, get_the_indent(), FALSE, 0, TRUE);
|
|
Karsten Hopp |
5d2990 |
! if (linewhite(curwin->w_cursor.lnum))
|
|
Karsten Hopp |
5d2990 |
! did_ai = TRUE; /* delete the indent if the line stays empty */
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
void
|
|
Karsten Hopp |
5d2990 |
--- 7813,7826 ----
|
|
Karsten Hopp |
5d2990 |
fixthisline(get_the_indent)
|
|
Karsten Hopp |
5d2990 |
int (*get_the_indent) __ARGS((void));
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
! int amount = get_the_indent();
|
|
Karsten Hopp |
5d2990 |
!
|
|
Karsten Hopp |
5d2990 |
! if (amount >= 0)
|
|
Karsten Hopp |
5d2990 |
! {
|
|
Karsten Hopp |
5d2990 |
! change_indent(INDENT_SET, amount, FALSE, 0, TRUE);
|
|
Karsten Hopp |
5d2990 |
! if (linewhite(curwin->w_cursor.lnum))
|
|
Karsten Hopp |
5d2990 |
! did_ai = TRUE; /* delete the indent if the line stays empty */
|
|
Karsten Hopp |
5d2990 |
! }
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
void
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/ops.c 2015-07-22 22:46:08.127010101 +0200
|
|
Karsten Hopp |
5d2990 |
--- src/ops.c 2015-07-28 19:45:37.060848436 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 686,692 ****
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
long i;
|
|
Karsten Hopp |
5d2990 |
char_u *l;
|
|
Karsten Hopp |
5d2990 |
! int count;
|
|
Karsten Hopp |
5d2990 |
linenr_T first_changed = 0;
|
|
Karsten Hopp |
5d2990 |
linenr_T last_changed = 0;
|
|
Karsten Hopp |
5d2990 |
linenr_T start_lnum = curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
--- 686,692 ----
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
long i;
|
|
Karsten Hopp |
5d2990 |
char_u *l;
|
|
Karsten Hopp |
5d2990 |
! int amount;
|
|
Karsten Hopp |
5d2990 |
linenr_T first_changed = 0;
|
|
Karsten Hopp |
5d2990 |
linenr_T last_changed = 0;
|
|
Karsten Hopp |
5d2990 |
linenr_T start_lnum = curwin->w_cursor.lnum;
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 719,729 ****
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
l = skipwhite(ml_get_curline());
|
|
Karsten Hopp |
5d2990 |
if (*l == NUL) /* empty or blank line */
|
|
Karsten Hopp |
5d2990 |
! count = 0;
|
|
Karsten Hopp |
5d2990 |
else
|
|
Karsten Hopp |
5d2990 |
! count = how(); /* get the indent for this line */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (set_indent(count, SIN_UNDO))
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* did change the indent, call changed_lines() later */
|
|
Karsten Hopp |
5d2990 |
if (first_changed == 0)
|
|
Karsten Hopp |
5d2990 |
--- 719,729 ----
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
l = skipwhite(ml_get_curline());
|
|
Karsten Hopp |
5d2990 |
if (*l == NUL) /* empty or blank line */
|
|
Karsten Hopp |
5d2990 |
! amount = 0;
|
|
Karsten Hopp |
5d2990 |
else
|
|
Karsten Hopp |
5d2990 |
! amount = how(); /* get the indent for this line */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
! if (amount >= 0 && set_indent(amount, SIN_UNDO))
|
|
Karsten Hopp |
5d2990 |
{
|
|
Karsten Hopp |
5d2990 |
/* did change the indent, call changed_lines() later */
|
|
Karsten Hopp |
5d2990 |
if (first_changed == 0)
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/testdir/test3.in 2015-03-20 19:06:01.982429823 +0100
|
|
Karsten Hopp |
5d2990 |
--- src/testdir/test3.in 2015-07-28 20:03:32.290099553 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 891,896 ****
|
|
Karsten Hopp |
5d2990 |
--- 891,915 ----
|
|
Karsten Hopp |
5d2990 |
111111111111111111;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
+ void getstring() {
|
|
Karsten Hopp |
5d2990 |
+ /* Raw strings */
|
|
Karsten Hopp |
5d2990 |
+ const char* s = R"(
|
|
Karsten Hopp |
5d2990 |
+ test {
|
|
Karsten Hopp |
5d2990 |
+ # comment
|
|
Karsten Hopp |
5d2990 |
+ field: 123
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ )";
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ void getstring() {
|
|
Karsten Hopp |
5d2990 |
+ const char* s = R"foo(
|
|
Karsten Hopp |
5d2990 |
+ test {
|
|
Karsten Hopp |
5d2990 |
+ # comment
|
|
Karsten Hopp |
5d2990 |
+ field: 123
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ )foo";
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
/* end of AUTO */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
STARTTEST
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/testdir/test3.ok 2015-03-20 19:06:01.986429778 +0100
|
|
Karsten Hopp |
5d2990 |
--- src/testdir/test3.ok 2015-07-28 20:03:59.985823030 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 879,884 ****
|
|
Karsten Hopp |
5d2990 |
--- 879,903 ----
|
|
Karsten Hopp |
5d2990 |
111111111111111111;
|
|
Karsten Hopp |
5d2990 |
}
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
+ void getstring() {
|
|
Karsten Hopp |
5d2990 |
+ /* Raw strings */
|
|
Karsten Hopp |
5d2990 |
+ const char* s = R"(
|
|
Karsten Hopp |
5d2990 |
+ test {
|
|
Karsten Hopp |
5d2990 |
+ # comment
|
|
Karsten Hopp |
5d2990 |
+ field: 123
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ )";
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
+ void getstring() {
|
|
Karsten Hopp |
5d2990 |
+ const char* s = R"foo(
|
|
Karsten Hopp |
5d2990 |
+ test {
|
|
Karsten Hopp |
5d2990 |
+ # comment
|
|
Karsten Hopp |
5d2990 |
+ field: 123
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+ )foo";
|
|
Karsten Hopp |
5d2990 |
+ }
|
|
Karsten Hopp |
5d2990 |
+
|
|
Karsten Hopp |
5d2990 |
/* end of AUTO */
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
*** ../vim-7.4.802/src/version.c 2015-07-28 17:16:28.302488118 +0200
|
|
Karsten Hopp |
5d2990 |
--- src/version.c 2015-07-28 21:07:42.219893314 +0200
|
|
Karsten Hopp |
5d2990 |
***************
|
|
Karsten Hopp |
5d2990 |
*** 743,744 ****
|
|
Karsten Hopp |
5d2990 |
--- 743,746 ----
|
|
Karsten Hopp |
5d2990 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
5d2990 |
+ /**/
|
|
Karsten Hopp |
5d2990 |
+ 803,
|
|
Karsten Hopp |
5d2990 |
/**/
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
--
|
|
Karsten Hopp |
5d2990 |
Facepalm statement #4: "3000 year old graves? That's not possible, it's only
|
|
Karsten Hopp |
5d2990 |
2014!"
|
|
Karsten Hopp |
5d2990 |
|
|
Karsten Hopp |
5d2990 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
5d2990 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
5d2990 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
5d2990 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|