Skip to content

Commit

Permalink
infer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RealMelkor committed Jun 25, 2022
1 parent d02bc3e commit a996946
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ int input(struct tb_event ev) {
int firstspace = 0;
while (i + ignore < tab->page.data_len) {
if (tab->page.data[i + ignore] != '\n') {
ignore += 2 + firstspace;
i += 2 + firstspace;
break;
}
if (tab->page.data[i + ignore] == ' ') {
Expand All @@ -411,6 +411,8 @@ int input(struct tb_event ev) {
ignore++;
firstspace = 1;
}
if (i > tab->page.data_len)
break;
}
if (lines && !strncasecmp(&client.input.field[1],
&tab->page.data[i],
Expand Down
10 changes: 8 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ int main(int argc, char* argv[]) {
const char* term = getenv("TERM");
if (!term) {
printf("Failed to detect terminal\n");
#if defined(__FreeBSD__) || defined(__linux__)
close(ttyfd);
#endif
return -1;
}

Expand All @@ -47,6 +50,9 @@ int main(int argc, char* argv[]) {

if (sandbox_init()) {
printf("Failed to sandbox\n");
#if defined(__FreeBSD__) || defined(__linux__)
close(ttyfd);
#endif
return -1;
}

Expand All @@ -64,7 +70,7 @@ int main(int argc, char* argv[]) {
if (tb_set_output_mode(TB_OUTPUT_256)) {
printf("Terminal doesn't support 256 colors mode\n");
gmi_free();
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__linux__)
close(ttyfd);
#endif
return -1;
Expand Down Expand Up @@ -95,7 +101,7 @@ int main(int argc, char* argv[]) {
if (input(ev)) break;
}
tb_shutdown();
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__linux__)
close(ttyfd);
#endif
gmi_free();
Expand Down

0 comments on commit a996946

Please sign in to comment.