loop #2

Merged
cromer merged 11 commits from loop into master 2021-06-19 23:03:40 -04:00
4 changed files with 30 additions and 8 deletions
Showing only changes of commit cc74038008 - Show all commits

View File

@ -1,13 +1,14 @@
CC=clang
CFLAGS=-Wall -Isrc/include -DDEBUG -g
LDFLAGS=-lm
SRC=src/myshellin.c
CFLAGS=-Wall -Isrc/include -DDEBUG -g -std=c17
LDFLAGS=
FILENAME=myshellin
SRC=src/myshellin.c src/loop.c
OBJ=$(SRC:.c=.o)
all: myshellin informe
all: myshellin
myshellin: $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
$(CC) $(CFLAGS) -o $(FILENAME) $^ $(LDFLAGS)
informe:
# if pdflatex is installed create the informe
@ -16,7 +17,7 @@ ifneq (, $(shell which pdflatex))
mv doc/Informe.pdf Informe.pdf
endif
clean: cleanmyshellin cleaninforme
clean: cleanmyshellin
cleanmyshellin:
rm -f src/*.o myshellin

2
src/include/loop.h Normal file
View File

@ -0,0 +1,2 @@
void print_input_line();
void loop();

18
src/loop.c Normal file
View File

@ -0,0 +1,18 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
void print_input_line() {
printf("$ ");
}
void loop() {
size_t buffer_size = 0;
char *line = NULL;
while (1) {
print_input_line();
getline(&line, &buffer_size, stdin);
}
}

View File

@ -1,5 +1,6 @@
int main(int argc, char **argv)
{
#include "loop.h"
int main(int argc, char **argv) {
loop();
return 0;
}