return line;
}
+/*
+ * Return TRUE if "p" points at a "#" but not at "#{".
+ */
+ static int
+comment_start(char_u *p)
+{
+ return p[0] == '#' && p[1] != '{';
+}
+
/*
* If "*arg" is at the end of the line, advance to the next line.
+ * Also when "whitep" points to white space and "*arg" is on a "#".
* Return FAIL if beyond the last line, "*arg" is unmodified then.
*/
static int
-may_get_next_line(char_u **arg, cctx_T *cctx)
+may_get_next_line(char_u *whitep, char_u **arg, cctx_T *cctx)
{
- if (**arg == NUL)
+ if (**arg == NUL || (VIM_ISWHITE(*whitep) && comment_start(*arg)))
{
char_u *next = next_line_from_context(cctx);
static int
compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
{
- char_u *p = *arg;
+ char_u *p = *arg;
+ char_u *whitep = *arg;
for (;;)
{
- if (*p == NUL)
+ while (*p == NUL || (VIM_ISWHITE(*whitep) && comment_start(p)))
{
p = next_line_from_context(cctx);
if (p == NULL)
- break;
+ goto failret;
+ whitep = (char_u *)" ";
p = skipwhite(p);
}
if (*p == ')')
if (*p != NUL && !VIM_ISWHITE(*p))
semsg(_(e_white_after), ",");
}
+ whitep = p;
p = skipwhite(p);
}
-
+failret:
emsg(_(e_missing_close));
return FAIL;
}
compile_list(char_u **arg, cctx_T *cctx)
{
char_u *p = skipwhite(*arg + 1);
+ char_u *whitep = *arg + 1;
int count = 0;
for (;;)
{
- if (*p == NUL)
+ while (*p == NUL || (VIM_ISWHITE(*whitep) && comment_start(p)))
{
p = next_line_from_context(cctx);
if (p == NULL)
semsg(_(e_list_end), *arg);
return FAIL;
}
+ whitep = (char_u *)" ";
p = skipwhite(p);
}
if (*p == ']')
++count;
if (*p == ',')
++p;
+ whitep = p;
p = skipwhite(p);
}
*arg = p;
int count = 0;
dict_T *d = dict_alloc();
dictitem_T *item;
+ char_u *whitep = *arg;
+ char_u *p;
if (d == NULL)
return FAIL;
{
char_u *key = NULL;
- if (**arg == NUL || (literal && **arg == '"'))
+ while (**arg == NUL || (literal && **arg == '"')
+ || (VIM_ISWHITE(*whitep) && comment_start(*arg)))
{
*arg = next_line_from_context(cctx);
if (*arg == NULL)
goto failret;
+ whitep = (char_u *)" ";
*arg = skipwhite(*arg);
}
if (literal)
{
- char_u *p = to_name_end(*arg, !literal);
+ char_u *end = to_name_end(*arg, !literal);
- if (p == *arg)
+ if (end == *arg)
{
semsg(_("E1014: Invalid key: %s"), *arg);
return FAIL;
}
- key = vim_strnsave(*arg, p - *arg);
+ key = vim_strnsave(*arg, end - *arg);
if (generate_PUSHS(cctx, key) == FAIL)
return FAIL;
- *arg = p;
+ *arg = end;
}
else
{
return FAIL;
}
+ whitep = *arg + 1;
*arg = skipwhite(*arg + 1);
- if (**arg == NUL)
+ while (**arg == NUL || (VIM_ISWHITE(*whitep) && comment_start(*arg)))
{
*arg = next_line_from_context(cctx);
if (*arg == NULL)
goto failret;
+ whitep = (char_u *)" ";
*arg = skipwhite(*arg);
}
return FAIL;
++count;
- if (**arg == NUL || *skipwhite(*arg) == '"')
+ whitep = *arg;
+ p = skipwhite(*arg);
+ while (*p == NUL || (VIM_ISWHITE(*whitep) && comment_start(p)))
{
*arg = next_line_from_context(cctx);
if (*arg == NULL)
goto failret;
+ whitep = (char_u *)" ";
*arg = skipwhite(*arg);
+ p = *arg;
}
if (**arg == '}')
break;
semsg(_(e_missing_dict_comma), *arg);
goto failret;
}
+ whitep = *arg + 1;
*arg = skipwhite(*arg + 1);
}
*arg = *arg + 1;
// Allow for following comment, after at least one space.
- if (VIM_ISWHITE(**arg) && *skipwhite(*arg) == '"')
+ p = skipwhite(*arg);
+ if (VIM_ISWHITE(**arg) && (*p == '"' || comment_start(p)))
*arg += STRLEN(*arg);
dict_unref(d);
return FAIL;
}
*arg = skipwhite(op + 1);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(op + 1, arg, cctx) == FAIL)
return FAIL;
// get the second variable
}
*arg = skipwhite(op + oplen);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(op + oplen, arg, cctx) == FAIL)
return FAIL;
// get the second variable
// get the second variable
*arg = skipwhite(p + len);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(p + len, arg, cctx) == FAIL)
return FAIL;
if (compile_expr5(arg, cctx) == FAIL)
// eval the next expression
*arg = skipwhite(p + 2);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(p + 2, arg, cctx) == FAIL)
return FAIL;
if ((opchar == '|' ? compile_expr3(arg, cctx)
// evaluate the second expression; any type is accepted
*arg = skipwhite(p + 1);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(p + 1, arg, cctx) == FAIL)
return FAIL;
if (compile_expr1(arg, cctx) == FAIL)
// evaluate the third expression
*arg = skipwhite(p + 1);
- if (may_get_next_line(arg, cctx) == FAIL)
+ if (may_get_next_line(p + 1, arg, cctx) == FAIL)
return FAIL;
if (compile_expr1(arg, cctx) == FAIL)