From d620a37d75125a584b660f7e01279d8ddf8fc00e Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 31 Oct 2018 21:43:15 +0000 Subject: [PATCH] Table: check ext ignoring text case git-svn-id: svn://kolibrios.org@7517 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/other/table/calc.cpp | 32 +++++++++----------------------- programs/other/table/func.cpp | 23 +++++++++++++++++++++++ programs/other/table/func.h | 2 ++ programs/other/table/hello.cpp | 2 +- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/programs/other/table/calc.cpp b/programs/other/table/calc.cpp index 3e5954ee92..01922e38d6 100644 --- a/programs/other/table/calc.cpp +++ b/programs/other/table/calc.cpp @@ -353,28 +353,6 @@ void fill_cells(int sel_x, int sel_y, int sel_end_x, int sel_end_y, int old_end_ calculate_values(); } -const char *csv_name = ".csv"; - -int str_is_csv(char *str) -{ - int i, j = 0; - - for (i = 0; i < strlen(str); i++) - { - if (str[i] == csv_name[j]) - { - j++; - if (j == strlen(csv_name)) - return 1; - } - else - { - j = 0; - } - } - return 0; -} - int Kos_FileWrite(kosFileInfo &fileInfo, char *line, int mode = 3) // если mode = 2 - перезаписать файл { int res = 0; @@ -441,7 +419,7 @@ int SaveCSV(char *fname) } buffer[buf_len++] = '\"'; } - buffer[buf_len++] = ';'; + buffer[buf_len++] = ','; } rtlDebugOutString(buffer); // очередная строка теперь в буфере @@ -450,7 +428,15 @@ int SaveCSV(char *fname) return 0; } return 1; +} +int str_is_csv(char *str) +{ + int str_len = strlen(str); + if (str_len >= 5) { + if ( strnicmp(str + str_len - 4, ".CSV", 4) == 0) return 1; + } + return 0; } #define BUF_FOR_ALL 5000 diff --git a/programs/other/table/func.cpp b/programs/other/table/func.cpp index 4c1f9efa79..c400b88989 100644 --- a/programs/other/table/func.cpp +++ b/programs/other/table/func.cpp @@ -40,6 +40,29 @@ int atoi(const char* string) return res; } +int toupper(int c) +{ + if ( (c >= 97) && (c <= 122) ) return c-32 ; + if ( (c >= 160) && (c <= 175) ) return c-32 ; + if ( (c >= 224) && (c <= 239) ) return c-80 ; + if ( (c == 241) || (c == 243) || (c == 245) || (c == 247) ) return c-1; + return c; +} + +int strnicmp(const char* string1, const char* string2, unsigned count) +{ +int pc = 0; +while (1) + { + if (toupper(*string1)toupper(*string2)) return 1; + if (*string1=='\0' || pc == count) return 0; + string1++; + string2++; + pc++; + } +} + /*int abs(int n) { return (n<0)?-n:n; diff --git a/programs/other/table/func.h b/programs/other/table/func.h index dd347170e7..d8674ee707 100644 --- a/programs/other/table/func.h +++ b/programs/other/table/func.h @@ -54,6 +54,8 @@ void kos_GetMouseStateWnd( Dword & buttons, int & cursorX, int & cursorY ); void kos_DrawRegion(Word x, Word y,Word width, Word height, Dword color1, Word invert); void kos_DrawCutTextSmall(Word x, Word y, int areaWidth, Dword textColour, char *textPtr); int atoi(const char* string); +int toupper(int c); +int strnicmp(const char* string1, const char* string2, unsigned count); void kos_GetScrollInfo(int &vert, int &hor); diff --git a/programs/other/table/hello.cpp b/programs/other/table/hello.cpp index f86a0844d8..200ef7ed41 100644 --- a/programs/other/table/hello.cpp +++ b/programs/other/table/hello.cpp @@ -11,7 +11,7 @@ extern char params[1024]; #endif char params[1024]; -#define TABLE_VERSION "0.99.1" +#define TABLE_VERSION "0.99.1a" // strings const char *sFileSign = "KolibriTable File\n";