mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
LibC: Implemented getc_unlocked, stubbed flockfile
Implemented getc_unlocked and stubbed out flockfile() and funlockfile().
This commit is contained in:
parent
bda36853c9
commit
3069988a75
Notes:
sideshowbarker
2024-07-19 11:11:57 +09:00
Author: https://github.com/xeons Commit: https://github.com/SerenityOS/serenity/commit/3069988a757 Pull-request: https://github.com/SerenityOS/serenity/pull/788 Reviewed-by: https://github.com/awesomekling ✅
@ -140,12 +140,17 @@ int getc(FILE* stream)
|
||||
return fgetc(stream);
|
||||
}
|
||||
|
||||
int getc_unlocked(FILE* stream)
|
||||
{
|
||||
return fgetc(stream);
|
||||
}
|
||||
|
||||
int getchar()
|
||||
{
|
||||
return getc(stdin);
|
||||
}
|
||||
|
||||
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
|
||||
ssize_t getdelim(char** lineptr, size_t* n, int delim, FILE* stream)
|
||||
{
|
||||
char *ptr, *eptr;
|
||||
if (*lineptr == nullptr || *n == 0) {
|
||||
@ -170,7 +175,7 @@ ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
|
||||
return ptr - *lineptr;
|
||||
}
|
||||
if (ptr + 2 >= eptr) {
|
||||
char *nbuf;
|
||||
char* nbuf;
|
||||
size_t nbuf_sz = *n * 2;
|
||||
ssize_t d = ptr - *lineptr;
|
||||
if ((nbuf = static_cast<char*>(realloc(*lineptr, nbuf_sz))) == nullptr) {
|
||||
@ -184,7 +189,7 @@ ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t getline(char **lineptr, size_t *n, FILE *stream)
|
||||
ssize_t getline(char** lineptr, size_t* n, FILE* stream)
|
||||
{
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
}
|
||||
@ -413,7 +418,7 @@ int vsnprintf(char* buffer, size_t size, const char* fmt, va_list ap)
|
||||
__vsnprintf_space_remaining = size;
|
||||
int ret = printf_internal(sized_buffer_putch, buffer, fmt, ap);
|
||||
if (__vsnprintf_space_remaining) {
|
||||
buffer[ret] = '\0';
|
||||
buffer[ret] = '\0';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -616,6 +621,18 @@ int vfscanf(FILE* stream, const char* fmt, va_list ap)
|
||||
return vsscanf(buffer, fmt, ap);
|
||||
}
|
||||
|
||||
void flockfile(FILE* filehandle)
|
||||
{
|
||||
(void)filehandle;
|
||||
dbgprintf("FIXME: Implement flockfile()\n");
|
||||
}
|
||||
|
||||
void funlockfile(FILE* filehandle)
|
||||
{
|
||||
(void)filehandle;
|
||||
dbgprintf("FIXME: Implement funlockfile()\n");
|
||||
}
|
||||
|
||||
FILE* tmpfile()
|
||||
{
|
||||
dbgprintf("FIXME: Implement tmpfile()\n");
|
||||
|
@ -56,6 +56,7 @@ int fputc(int ch, FILE*);
|
||||
int fileno(FILE*);
|
||||
int fgetc(FILE*);
|
||||
int getc(FILE*);
|
||||
int getc_unlocked(FILE* stream);
|
||||
int getchar();
|
||||
ssize_t getdelim(char**, size_t*, int, FILE*);
|
||||
ssize_t getline(char**, size_t*, FILE*);
|
||||
@ -64,6 +65,8 @@ int remove(const char* pathname);
|
||||
FILE* fdopen(int fd, const char* mode);
|
||||
FILE* fopen(const char* pathname, const char* mode);
|
||||
FILE* freopen(const char* pathname, const char* mode, FILE*);
|
||||
void flockfile(FILE* filehandle);
|
||||
void funlockfile(FILE* filehandle);
|
||||
int fclose(FILE*);
|
||||
void rewind(FILE*);
|
||||
void clearerr(FILE*);
|
||||
|
Loading…
Reference in New Issue
Block a user