diff --git a/programs/other/table/calc.cpp b/programs/other/table/calc.cpp index a1854af074..b803239b0e 100644 --- a/programs/other/table/calc.cpp +++ b/programs/other/table/calc.cpp @@ -20,6 +20,7 @@ extern DWORD *cell_x, *cell_y; extern char ***buffer; extern DWORD buf_col, buf_row; extern DWORD buf_old_x, buf_old_y; +DWORD filesize; extern bool sel_moved; @@ -576,15 +577,22 @@ char *Kos_FileRead(kosFileInfo &fileInfo, int &code) char GetCsvSeparator(char *fname) { - char buffer[512]; + char buffer[4096]; kosFileInfo fileInfo; + DWORD load_size; + + if (filesize < 4096) { + load_size = filesize; + } else { + load_size = 4096; + } rtlDebugOutString(fname); strcpy(fileInfo.fileURL, fname); fileInfo.OffsetLow = 0; fileInfo.OffsetHigh = 0; - fileInfo.dataCount = 512; + fileInfo.dataCount = load_size; fileInfo.rwMode = 0; fileInfo.bufferPtr = (Byte *)buffer; @@ -714,7 +722,7 @@ int LoadFile(char *fname) kosFileInfo fileInfo; kosBDVK bdvk; int filePointer = 0, i, j; - Dword res, filesize; + Dword res; char buffer[512 + 1]; char *d, *s, *k; int step = 0, items; @@ -732,6 +740,8 @@ int LoadFile(char *fname) { return -1; } + + filesize = bdvk.size_low; if (str_is_csv(fname)) return LoadCSV(fname); @@ -740,8 +750,6 @@ int LoadFile(char *fname) // clear the table reinit(); - filesize = bdvk.size_low; - fileInfo.rwMode = 0; fileInfo.dataCount = strlen(sFileSign); fileInfo.bufferPtr = (Byte*)buffer; diff --git a/programs/other/table/hello.cpp b/programs/other/table/hello.cpp index 5577b8e2b7..cb1310125d 100644 --- a/programs/other/table/hello.cpp +++ b/programs/other/table/hello.cpp @@ -23,7 +23,7 @@ const char sNew[] = "New"; const char er_file_not_found[] = "'Cannot open file' -E"; const char er_format[] = "'Error: bad format' -E"; const char msg_save[] = "'File saved' -O"; -const char msg_load[] = "'File loaded' -O"; +//const char msg_load[] = "'File loaded' -O"; const char msg_save_error[] = "'Error saving file' -E"; const char msg_new[] = "'Memory cleared' -I"; @@ -1058,16 +1058,17 @@ void EventLoadFile() { stop_edit(); int r = LoadFile(fname); - char *result; if (r > 0) { calculate_values(); sel_moved = 0; draw_grid(); - result = (char*)msg_load; + //result = (char*)msg_load; + } else { + char *result; + if (r == -1) result = (char*)er_file_not_found; + else if (r == -2) result = (char*)er_format; + kos_AppRun("/sys/@notify", result); } - else if (r == -1) result = (char*)er_file_not_found; - else if (r == -2) result = (char*)er_format; - kos_AppRun("/sys/@notify", result); } void EventGridSelectAll()