From 756cd4a4b820b3d10fadf41ad0e279b8c5d9618e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 18 Feb 2022 10:27:47 +0100 Subject: [PATCH] tweaks: store a result, to avoid calling a function twice --- src/text.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/text.c b/src/text.c index 00f74ee8..85d1bd40 100644 --- a/src/text.c +++ b/src/text.c @@ -2649,10 +2649,11 @@ void do_linter(void) if (onelint != pointer) { char *filename, *linestring, *colstring; char *complaint = copy_of(onelint); + char *spacer = strstr(complaint, " "); /* The recognized format is "filename:line:column: message", * where ":column" may be absent or be ",column" instead. */ - if ((filename = strtok(onelint, ":")) && strstr(complaint, " ")) { + if ((filename = strtok(onelint, ":")) && spacer) { if ((linestring = strtok(NULL, ":"))) { if ((colstring = strtok(NULL, " "))) { ssize_t linenumber = strtol(linestring, NULL, 10); @@ -2681,7 +2682,7 @@ void do_linter(void) curlint->filename = copy_of(filename); curlint->lineno = linenumber; curlint->colno = colnumber; - curlint->msg = copy_of(strstr(complaint, " ") + 1); + curlint->msg = copy_of(spacer + 1); if (lints == NULL) lints = curlint;