summaryrefslogtreecommitdiff
path: root/src/user/lib
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-06-09 14:35:40 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-06-09 14:35:40 +0200
commit9c74cb8c5bb5661d7f71f43b88816e70cc9fc022 (patch)
tree77a893ff826dcb14e9b8768c23e4970033e934ea /src/user/lib
parent4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4 (diff)
downloadTCE-9c74cb8c5bb5661d7f71f43b88816e70cc9fc022.tar.gz
TCE-9c74cb8c5bb5661d7f71f43b88816e70cc9fc022.zip
Many bug corrections.
Diffstat (limited to 'src/user/lib')
-rw-r--r--src/user/lib/libc/include/readline.h6
-rw-r--r--src/user/lib/libc/include/tce/syscall.h2
-rw-r--r--src/user/lib/libc/std/ctype.c4
-rw-r--r--src/user/lib/libc/std/readline.c38
-rw-r--r--src/user/lib/libc/std/stdio.c2
-rw-r--r--src/user/lib/libc/std/stdlib.c1
-rw-r--r--src/user/lib/libc/tce/syscall.c2
7 files changed, 11 insertions, 44 deletions
diff --git a/src/user/lib/libc/include/readline.h b/src/user/lib/libc/include/readline.h
index 9fa2ee7..b5e0a1a 100644
--- a/src/user/lib/libc/include/readline.h
+++ b/src/user/lib/libc/include/readline.h
@@ -13,9 +13,11 @@ typedef struct _rdln_hist {
#ifdef __cplusplus
extern "C" { namespace libc {
#endif
-char *readln();
-char* freadln(FILE *f); // minimal line-reading function. user must free the returned value.
+
+
char* freadline(FILE *f, readline_history *h);
+
+
#ifdef __cplusplus
} }
#endif
diff --git a/src/user/lib/libc/include/tce/syscall.h b/src/user/lib/libc/include/tce/syscall.h
index 4a1c6ef..478ed3e 100644
--- a/src/user/lib/libc/include/tce/syscall.h
+++ b/src/user/lib/libc/include/tce/syscall.h
@@ -23,7 +23,7 @@ int proc_priv();
void* sbrk(ptrdiff_t size);
void brk(void* ptr);
-int run(const char* file, const char** args, int zero_fd);
+int run(const char* file, char** args, int zero_fd);
int waitpid(int pid, int block);
int open(const char* filename, int mode);
diff --git a/src/user/lib/libc/std/ctype.c b/src/user/lib/libc/std/ctype.c
index f0e7750..13f2ab0 100644
--- a/src/user/lib/libc/std/ctype.c
+++ b/src/user/lib/libc/std/ctype.c
@@ -15,14 +15,14 @@ int isalnum(int c) {
int tolower(int c) {
if (c >= 'A' && c <= 'Z') {
- return c + ('a' - 'A');
+ c += ('a' - 'A');
}
return c;
}
int toupper(int c) {
if (c >= 'a' && c <= 'z') {
- return c - ('a' - 'A');
+ c -= ('a' - 'A');
}
return c;
}
diff --git a/src/user/lib/libc/std/readline.c b/src/user/lib/libc/std/readline.c
index 4177bf6..5dfd442 100644
--- a/src/user/lib/libc/std/readline.c
+++ b/src/user/lib/libc/std/readline.c
@@ -1,44 +1,6 @@
#include <readline.h>
#include <stdlib.h>
-char* freadln(FILE *f) {
- int i;
-
- char *p = (char*)malloc(256);
- char *b = p;
-
- while (1) {
- int l = fread(b, 255, 1, f);
- if (l < 0) {
- free(b);
- return 0;
- }
-
- for (i = 0; i < l; i++) {
- if (b[i] == '\n') {
- b[i+1] = 0;
- return p;
- } else if (b[i] == 27) { // ignore escape sequences
- b[i] = 0;
- l = i;
- }
- }
-
- int d = b - p + l;
-
- char* newp = (char*)malloc(d + 256);
- memcpy(newp, p, d);
- free(p);
- p = newp;
- b = p + d;
- }
-}
-
-char* readln() {
- return freadln(&term);
-}
-
-
// ** READLINE
char *freadline(FILE *f, readline_history *h) {
diff --git a/src/user/lib/libc/std/stdio.c b/src/user/lib/libc/std/stdio.c
index be65505..043cc59 100644
--- a/src/user/lib/libc/std/stdio.c
+++ b/src/user/lib/libc/std/stdio.c
@@ -42,6 +42,8 @@ void __tce_libc_fsetup(FILE *f) {
f->tib_u_begin = f->tib_begin;
f->tib_u_end = f->tib_u_begin;
f->term_echo = 1;
+ } else {
+ f->tib_begin = f->tib_end = f->tib_u_begin = f->tib_u_end = 0;
}
}
diff --git a/src/user/lib/libc/std/stdlib.c b/src/user/lib/libc/std/stdlib.c
index 15f9ddc..10bce0a 100644
--- a/src/user/lib/libc/std/stdlib.c
+++ b/src/user/lib/libc/std/stdlib.c
@@ -33,6 +33,7 @@ int atoi(char *s) {
while (*s >= '0' && *s <= '9') {
r *= 10;
r += (*s) - '0';
+ s++;
};
return r;
}
diff --git a/src/user/lib/libc/tce/syscall.c b/src/user/lib/libc/tce/syscall.c
index f4f1333..780b573 100644
--- a/src/user/lib/libc/tce/syscall.c
+++ b/src/user/lib/libc/tce/syscall.c
@@ -75,7 +75,7 @@ void brk(void* ptr) {
// ********** proc
-int run(const char* filename, const char** args, int zero_fd) {
+int run(const char* filename, char** args, int zero_fd) {
return call(SC_RUN, (unsigned)filename, (unsigned)args, (unsigned)zero_fd, 0, 0);
}