mirror of
https://github.com/samsonjs/csc360-a1-shell.git
synced 2026-03-25 08:45:52 +00:00
[c] Remove debugging output
This commit is contained in:
parent
62b2bd19e2
commit
cd864989ce
4 changed files with 4 additions and 23 deletions
14
c/jobs.c
14
c/jobs.c
|
|
@ -35,15 +35,11 @@ job add_job(pid_t pid, char **argv) {
|
||||||
j->id = get_next_id();
|
j->id = get_next_id();
|
||||||
j->pid = pid;
|
j->pid = pid;
|
||||||
j->cmdline = array_cat(argv);
|
j->cmdline = array_cat(argv);
|
||||||
if (DEBUG)
|
|
||||||
printf("DEBUG: cmdline='%s'\n", j->cmdline);
|
|
||||||
j->next = NULL;
|
j->next = NULL;
|
||||||
j->prev = NULL;
|
j->prev = NULL;
|
||||||
|
|
||||||
for (i = job_list_head; i && i->next; i = i->next) { /* insert jobs in job_id order */
|
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 (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->next = i;
|
||||||
j->prev = i->prev;
|
j->prev = i->prev;
|
||||||
if (i->prev)
|
if (i->prev)
|
||||||
|
|
@ -58,18 +54,12 @@ job add_job(pid_t pid, char **argv) {
|
||||||
|
|
||||||
if (i == NULL) /* empty list */
|
if (i == NULL) /* empty list */
|
||||||
{
|
{
|
||||||
if (DEBUG)
|
|
||||||
printf("DEBUG: i=%p, job_list_head=%p\n", i, job_list_head);
|
|
||||||
job_list_head = j;
|
job_list_head = j;
|
||||||
} else if (!i->next) /* at the end, i->next == NULL */
|
} else if (!i->next) /* at the end, i->next == NULL */
|
||||||
{ /* at this point, append the new job to the end of the list */
|
{ /* 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;
|
i->next = j;
|
||||||
j->prev = i;
|
j->prev = i;
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
|
||||||
printf("DEBUG: job added: (%i,%i)\n", j->id, j->pid);
|
|
||||||
num_jobs++;
|
num_jobs++;
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +78,6 @@ void delete_job(job j) {
|
||||||
if (j->next)
|
if (j->next)
|
||||||
j->next->prev = j->prev;
|
j->next->prev = j->prev;
|
||||||
|
|
||||||
if (DEBUG)
|
|
||||||
printf("DEBUG: str=%p\n", j->cmdline);
|
|
||||||
xfree(j->cmdline);
|
xfree(j->cmdline);
|
||||||
xfree(j);
|
xfree(j);
|
||||||
num_jobs--;
|
num_jobs--;
|
||||||
|
|
@ -103,7 +91,6 @@ void free_job_list(void) {
|
||||||
job job_with_id(int job_id) {
|
job job_with_id(int job_id) {
|
||||||
job j;
|
job j;
|
||||||
for (j = job_list_head; j; j = j->next) {
|
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)
|
if (j->id == job_id)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +100,6 @@ job job_with_id(int job_id) {
|
||||||
job job_with_pid(pid_t pid) {
|
job job_with_pid(pid_t pid) {
|
||||||
job j;
|
job j;
|
||||||
for (j = job_list_head; j; j = j->next) {
|
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)
|
if (j->pid == pid)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
c/main.c
8
c/main.c
|
|
@ -221,12 +221,12 @@ int process_command(char *line, options_t options) {
|
||||||
wordexp_t words;
|
wordexp_t words;
|
||||||
int result = wordexp(line, &words, WRDE_SHOWERR);
|
int result = wordexp(line, &words, WRDE_SHOWERR);
|
||||||
if (handle_wordexp_result(result, line) && words.we_wordc > 0) {
|
if (handle_wordexp_result(result, line) && words.we_wordc > 0) {
|
||||||
if (DEBUG || options->verbose) {
|
if (options->verbose) {
|
||||||
int i;
|
int i;
|
||||||
printf("[DEBUG] args = { ");
|
fprintf(stderr, "[DEBUG] args = { ");
|
||||||
for (i = 0; i < words.we_wordc; i++)
|
for (i = 0; i < words.we_wordc; i++)
|
||||||
printf("'%s', ", words.we_wordv[i]);
|
fprintf(stderr, "'%s', ", words.we_wordv[i]);
|
||||||
printf("}\n");
|
fprintf(stderr, "}\n");
|
||||||
}
|
}
|
||||||
/* try the built-in commands */
|
/* try the built-in commands */
|
||||||
if (cmd_matches("bg", words.we_wordv[0]))
|
if (cmd_matches("bg", words.we_wordv[0]))
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ char *array_cat(char **array) {
|
||||||
char *p = NULL, *str = NULL;
|
char *p = NULL, *str = NULL;
|
||||||
int i, pos = 0;
|
int i, pos = 0;
|
||||||
for (i = 0; array[i]; i++) {
|
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]);
|
int len = strlen(array[i]);
|
||||||
str = (char *)myxrealloc(str, pos + len + 1);
|
str = (char *)myxrealloc(str, pos + len + 1);
|
||||||
p = str + pos;
|
p = str + pos;
|
||||||
|
|
@ -29,8 +27,6 @@ char *array_cat(char **array) {
|
||||||
pos += len + 1;
|
pos += len + 1;
|
||||||
}
|
}
|
||||||
*--p = '\0';
|
*--p = '\0';
|
||||||
if (DEBUG)
|
|
||||||
printf("DEBUG: str=%p\n", str);
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define DEBUG 1
|
|
||||||
#define MSGLEN 255 /* soft limit on message lengths */
|
#define MSGLEN 255 /* soft limit on message lengths */
|
||||||
|
|
||||||
/* these colours should be safe on dark and light backgrounds */
|
/* these colours should be safe on dark and light backgrounds */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue