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.
This commit is contained in:
Benno Schulenberg 2022-02-17 14:16:32 +01:00
parent 165da9b447
commit 1b186fcff3
1 changed files with 10 additions and 11 deletions

View File

@ -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;