|
Karsten Hopp |
348c77 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
348c77 |
Subject: Patch 7.3.844
|
|
Karsten Hopp |
348c77 |
Fcc: outbox
|
|
Karsten Hopp |
348c77 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
348c77 |
Mime-Version: 1.0
|
|
Karsten Hopp |
348c77 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
348c77 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
348c77 |
------------
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
Patch 7.3.844
|
|
Karsten Hopp |
348c77 |
Problem: Enum is not indented correctly with "public" etc.
|
|
Karsten Hopp |
348c77 |
Solution: Skip "public", "private" and "protected". (Hong Xu)
|
|
Karsten Hopp |
348c77 |
Files: src/misc1.c
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
*** ../vim-7.3.843/src/misc1.c 2013-02-13 16:10:13.000000000 +0100
|
|
Karsten Hopp |
348c77 |
--- src/misc1.c 2013-03-07 12:59:45.000000000 +0100
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 5275,5280 ****
|
|
Karsten Hopp |
348c77 |
--- 5275,5281 ----
|
|
Karsten Hopp |
348c77 |
static int cin_is_cpp_baseclass __ARGS((colnr_T *col));
|
|
Karsten Hopp |
348c77 |
static int get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
|
|
Karsten Hopp |
348c77 |
static int cin_ends_in __ARGS((char_u *, char_u *, char_u *));
|
|
Karsten Hopp |
348c77 |
+ static int cin_starts_with __ARGS((char_u *s, char *word));
|
|
Karsten Hopp |
348c77 |
static int cin_skip2pos __ARGS((pos_T *trypos));
|
|
Karsten Hopp |
348c77 |
static pos_T *find_start_brace __ARGS((int));
|
|
Karsten Hopp |
348c77 |
static pos_T *find_match_paren __ARGS((int, int));
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 5446,5469 ****
|
|
Karsten Hopp |
348c77 |
}
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
/*
|
|
Karsten Hopp |
348c77 |
! * Recognize structure initialization and enumerations.
|
|
Karsten Hopp |
348c77 |
! * Q&D-Implementation:
|
|
Karsten Hopp |
348c77 |
! * check for "=" at end or "[typedef] enum" at beginning of line.
|
|
Karsten Hopp |
348c77 |
*/
|
|
Karsten Hopp |
348c77 |
static int
|
|
Karsten Hopp |
348c77 |
cin_isinit(void)
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
char_u *s;
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(ml_get_curline());
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(s, "typedef", 7) == 0 && !vim_isIDc(s[7]))
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s + 7);
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(s, "static", 6) == 0 && !vim_isIDc(s[6]))
|
|
Karsten Hopp |
348c77 |
! s = cin_skipcomment(s + 6);
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(s, "enum", 4) == 0 && !vim_isIDc(s[4]))
|
|
Karsten Hopp |
348c77 |
return TRUE;
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
if (cin_ends_in(s, (char_u *)"=", (char_u *)"{"))
|
|
Karsten Hopp |
348c77 |
--- 5447,5486 ----
|
|
Karsten Hopp |
348c77 |
}
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
/*
|
|
Karsten Hopp |
348c77 |
! * Recognize structure initialization and enumerations:
|
|
Karsten Hopp |
348c77 |
! * "[typedef] [static|public|protected|private] enum"
|
|
Karsten Hopp |
348c77 |
! * "[typedef] [static|public|protected|private] = {"
|
|
Karsten Hopp |
348c77 |
*/
|
|
Karsten Hopp |
348c77 |
static int
|
|
Karsten Hopp |
348c77 |
cin_isinit(void)
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
char_u *s;
|
|
Karsten Hopp |
348c77 |
+ static char *skip[] = {"static", "public", "protected", "private"};
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(ml_get_curline());
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(s, "typedef"))
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s + 7);
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! for (;;)
|
|
Karsten Hopp |
348c77 |
! {
|
|
Karsten Hopp |
348c77 |
! int i, l;
|
|
Karsten Hopp |
348c77 |
!
|
|
Karsten Hopp |
348c77 |
! for (i = 0; i < (int)(sizeof(skip) / sizeof(char *)); ++i)
|
|
Karsten Hopp |
348c77 |
! {
|
|
Karsten Hopp |
348c77 |
! l = strlen(skip[i]);
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(s, skip[i]))
|
|
Karsten Hopp |
348c77 |
! {
|
|
Karsten Hopp |
348c77 |
! s = cin_skipcomment(s + l);
|
|
Karsten Hopp |
348c77 |
! l = 0;
|
|
Karsten Hopp |
348c77 |
! break;
|
|
Karsten Hopp |
348c77 |
! }
|
|
Karsten Hopp |
348c77 |
! }
|
|
Karsten Hopp |
348c77 |
! if (l != 0)
|
|
Karsten Hopp |
348c77 |
! break;
|
|
Karsten Hopp |
348c77 |
! }
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(s, "enum"))
|
|
Karsten Hopp |
348c77 |
return TRUE;
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
if (cin_ends_in(s, (char_u *)"=", (char_u *)"{"))
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 5481,5487 ****
|
|
Karsten Hopp |
348c77 |
int strict; /* Allow relaxed check of case statement for JS */
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s);
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(s, "case", 4) == 0 && !vim_isIDc(s[4]))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
for (s += 4; *s; ++s)
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
--- 5498,5504 ----
|
|
Karsten Hopp |
348c77 |
int strict; /* Allow relaxed check of case statement for JS */
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s);
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(s, "case"))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
for (s += 4; *s; ++s)
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 6049,6055 ****
|
|
Karsten Hopp |
348c77 |
p = cin_skipcomment(p);
|
|
Karsten Hopp |
348c77 |
if (*p == '}') /* accept "} while (cond);" */
|
|
Karsten Hopp |
348c77 |
p = cin_skipcomment(p + 1);
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(p, "while", 5) == 0 && !vim_isIDc(p[5]))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
cursor_save = curwin->w_cursor;
|
|
Karsten Hopp |
348c77 |
curwin->w_cursor.lnum = lnum;
|
|
Karsten Hopp |
348c77 |
--- 6066,6072 ----
|
|
Karsten Hopp |
348c77 |
p = cin_skipcomment(p);
|
|
Karsten Hopp |
348c77 |
if (*p == '}') /* accept "} while (cond);" */
|
|
Karsten Hopp |
348c77 |
p = cin_skipcomment(p + 1);
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(p, "while"))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
cursor_save = curwin->w_cursor;
|
|
Karsten Hopp |
348c77 |
curwin->w_cursor.lnum = lnum;
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 6156,6162 ****
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(ml_get(trypos->lnum));
|
|
Karsten Hopp |
348c77 |
if (*s == '}') /* accept "} while (cond);" */
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s + 1);
|
|
Karsten Hopp |
348c77 |
! if (STRNCMP(s, "while", 5) == 0 && !vim_isIDc(s[5]))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
curwin->w_cursor.lnum = trypos->lnum;
|
|
Karsten Hopp |
348c77 |
return TRUE;
|
|
Karsten Hopp |
348c77 |
--- 6173,6179 ----
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(ml_get(trypos->lnum));
|
|
Karsten Hopp |
348c77 |
if (*s == '}') /* accept "} while (cond);" */
|
|
Karsten Hopp |
348c77 |
s = cin_skipcomment(s + 1);
|
|
Karsten Hopp |
348c77 |
! if (cin_starts_with(s, "while"))
|
|
Karsten Hopp |
348c77 |
{
|
|
Karsten Hopp |
348c77 |
curwin->w_cursor.lnum = trypos->lnum;
|
|
Karsten Hopp |
348c77 |
return TRUE;
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 6406,6411 ****
|
|
Karsten Hopp |
348c77 |
--- 6423,6441 ----
|
|
Karsten Hopp |
348c77 |
}
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
/*
|
|
Karsten Hopp |
348c77 |
+ * Return TRUE when "s" starts with "word" and then a non-ID character.
|
|
Karsten Hopp |
348c77 |
+ */
|
|
Karsten Hopp |
348c77 |
+ static int
|
|
Karsten Hopp |
348c77 |
+ cin_starts_with(s, word)
|
|
Karsten Hopp |
348c77 |
+ char_u *s;
|
|
Karsten Hopp |
348c77 |
+ char *word;
|
|
Karsten Hopp |
348c77 |
+ {
|
|
Karsten Hopp |
348c77 |
+ int l = STRLEN(word);
|
|
Karsten Hopp |
348c77 |
+
|
|
Karsten Hopp |
348c77 |
+ return (STRNCMP(s, word, l) == 0 && !vim_isIDc(s[l]));
|
|
Karsten Hopp |
348c77 |
+ }
|
|
Karsten Hopp |
348c77 |
+
|
|
Karsten Hopp |
348c77 |
+ /*
|
|
Karsten Hopp |
348c77 |
* Skip strings, chars and comments until at or past "trypos".
|
|
Karsten Hopp |
348c77 |
* Return the column found.
|
|
Karsten Hopp |
348c77 |
*/
|
|
Karsten Hopp |
348c77 |
*** ../vim-7.3.843/src/version.c 2013-02-26 22:54:06.000000000 +0100
|
|
Karsten Hopp |
348c77 |
--- src/version.c 2013-03-07 13:12:20.000000000 +0100
|
|
Karsten Hopp |
348c77 |
***************
|
|
Karsten Hopp |
348c77 |
*** 730,731 ****
|
|
Karsten Hopp |
348c77 |
--- 730,733 ----
|
|
Karsten Hopp |
348c77 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
348c77 |
+ /**/
|
|
Karsten Hopp |
348c77 |
+ 844,
|
|
Karsten Hopp |
348c77 |
/**/
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
--
|
|
Karsten Hopp |
348c77 |
Now it is such a bizarrely improbable coincidence that anything as
|
|
Karsten Hopp |
348c77 |
mind-bogglingly useful as the Babel fish could have evolved purely by chance
|
|
Karsten Hopp |
348c77 |
that some thinkers have chosen to see it as a final and clinching proof of the
|
|
Karsten Hopp |
348c77 |
NON-existence of God.
|
|
Karsten Hopp |
348c77 |
The argument goes something like this: 'I refuse to prove that I exist,' says
|
|
Karsten Hopp |
348c77 |
God, 'for proof denies faith, and without faith I am nothing.'
|
|
Karsten Hopp |
348c77 |
'But,' says Man, 'the Babel fish is a dead giveaway, isn't it? It could not
|
|
Karsten Hopp |
348c77 |
have evolved by chance. It proves you exist, and so therefore, by your own
|
|
Karsten Hopp |
348c77 |
arguments, you don't. QED.'
|
|
Karsten Hopp |
348c77 |
'Oh dear,' says God, 'I hadn't thought of that,' and promptly vanishes in a
|
|
Karsten Hopp |
348c77 |
puff of logic.
|
|
Karsten Hopp |
348c77 |
'Oh, that was easy,' says Man, and for an encore goes on to prove that black
|
|
Karsten Hopp |
348c77 |
is white and gets himself killed on the next pedestrian crossing.
|
|
Karsten Hopp |
348c77 |
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
|
|
Karsten Hopp |
348c77 |
|
|
Karsten Hopp |
348c77 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
348c77 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
348c77 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
348c77 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|