修复tty设备清屏BUG
This commit is contained in:
parent
229523beb2
commit
84278651b6
@ -535,6 +535,12 @@ int filesize(const char* filename){
|
||||
|
||||
int fputc(int ch, FILE *stream) {
|
||||
if (CANWRITE(stream->mode)) {
|
||||
|
||||
if(strcmp("<stdout>",stream->name)||strcmp("<stderr>",stream->name)){
|
||||
syscall_putchar(ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// printk("Current Buffer=%s\n",stream->buffer);
|
||||
if (stream->p >= stream->bufferSize) {
|
||||
// printk("Realloc....(%d,%d)\n",stream->p,stream->bufferSize);
|
||||
@ -632,6 +638,10 @@ FILE *fopen(char *filename, char *mode) {
|
||||
|
||||
int fgetc(FILE *stream) {
|
||||
if (CANREAD(stream->mode)) {
|
||||
if(strcmp("<stdin>",stream->name)) {
|
||||
return getc();
|
||||
}
|
||||
|
||||
if (stream->p >= stream->fileSize) {
|
||||
return EOF;
|
||||
} else {
|
||||
@ -698,6 +708,12 @@ char *fgets(char *str, int n, FILE *stream) {
|
||||
|
||||
int fputs(const char *str, FILE *stream) {
|
||||
if (CANWRITE(stream->mode)) {
|
||||
|
||||
if(strcmp("<stdout>",stream->name)||strcmp("<stderr>",stream->name)){
|
||||
syscall_print(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < strlen(str); i++) {
|
||||
fputc(str[i], stream);
|
||||
}
|
||||
@ -713,7 +729,9 @@ int fprintf(FILE *stream, const char *format, ...) {
|
||||
va_start(ap, format);
|
||||
char *buf = malloc(1024);
|
||||
len = vsprintf(buf, format, ap);
|
||||
fputs(buf, stream);
|
||||
if(strcmp("<stdout>",stream->name)||strcmp("<stderr>",stream->name)){
|
||||
syscall_print(buf);
|
||||
} else fputs(buf, stream);
|
||||
free(buf);
|
||||
va_end(ap);
|
||||
return len;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define LUA_VERSION_NUM 504
|
||||
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 4)
|
||||
|
||||
#define LUA_VERSION "CoolPotOS Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
|
||||
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2022 Lua.org, PUC-Rio"
|
||||
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
|
||||
|
@ -121,7 +121,7 @@
|
||||
|
||||
|
||||
#if !defined(LUA_PROGNAME)
|
||||
#define LUA_PROGNAME "lua"
|
||||
#define LUA_PROGNAME "lua.elf"
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_INIT_VAR)
|
||||
@ -149,11 +149,14 @@ static void laction(int i) {
|
||||
|
||||
|
||||
static void print_usage(const char *badoption) {
|
||||
if(badoption[0] != '+'){
|
||||
lua_writestringerror("%s: ", progname);
|
||||
if (badoption[1] == 'e' || badoption[1] == 'l')
|
||||
lua_writestringerror("'%s' needs argument\n", badoption);
|
||||
else
|
||||
lua_writestringerror("unrecognized option '%s'\n", badoption);
|
||||
}
|
||||
|
||||
lua_writestringerror(
|
||||
"usage: %s [options] [script [args]]\n"
|
||||
"Available options are:\n"
|
||||
@ -333,6 +336,7 @@ static int handle_script(lua_State *L, char **argv) {
|
||||
#define has_v 4 /* -v */
|
||||
#define has_e 8 /* -e */
|
||||
#define has_E 16 /* -E */
|
||||
#define has_h 32 /* -h */
|
||||
|
||||
|
||||
/*
|
||||
@ -380,6 +384,11 @@ static int collectargs(char **argv, int *first) {
|
||||
return has_error; /* invalid option */
|
||||
args |= has_v;
|
||||
break;
|
||||
case 'h':
|
||||
if (argv[i][2] != '\0') /* extra characters? */
|
||||
return has_error; /* invalid option */
|
||||
args |= has_h;
|
||||
break;
|
||||
case 'e':
|
||||
args |= has_e; /* FALLTHROUGH */
|
||||
case 'l': /* both options need an argument */
|
||||
@ -858,6 +867,10 @@ static int pmain(lua_State *L) {
|
||||
char **argv = (char **) lua_touserdata(L, 2);
|
||||
int script;
|
||||
|
||||
if(argc == 1){
|
||||
print_usage("+");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int args = collectargs(argv, &script);
|
||||
int optlim = (script > 0) ? script : argc; /* first argv not an option */
|
||||
@ -866,6 +879,9 @@ static int pmain(lua_State *L) {
|
||||
print_usage(argv[script]); /* 'script' has index of bad arg. */
|
||||
return 0;
|
||||
}
|
||||
if(args & has_h){
|
||||
print_usage("<null>");
|
||||
}
|
||||
if (args & has_v) /* option '-v'? */
|
||||
print_version();
|
||||
if (args & has_E) { /* option '-E'? */
|
||||
@ -875,8 +891,8 @@ static int pmain(lua_State *L) {
|
||||
// printf("In this2\n");
|
||||
luaopen_base(L);
|
||||
luaL_setfuncs(L, my_lib_bsp, 0);
|
||||
luaL_requiref(L, "pio", open_io, 1);
|
||||
luaL_requiref(L, "pl_api", open_os, 1);
|
||||
luaL_requiref(L, "cpio", open_io, 1);
|
||||
luaL_requiref(L, "cp_api", open_os, 1);
|
||||
luaL_openlibs(L); /* open standard libraries */
|
||||
createargtable(L, argv, argc, script); /* create table 'arg' */
|
||||
lua_gc(L, LUA_GCGEN, 0, 0); /* GC in generational mode */
|
||||
|
@ -393,7 +393,7 @@ void init_default_tty(struct task_struct *task){
|
||||
|
||||
task->tty->is_using = true;
|
||||
task->tty->print = tty_print;
|
||||
task->tty->clear = clear_TextMode;
|
||||
task->tty->clear = vbe_clear;
|
||||
task->tty->putchar = vbe_putchar;
|
||||
task->tty->gotoxy = tty_gotoxy;
|
||||
task->tty->screen_ne = screen_ne_TextMode;
|
||||
|
@ -312,6 +312,7 @@ void screen_clear(){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(vbe_status){
|
||||
vbe_clear();
|
||||
} else vga_clear();
|
||||
|
Loading…
Reference in New Issue
Block a user