aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <git@madler.net>2026-03-26 17:27:50 -0700
committerMark Adler <git@madler.net>2026-03-26 17:27:50 -0700
commitf9dd6009be3ed32415edf1e89d1bc38380ecb95d (patch)
treeea8a60e0de58c9f01a702e3c90ae57e210a54ed4
parent7cdaaa09095e9266dee21314599a9258db53685e (diff)
downloadzlib-develop.tar.gz
zlib-develop.tar.bz2
zlib-develop.zip
Clean up comment formatting in minizip's zip.c and unzip.c.HEADdevelop
-rw-r--r--contrib/minizip/unzip.c16
-rw-r--r--contrib/minizip/zip.c70
2 files changed, 42 insertions, 44 deletions
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index d7ff21cb..827c23a1 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -1167,13 +1167,12 @@ extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCase
1167 1167
1168 1168
1169/* 1169/*
1170/////////////////////////////////////////// 1170 Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
1171// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) 1171 I need random access
1172// I need random access 1172
1173// 1173 Further optimization could be realized by adding an ability
1174// Further optimization could be realized by adding an ability 1174 to cache the directory in memory. The goal being a single
1175// to cache the directory in memory. The goal being a single 1175 comprehensive file read to put the file I need in a memory.
1176// comprehensive file read to put the file I need in a memory.
1177*/ 1176*/
1178 1177
1179/* 1178/*
@@ -1242,8 +1241,7 @@ extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) {
1242} 1241}
1243 1242
1244/* 1243/*
1245// Unzip Helper Functions - should be here? 1244 Unzip Helper Functions - should be here?
1246///////////////////////////////////////////
1247*/ 1245*/
1248 1246
1249/* 1247/*
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 03424ab0..0bbdf77e 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -128,7 +128,7 @@ typedef struct linkedlist_data_s
128 128
129 129
130/* zipAlreadyThere() set functions for a set of zero-terminated strings, and 130/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
131// a block_t type for reading the central directory datablocks. */ 131 a block_t type for reading the central directory datablocks. */
132#define SKIPSET_EXPORT static 132#define SKIPSET_EXPORT static
133typedef char *set_key_t; 133typedef char *set_key_t;
134#define set_cmp(a, b) strcmp(a, b) 134#define set_cmp(a, b) strcmp(a, b)
@@ -287,18 +287,18 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
287} 287}
288 288
289/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the 289/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the
290// set of names that are in the under-construction central directory so far. A 290 set of names that are in the under-construction central directory so far. A
291// skipset provides ~O(log n) time insertion and searching. Central directory 291 skipset provides ~O(log n) time insertion and searching. Central directory
292// records, stored in a linked list of allocated memory datablocks, is read 292 records, stored in a linked list of allocated memory datablocks, is read
293// through "block" in the zip internal structure. 293 through "block" in the zip internal structure.
294 294
295// The block_*() functions support extracting the central directory file names 295 The block_*() functions support extracting the central directory file names
296// from the datablocks. They are designed to support a growing directory by 296 from the datablocks. They are designed to support a growing directory by
297// automatically continuing once more data has been appended to the linked 297 automatically continuing once more data has been appended to the linked
298// datablocks. 298 datablocks.
299 299
300// Initialize *block to the head of list. This should only be called once the 300 Initialize *block to the head of list. This should only be called once the
301// list has at least some data in it, i.e. list->first_block is not NULL. */ 301 list has at least some data in it, i.e. list->first_block is not NULL. */
302local void block_init(block_t *block, linkedlist_data *list) { 302local void block_init(block_t *block, linkedlist_data *list) {
303 block->node = list->first_block; 303 block->node = list->first_block;
304 block->next = block->node->data; 304 block->next = block->node->data;
@@ -306,8 +306,8 @@ local void block_init(block_t *block, linkedlist_data *list) {
306} 306}
307 307
308/* Mark *block as bad, with all subsequent reads returning end, even if more 308/* Mark *block as bad, with all subsequent reads returning end, even if more
309// data is added to the datablocks. This is invoked if the central directory is 309 data is added to the datablocks. This is invoked if the central directory is
310// invalid, so there is no longer any point in attempting to interpret it. */ 310 invalid, so there is no longer any point in attempting to interpret it. */
311local void block_stop(block_t *block) { 311local void block_stop(block_t *block) {
312 block->left = 0; 312 block->left = 0;
313 block->next = NULL; 313 block->next = NULL;
@@ -358,7 +358,7 @@ local int block_get(block_t *block) {
358} 358}
359 359
360/* Return a 16-bit unsigned little-endian value from block, or a negative value 360/* Return a 16-bit unsigned little-endian value from block, or a negative value
361// if the end is reached. */ 361 if the end is reached. */
362local long block_get2(block_t *block) { 362local long block_get2(block_t *block) {
363 int low = block_get(block); 363 int low = block_get(block);
364 int high = block_get(block); 364 int high = block_get(block);
@@ -391,7 +391,7 @@ local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
391} 391}
392 392
393/* Skip n bytes in block. Return 0 on success or -1 if there are less than n 393/* Skip n bytes in block. Return 0 on success or -1 if there are less than n
394// bytes to the end. */ 394 bytes to the end. */
395local int block_skip(block_t *block, size_t n) { 395local int block_skip(block_t *block, size_t n) {
396 while (n > block->left) { 396 while (n > block->left) {
397 n -= block->left; 397 n -= block->left;
@@ -407,8 +407,8 @@ local int block_skip(block_t *block, size_t n) {
407} 407}
408 408
409/* Process the next central directory record at *block. Return the allocated, 409/* Process the next central directory record at *block. Return the allocated,
410// zero-terminated file name, or NULL for end of input or invalid data. If 410 zero-terminated file name, or NULL for end of input or invalid data. If
411// invalid, *block is marked bad. This uses *set for the allocation of memory. */ 411 invalid, *block is marked bad. This uses *set for the allocation of memory. */
412local char *block_central_name(block_t *block, set_t *set) { 412local char *block_central_name(block_t *block, set_t *set) {
413 unsigned flen, xlen, clen; 413 unsigned flen, xlen, clen;
414 char *name = NULL; 414 char *name = NULL;
@@ -424,7 +424,7 @@ local char *block_central_name(block_t *block, set_t *set) {
424 break; 424 break;
425 425
426 /* Go through the remaining fixed-length portion of the record, 426 /* Go through the remaining fixed-length portion of the record,
427 // extracting the lengths of the three variable-length fields. */ 427 extracting the lengths of the three variable-length fields. */
428 block_skip(block, 24); 428 block_skip(block, 24);
429 flen = (unsigned)block_get2(block); /* file name length */ 429 flen = (unsigned)block_get2(block); /* file name length */
430 xlen = (unsigned)block_get2(block); /* extra length */ 430 xlen = (unsigned)block_get2(block); /* extra length */
@@ -443,9 +443,9 @@ local char *block_central_name(block_t *block, set_t *set) {
443 /* Check for embedded nuls in the name. */ 443 /* Check for embedded nuls in the name. */
444 if (memchr(name, 0, flen) != NULL) { 444 if (memchr(name, 0, flen) != NULL) {
445 /* This name can never match the zero-terminated name provided to 445 /* This name can never match the zero-terminated name provided to
446 // zipAlreadyThere(), so we discard it and go back to get another 446 zipAlreadyThere(), so we discard it and go back to get another
447 // name. (Who the heck is putting nuls inside their zip file entry 447 name. (Who the heck is putting nuls inside their zip file entry
448 // names anyway?) */ 448 names anyway?) */
449 set_free(set, name); 449 set_free(set, name);
450 continue; 450 continue;
451 } 451 }
@@ -456,15 +456,15 @@ local char *block_central_name(block_t *block, set_t *set) {
456 } 456 }
457 457
458 /* Invalid signature or premature end of the central directory record. 458 /* Invalid signature or premature end of the central directory record.
459 // Abandon trying to process the central directory. */ 459 Abandon trying to process the central directory. */
460 set_free(set, name); 460 set_free(set, name);
461 block_stop(block); 461 block_stop(block);
462 return NULL; 462 return NULL;
463} 463}
464 464
465/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if 465/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if
466// the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if 466 the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
467// file is NULL. */ 467 file is NULL. */
468extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) { 468extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
469 size_t len; 469 size_t len;
470 char *copy; 470 char *copy;
@@ -482,14 +482,14 @@ extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
482 } 482 }
483 if (!set_ok(&zip->set)) { 483 if (!set_ok(&zip->set)) {
484 /* This is the first time here with some central directory content. We 484 /* This is the first time here with some central directory content. We
485 // construct this set of names only on demand. Prepare set and block. */ 485 construct this set of names only on demand. Prepare set and block. */
486 set_start(&zip->set); 486 set_start(&zip->set);
487 block_init(&zip->block, &zip->central_dir); 487 block_init(&zip->block, &zip->central_dir);
488 } 488 }
489 489
490 /* Update the set of names from the current central directory contents. 490 /* Update the set of names from the current central directory contents.
491 // This reads any new central directory records since the last time we were 491 This reads any new central directory records since the last time we were
492 // here. */ 492 here. */
493 for (;;) { 493 for (;;) {
494 char *there = block_central_name(&zip->block, &zip->set); 494 char *there = block_central_name(&zip->block, &zip->set);
495 if (there == NULL) { 495 if (there == NULL) {
@@ -502,7 +502,7 @@ extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
502 /* Add there to the set. */ 502 /* Add there to the set. */
503 if (set_insert(&zip->set, there)) 503 if (set_insert(&zip->set, there))
504 /* There's already a duplicate in the central directory! We'll just 504 /* There's already a duplicate in the central directory! We'll just
505 // let this be and carry on. */ 505 let this be and carry on. */
506 set_free(&zip->set, there); 506 set_free(&zip->set, there);
507 } 507 }
508 508
@@ -945,7 +945,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
945 err=ZIP_ERRNO; 945 err=ZIP_ERRNO;
946 946
947 /* TODO.. 947 /* TODO..
948 // read the comment from the standard central header. */ 948 read the comment from the standard central header. */
949 size_comment = 0; 949 size_comment = 0;
950 } 950 }
951 else 951 else
@@ -1340,8 +1340,8 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
1340 if ((comment!=NULL) && (strlen(comment)>0xffff)) 1340 if ((comment!=NULL) && (strlen(comment)>0xffff))
1341 return ZIP_PARAMERROR; 1341 return ZIP_PARAMERROR;
1342 /* The extra field length must fit in 16 bits. If the member also requires 1342 /* The extra field length must fit in 16 bits. If the member also requires
1343 // a Zip64 extra block, that will also need to fit within that 16-bit 1343 a Zip64 extra block, that will also need to fit within that 16-bit
1344 // length, but that will be checked for later. */ 1344 length, but that will be checked for later. */
1345 if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) 1345 if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
1346 return ZIP_PARAMERROR; 1346 return ZIP_PARAMERROR;
1347 1347
@@ -1933,8 +1933,8 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
1933 } 1933 }
1934 1934
1935 /* Update how much extra free space we got in the memory buffer 1935 /* Update how much extra free space we got in the memory buffer
1936 // and increase the centralheader size so the new ZIP64 fields are included 1936 and increase the centralheader size so the new ZIP64 fields are included
1937 // ( 4 below is the size of HeaderID and DataSize field ) */ 1937 ( 4 below is the size of HeaderID and DataSize field ) */
1938 zi->ci.size_centralExtraFree -= datasize + 4; 1938 zi->ci.size_centralExtraFree -= datasize + 4;
1939 zi->ci.size_centralheader += datasize + 4; 1939 zi->ci.size_centralheader += datasize + 4;
1940 1940