* src/cksum.h: Thread DELIM through the output functions.
* src/digest.c: Likewise.
* src/sum.c: Likewise.
* src/sum.h: Likewise.
* src/cksum.c: Likewise. Also adjust check to allow -z
with traditional output modes. Also ajust the global variable
name to avoid shadowing warnings.
* tests/misc/cksum-a.sh: Adjust accordingly.
void
output_crc (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED)
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED)
{
char length_buf[INT_BUFSIZE_BOUND (uintmax_t)];
printf ("%u %s", *(unsigned int *)digest, umaxtostr (length, length_buf));
if (args)
printf (" %s", file);
- putchar ('\n');
+ putchar (delim);
}
#endif /* !CRCTAB */
extern void
output_crc (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED);
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED);
extern bool
cksum_pclmul (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
#if !HASH_ALGO_SUM
static void
output_file (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED);
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED);
#endif
/* True if any of the files read were the standard input. */
static int bsd_reversed = -1;
/* line delimiter. */
-static unsigned char delim = '\n';
+static unsigned char digest_delim = '\n';
#if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
# define BLAKE2B_MAX_LEN BLAKE2B_OUTBYTES
#endif /* HASH_ALGO_BLAKE2 */
typedef void (*digest_output_fn)(char const*, int, void const*,
- bool, bool, uintmax_t);
+ bool, unsigned char, bool, uintmax_t);
#if HASH_ALGO_SUM
enum Algorithm
{
#if !HASH_ALGO_SUM
static void
output_file (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED)
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED)
{
unsigned char const *bin_buffer = digest;
/* We don't really need to escape, and hence detect, the '\\'
binary = 1;
break;
case 'z':
- delim = '\0';
+ digest_delim = '\0';
break;
#endif
#if HASH_ALGO_SUM
case bsd:
case sysv:
case crc:
- if (delim != '\n')
- die (EXIT_FAILURE, 0,
- _("--zero is not supported with --algorithm={bsd,sysv,crc}"));
if (prefix_tag)
die (EXIT_FAILURE, 0,
_("--tag is not supported with --algorithm={bsd,sysv,crc}"));
usage (EXIT_FAILURE);
}
- if (delim != '\n' && do_check)
+ if (digest_delim != '\n' && do_check)
{
error (0, 0, _("the --zero option is not supported when "
"verifying checksums"));
else
{
DIGEST_OUT (file, binary_file, bin_buffer, prefix_tag,
- optind != argc, length);
+ digest_delim, optind != argc, length);
}
}
}
void
output_bsd (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED)
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
human_readable (length, hbuf, human_ceiling, 1, 1024));
if (args)
printf (" %s", file);
- putchar ('\n');
+ putchar (delim);
}
/* Print the checksum and size (in 512 byte blocks) to stdout.
void
output_sysv (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED)
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
human_readable (length, hbuf, human_ceiling, 1, 512));
if (args)
printf (" %s", file);
- putchar ('\n');
+ putchar (delim);
}
extern void
output_bsd (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED);
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED);
extern void
output_sysv (char const *file, int binary_file, void const *digest,
- bool tagged, bool args _GL_UNUSED, uintmax_t length _GL_UNUSED);
+ bool tagged, unsigned char delim, bool args _GL_UNUSED,
+ uintmax_t length _GL_UNUSED);
compare out out-a || fail=1
returns_ 1 cksum -a bsd --tag </dev/null
-returns_ 1 cksum -a bsd --zero </dev/null
returns_ 1 cksum -a bsd --check </dev/null
Exit $fail