1
0
mirror of https://github.com/koenkooi/foo2zjs.git synced 2026-01-22 11:44:49 +08:00

Merge 36442ffa719d4bc9a767925f38f18e4a4a79002a into e04290de6b7a30d588f3411fd9834618e09f7b9b

This commit is contained in:
Gábor 2022-06-25 11:58:32 +02:00 committed by GitHub
commit 96a53e690f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,6 +142,27 @@ proff(int curOff)
printf("%6x: ", curOff);
}
char*
fgetsn(char* str, int n, FILE* stream)
{
register int c;
register char ch;
register char* cs;
cs = str;
while (--n > 0 && (c = getc(stream)) != EOF) {
ch = (*cs++ = c);
if (ch == '\n') {
*cs = '\0';
break;
}
else if (ch == '\0')
break;
}
return (c == EOF && cs == str) ? NULL : str;
}
void
decode(FILE *fp)
{
@ -178,7 +199,7 @@ decode(FILE *fp)
{
char buf[1024];
while (fgets(buf, sizeof(buf), fp))
while (fgetsn(buf, sizeof(buf), fp))
{
proff(curOff);
if (buf[0] == '\033')