From 0d2f7645c3fb45d83497faf2a4b6fff8c3f175d1 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT <alexis211@gmail.com> Date: Sat, 19 May 2012 14:07:01 +0200 Subject: Added string class for FWIK. --- src/user/lib/fwik/io/IOStream.cpp | 4 ++-- src/user/lib/fwik/io/Term.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/user/lib/fwik/io') diff --git a/src/user/lib/fwik/io/IOStream.cpp b/src/user/lib/fwik/io/IOStream.cpp index bcaa581..ae495c0 100644 --- a/src/user/lib/fwik/io/IOStream.cpp +++ b/src/user/lib/fwik/io/IOStream.cpp @@ -13,7 +13,7 @@ void IOStream::printf(char* fmt, ...) { va_end(ap); } -char* IOStream::readln() { - if (term == 0) return 0; +String IOStream::readln() { + if (term == 0) return ""; return term->readln(); } diff --git a/src/user/lib/fwik/io/Term.cpp b/src/user/lib/fwik/io/Term.cpp index 1c6db66..f7f28ec 100644 --- a/src/user/lib/fwik/io/Term.cpp +++ b/src/user/lib/fwik/io/Term.cpp @@ -42,10 +42,13 @@ void Term::vprintf(char* fmt, va_list ap) { libc::vfprintf(fd, fmt, ap); } -char* Term::readln() { - return libc::freadln(fd); +String Term::readln() { + char *s = libc::freadln(fd); + String ret(s); + free(s); + return ret; } -char *Term::readline() { - return libc::freadline(fd, &hist); +String Term::readline() { + return String(libc::freadline(fd, &hist)); } -- cgit v1.2.3