Table: check ext ignoring text case

git-svn-id: svn://kolibrios.org@7517 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-31 21:43:15 +00:00
parent a192c7b7ee
commit d620a37d75
4 changed files with 35 additions and 24 deletions

View File

@ -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

View File

@ -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 (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;

View File

@ -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);

View File

@ -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";