Mercurial > vim
comparison src/fold.c @ 45:e474bae3795f
updated for version 7.0027
author | vimboss |
---|---|
date | Fri, 31 Dec 2004 20:58:58 +0000 |
parents | f529edb9bab3 |
children | f713fc55bf7b |
comparison
equal
deleted
inserted
replaced
44:af1bcb9a13c0 | 45:e474bae3795f |
---|---|
1999 char_u *cms_start; /* first part or the whole comment */ | 1999 char_u *cms_start; /* first part or the whole comment */ |
2000 int cms_slen = 0; /* length of cms_start */ | 2000 int cms_slen = 0; /* length of cms_start */ |
2001 char_u *cms_end; /* last part of the comment or NULL */ | 2001 char_u *cms_end; /* last part of the comment or NULL */ |
2002 int cms_elen = 0; /* length of cms_end */ | 2002 int cms_elen = 0; /* length of cms_end */ |
2003 char_u *s; | 2003 char_u *s; |
2004 char_u *p; | |
2004 int len; | 2005 int len; |
2005 int did1 = FALSE; | 2006 int did1 = FALSE; |
2006 int did2 = FALSE; | 2007 int did2 = FALSE; |
2007 | 2008 |
2008 /* Ignore leading and trailing white space in 'commentstring'. */ | 2009 /* Ignore leading and trailing white space in 'commentstring'. */ |
2031 | 2032 |
2032 for (s = str; *s != NUL; ) | 2033 for (s = str; *s != NUL; ) |
2033 { | 2034 { |
2034 len = 0; | 2035 len = 0; |
2035 if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) | 2036 if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) |
2036 { | |
2037 len = foldstartmarkerlen; | 2037 len = foldstartmarkerlen; |
2038 else if (STRNCMP(s, foldendmarker, foldendmarkerlen) == 0) | |
2039 len = foldendmarkerlen; | |
2040 if (len > 0) | |
2041 { | |
2038 if (VIM_ISDIGIT(s[len])) | 2042 if (VIM_ISDIGIT(s[len])) |
2039 ++len; | 2043 ++len; |
2040 } | 2044 |
2041 else if (STRNCMP(s, foldendmarker, foldendmarkerlen) == 0) | 2045 /* May remove 'commentstring' start. Useful when it's a double |
2042 { | 2046 * quote and we already removed a double quote. */ |
2043 len = foldendmarkerlen; | 2047 for (p = s; p > str && vim_iswhite(p[-1]); --p) |
2044 if (VIM_ISDIGIT(s[len])) | 2048 ; |
2045 ++len; | 2049 if (p >= str + cms_slen |
2050 && STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) | |
2051 { | |
2052 len += (s - p) + cms_slen; | |
2053 s = p - cms_slen; | |
2054 } | |
2046 } | 2055 } |
2047 else if (cms_end != NULL) | 2056 else if (cms_end != NULL) |
2048 { | 2057 { |
2049 if (!did1 && STRNCMP(s, cms_start, cms_slen) == 0) | 2058 if (!did1 && cms_slen > 0 && STRNCMP(s, cms_start, cms_slen) == 0) |
2050 { | 2059 { |
2051 len = cms_slen; | 2060 len = cms_slen; |
2052 did1 = TRUE; | 2061 did1 = TRUE; |
2053 } | 2062 } |
2054 else if (!did2 && STRNCMP(s, cms_end, cms_elen) == 0) | 2063 else if (!did2 && cms_elen > 0 |
2064 && STRNCMP(s, cms_end, cms_elen) == 0) | |
2055 { | 2065 { |
2056 len = cms_elen; | 2066 len = cms_elen; |
2057 did2 = TRUE; | 2067 did2 = TRUE; |
2058 } | 2068 } |
2059 } | 2069 } |