Skip to content

Commit 86cb047

Browse files
committed
rm abort and exit
1 parent c59c438 commit 86cb047

File tree

10 files changed

+20
-125
lines changed

10 files changed

+20
-125
lines changed

.Rbuildignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
^\.clangd$
44
^\.clang-format$
55
^.*\.tbi$
6-
^src/htslib-1.18/htscodecs/tests
6+
^src/htslib-1.21/htscodecs/tests
7+
^src/htslib-1.21/.*\.o$
8+
^src/.*\.o$
79
^cran-comments\.md$
810
^CRAN-SUBMISSION$
911
\.github

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: vcfppR
22
Title: Rapid Manipulation of the Variant Call Format (VCF)
3-
Version: 0.7.5
3+
Version: 0.7.6
44
Authors@R: c(
55
person("Zilong", "Li", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-5859-2078")),

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ check:
3030

3131
check2: build
3232
cd ..;\
33-
R CMD check $(PKGNAME)_$(PKGVERS).tar.gz
33+
R CMD check $(PKGNAME)_$(PKGVERS).tar.gz --as-cran
3434

3535
clean:
3636
cd ..;\

src/htslib-1.21/annot-tsv.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ error(const char *format, ...)
124124
vfprintf(stderr, format, ap);
125125
va_end(ap);
126126
fflush(stderr);
127-
exit(EXIT_FAILURE);
127+
/* exit(EXIT_FAILURE); */
128128
}
129129

130130
static nbp_t *nbp_init(void)
@@ -986,7 +986,7 @@ int main(int argc, char **argv)
986986
case 's': args->src.fname = optarg; break;
987987
case 'f': args->transfer_str = optarg; break;
988988
case 'x': args->mode = PRINT_NONMATCHING; break;
989-
case 4 : printf("\nVersion: %s\n%s\n",hts_version(),usage_text()); exit(EXIT_SUCCESS); break;
989+
case 4 : printf("\nVersion: %s\n%s\n",hts_version(),usage_text()); break;
990990
case '?': // fall through
991991
default: error("\nVersion: %s\n%s\n",hts_version(),usage_text()); break;
992992
}

src/htslib-1.21/htscodecs/htscodecs/rANS_static32x16pr.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ unsigned char *rans_compress_O0_32x16(unsigned char *in,
160160
RansEncPutSymbol_branched(&ransN[z-3], &ptr, s3);
161161
}
162162
}
163-
if (z < -1) abort();
163+
if (z < -1) return NULL;
164164
}
165165
} else {
166166
// Branchless version optimises poorly with gcc unless we have
@@ -237,7 +237,7 @@ unsigned char *rans_compress_O0_32x16(unsigned char *in,
237237
rp[3-k] += sy[k]->bias + q*sy[k]->cmpl_freq;
238238
}
239239
}
240-
if (z < -1) abort();
240+
if (z < -1) return NULL;
241241
}
242242
ptr = (uint8_t *)ptr16;
243243
}

src/htslib-1.21/htscodecs/htscodecs/rANS_static32x16pr_neon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ unsigned char *rans_compress_O0_32x16_neon(unsigned char *in,
295295
vst1q_u32(&R[z-3], Rv1);
296296
vst1q_u32(&R[z-7], Rv2);
297297
}
298-
if (z < -1) abort();
298+
if (z < -1) return NULL;
299299
}
300300
for (z = NX-1; z >= 0; z--)
301301
RansEncFlush(&R[z], &ptr);

src/htslib-1.21/htscodecs/htscodecs/varint2.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -181,26 +181,26 @@ static inline int var_put_u32(uint8_t *cp, const uint8_t *endp, uint32_t x) {
181181
uint8_t *op = cp;
182182

183183
if (x < 177) {
184-
if (endp && endp - cp < 1) abort();//return 0;
184+
if (endp && endp - cp < 1) return 0;
185185
// 0 to 176 in single byte as-is
186186
*cp++ = x;
187187
} else if (x < 16561) {
188-
if (endp && endp - cp < 2) abort();//return 0;
188+
if (endp && endp - cp < 2) return 0;
189189
*cp++ = ((x-177)>>8)+177;
190190
*cp++ = x-177;
191191
} else if (x < 540849) {
192-
if (endp && endp - cp < 3) abort();//return 0;
192+
if (endp && endp - cp < 3) return 0;
193193
*cp++ = ((x-16561)>>16)+241;
194194
*cp++ = (x-16561)>>8;
195195
*cp++ = x-16561;
196196
} else if (x < (1<<24)) {
197-
if (endp && endp - cp < 4) abort();//return 0;
197+
if (endp && endp - cp < 4) return 0;
198198
*cp++ = 249;
199199
*cp++ = x>>16;
200200
*cp++ = x>>8;
201201
*cp++ = x;
202202
} else {
203-
if (endp && endp - cp < 5) abort();//return 0;
203+
if (endp && endp - cp < 5) return 0;
204204
*cp++ = 250;
205205
*cp++ = x>>24;
206206
*cp++ = x>>16;

src/htslib-1.21/htsfile.c

+1-108
Original file line numberDiff line numberDiff line change
@@ -210,115 +210,8 @@ static void copy_raw(const char *srcfilename, const char *destfilename)
210210
free(buffer);
211211
}
212212

213-
static void usage(FILE *fp, int status)
214-
{
215-
fprintf(fp,
216-
"Usage: htsfile [-chHv] FILE...\n"
217-
" htsfile --copy [-v] FILE DESTFILE\n"
218-
"Options:\n"
219-
" -c, --view Write textual form of FILEs to standard output\n"
220-
" -C, --copy Copy the exact contents of FILE to DESTFILE\n"
221-
" -h, --header-only Display only headers in view mode, not records\n"
222-
" -H, --no-header Suppress header display in view mode\n"
223-
" -v, --verbose Increase verbosity of warnings and diagnostics\n");
224-
exit(status);
225-
}
226213

227214
int main(int argc, char **argv)
228215
{
229-
static const struct option options[] = {
230-
{ "copy", no_argument, NULL, 'C' },
231-
{ "header-only", no_argument, NULL, 'h' },
232-
{ "no-header", no_argument, NULL, 'H' },
233-
{ "view", no_argument, NULL, 'c' },
234-
{ "verbose", no_argument, NULL, 'v' },
235-
{ "help", no_argument, NULL, 2 },
236-
{ "version", no_argument, NULL, 1 },
237-
{ NULL, 0, NULL, 0 }
238-
};
239-
240-
int c, i;
241-
242-
status = EXIT_SUCCESS;
243-
while ((c = getopt_long(argc, argv, "cChHv", options, NULL)) >= 0)
244-
switch (c) {
245-
case 'c': mode = view_all; break;
246-
case 'C': mode = copy; break;
247-
case 'h': mode = view_headers; show_headers = 1; break;
248-
case 'H': show_headers = 0; break;
249-
case 'v': hts_verbose++; verbose++; break;
250-
case 1:
251-
printf(
252-
"htsfile (htslib) %s\n"
253-
"Copyright (C) 2024 Genome Research Ltd.\n",
254-
hts_version());
255-
exit(EXIT_SUCCESS);
256-
break;
257-
case 2: usage(stdout, EXIT_SUCCESS); break;
258-
default: usage(stderr, EXIT_FAILURE); break;
259-
}
260-
261-
if (optind == argc) usage(stderr, EXIT_FAILURE);
262-
263-
if (mode == copy) {
264-
if (optind + 2 != argc) usage(stderr, EXIT_FAILURE);
265-
copy_raw(argv[optind], argv[optind + 1]);
266-
return status;
267-
}
268-
269-
for (i = optind; i < argc; i++) {
270-
hFILE *fp = hopen(argv[i], "r");
271-
if (fp == NULL) {
272-
error("can't open \"%s\"", argv[i]);
273-
continue;
274-
}
275-
276-
if (mode == identify) {
277-
htsFormat fmt;
278-
if (hts_detect_format2(fp, argv[i], &fmt) < 0) {
279-
error("detecting \"%s\" format failed", argv[i]);
280-
hclose_abruptly(fp);
281-
continue;
282-
}
283-
284-
char *description = hts_format_description(&fmt);
285-
printf("%s:\t%s\n", argv[i], description);
286-
free(description);
287-
}
288-
else {
289-
htsFile *hts = hts_hopen(fp, argv[i], "r");
290-
if (hts) {
291-
switch (hts_get_format(hts)->category) {
292-
case sequence_data:
293-
view_sam(hts, argv[i]);
294-
break;
295-
case variant_data:
296-
view_vcf(hts, argv[i]);
297-
break;
298-
default:
299-
if (verbose)
300-
view_raw(fp, argv[i]);
301-
else {
302-
errno = 0;
303-
error("can't view \"%s\": unknown format", argv[i]);
304-
}
305-
break;
306-
}
307-
308-
if (hts_close(hts) < 0) error("closing \"%s\" failed", argv[i]);
309-
fp = NULL;
310-
}
311-
else if ((errno == EFTYPE || errno == ENOEXEC) && verbose)
312-
view_raw(fp, argv[i]);
313-
else
314-
error("can't view \"%s\"", argv[i]);
315-
}
316-
317-
if (fp && hclose(fp) < 0) error("closing \"%s\" failed", argv[i]);
318-
}
319-
320-
if (fclose(stdout) != 0 && errno != EBADF)
321-
error("closing standard output failed");
322-
323-
return status;
216+
return 0;
324217
}

src/htslib-1.21/tabix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ error(const char *format, ...)
6666
vfprintf(stderr, format, ap);
6767
va_end(ap);
6868
fflush(stderr);
69-
exit(EXIT_FAILURE);
69+
/* exit(EXIT_FAILURE); */
7070
}
7171

7272
static void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) HTS_NORETURN
@@ -86,7 +86,7 @@ error_errno(const char *format, ...)
8686
fprintf(stderr, "\n");
8787
}
8888
fflush(stderr);
89-
exit(EXIT_FAILURE);
89+
/* exit(EXIT_FAILURE); */
9090
}
9191

9292

src/htslib-1.21/thread_pool.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ int main(int argc, char **argv) {
15201520
fprintf(stderr, "ordered1 # Main thread with non-block API\n");
15211521
fprintf(stderr, "ordered2 # Dispatch thread, blocking API\n");
15221522
fprintf(stderr, "pipe # Multi-stage pipeline, several queues\n");
1523-
exit(1);
1523+
return 1;
15241524
}
15251525

15261526
n = atoi(argv[2]);
@@ -1530,6 +1530,6 @@ int main(int argc, char **argv) {
15301530
if (strcmp(argv[1], "pipe") == 0) return test_pipe(n);
15311531

15321532
fprintf(stderr, "Unknown sub-command\n");
1533-
exit(1);
1533+
return 1;
15341534
}
15351535
#endif

0 commit comments

Comments
 (0)