Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ static int get_input(char player)
parseX = 1;
for (int i = 0; i < (r - 1); i++) {
if (isalpha(line[i]) && parseX) {
// input has multiple column alphabets
if (i > 0 && isalpha(line[i])) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite late to respond. But the isalpha(line[i]) check seems to be checked twice in the same path, so it looks like a redundant condition to me?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite late to respond. But the isalpha(line[i]) check seems to be checked twice in the same path, so it looks like a redundant condition to me?

Inputs like aa previously showed "index exceeds board size," which wasn’t accurate since the issue was multiple column letters. Also, isalpha(line[i]) is checked twice, which might be redundant, there could be a better way to handle this. I'll look into it!

printf(
"Invalid operation: multiple column alphabets "
"detected\n");
x = y = 0;
break;
}
x = x * 26 + (tolower(line[i]) - 'a' + 1);
if (x > BOARD_SIZE) {
// could be any value in [BOARD_SIZE + 1, INT_MAX]
Expand Down Expand Up @@ -92,7 +100,7 @@ static int get_input(char player)
x = y = 0;
break;
}
// input does not have row number
// input does not have row numbers
if (x > 0 && x <= BOARD_SIZE && parseX == 1)
printf("Invalid operation: No row number\n");
x -= 1;
Expand Down