From: John Darrington Date: Mon, 18 Feb 2013 08:35:53 +0000 (+0100) Subject: Zip Reader: Take members from the index if they exist. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc4deba1edb1310028d00bf6eb3217378e1cc713;p=pspp Zip Reader: Take members from the index if they exist. This allows readers to be iterated more than once. --- diff --git a/src/libpspp/zip-reader.c b/src/libpspp/zip-reader.c index 4672a1079f..59c47bc975 100644 --- a/src/libpspp/zip-reader.c +++ b/src/libpspp/zip-reader.c @@ -390,17 +390,15 @@ zip_member_open (struct zip_reader *zr, const char *member) if ( zr == NULL) return NULL; - for (i = 0 ; i < zr->n_members; ++i) + for (i = 0; i < zr->n_members; ++i) { - zm = zr->members[i] = zip_header_read_next (zr); + zm = zr->members[i]; + if (zm == NULL) + zm = zr->members[i] = zip_header_read_next (zr); if (zm && 0 == strcmp (zm->name, member)) - { - break; - } + break; else - { - zm = NULL; - } + zm = NULL; } if ( zm == NULL)