X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fmessage.c;h=07cc270787bab365b6b2a5f4e7d568e8ceeb0d3c;hb=dfb794fa53a423c1f20c3a21811c0bec4a64a916;hp=83c7320168eef5a8ca4cf68baaa6c129bd98dd0d;hpb=510cc9dd9baf3108ba55cfb7893384517c9930b4;p=pspp diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 83c7320168..07cc270787 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -112,6 +112,28 @@ msg_set_handler (const struct msg_handler *handler) msg_handler = *handler; } +/* msg_point. */ + +/* Takes POINT, adds to it the syntax in SYNTAX, incrementing the line number + for each new-line in SYNTAX and the column number for each column, and + returns the result. */ +struct msg_point +msg_point_advance (struct msg_point point, struct substring syntax) +{ + for (;;) + { + size_t newline = ss_find_byte (syntax, '\n'); + if (newline == SIZE_MAX) + break; + point.line++; + point.column = 1; + ss_advance (&syntax, newline + 1); + } + + point.column += ss_utf8_count_columns (syntax); + return point; +} + /* msg_location. */ void @@ -174,6 +196,16 @@ msg_location_merge (struct msg_location **dstp, const struct msg_location *src) dst->end = src->end; } +struct msg_location * +msg_location_merged (const struct msg_location *a, + const struct msg_location *b) +{ + struct msg_location *new = msg_location_dup (a); + if (b) + msg_location_merge (&new, b); + return new; +} + struct msg_location * msg_location_dup (const struct msg_location *src) { @@ -391,7 +423,7 @@ msg_to_string (const struct msg *m) int c0 = ln == l0 ? loc->start.column : 1; int c1 = ln == l1 ? loc->end.column : ss_utf8_count_columns (line); - if (c0 > 0 && c1 >= c0) + if (c0 > 0 && c1 >= c0 && !loc->omit_underlines) { ds_put_cstr (&s, "\n |"); ds_put_byte_multiple (&s, ' ', c0);