Compare commits

..

2 Commits

2 changed files with 8 additions and 10 deletions

View File

@ -136,7 +136,7 @@ extern "C"
return 0;
}
if (status == 0) stream->f_eof = 1;
return (size_t)status;
return (size_t)status / size;
}
char* fgets(char* buf, int size, FILE* stream)
@ -257,9 +257,7 @@ extern "C"
long ftell(FILE* stream)
{
return lseek(stream->f_fd, 0,
SEEK_CUR); // FIXME: Store the last seeked position in the file struct to avoid redundant syscalls
// maybe? We'd have to update this value in fread() and fwrite() as well...
return lseek(stream->f_fd, 0, SEEK_CUR);
}
off_t ftello(FILE* stream)
@ -290,7 +288,7 @@ extern "C"
return 0;
}
if (status == 0) stream->f_eof = 1;
return (size_t)status;
return (size_t)status / size;
}
void setbuf(FILE*, char*)

View File

@ -2,7 +2,7 @@
#include <string.h>
#include <strings.h>
static char fold(char c)
static char lowercase(char c)
{
if (isalpha(c)) return (char)tolower(c);
return c;
@ -22,22 +22,22 @@ extern "C"
int strcasecmp(const char* a, const char* b)
{
while (*a && (fold(*a) == fold(*b)))
while (*a && (lowercase(*a) == lowercase(*b)))
{
a++;
b++;
}
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
}
int strncasecmp(const char* a, const char* b, size_t max)
{
const char* base = a;
while (*a && (fold(*a) == fold(*b)) && (size_t)(a - base) < (max - 1))
while (*a && (lowercase(*a) == lowercase(*b)) && (size_t)(a - base) < (max - 1))
{
a++;
b++;
}
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
}
}