mirror of
https://https.git.savannah.gnu.org/git/groff.git
synced 2026-01-26 15:39:07 +00:00
Improve assertion messages.
* src/libs/libgroff/color.cpp (color::get_rgb, color::get_cmy) (color::get_cmyk, color::get_gray): * src/preproc/eqn/pile.cpp (pile_box::output) (matrix_box::output, column::debug_print) * src/preproc/eqn/common.cpp (common_output::rounded_box): * src/preproc/pic/lex.cpp (get_delimited): * src/preproc/pic/object.cpp (object_spec::position_rectangle) (object_spec::make_move, object_spec::make_line) (object_spec::make_object): * src/preproc/pic/tex.cpp (tex_output::spline) (tex_output::circle, tex_output::ellipse): * src/preproc/pic/troff.cpp (simple_output::line) (simple_output::ellipse, simple_output::circle): * src/preproc/refer/command.cpp (check_args): * src/preproc/refer/label.ypp (format_serial) (extractor_expr::evaluate): * src/utils/hpftodit/hpftodit.cpp (main): * src/utils/lkbib/lkbib.cpp (main): Replace `assert(0)` calls with communicative predicates. With this change, no `assert(0)` calls remain in groff.
This commit is contained in:
parent
6752ad1639
commit
9d210665e3
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
||||
2025-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
|
||||
|
||||
* src/libs/libgroff/color.cpp (color::get_rgb, color::get_cmy)
|
||||
(color::get_cmyk, color::get_gray):
|
||||
* src/preproc/eqn/pile.cpp (pile_box::output)
|
||||
(matrix_box::output, column::debug_print)
|
||||
* src/preproc/eqn/common.cpp (common_output::rounded_box):
|
||||
* src/preproc/pic/lex.cpp (get_delimited):
|
||||
* src/preproc/pic/object.cpp (object_spec::position_rectangle)
|
||||
(object_spec::make_move, object_spec::make_line)
|
||||
(object_spec::make_object):
|
||||
* src/preproc/pic/tex.cpp (tex_output::spline)
|
||||
(tex_output::circle, tex_output::ellipse):
|
||||
* src/preproc/pic/troff.cpp (simple_output::line)
|
||||
(simple_output::ellipse, simple_output::circle):
|
||||
* src/preproc/refer/command.cpp (check_args):
|
||||
* src/preproc/refer/label.ypp (format_serial)
|
||||
(extractor_expr::evaluate):
|
||||
* src/utils/hpftodit/hpftodit.cpp (main):
|
||||
* src/utils/lkbib/lkbib.cpp (main): Replace `assert(0)` calls
|
||||
with communicative predicates.
|
||||
|
||||
2025-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
|
||||
|
||||
* src/preproc/pic/lex.cpp (get_delimited): Drop `switch` case
|
||||
|
||||
@ -249,7 +249,7 @@ color::get_rgb(unsigned int *r, unsigned int *g, unsigned int *b) const
|
||||
*r = *g = *b = Gray;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of color scheme");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -280,7 +280,7 @@ color::get_cmy(unsigned int *c, unsigned int *m, unsigned int *y) const
|
||||
*c = *m = *y = MAX_COLOR_VAL - Gray;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of color scheme");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -330,7 +330,7 @@ void color::get_cmyk(unsigned int *c, unsigned int *m,
|
||||
*k = MAX_COLOR_VAL - Gray;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of color scheme");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -355,7 +355,7 @@ void color::get_gray(unsigned int *g) const
|
||||
*g = Gray;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of color scheme");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ void pile_box::output()
|
||||
uid, col.p[i]->uid);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
col.p[i]->output();
|
||||
printf("\\h'-\\n[" WIDTH_FORMAT "]u'", col.p[i]->uid);
|
||||
@ -95,7 +95,7 @@ void pile_box::output()
|
||||
col.p[i]->uid, uid);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
if (i != col.len - 1)
|
||||
printf("\\v'\\n[" BASELINE_SEP_FORMAT "]u'", uid);
|
||||
@ -117,7 +117,7 @@ void pile_box::output()
|
||||
av = "center";
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
printf("<mtable columnalign='%s'>", av);
|
||||
for (int i = 0; i < col.len; i++) {
|
||||
@ -216,7 +216,7 @@ void matrix_box::output()
|
||||
uid, i, p[i]->p[j]->uid);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
p[i]->p[j]->output();
|
||||
printf("\\h'-\\n[" WIDTH_FORMAT "]u'", p[i]->p[j]->uid);
|
||||
@ -232,7 +232,7 @@ void matrix_box::output()
|
||||
p[i]->p[j]->uid, uid, i);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
if (j != p[i]->len - 1)
|
||||
printf("\\v'\\n[" BASELINE_SEP_FORMAT "]u'", uid);
|
||||
@ -263,7 +263,7 @@ void matrix_box::output()
|
||||
av = "center";
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
printf("<mtd columnalign='%s'>", av);
|
||||
p[j]->p[i]->output();
|
||||
@ -349,7 +349,7 @@ void column::debug_print(const char *s)
|
||||
c = 'c';
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of column alignment");
|
||||
}
|
||||
fprintf(stderr, "%c%s %d { ", c, s, space);
|
||||
list_debug_print(" above ");
|
||||
|
||||
@ -342,7 +342,7 @@ void common_output::rounded_box(const position ¢, const distance &dim,
|
||||
solid_rounded_box(cent, dim, rad, lt);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1392,7 +1392,7 @@ int get_delimited()
|
||||
state = IN_STRING_QUOTED;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of lexical analyzer state");
|
||||
}
|
||||
if (state == DELIM_END)
|
||||
break;
|
||||
|
||||
@ -902,7 +902,7 @@ int object_spec::position_rectangle(rectangle_object *p,
|
||||
motion.x = p->width()/2.0;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of motion direction");
|
||||
}
|
||||
if (flags & HAS_AT) {
|
||||
pos = at;
|
||||
@ -1205,7 +1205,7 @@ graphic_object *object_spec::make_move(position *curpos, direction *dirp)
|
||||
segment_pos.x = segment_width;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of motion direction");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1567,7 +1567,7 @@ linear_object *object_spec::make_line(position *curpos, direction *dirp)
|
||||
segment_pos.x = segment_width;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of motion direction");
|
||||
}
|
||||
}
|
||||
segment_list = new segment(segment_pos, segment_is_absolute, segment_list);
|
||||
@ -1693,7 +1693,7 @@ linear_object *object_spec::make_line(position *curpos, direction *dirp)
|
||||
p->set_vertex_number(vertex_number);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of picture object type");
|
||||
}
|
||||
have_last_line = 1;
|
||||
last_line = endpos - startpos;
|
||||
@ -2045,7 +2045,7 @@ object *object_spec::make_object(position *curpos, direction *dirp)
|
||||
case MARK_OBJECT:
|
||||
case OTHER_OBJECT:
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of picture object type");
|
||||
break;
|
||||
}
|
||||
if (obj) {
|
||||
|
||||
@ -239,7 +239,7 @@ void tex_output::spline(const position &start, const position *v, int n,
|
||||
printf(" %.3f", lt.dash_width/scale);
|
||||
break;
|
||||
case line_type::invisible:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
fputs("}%\n", stdout);
|
||||
}
|
||||
@ -312,7 +312,7 @@ void tex_output::circle(const position ¢, double rad,
|
||||
dotted_circle(cent, rad, lt);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ void tex_output::ellipse(const position ¢, const distance &dim,
|
||||
dotted_ellipse(cent, dim / scale, lt);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ void simple_output::line(const position &start, const position *v,
|
||||
case line_type::invisible:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
pos = v[i];
|
||||
}
|
||||
@ -190,7 +190,7 @@ void simple_output::circle(const position ¢, double rad,
|
||||
simple_circle(0, cent, rad);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ void simple_output::ellipse(const position ¢, const distance &dim,
|
||||
simple_ellipse(0, cent, dim);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of line type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -739,7 +739,7 @@ static int check_args(const char *types, const char *name,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of command type");
|
||||
}
|
||||
if (types[1] == '?')
|
||||
types += 2;
|
||||
|
||||
@ -620,7 +620,7 @@ static const char *format_serial(char c, int n)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of register format");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
@ -715,7 +715,7 @@ void extractor_expr::evaluate(int tentative, const reference &ref,
|
||||
result.append(end, temp.contents() + temp.length() - end);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of part in expression evaluator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ main(int argc, char **argv)
|
||||
exit(2);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of command-line option");
|
||||
}
|
||||
|
||||
if (debug_flag && argc - optind < 1)
|
||||
|
||||
@ -119,7 +119,7 @@ int main(int argc, char **argv)
|
||||
exit(2);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
assert(0 == "unhandled case of command-line option");
|
||||
}
|
||||
if (optind >= argc) {
|
||||
usage(stderr);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user