commit 1b186fcff3458c5cd7cfa7cf26c8fb30380e79ec
parent 165da9b44791ddf495c843e066985ee6df6053f5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 17 Feb 2022 14:16:32 +0100
tweaks: rename two more variables, and drop unneeded initializations
Also, make sure that there is a space in the complaint so that the
later strstr() call cannot fail. And reshuffle a line.
Diffstat:
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -2647,16 +2647,16 @@ void do_linter(void)
if ((*pointer == '\r') || (*pointer == '\n')) {
*pointer = '\0';
if (onelint != pointer) {
- char *filename = NULL, *linestr = NULL, *maybecol = NULL;
+ char *filename, *linestring, *colstring;
char *complaint = copy_of(onelint);
/* The recognized format is "filename:line:column: message",
* where ":column" may be absent or be ",column" instead. */
- if ((filename = strtok(onelint, ":")) != NULL) {
- if ((linestr = strtok(NULL, ":")) != NULL) {
- if ((maybecol = strtok(NULL, " ")) != NULL) {
- ssize_t linenumber = strtol(linestr, NULL, 10);
- ssize_t colnumber = strtol(maybecol, NULL, 10);
+ if ((filename = strtok(onelint, ":")) && strstr(complaint, " ")) {
+ if ((linestring = strtok(NULL, ":"))) {
+ if ((colstring = strtok(NULL, " "))) {
+ ssize_t linenumber = strtol(linestring, NULL, 10);
+ ssize_t colnumber = strtol(colstring, NULL, 10);
if (linenumber <= 0) {
free(complaint);
@@ -2665,11 +2665,10 @@ void do_linter(void)
}
if (colnumber <= 0) {
- strtok(linestr, ",");
- if ((maybecol = strtok(NULL, ",")) != NULL)
- colnumber = strtol(maybecol, NULL, 10);
- else
- colnumber = 1;
+ colnumber = 1;
+ strtok(linestring, ",");
+ if ((colstring = strtok(NULL, ",")))
+ colnumber = strtol(colstring, NULL, 10);
}
parsesuccess = TRUE;