Skip to content

Commit

Permalink
fix whole code for full compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
GideonBature committed Jul 26, 2023
1 parent d4386c1 commit 7c84497
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 4 additions & 5 deletions linkedlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

envstruct *insert_end(envstruct *head, char *key, char *value)
{
envstruct *curr = head;
envstruct *new_node = malloc(sizeof(envstruct));

if (new_node == NULL)
Expand All @@ -18,8 +19,6 @@ envstruct *insert_end(envstruct *head, char *key, char *value)
return (new_node);
}

envstruct *curr;
curr = head;

while (curr->next != NULL)
{
Expand Down Expand Up @@ -67,14 +66,14 @@ char *get_value(envstruct *head, char *key)
*/
int remove_value(envstruct **head, char *key)
{
envstruct *curr = *head;
envstruct *prev = NULL;

if (head == NULL || *head == NULL)
{
return (1);
}

envstruct *curr = *head;
envstruct *prev = NULL;

while (curr != NULL)
{
if (strcmp(curr->key, key) == 0)
Expand Down
9 changes: 6 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ char *lineptr;
*/
int main(void)
{
envstruct *head = NULL;

atexit(clean_up);
signal(SIGINT, sig_int_handler);
envstruct *head = NULL;

while (1)
{
Expand Down Expand Up @@ -235,7 +236,9 @@ void env_cmd(void)
*/
void init_env_list(envstruct *head)
{
while (*environ != NULL)
int i = 0;

while (environ[i] != NULL)
{
char *key = strtok(*environ, "="), *val = NULL;

Expand All @@ -246,7 +249,7 @@ void init_env_list(envstruct *head)
}
head = insert_end(head, key, val);

*environ++;
i++;
}
}

Expand Down
Binary file modified shell
Binary file not shown.

0 comments on commit 7c84497

Please sign in to comment.