Просмотр исходного кода

rewrite using the editline library.

tiny line editing, dunno why we're not using readline, probably because
of some licensing stuff.
Lucas Stadler лет назад: 11
Родитель
Сommit
41355ef886
2 измененных файлов с 7 добавлено и 4 удалено
  1. 1 1
      c/mul/Makefile
  2. 6 3
      c/mul/main.c

+ 1 - 1
c/mul/Makefile

4
	./mul
4
	./mul
5
5
6
mul: main.c
6
mul: main.c
7
	$(CC) main.c -o mul
7
	$(CC) -ledit main.c -o mul
8
8
9
clean:
9
clean:
10
	rm -f mul
10
	rm -f mul

+ 6 - 3
c/mul/main.c

1
#include <stdio.h>
1
#include <stdio.h>
2
2
3
#include <editline/readline.h>
4
3
int main(int argc, char** argv) {
5
int main(int argc, char** argv) {
4
	puts("mul v0.0.1\n");
6
	puts("mul v0.0.1\n");
5
7
6
	while (1) {
8
	while (1) {
7
		fputs("> ", stdout);
8
9
		fgets(input, 2048, stdin);
9
		char* input = readline("> ");
10
		add_history(input);
10
11
11
		printf("%s, yes.", input);
12
		printf("%s, yes.", input);
13
14
		free(input);
12
	}
15
	}
13
16
14
	return 0;
17
	return 0;