mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Make improvements
- Document redbean's argon2 module - Fix regressions in cthreads library - Make testlib work better with threads - Give the cthreads library lots of love - Remove some of the stdio assembly code - Implement getloadavg() across platforms - Code size optimizations for errnos, etc. - Only check for signals in main thread on Windows - Make errnos for dup2 / dup3 consistent with posix This change also fixes a bug in the argon2 module, where the NUL terminator was being included in the hash encoded ascii string. This shouldn't require any database migrations to folks who found this module and productionized it, since the argon2 library treats it as a c string.
This commit is contained in:
parent
cb67223051
commit
de5de19004
234 changed files with 1728 additions and 1993 deletions
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
|
@ -31,24 +30,13 @@
|
|||
* @param f is non-null file oject stream pointer
|
||||
* @return s on success, NULL on error, or NULL if EOF happens when
|
||||
* zero characters have been read
|
||||
* @see fgets_unlocked()
|
||||
* @threadsafe
|
||||
*/
|
||||
char *fgets_unlocked(char *s, int size, FILE *f) {
|
||||
int c;
|
||||
char *p;
|
||||
p = s;
|
||||
if (size > 0) {
|
||||
while (--size > 0) {
|
||||
if ((c = fgetc_unlocked(f)) == -1) {
|
||||
if (ferror_unlocked(f) == EINTR) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*p++ = c & 255;
|
||||
if (c == '\n') break;
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
return p > s ? s : NULL;
|
||||
char *fgets(char *s, int size, FILE *f) {
|
||||
char *res;
|
||||
flockfile(f);
|
||||
res = fgets_unlocked(s, size, f);
|
||||
funlockfile(f);
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue