From cd864989ce412119bc76e9bef9cb77077844342d Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 22 Jan 2022 16:28:54 -0800 Subject: [PATCH] [c] Remove debugging output --- c/jobs.c | 14 -------------- c/main.c | 8 ++++---- c/utils.c | 4 ---- c/utils.h | 1 - 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/c/jobs.c b/c/jobs.c index f6f458b..e7c743d 100644 --- a/c/jobs.c +++ b/c/jobs.c @@ -35,15 +35,11 @@ job add_job(pid_t pid, char **argv) { j->id = get_next_id(); j->pid = pid; j->cmdline = array_cat(argv); - if (DEBUG) - printf("DEBUG: cmdline='%s'\n", j->cmdline); j->next = NULL; j->prev = NULL; for (i = job_list_head; i && i->next; i = i->next) { /* insert jobs in job_id order */ if (i->id > j->id) { /* insert BEFORE i */ - if (DEBUG) - printf("DEBUG: i=%i, i->next=%i, i->prev=%p\n", i->id, i->next->id, i->prev); j->next = i; j->prev = i->prev; if (i->prev) @@ -58,18 +54,12 @@ job add_job(pid_t pid, char **argv) { if (i == NULL) /* empty list */ { - if (DEBUG) - printf("DEBUG: i=%p, job_list_head=%p\n", i, job_list_head); job_list_head = j; } else if (!i->next) /* at the end, i->next == NULL */ { /* at this point, append the new job to the end of the list */ - if (DEBUG) - printf("DEBUG: i=%i\n", i->id); i->next = j; j->prev = i; } - if (DEBUG) - printf("DEBUG: job added: (%i,%i)\n", j->id, j->pid); num_jobs++; return j; } @@ -88,8 +78,6 @@ void delete_job(job j) { if (j->next) j->next->prev = j->prev; - if (DEBUG) - printf("DEBUG: str=%p\n", j->cmdline); xfree(j->cmdline); xfree(j); num_jobs--; @@ -103,7 +91,6 @@ void free_job_list(void) { job job_with_id(int job_id) { job j; for (j = job_list_head; j; j = j->next) { - /* printf("DEBUG: id=%i, j=%p:%i:%i\n", job_id, j, j->id, j->pid); */ if (j->id == job_id) return j; } @@ -113,7 +100,6 @@ job job_with_id(int job_id) { job job_with_pid(pid_t pid) { job j; for (j = job_list_head; j; j = j->next) { - printf("DEBUG: pid=%i, j=%p:%i:%i\n", pid, j, j->id, j->pid); if (j->pid == pid) return j; } diff --git a/c/main.c b/c/main.c index f365792..3832191 100644 --- a/c/main.c +++ b/c/main.c @@ -221,12 +221,12 @@ int process_command(char *line, options_t options) { wordexp_t words; int result = wordexp(line, &words, WRDE_SHOWERR); if (handle_wordexp_result(result, line) && words.we_wordc > 0) { - if (DEBUG || options->verbose) { + if (options->verbose) { int i; - printf("[DEBUG] args = { "); + fprintf(stderr, "[DEBUG] args = { "); for (i = 0; i < words.we_wordc; i++) - printf("'%s', ", words.we_wordv[i]); - printf("}\n"); + fprintf(stderr, "'%s', ", words.we_wordv[i]); + fprintf(stderr, "}\n"); } /* try the built-in commands */ if (cmd_matches("bg", words.we_wordv[0])) diff --git a/c/utils.c b/c/utils.c index 949304e..e179dc0 100644 --- a/c/utils.c +++ b/c/utils.c @@ -18,8 +18,6 @@ char *array_cat(char **array) { char *p = NULL, *str = NULL; int i, pos = 0; for (i = 0; array[i]; i++) { - if (DEBUG) - printf("DEBUG: array[%i]=%p:'%s'\n", i, array[i], array[i]); int len = strlen(array[i]); str = (char *)myxrealloc(str, pos + len + 1); p = str + pos; @@ -29,8 +27,6 @@ char *array_cat(char **array) { pos += len + 1; } *--p = '\0'; - if (DEBUG) - printf("DEBUG: str=%p\n", str); return str; } diff --git a/c/utils.h b/c/utils.h index 9eb6546..166c508 100644 --- a/c/utils.h +++ b/c/utils.h @@ -11,7 +11,6 @@ #include -#define DEBUG 1 #define MSGLEN 255 /* soft limit on message lengths */ /* these colours should be safe on dark and light backgrounds */