@@ -77,7 +77,7 @@ shuffile(const char *input, int argn, size_t inputlen)
77
77
size_t len ;
78
78
79
79
if ((args = reallocarray (args , argn , sizeof (char * ))) == NULL )
80
- err (1 , "shuffile" );
80
+ err (1 , "could not create shuffile buffer " );
81
81
82
82
while (i < argn ) {
83
83
for (s = input ; * s != delimiter ; s ++ ) {
@@ -87,7 +87,7 @@ shuffile(const char *input, int argn, size_t inputlen)
87
87
len = s - input ;
88
88
89
89
if ((args [i ] = malloc (len + 1 )) == NULL )
90
- err (1 , "shuffile" );
90
+ err (1 , "could not create shuffile item buffer " );
91
91
argt = args [i ++ ];
92
92
93
93
while (len -- > 0 )
@@ -160,7 +160,7 @@ repledge(int oflag)
160
160
new = "stdio" ;
161
161
162
162
if (pledge (new , NULL ) == -1 )
163
- errx (1 , "pledge " );
163
+ err (1 , "repledge " );
164
164
#endif
165
165
}
166
166
@@ -183,7 +183,7 @@ static void __dead
183
183
version (void )
184
184
{
185
185
186
- fputs ("shuf 2.8 \n"
186
+ fputs ("shuf 2.9 \n"
187
187
"Copyright (c) 2017-2019 Brian Callahan <[email protected] >\n"
188
188
"\nPermission to use, copy, modify, and distribute this software"
189
189
" for any\npurpose with or without fee is hereby granted, "
@@ -213,26 +213,22 @@ main(int argc, char *argv[])
213
213
214
214
#ifdef HAVE_PLEDGE
215
215
if (pledge ("stdio rpath wpath cpath" , NULL ) == -1 )
216
- errx (1 , "pledge" );
216
+ err (1 , "pledge" );
217
217
#endif
218
218
219
219
while ((ch = getopt (argc , argv , "ehi:n:o:rvz" )) != -1 ) {
220
220
switch (ch ) {
221
221
case 'e' :
222
- if (iflag )
223
- errx (1 , "cannot combine -e with -i" );
224
222
eflag = 1 ;
225
223
break ;
226
224
case 'h' :
227
225
usage ();
228
226
case 'i' :
229
- if (eflag )
230
- errx (1 , "cannot combine -i with -e" );
231
227
if (iflag ++ )
232
- errx (1 , "cannot have multiple -i" );
228
+ errx (1 , "cannot have multiple -i options " );
233
229
234
230
if ((argp = strchr (optarg , '-' )) == NULL )
235
- errx (1 , "must provide lo and hi for -i" );
231
+ errx (1 , "must provide lo and hi for -i option " );
236
232
* argp = '\0' ;
237
233
238
234
lo = strtonum (optarg , 0 , INT_MAX , & errstr );
@@ -246,7 +242,7 @@ main(int argc, char *argv[])
246
242
if (lo >= hi )
247
243
errx (1 , "lo is greater than or equal to hi" );
248
244
if (hi == INT_MAX && lo == 0 )
249
- errx (1 , "lo-hi range too large" );
245
+ errx (1 , "lo-hi range too large for -i option " );
250
246
break ;
251
247
case 'n' :
252
248
most = strtonum (optarg , 0 , INT_MAX , & errstr );
@@ -258,10 +254,10 @@ main(int argc, char *argv[])
258
254
break ;
259
255
case 'o' :
260
256
if (oflag ++ )
261
- errx (1 , "cannot have multiple -o" );
257
+ errx (1 , "cannot have multiple -o options " );
262
258
263
259
if ((ofile = fopen (optarg , "w" )) == NULL )
264
- err (1 , "couldn't open output file %s" , optarg );
260
+ err (1 , "could not open output file %s" , optarg );
265
261
266
262
break ;
267
263
case 'r' :
@@ -279,6 +275,9 @@ main(int argc, char *argv[])
279
275
argc -= optind ;
280
276
argv += optind ;
281
277
278
+ if (eflag && iflag )
279
+ errx (1 , "cannot combine -e and -i options" );
280
+
282
281
if (oflag == 0 )
283
282
ofile = stdout ;
284
283
@@ -312,7 +311,7 @@ main(int argc, char *argv[])
312
311
repledge (oflag );
313
312
314
313
if ((buf = malloc (bufsize )) == NULL )
315
- err (1 , "malloc failed " );
314
+ err (1 , "could not create initial shuffle buffer " );
316
315
317
316
while ((ch = fgetc (ifile )) != EOF ) {
318
317
buf [buflen ++ ] = ch ;
@@ -322,7 +321,7 @@ main(int argc, char *argv[])
322
321
if ((nbuf = realloc (buf , nbufsize )) == NULL ) {
323
322
free (buf );
324
323
buf = NULL ;
325
- err (1 , "main " );
324
+ err (1 , "could not resize shuffle buffer " );
326
325
}
327
326
buf = nbuf ;
328
327
bufsize = nbufsize ;
0 commit comments