version 1.19, 2009/07/19 21:26:27 |
version 1.22, 2009/08/19 14:44:35 |
|
|
* There's no limit to the number or arguments that may be allocated. |
* There's no limit to the number or arguments that may be allocated. |
*/ |
*/ |
|
|
/* FIXME .Bf Li raises "macro-like parameter". */ |
|
|
|
#define ARGS_DELIM (1 << 1) |
#define ARGS_DELIM (1 << 1) |
#define ARGS_TABSEP (1 << 2) |
#define ARGS_TABSEP (1 << 2) |
|
|
Line 421 args(struct mdoc *m, int line, int *pos, |
|
Line 419 args(struct mdoc *m, int line, int *pos, |
|
*/ |
*/ |
|
|
if (ARGS_TABSEP & fl) { |
if (ARGS_TABSEP & fl) { |
/* Scan ahead to unescaped tab. */ |
/* Scan ahead to tab (can't be escaped). */ |
p = strchr(*v, '\t'); |
p = strchr(*v, '\t'); |
|
|
/* Scan ahead to unescaped `Ta'. */ |
/* Scan ahead to unescaped `Ta'. */ |
Line 434 args(struct mdoc *m, int line, int *pos, |
|
Line 432 args(struct mdoc *m, int line, int *pos, |
|
break; |
break; |
} |
} |
|
|
/* Choose delimiter tab/Ta. */ |
/* |
if (p && pp) |
* Adjust new-buffer position to be beyond delimiter |
p = (p < pp ? p : pp); |
* mark (e.g., Ta -> end + 2). |
else if ( ! p && pp) |
*/ |
|
if (p && pp) { |
|
*pos += pp < p ? 2 : 1; |
|
p = pp < p ? pp : p; |
|
} else if (p && ! pp) { |
|
*pos += 1; |
|
} else if (pp && ! p) { |
p = pp; |
p = pp; |
|
*pos += 2; |
|
} else |
|
p = strchr(*v, 0); |
|
|
/* Strip delimiter's preceding whitespace. */ |
/* Whitespace check for eoln case... */ |
/* FIXME: escaped whitespace? */ |
if (0 == *p && ' ' == *(p - 1)) |
if (p && p > *v) { |
|
pp = p - 1; |
|
while (pp > *v && ' ' == *pp) |
|
pp--; |
|
if (pp == *v && ' ' == *pp) |
|
*pp = 0; |
|
else if (' ' == *pp) |
|
*(pp + 1) = 0; |
|
} |
|
|
|
/* ...in- and proceding whitespace. */ |
|
if (p && ('\t' != *p)) { |
|
*p++ = 0; |
|
*p++ = 0; |
|
} else if (p) |
|
*p++ = 0; |
|
|
|
if (p) { |
|
while (' ' == *p) |
|
p++; |
|
if (0 != *p) |
|
*(p - 1) = 0; |
|
*pos += (int)(p - *v); |
|
} |
|
|
|
/* Some warnings, if applicable. */ |
|
if (p && 0 == *p) |
|
if ( ! mdoc_pwarn(m, line, *pos, ECOLEMPTY)) |
|
return(ARGS_ERROR); |
|
if (p && 0 == *p && p > *v && ' ' == *(p - 1)) |
|
if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) |
if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) |
return(ARGS_ERROR); |
return(ARGS_ERROR); |
|
|
/* Non-eoln case returns now. */ |
*pos += (int)(p - *v); |
if (p) |
|
return(ARGS_PHRASE); |
|
|
|
/* Configure the eoln case, too. */ |
/* Strip delimiter's preceding whitespace. */ |
p = strchr(*v, 0); |
pp = p - 1; |
assert(p); |
while (pp > *v && ' ' == *pp) { |
|
if (pp > *v && '\\' == *(pp - 1)) |
|
break; |
|
pp--; |
|
} |
|
*(pp + 1) = 0; |
|
|
if (p > *v && ' ' == *(p - 1)) |
/* Strip delimiter's proceeding whitespace. */ |
if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) |
for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++) |
return(ARGS_ERROR); |
/* Skip ahead. */ ; |
*pos += (int)(p - *v); |
|
|
|
return(ARGS_PHRASE); |
return(ARGS_PHRASE); |
} |
} |