Skip to content

Commit

Permalink
fix comment error at intercative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ysw421 committed Jul 21, 2024
1 parent 6ffe1af commit 033924e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

echo "This shell file will check dependencies, install if necessary, and build ORORA."
sudo echo "This shell file will check dependencies, install if necessary, and build ORORA."


command_exists() {
command -v "$1" >/dev/null 2>&1
Expand Down Expand Up @@ -80,11 +81,10 @@ if [ $? -ne 0 ]; then
exit 1
fi

echo "orora has been installed successfully."
echo "orora has been installed successfully!"
echo "You can now run 'orora' from any directory."

# Optional: Set up man page or help documentation
# sudo cp orora.1 /usr/local/share/man/man1/
# sudo mandb

echo "Installation process completed."
7 changes: 4 additions & 3 deletions src/loader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ bool init_orora();
void handle_sigint(int sig)
{
fprintf(stderr, "\n");
fprintf(stderr, DIALOGUE);
// fprintf(stderr, DIALOGUE);
}

void handle_sigterm(int sig)
{
fprintf(stderr, "\n");
exit(0);
}

bool INTERACTIVE_MODE = 0;
Expand Down Expand Up @@ -141,8 +142,8 @@ int main(int argc, char** argv)
{
change_interactive_mode(1);

signal(SIGINT, handle_sigint);
signal(SIGTERM, handle_sigterm);
// signal(SIGINT, handle_sigint);
// signal(SIGTERM, handle_sigterm);
fflush(stdout);

int port = START_PORT;
Expand Down
2 changes: 0 additions & 2 deletions src/server/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void run_client(int port)
}
else if (n == 0)
{
printf("Server disconnected\n");
return;
}
else if (errno != EAGAIN && errno != EWOULDBLOCK)
Expand Down Expand Up @@ -141,7 +140,6 @@ void run_client(int port)
}
else if (n == 0)
{
printf("Server disconnected\n");
free(response);
return;
}
Expand Down
30 changes: 25 additions & 5 deletions src/server/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ int is_end_interactive_line(Lexer* root)

void run_daemon()
{
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
// signal(SIGTERM, handle_signal);
// signal(SIGINT, handle_signal);

char buffer[BUFFER_SIZE];

Expand All @@ -79,7 +79,7 @@ void run_daemon()
if (is_first_line)
{
input = malloc(num_read + 1);
if (input == NULL)
if (input == (void*) 0)
{
syslog(LOG_ERR, "Memory allocation failed");
break;
Expand All @@ -92,7 +92,7 @@ void run_daemon()
else
{
char *temp = realloc(input, len_input + num_read + 1);
if (temp == NULL)
if (temp == (void*) 0)
{
syslog(LOG_ERR, "Memory reallocation failed");
free(input);
Expand All @@ -112,6 +112,20 @@ void run_daemon()
*len_p = (off_t) len_input;

Lexer* root = init_lexer(input, len_p);

Lexer* lexer_null_checker = malloc(sizeof(Lexer));
memcpy(lexer_null_checker, root, sizeof(Lexer));
if (lexer_get_token(lexer_null_checker) == (void*) 0)
{
free(lexer_null_checker);
orora_write("", ORORA_STATUS_SUCCESS);
continue;
}
free(lexer_null_checker);

// #include "develop/develop_mode.h"
// printf("root_size: %d\n", root->size);
// print_tokens(root);
int right_space = is_end_interactive_line(root);
if (right_space == 0)
{
Expand All @@ -137,7 +151,13 @@ void run_daemon()
{
if (new_value->type != AST_VALUE_NULL || !(ast->type == AST_FUNCTION
|| ast->type == AST_CODE
|| (ast->type == AST_VALUE && ast->value.value_v->stack->type == AST_VALUE_CODE)))
|| ast->type == AST_FOR
|| ast->type == AST_WHILE
|| ast->type == AST_CASES
|| (ast->type == AST_VALUE && (ast->value.value_v->stack->type == AST_VALUE_CODE)
)
)
)
visitor_print_function_value(new_value);
orora_write("\n", ORORA_STATUS_SUCCESS);
}
Expand Down

0 comments on commit 033924e

Please sign in to comment.