Skip to content

Commit

Permalink
Fix multiline outputs only showing the first line
Browse files Browse the repository at this point in the history
  • Loading branch information
jdholtz committed Dec 18, 2024
1 parent 5f8e528 commit fa5099a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,18 +539,18 @@ static void process_cb(GObject* source_object, GAsyncResult* res, gpointer user_
error = NULL;
}

gsize bytes_read = 0;
unsigned int stdout_bufsize = 4096;
char stdout_buf[stdout_bufsize];
g_input_stream_read_all(stdout_stream, stdout_buf, stdout_bufsize, NULL, NULL, &error);
g_input_stream_read_all(stdout_stream, stdout_buf, stdout_bufsize, &bytes_read, NULL, &error);

if (error != NULL) {
g_error("Process errored with: %s", error->message);
g_error_free(error);
error = NULL;
}

unsigned int line_length = strcspn(stdout_buf, "\n");
*last_result = g_strndup(stdout_buf, line_length);
*last_result = g_strndup(stdout_buf, bytes_read - 1);
g_input_stream_close(stdout_stream, NULL, &error);

if (error != NULL) {
Expand Down

0 comments on commit fa5099a

Please sign in to comment.