This commit is contained in:
iceman1001 2019-04-07 18:42:47 +02:00
parent c881acd631
commit 98d24a4fe8

View file

@ -2960,10 +2960,19 @@ static int trex_class(TRex *exp) {
while (*exp->_p != ']' && exp->_p != exp->_eol) { while (*exp->_p != ']' && exp->_p != exp->_eol) {
if (*exp->_p == '-' && first != -1) { if (*exp->_p == '-' && first != -1) {
int r, t; int r, t;
if (*exp->_p++ == ']') trex_error(exp, _SC("unfinished range")); if (*exp->_p++ == ']') {
trex_error(exp, _SC("unfinished range"));
}
r = trex_newnode(exp, OP_RANGE); r = trex_newnode(exp, OP_RANGE);
if (first > *exp->_p) trex_error(exp, _SC("invalid range")); if (first > *exp->_p) {
if (exp->_nodes[first].type == OP_CCLASS) trex_error(exp, _SC("cannot use character classes in ranges")); trex_error(exp, _SC("invalid range"));
}
if (exp->_nodes[first].type == OP_CCLASS) {
trex_error(exp, _SC("cannot use character classes in ranges"));
}
exp->_nodes[r].left = exp->_nodes[first].type; exp->_nodes[r].left = exp->_nodes[first].type;
t = trex_escapechar(exp); t = trex_escapechar(exp);
exp->_nodes[r].right = t; exp->_nodes[r].right = t;
@ -2984,8 +2993,6 @@ static int trex_class(TRex *exp) {
if (first != -1) { if (first != -1) {
int c = first; int c = first;
exp->_nodes[chain].next = c; exp->_nodes[chain].next = c;
chain = c;
first = -1;
} }
/* hack? */ /* hack? */
exp->_nodes[ret].left = exp->_nodes[ret].next; exp->_nodes[ret].left = exp->_nodes[ret].next;
@ -4541,8 +4548,9 @@ void arg_print_formatted(FILE *fp,
const unsigned colwidth = (rmargin - lmargin) + 1; const unsigned colwidth = (rmargin - lmargin) + 1;
/* Someone doesn't like us... */ /* Someone doesn't like us... */
if (line_end < line_start) if (line_end == line_start) {
{ fprintf(fp, "%s\n", text); } fprintf(fp, "%s\n", text);
}
while (line_end - 1 > line_start) { while (line_end - 1 > line_start) {
/* Eat leading whitespaces. This is essential because while /* Eat leading whitespaces. This is essential because while