From ed02cafaf584666fae23a270a6b989259cd8c989 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 25 Jul 2016 14:43:59 -0300 Subject: [PATCH] sch2fig/sch.c (dump_fields): break into two functions; make more "const" "const" may come in handy at a later stage, when we want to keep things around for a bit longer. --- sch2fig/sch.c | 62 +++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/sch2fig/sch.c b/sch2fig/sch.c index cd0ec0a..fc3cf94 100644 --- a/sch2fig/sch.c +++ b/sch2fig/sch.c @@ -150,45 +150,49 @@ static bool parse_field(struct sch_ctx *ctx, const char *line) } +static void dump_field(const struct sch_field *field, int m[6]) +{ + struct text txt = field->txt; + int dx, dy; + + dx = txt.x - m[0]; + dy = txt.y - m[3]; + txt.x = mx(dx, dy, m); + txt.y = my(dx, dy, m); + + text_rot(&txt, matrix_to_angle(m)); + + switch (txt.rot) { + case 180: + text_rot(&txt, 180); + txt.hor = text_flip(txt.hor); + txt.vert = text_flip(txt.vert); + break; + case 270: + text_rot(&txt, 180); + txt.vert = text_flip(txt.vert); + txt.hor = text_flip(txt.hor); + break; + default: + break; + } + + text_fig(&txt, COLOR_FIELD, LAYER_FIELD); +} + + static void dump_fields(struct sch_field *fields, int m[6]) { - while (fields) { struct text *txt = &fields->txt; - struct sch_field *next; - int dx, dy; + struct sch_field *next = fields->next; - next = fields->next; - - dx = txt->x - m[0]; - dy = txt->y - m[3]; - txt->x = mx(dx, dy, m); - txt->y = my(dx, dy, m); - - text_rot(txt, matrix_to_angle(m)); - - switch (txt->rot) { - case 180: - text_rot(txt, 180); - txt->hor = text_flip(txt->hor); - txt->vert = text_flip(txt->vert); - break; - case 270: - text_rot(txt, 180); - txt->vert = text_flip(txt->vert); - txt->hor = text_flip(txt->hor); - break; - default: - break; - } - - text_fig(txt, COLOR_FIELD, LAYER_FIELD); + dump_field(fields, m); text_free(txt); free(fields); fields = next; } - }