Restore zip.com and .symtab files

This change restores the .symtab symbol table files in our flagship
programs (e.g. redbean.com, python.com) needed to show backtraces. This
also rolls back earlier changes to zip.com w.r.t. temp directories since
the right way to do it turned out to be the -b DIR flag.

This change also improves the performance of zip.com. It turned out
mmap() wasn't being used, because zip.com was assuming a 4096-byte
granularity, but cosmo requires 65536. There was also a chance to speed
up stdio scanning using the unlocked functions.
This commit is contained in:
Justine Tunney 2022-08-21 00:17:20 -07:00
parent 35203c0551
commit 73845be1f0
27 changed files with 256 additions and 246 deletions

44
third_party/zip/zip.c vendored
View file

@ -35,17 +35,10 @@
#include "libc/stdio/stdio.h"
#include "libc/stdio/temp.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/gc.internal.h"
#include "libc/x/x.h"
#include "third_party/bzip2/bzlib.h"
#define MAXCOM 256 /* Maximum one-line comment size */
static char *EnsureDirs(char *path) {
makedirs(gc(xdirname(path)), 0755);
return path;
}
/* Local option flags */
#ifndef DELETE
#define DELETE 0
@ -2204,15 +2197,6 @@ char **argv; /* command line tokens */
}
#endif
#ifdef RISCOS
set_prefix();
#endif
#ifdef __human68k__
fflush(stderr);
setbuf(stderr, NULL);
#endif
/* Re-initialize global variables to make the zip dll re-entrant. It is
* possible that we could get away with not re-initializing all of these
* but better safe than sorry.
@ -2591,25 +2575,6 @@ char **argv; /* command line tokens */
{
switch (option)
{
#ifdef EBCDIC
case 'a':
aflag = ASCII;
printf("Translating to ASCII...\n");
break;
#endif /* EBCDIC */
#ifdef CMS_MVS
case 'B':
bflag = 1;
printf("Using binary mode...\n");
break;
#endif /* CMS_MVS */
#ifdef TANDEM
case 'B':
nskformatopt(value);
free(value);
break;
#endif
case '0':
method = STORE; level = 0; break;
case '1': case '2': case '3': case '4':
@ -2645,11 +2610,6 @@ char **argv; /* command line tokens */
}
action = DELETE;
break;
#ifdef MACOS
case o_df:
MacZip.DataForkOnly = true;
break;
#endif /* MACOS */
case o_db:
if (negated)
display_bytes = 0;
@ -3835,7 +3795,7 @@ char **argv; /* command line tokens */
}
strcat(tempzip, "ziXXXXXX");
if ((yd = mkstemp(EnsureDirs(gc(xjoinpaths(kTmpPath, tempzip))))) == EOF) {
if ((yd = mkstemp(tempzip)) == EOF) {
ZIPERR(ZE_TEMP, tempzip);
}
if ((y = fdopen(yd, FOPW_TMP)) == NULL) {
@ -4838,7 +4798,7 @@ char **argv; /* command line tokens */
}
strcat(tempzip, "ziXXXXXX");
if ((yd = mkstemp(EnsureDirs(gc(xjoinpaths(kTmpPath, tempzip))))) == EOF) {
if ((yd = mkstemp(tempzip)) == EOF) {
ZIPERR(ZE_TEMP, tempzip);
}
if ((y = fdopen(yd, FOPW_TMP)) == NULL) {