Skip to content

Commit a14fded

Browse files
committedJul 21, 2020
Stop using tabs, update clang-format config.
1 parent 29c6a39 commit a14fded

File tree

137 files changed

+5744
-5744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+5744
-5744
lines changed
 

‎.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ BreakBeforeBraces: Custom
88
BraceWrapping:
99
BeforeElse: true
1010
AlignEscapedNewlines: Left
11-
UseTab: ForContinuationAndIndentation
11+
UseTab: Never
1212
#PPDirectiveIndentStyle: AfterHash

‎examples/in-memory.c

+69-69
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,34 @@ get_data(void **datap, size_t *sizep, const char *archive) {
4646
FILE *fp;
4747

4848
if ((fp = fopen(archive, "rb")) == NULL) {
49-
if (errno != ENOENT) {
50-
fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno));
51-
return -1;
52-
}
49+
if (errno != ENOENT) {
50+
fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno));
51+
return -1;
52+
}
5353

54-
*datap = NULL;
55-
*sizep = 0;
54+
*datap = NULL;
55+
*sizep = 0;
5656

57-
return 0;
57+
return 0;
5858
}
5959

6060
if (fstat(fileno(fp), &st) < 0) {
61-
fprintf(stderr, "can't stat %s: %s\n", archive, strerror(errno));
62-
fclose(fp);
63-
return -1;
61+
fprintf(stderr, "can't stat %s: %s\n", archive, strerror(errno));
62+
fclose(fp);
63+
return -1;
6464
}
6565

6666
if ((*datap = malloc((size_t)st.st_size)) == NULL) {
67-
fprintf(stderr, "can't allocate buffer\n");
68-
fclose(fp);
69-
return -1;
67+
fprintf(stderr, "can't allocate buffer\n");
68+
fclose(fp);
69+
return -1;
7070
}
7171

7272
if (fread(*datap, 1, (size_t)st.st_size, fp) < (size_t)st.st_size) {
73-
fprintf(stderr, "can't read %s: %s\n", archive, strerror(errno));
74-
free(*datap);
75-
fclose(fp);
76-
return -1;
73+
fprintf(stderr, "can't read %s: %s\n", archive, strerror(errno));
74+
free(*datap);
75+
fclose(fp);
76+
return -1;
7777
}
7878

7979
fclose(fp);
@@ -95,25 +95,25 @@ use_data(void *data, size_t size, const char *archive) {
9595
FILE *fp;
9696

9797
if (data == NULL) {
98-
if (remove(archive) < 0 && errno != ENOENT) {
99-
fprintf(stderr, "can't remove %s: %s\n", archive, strerror(errno));
100-
return -1;
101-
}
102-
return 0;
98+
if (remove(archive) < 0 && errno != ENOENT) {
99+
fprintf(stderr, "can't remove %s: %s\n", archive, strerror(errno));
100+
return -1;
101+
}
102+
return 0;
103103
}
104104

105105
if ((fp = fopen(archive, "wb")) == NULL) {
106-
fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno));
107-
return -1;
106+
fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno));
107+
return -1;
108108
}
109109
if (fwrite(data, 1, size, fp) < size) {
110-
fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno));
111-
fclose(fp);
112-
return -1;
110+
fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno));
111+
fclose(fp);
112+
return -1;
113113
}
114114
if (fclose(fp) < 0) {
115-
fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno));
116-
return -1;
115+
fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno));
116+
return -1;
117117
}
118118

119119
return 0;
@@ -130,31 +130,31 @@ main(int argc, char *argv[]) {
130130
size_t size;
131131

132132
if (argc < 2) {
133-
fprintf(stderr, "usage: %s archive\n", argv[0]);
134-
return 1;
133+
fprintf(stderr, "usage: %s archive\n", argv[0]);
134+
return 1;
135135
}
136136
archive = argv[1];
137137

138138
/* get buffer with zip archive inside */
139139
if (get_data(&data, &size, archive) < 0) {
140-
return 1;
140+
return 1;
141141
}
142142

143143
zip_error_init(&error);
144144
/* create source from buffer */
145145
if ((src = zip_source_buffer_create(data, size, 1, &error)) == NULL) {
146-
fprintf(stderr, "can't create source: %s\n", zip_error_strerror(&error));
147-
free(data);
148-
zip_error_fini(&error);
149-
return 1;
146+
fprintf(stderr, "can't create source: %s\n", zip_error_strerror(&error));
147+
free(data);
148+
zip_error_fini(&error);
149+
return 1;
150150
}
151151

152152
/* open zip archive from source */
153153
if ((za = zip_open_from_source(src, 0, &error)) == NULL) {
154-
fprintf(stderr, "can't open zip from source: %s\n", zip_error_strerror(&error));
155-
zip_source_free(src);
156-
zip_error_fini(&error);
157-
return 1;
154+
fprintf(stderr, "can't open zip from source: %s\n", zip_error_strerror(&error));
155+
zip_source_free(src);
156+
zip_error_fini(&error);
157+
return 1;
158158
}
159159
zip_error_fini(&error);
160160

@@ -166,43 +166,43 @@ main(int argc, char *argv[]) {
166166

167167
/* close archive */
168168
if (zip_close(za) < 0) {
169-
fprintf(stderr, "can't close zip archive '%s': %s\n", archive, zip_strerror(za));
170-
return 1;
169+
fprintf(stderr, "can't close zip archive '%s': %s\n", archive, zip_strerror(za));
170+
return 1;
171171
}
172172

173173

174174
/* copy new archive to buffer */
175175

176176
if (zip_source_is_deleted(src)) {
177-
/* new archive is empty, thus no data */
178-
data = NULL;
177+
/* new archive is empty, thus no data */
178+
data = NULL;
179179
}
180180
else {
181-
zip_stat_t zst;
182-
183-
if (zip_source_stat(src, &zst) < 0) {
184-
fprintf(stderr, "can't stat source: %s\n", zip_error_strerror(zip_source_error(src)));
185-
return 1;
186-
}
187-
188-
size = zst.size;
189-
190-
if (zip_source_open(src) < 0) {
191-
fprintf(stderr, "can't open source: %s\n", zip_error_strerror(zip_source_error(src)));
192-
return 1;
193-
}
194-
if ((data = malloc(size)) == NULL) {
195-
fprintf(stderr, "malloc failed: %s\n", strerror(errno));
196-
zip_source_close(src);
197-
return 1;
198-
}
199-
if ((zip_uint64_t)zip_source_read(src, data, size) < size) {
200-
fprintf(stderr, "can't read data from source: %s\n", zip_error_strerror(zip_source_error(src)));
201-
zip_source_close(src);
202-
free(data);
203-
return 1;
204-
}
205-
zip_source_close(src);
181+
zip_stat_t zst;
182+
183+
if (zip_source_stat(src, &zst) < 0) {
184+
fprintf(stderr, "can't stat source: %s\n", zip_error_strerror(zip_source_error(src)));
185+
return 1;
186+
}
187+
188+
size = zst.size;
189+
190+
if (zip_source_open(src) < 0) {
191+
fprintf(stderr, "can't open source: %s\n", zip_error_strerror(zip_source_error(src)));
192+
return 1;
193+
}
194+
if ((data = malloc(size)) == NULL) {
195+
fprintf(stderr, "malloc failed: %s\n", strerror(errno));
196+
zip_source_close(src);
197+
return 1;
198+
}
199+
if ((zip_uint64_t)zip_source_read(src, data, size) < size) {
200+
fprintf(stderr, "can't read data from source: %s\n", zip_error_strerror(zip_source_error(src)));
201+
zip_source_close(src);
202+
free(data);
203+
return 1;
204+
}
205+
zip_source_close(src);
206206
}
207207

208208
/* we're done with src */

0 commit comments

Comments
 (0)
Please sign in to comment.