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