Compare commits
No commits in common. "40b078e0a21ecb998702b895d80550ffb698414e" and "da182f1c2fc79cb47316f3224e48777cb25fbbec" have entirely different histories.
40b078e0a2
...
da182f1c2f
@ -136,7 +136,7 @@ extern "C"
|
||||
return 0;
|
||||
}
|
||||
if (status == 0) stream->f_eof = 1;
|
||||
return (size_t)status / size;
|
||||
return (size_t)status;
|
||||
}
|
||||
|
||||
char* fgets(char* buf, int size, FILE* stream)
|
||||
@ -257,7 +257,9 @@ extern "C"
|
||||
|
||||
long ftell(FILE* stream)
|
||||
{
|
||||
return lseek(stream->f_fd, 0, SEEK_CUR);
|
||||
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...
|
||||
}
|
||||
|
||||
off_t ftello(FILE* stream)
|
||||
@ -288,7 +290,7 @@ extern "C"
|
||||
return 0;
|
||||
}
|
||||
if (status == 0) stream->f_eof = 1;
|
||||
return (size_t)status / size;
|
||||
return (size_t)status;
|
||||
}
|
||||
|
||||
void setbuf(FILE*, char*)
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
static char lowercase(char c)
|
||||
static char fold(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 && (lowercase(*a) == lowercase(*b)))
|
||||
while (*a && (fold(*a) == fold(*b)))
|
||||
{
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
|
||||
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
|
||||
}
|
||||
|
||||
int strncasecmp(const char* a, const char* b, size_t max)
|
||||
{
|
||||
const char* base = a;
|
||||
while (*a && (lowercase(*a) == lowercase(*b)) && (size_t)(a - base) < (max - 1))
|
||||
while (*a && (fold(*a) == fold(*b)) && (size_t)(a - base) < (max - 1))
|
||||
{
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
|
||||
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user