View | Details | Raw Unified | Return to bug 257599 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.bin/ar/acplex.l (-2 / +2 lines)
Lines 33-40 __FBSDID("$FreeBSD$"); Link Here
33
#include <err.h>
33
#include <err.h>
34
#include <errno.h>
34
#include <errno.h>
35
#include <stdio.h>
35
#include <stdio.h>
36
#include <stdlib.h>
36
#include <string.h>
37
#include <string.h>
37
#include <sysexits.h>
38
38
39
#include "y.tab.h"
39
#include "y.tab.h"
40
40
Lines 72-78 SAVE|save { return (SAVE); } Link Here
72
[-_A-Za-z0-9/:$.\\]+	{
72
[-_A-Za-z0-9/:$.\\]+	{
73
	yylval.str = strdup(yytext);
73
	yylval.str = strdup(yytext);
74
	if (yylval.str == NULL)
74
	if (yylval.str == NULL)
75
		errc(EX_SOFTWARE, errno, "strdup failed");
75
		errc(EXIT_FAILURE, errno, "strdup failed");
76
	return (FNAME);
76
	return (FNAME);
77
}
77
}
78
78
(-)b/usr.bin/ar/acpyacc.y (-3 / +3 lines)
Lines 191-197 directory_cmd Link Here
191
	;
191
	;
192
192
193
end_cmd
193
end_cmd
194
	: END { arscp_end(EX_OK); }
194
	: END { arscp_end(EXIT_SUCCESS); }
195
	;
195
	;
196
196
197
extract_cmd
197
extract_cmd
Lines 655-663 ar_mode_script(struct bsdar *ar) Link Here
655
	interactive = isatty(fileno(stdin));
655
	interactive = isatty(fileno(stdin));
656
	while(yyparse()) {
656
	while(yyparse()) {
657
		if (!interactive)
657
		if (!interactive)
658
			arscp_end(1);
658
			arscp_end(EXIT_FAILURE);
659
	}
659
	}
660
660
661
	/* Script ends without END */
661
	/* Script ends without END */
662
	arscp_end(EX_OK);
662
	arscp_end(EXIT_SUCCESS);
663
}
663
}
(-)b/usr.bin/ar/ar.c (-29 / +33 lines)
Lines 72-78 __FBSDID("$FreeBSD$"); Link Here
72
#include <stdio.h>
72
#include <stdio.h>
73
#include <stdlib.h>
73
#include <stdlib.h>
74
#include <string.h>
74
#include <string.h>
75
#include <sysexits.h>
76
75
77
#include "ar.h"
76
#include "ar.h"
78
77
Lines 102-111 main(int argc, char **argv) Link Here
102
	struct bsdar	*bsdar, bsdar_storage;
101
	struct bsdar	*bsdar, bsdar_storage;
103
	char		*p;
102
	char		*p;
104
	size_t		 len;
103
	size_t		 len;
105
	int		 i, opt, Dflag, Uflag;
104
	int		 exitcode, i, opt, Dflag, Uflag;
106
105
107
	bsdar = &bsdar_storage;
106
	bsdar = &bsdar_storage;
108
	memset(bsdar, 0, sizeof(*bsdar));
107
	memset(bsdar, 0, sizeof(*bsdar));
108
	exitcode = EXIT_SUCCESS;
109
	Dflag = 0;
109
	Dflag = 0;
110
	Uflag = 0;
110
	Uflag = 0;
111
111
Lines 151-159 main(int argc, char **argv) Link Here
151
			bsdar->options |= AR_D;
151
			bsdar->options |= AR_D;
152
		bsdar->options |= AR_S;
152
		bsdar->options |= AR_S;
153
		while ((bsdar->filename = *argv++) != NULL)
153
		while ((bsdar->filename = *argv++) != NULL)
154
			ar_mode_s(bsdar);
154
			if (ar_mode_s(bsdar))
155
				exitcode = EXIT_FAILURE;
155
156
156
		exit(EX_OK);
157
		exit(exitcode);
157
	} else {
158
	} else {
158
		if (argc < 2)
159
		if (argc < 2)
159
			bsdar_usage();
160
			bsdar_usage();
Lines 161-167 main(int argc, char **argv) Link Here
161
		if (*argv[1] != '-') {
162
		if (*argv[1] != '-') {
162
			len = strlen(argv[1]) + 2;
163
			len = strlen(argv[1]) + 2;
163
			if ((p = malloc(len)) == NULL)
164
			if ((p = malloc(len)) == NULL)
164
				bsdar_errc(bsdar, EX_SOFTWARE, errno,
165
				bsdar_errc(bsdar, EXIT_FAILURE, errno,
165
				    "malloc failed");
166
				    "malloc failed");
166
			*p = '-';
167
			*p = '-';
167
			(void)strlcpy(p + 1, argv[1], len - 1);
168
			(void)strlcpy(p + 1, argv[1], len - 1);
Lines 262-284 main(int argc, char **argv) Link Here
262
		bsdar_usage();
263
		bsdar_usage();
263
264
264
	if (bsdar->options & AR_A && bsdar->options & AR_B)
265
	if (bsdar->options & AR_A && bsdar->options & AR_B)
265
		bsdar_errc(bsdar, EX_USAGE, 0,
266
		bsdar_errc(bsdar, EXIT_FAILURE, 0,
266
		    "only one of -a and -[bi] options allowed");
267
		    "only one of -a and -[bi] options allowed");
267
268
268
	if (bsdar->options & AR_J && bsdar->options & AR_Z)
269
	if (bsdar->options & AR_J && bsdar->options & AR_Z)
269
		bsdar_errc(bsdar, EX_USAGE, 0,
270
		bsdar_errc(bsdar, EXIT_FAILURE, 0,
270
		    "only one of -j and -z options allowed");
271
		    "only one of -j and -z options allowed");
271
272
272
	if (bsdar->options & AR_S && bsdar->options & AR_SS)
273
	if (bsdar->options & AR_S && bsdar->options & AR_SS)
273
		bsdar_errc(bsdar, EX_USAGE, 0,
274
		bsdar_errc(bsdar, EXIT_FAILURE, 0,
274
		    "only one of -s and -S options allowed");
275
		    "only one of -s and -S options allowed");
275
276
276
	if (bsdar->options & (AR_A | AR_B)) {
277
	if (bsdar->options & (AR_A | AR_B)) {
277
		if (*argv == NULL)
278
		if (*argv == NULL)
278
			bsdar_errc(bsdar, EX_USAGE, 0,
279
			bsdar_errc(bsdar, EXIT_FAILURE, 0,
279
			    "no position operand specified");
280
			    "no position operand specified");
280
		if ((bsdar->posarg = basename(*argv)) == NULL)
281
		if ((bsdar->posarg = basename(*argv)) == NULL)
281
			bsdar_errc(bsdar, EX_SOFTWARE, errno,
282
			bsdar_errc(bsdar, EXIT_FAILURE, errno,
282
			    "basename failed");
283
			    "basename failed");
283
		argc--;
284
		argc--;
284
		argv++;
285
		argv++;
Lines 310-316 main(int argc, char **argv) Link Here
310
311
311
	if (bsdar->mode == 'M') {
312
	if (bsdar->mode == 'M') {
312
		ar_mode_script(bsdar);
313
		ar_mode_script(bsdar);
313
		exit(EX_OK);
314
		exit(EXIT_SUCCESS);
314
	}
315
	}
315
316
316
	if ((bsdar->filename = *argv) == NULL)
317
	if ((bsdar->filename = *argv) == NULL)
Lines 321-364 main(int argc, char **argv) Link Here
321
322
322
	if ((!bsdar->mode || strchr("ptx", bsdar->mode)) &&
323
	if ((!bsdar->mode || strchr("ptx", bsdar->mode)) &&
323
	    bsdar->options & AR_S) {
324
	    bsdar->options & AR_S) {
324
		ar_mode_s(bsdar);
325
		exitcode = ar_mode_s(bsdar);
325
		if (!bsdar->mode)
326
		if (!bsdar->mode)
326
			exit(EX_OK);
327
			exit(exitcode);
327
	}
328
	}
328
329
329
	switch(bsdar->mode) {
330
	switch(bsdar->mode) {
330
	case 'd':
331
	case 'd':
331
		ar_mode_d(bsdar);
332
		exitcode = ar_mode_d(bsdar);
332
		break;
333
		break;
333
	case 'm':
334
	case 'm':
334
		ar_mode_m(bsdar);
335
		exitcode = ar_mode_m(bsdar);
335
		break;
336
		break;
336
	case 'p':
337
	case 'p':
337
		ar_mode_p(bsdar);
338
		exitcode = ar_mode_p(bsdar);
338
		break;
339
		break;
339
	case 'q':
340
	case 'q':
340
		ar_mode_q(bsdar);
341
		exitcode = ar_mode_q(bsdar);
341
		break;
342
		break;
342
	case 'r':
343
	case 'r':
343
		ar_mode_r(bsdar);
344
		exitcode = ar_mode_r(bsdar);
344
		break;
345
		break;
345
	case 't':
346
	case 't':
346
		ar_mode_t(bsdar);
347
		exitcode = ar_mode_t(bsdar);
347
		break;
348
		break;
348
	case 'x':
349
	case 'x':
349
		ar_mode_x(bsdar);
350
		exitcode = ar_mode_x(bsdar);
350
		break;
351
		break;
351
	default:
352
	default:
352
		bsdar_usage();
353
		bsdar_usage();
353
		/* NOTREACHED */
354
		/* NOTREACHED */
354
	}
355
	}
355
356
356
	for (i = 0; i < bsdar->argc; i++)
357
	for (i = 0; i < bsdar->argc; i++) {
357
		if (bsdar->argv[i] != NULL)
358
		if (bsdar->argv[i] != NULL) {
358
			bsdar_warnc(bsdar, 0, "%s: not found in archive",
359
			bsdar_warnc(bsdar, 0, "%s: not found in archive",
359
			    bsdar->argv[i]);
360
			    bsdar->argv[i]);
361
			exitcode = EXIT_FAILURE;
362
		}
363
	}
360
364
361
	exit(EX_OK);
365
	exit(exitcode);
362
}
366
}
363
367
364
static void
368
static void
Lines 366-372 set_mode(struct bsdar *bsdar, char opt) Link Here
366
{
370
{
367
371
368
	if (bsdar->mode != '\0' && bsdar->mode != opt)
372
	if (bsdar->mode != '\0' && bsdar->mode != opt)
369
		bsdar_errc(bsdar, EX_USAGE, 0,
373
		bsdar_errc(bsdar, EXIT_FAILURE, 0,
370
		    "Can't specify both -%c and -%c", opt, bsdar->mode);
374
		    "Can't specify both -%c and -%c", opt, bsdar->mode);
371
	bsdar->mode = opt;
375
	bsdar->mode = opt;
372
}
376
}
Lines 376-382 only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes) Link Here
376
{
380
{
377
381
378
	if (strchr(valid_modes, bsdar->mode) == NULL)
382
	if (strchr(valid_modes, bsdar->mode) == NULL)
379
		bsdar_errc(bsdar, EX_USAGE, 0,
383
		bsdar_errc(bsdar, EXIT_FAILURE, 0,
380
		    "Option %s is not permitted in mode -%c", opt, bsdar->mode);
384
		    "Option %s is not permitted in mode -%c", opt, bsdar->mode);
381
}
385
}
382
386
Lines 395-401 bsdar_usage(void) Link Here
395
	(void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n");
399
	(void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n");
396
	(void)fprintf(stderr, "\tar -x [-CTouv] archive [file ...]\n");
400
	(void)fprintf(stderr, "\tar -x [-CTouv] archive [file ...]\n");
397
	(void)fprintf(stderr, "\tar -V\n");
401
	(void)fprintf(stderr, "\tar -V\n");
398
	exit(EX_USAGE);
402
	exit(EXIT_FAILURE);
399
}
403
}
400
404
401
static void
405
static void
Lines 404-422 ranlib_usage(void) Link Here
404
408
405
	(void)fprintf(stderr, "usage:	ranlib [-DtU] archive ...\n");
409
	(void)fprintf(stderr, "usage:	ranlib [-DtU] archive ...\n");
406
	(void)fprintf(stderr, "\tranlib -V\n");
410
	(void)fprintf(stderr, "\tranlib -V\n");
407
	exit(EX_USAGE);
411
	exit(EXIT_FAILURE);
408
}
412
}
409
413
410
static void
414
static void
411
bsdar_version(void)
415
bsdar_version(void)
412
{
416
{
413
	(void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version_string());
417
	(void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version_string());
414
	exit(EX_OK);
418
	exit(EXIT_SUCCESS);
415
}
419
}
416
420
417
static void
421
static void
418
ranlib_version(void)
422
ranlib_version(void)
419
{
423
{
420
	(void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version_string());
424
	(void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version_string());
421
	exit(EX_OK);
425
	exit(EXIT_SUCCESS);
422
}
426
}
(-)b/usr.bin/ar/ar.h (-10 / +10 lines)
Lines 54-60 Link Here
54
 */
54
 */
55
#define	AC(CALL) do {							\
55
#define	AC(CALL) do {							\
56
	if ((CALL))							\
56
	if ((CALL))							\
57
		bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s",	\
57
		bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s",	\
58
		    archive_error_string(a));				\
58
		    archive_error_string(a));				\
59
} while (0)
59
} while (0)
60
60
Lines 117-129 struct bsdar { Link Here
117
void	bsdar_errc(struct bsdar *, int _eval, int _code,
117
void	bsdar_errc(struct bsdar *, int _eval, int _code,
118
	    const char *fmt, ...) __dead2;
118
	    const char *fmt, ...) __dead2;
119
void	bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...);
119
void	bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...);
120
void	ar_mode_d(struct bsdar *bsdar);
120
int	ar_mode_d(struct bsdar *bsdar);
121
void	ar_mode_m(struct bsdar *bsdar);
121
int	ar_mode_m(struct bsdar *bsdar);
122
void	ar_mode_p(struct bsdar *bsdar);
122
int	ar_mode_p(struct bsdar *bsdar);
123
void	ar_mode_q(struct bsdar *bsdar);
123
int	ar_mode_q(struct bsdar *bsdar);
124
void	ar_mode_r(struct bsdar *bsdar);
124
int	ar_mode_r(struct bsdar *bsdar);
125
void	ar_mode_s(struct bsdar *bsdar);
125
int	ar_mode_s(struct bsdar *bsdar);
126
void	ar_mode_t(struct bsdar *bsdar);
126
int	ar_mode_t(struct bsdar *bsdar);
127
void	ar_mode_x(struct bsdar *bsdar);
127
int	ar_mode_x(struct bsdar *bsdar);
128
void	ar_mode_A(struct bsdar *bsdar);
128
int	ar_mode_A(struct bsdar *bsdar);
129
void	ar_mode_script(struct bsdar *ar);
129
void	ar_mode_script(struct bsdar *ar);
(-)b/usr.bin/ar/read.c (-13 / +23 lines)
Lines 37-74 __FBSDID("$FreeBSD$"); Link Here
37
#include <errno.h>
37
#include <errno.h>
38
#include <libgen.h>
38
#include <libgen.h>
39
#include <stdio.h>
39
#include <stdio.h>
40
#include <stdlib.h>
40
#include <string.h>
41
#include <string.h>
41
#include <sysexits.h>
42
42
43
#include "ar.h"
43
#include "ar.h"
44
44
45
static void read_archive(struct bsdar *bsdar, char mode);
45
static int read_archive(struct bsdar *bsdar, char mode);
46
46
47
void
47
int
48
ar_mode_p(struct bsdar *bsdar)
48
ar_mode_p(struct bsdar *bsdar)
49
{
49
{
50
50
51
	read_archive(bsdar, 'p');
51
	return (read_archive(bsdar, 'p'));
52
}
52
}
53
53
54
void
54
int
55
ar_mode_t(struct bsdar *bsdar)
55
ar_mode_t(struct bsdar *bsdar)
56
{
56
{
57
57
58
	read_archive(bsdar, 't');
58
	return (read_archive(bsdar, 't'));
59
}
59
}
60
60
61
void
61
int
62
ar_mode_x(struct bsdar *bsdar)
62
ar_mode_x(struct bsdar *bsdar)
63
{
63
{
64
64
65
	read_archive(bsdar, 'x');
65
	return (read_archive(bsdar, 'x'));
66
}
66
}
67
67
68
/*
68
/*
69
 * Handle read modes: 'x', 't' and 'p'.
69
 * Handle read modes: 'x', 't' and 'p'.
70
 */
70
 */
71
static void
71
static int
72
read_archive(struct bsdar *bsdar, char mode)
72
read_archive(struct bsdar *bsdar, char mode)
73
{
73
{
74
	struct archive		 *a;
74
	struct archive		 *a;
Lines 85-97 read_archive(struct bsdar *bsdar, char mode) Link Here
85
	char			**av;
85
	char			**av;
86
	char			  buf[25];
86
	char			  buf[25];
87
	char			  find;
87
	char			  find;
88
	int			  flags, r, i;
88
	int			  exitcode, flags, r, i;
89
89
90
	if ((a = archive_read_new()) == NULL)
90
	if ((a = archive_read_new()) == NULL)
91
		bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed");
91
		bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed");
92
	archive_read_support_format_ar(a);
92
	archive_read_support_format_ar(a);
93
	AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ));
93
	AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ));
94
94
95
	exitcode = EXIT_SUCCESS;
96
95
	for (;;) {
97
	for (;;) {
96
		r = archive_read_next_header(a, &entry);
98
		r = archive_read_next_header(a, &entry);
97
		if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
99
		if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
Lines 120-126 read_archive(struct bsdar *bsdar, char mode) Link Here
120
				if (*av == NULL)
122
				if (*av == NULL)
121
					continue;
123
					continue;
122
				if ((bname = basename(*av)) == NULL)
124
				if ((bname = basename(*av)) == NULL)
123
					bsdar_errc(bsdar, EX_SOFTWARE, errno,
125
					bsdar_errc(bsdar, EXIT_FAILURE, errno,
124
					    "basename failed");
126
					    "basename failed");
125
				if (strcmp(bname, name) != 0)
127
				if (strcmp(bname, name) != 0)
126
					continue;
128
					continue;
Lines 206-216 read_archive(struct bsdar *bsdar, char mode) Link Here
206
				r = archive_read_extract(a, entry, flags);
208
				r = archive_read_extract(a, entry, flags);
207
			}
209
			}
208
210
209
			if (r)
211
			if (r) {
210
				bsdar_warnc(bsdar, archive_errno(a), "%s",
212
				bsdar_warnc(bsdar, archive_errno(a), "%s",
211
				    archive_error_string(a));
213
				    archive_error_string(a));
214
				exitcode = EXIT_FAILURE;
215
			}
212
		}
216
		}
213
	}
217
	}
218
219
	if (r == ARCHIVE_FATAL)
220
		exitcode = EXIT_FAILURE;
221
214
	AC(archive_read_close(a));
222
	AC(archive_read_close(a));
215
	AC(archive_read_free(a));
223
	AC(archive_read_free(a));
224
225
	return (exitcode);
216
}
226
}
(-)b/usr.bin/ar/write.c (-20 / +29 lines)
Lines 67-118 static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, Link Here
67
static void	prefault_buffer(const char *buf, size_t s);
67
static void	prefault_buffer(const char *buf, size_t s);
68
static void	read_objs(struct bsdar *bsdar, const char *archive,
68
static void	read_objs(struct bsdar *bsdar, const char *archive,
69
		    int checkargv);
69
		    int checkargv);
70
static void	write_archive(struct bsdar *bsdar, char mode);
70
static int	write_archive(struct bsdar *bsdar, char mode);
71
static void	write_cleanup(struct bsdar *bsdar);
71
static void	write_cleanup(struct bsdar *bsdar);
72
static void	write_data(struct bsdar *bsdar, struct archive *a,
72
static void	write_data(struct bsdar *bsdar, struct archive *a,
73
		    const void *buf, size_t s);
73
		    const void *buf, size_t s);
74
static void	write_objs(struct bsdar *bsdar);
74
static void	write_objs(struct bsdar *bsdar);
75
75
76
void
76
int
77
ar_mode_d(struct bsdar *bsdar)
77
ar_mode_d(struct bsdar *bsdar)
78
{
78
{
79
79
80
	write_archive(bsdar, 'd');
80
	return (write_archive(bsdar, 'd'));
81
}
81
}
82
82
83
void
83
int
84
ar_mode_m(struct bsdar *bsdar)
84
ar_mode_m(struct bsdar *bsdar)
85
{
85
{
86
86
87
	write_archive(bsdar, 'm');
87
	return (write_archive(bsdar, 'm'));
88
}
88
}
89
89
90
void
90
int
91
ar_mode_q(struct bsdar *bsdar)
91
ar_mode_q(struct bsdar *bsdar)
92
{
92
{
93
93
94
	write_archive(bsdar, 'q');
94
	return (write_archive(bsdar, 'q'));
95
}
95
}
96
96
97
void
97
int
98
ar_mode_r(struct bsdar *bsdar)
98
ar_mode_r(struct bsdar *bsdar)
99
{
99
{
100
100
101
	write_archive(bsdar, 'r');
101
	return (write_archive(bsdar, 'r'));
102
}
102
}
103
103
104
void
104
int
105
ar_mode_s(struct bsdar *bsdar)
105
ar_mode_s(struct bsdar *bsdar)
106
{
106
{
107
107
108
	write_archive(bsdar, 's');
108
	return (write_archive(bsdar, 's'));
109
}
109
}
110
110
111
void
111
int
112
ar_mode_A(struct bsdar *bsdar)
112
ar_mode_A(struct bsdar *bsdar)
113
{
113
{
114
114
115
	write_archive(bsdar, 'A');
115
	return (write_archive(bsdar, 'A'));
116
}
116
}
117
117
118
/*
118
/*
Lines 378-393 read_objs(struct bsdar *bsdar, const char *archive, int checkargv) Link Here
378
/*
378
/*
379
 * Determine the constitution of resulting archive.
379
 * Determine the constitution of resulting archive.
380
 */
380
 */
381
static void
381
static int
382
write_archive(struct bsdar *bsdar, char mode)
382
write_archive(struct bsdar *bsdar, char mode)
383
{
383
{
384
	struct ar_obj		 *nobj, *obj, *obj_temp, *pos;
384
	struct ar_obj		 *nobj, *obj, *obj_temp, *pos;
385
	struct stat		  sb;
385
	struct stat		  sb;
386
	const char		 *bname;
386
	const char		 *bname;
387
	char			**av;
387
	char			**av;
388
	int			  i;
388
	int			  exitcode, i;
389
389
390
	TAILQ_INIT(&bsdar->v_obj);
390
	TAILQ_INIT(&bsdar->v_obj);
391
	exitcode = EXIT_SUCCESS;
391
	nobj = NULL;
392
	nobj = NULL;
392
	pos = NULL;
393
	pos = NULL;
393
	memset(&sb, 0, sizeof(sb));
394
	memset(&sb, 0, sizeof(sb));
Lines 400-413 write_archive(struct bsdar *bsdar, char mode) Link Here
400
		if (errno != ENOENT) {
401
		if (errno != ENOENT) {
401
			bsdar_warnc(bsdar, 0, "stat %s failed",
402
			bsdar_warnc(bsdar, 0, "stat %s failed",
402
			    bsdar->filename);
403
			    bsdar->filename);
403
			return;
404
			return (EXIT_FAILURE);
404
		}
405
		}
405
406
406
		/* We do not create archive in mode 'd', 'm' and 's'.  */
407
		/* We do not create archive in mode 'd', 'm' and 's'.  */
407
		if (mode != 'r' && mode != 'q') {
408
		if (mode != 'r' && mode != 'q') {
408
			bsdar_warnc(bsdar, 0, "%s: no such file",
409
			bsdar_warnc(bsdar, 0, "%s: no such file",
409
			    bsdar->filename);
410
			    bsdar->filename);
410
			return;
411
			return (EXIT_FAILURE);
411
		}
412
		}
412
413
413
		/* Issue a warning if -c is not specified when creating. */
414
		/* Issue a warning if -c is not specified when creating. */
Lines 491-498 write_archive(struct bsdar *bsdar, char mode) Link Here
491
				 */
492
				 */
492
				nobj = create_obj_from_file(bsdar, *av,
493
				nobj = create_obj_from_file(bsdar, *av,
493
				    obj->mtime);
494
				    obj->mtime);
494
				if (nobj == NULL)
495
				if (nobj == NULL) {
496
					exitcode = EXIT_FAILURE;
495
					goto skip_obj;
497
					goto skip_obj;
498
				}
496
			}
499
			}
497
500
498
			if (bsdar->options & AR_V)
501
			if (bsdar->options & AR_V)
Lines 526-533 write_archive(struct bsdar *bsdar, char mode) Link Here
526
		av = &bsdar->argv[i];
529
		av = &bsdar->argv[i];
527
		if (*av != NULL && (mode == 'r' || mode == 'q')) {
530
		if (*av != NULL && (mode == 'r' || mode == 'q')) {
528
			nobj = create_obj_from_file(bsdar, *av, 0);
531
			nobj = create_obj_from_file(bsdar, *av, 0);
529
			if (nobj != NULL)
532
			if (nobj == NULL) {
530
				insert_obj(bsdar, nobj, pos);
533
				exitcode = EXIT_FAILURE;
534
				*av = NULL;
535
				continue;
536
			}
537
			insert_obj(bsdar, nobj, pos);
531
			if (bsdar->options & AR_V && nobj != NULL)
538
			if (bsdar->options & AR_V && nobj != NULL)
532
				(void)fprintf(stdout, "a - %s\n", *av);
539
				(void)fprintf(stdout, "a - %s\n", *av);
533
			*av = NULL;
540
			*av = NULL;
Lines 537-542 write_archive(struct bsdar *bsdar, char mode) Link Here
537
write_objs:
544
write_objs:
538
	write_objs(bsdar);
545
	write_objs(bsdar);
539
	write_cleanup(bsdar);
546
	write_cleanup(bsdar);
547
548
	return (exitcode);
540
}
549
}
541
550
542
/*
551
/*

Return to bug 257599