diff options
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -79,7 +79,6 @@ local void gz_reset(state) | |||
79 | if (state->mode == GZ_READ) { /* for reading ... */ | 79 | if (state->mode == GZ_READ) { /* for reading ... */ |
80 | state->eof = 0; /* not at end of file */ | 80 | state->eof = 0; /* not at end of file */ |
81 | state->how = LOOK; /* look for gzip header */ | 81 | state->how = LOOK; /* look for gzip header */ |
82 | state->direct = 1; /* default for empty file */ | ||
83 | } | 82 | } |
84 | state->seek = 0; /* no seek request pending */ | 83 | state->seek = 0; /* no seek request pending */ |
85 | gz_error(state, Z_OK, NULL); /* clear error */ | 84 | gz_error(state, Z_OK, NULL); /* clear error */ |
@@ -111,6 +110,7 @@ local gzFile gz_open(path, fd, mode) | |||
111 | state->mode = GZ_NONE; | 110 | state->mode = GZ_NONE; |
112 | state->level = Z_DEFAULT_COMPRESSION; | 111 | state->level = Z_DEFAULT_COMPRESSION; |
113 | state->strategy = Z_DEFAULT_STRATEGY; | 112 | state->strategy = Z_DEFAULT_STRATEGY; |
113 | state->direct = 0; | ||
114 | while (*mode) { | 114 | while (*mode) { |
115 | if (*mode >= '0' && *mode <= '9') | 115 | if (*mode >= '0' && *mode <= '9') |
116 | state->level = *mode - '0'; | 116 | state->level = *mode - '0'; |
@@ -143,6 +143,8 @@ local gzFile gz_open(path, fd, mode) | |||
143 | break; | 143 | break; |
144 | case 'F': | 144 | case 'F': |
145 | state->strategy = Z_FIXED; | 145 | state->strategy = Z_FIXED; |
146 | case 'T': | ||
147 | state->direct = 1; | ||
146 | default: /* could consider as an error, but just ignore */ | 148 | default: /* could consider as an error, but just ignore */ |
147 | ; | 149 | ; |
148 | } | 150 | } |
@@ -155,6 +157,15 @@ local gzFile gz_open(path, fd, mode) | |||
155 | return NULL; | 157 | return NULL; |
156 | } | 158 | } |
157 | 159 | ||
160 | /* can't force transparent read */ | ||
161 | if (state->mode == GZ_READ) { | ||
162 | if (state->direct) { | ||
163 | free(state); | ||
164 | return NULL; | ||
165 | } | ||
166 | state->direct = 1; /* for empty file */ | ||
167 | } | ||
168 | |||
158 | /* save the path name for error messages */ | 169 | /* save the path name for error messages */ |
159 | state->path = malloc(strlen(path) + 1); | 170 | state->path = malloc(strlen(path) + 1); |
160 | if (state->path == NULL) { | 171 | if (state->path == NULL) { |