* src/digest.c (main): If --binary was enabled with a previous --tag,
then reset the binary mode to auto select if --untagged then specified.
* tests/cksum/cksum-a.sh: Add a test case.
#include "xdectoint.h"
#include "xstrtol.h"
+#ifndef HASH_ALGO_CKSUM
+# define HASH_ALGO_CKSUM 0
+#endif
+
#if HASH_ALGO_SUM || HASH_ALGO_CKSUM
# include "sum.h"
#endif
int opt;
bool ok = true;
int binary = -1;
-#if HASH_ALGO_CKSUM
- bool prefix_tag = true;
-#else
- bool prefix_tag = false;
-#endif
+ int prefix_tag = -1;
/* Setting values of global variables. */
initialize_main (&argc, &argv);
raw_digest = true;
break;
case UNTAG_OPTION:
- prefix_tag = false;
+ if (prefix_tag == 1)
+ binary = -1;
+ prefix_tag = 0;
break;
# endif
case TAG_OPTION:
- prefix_tag = true;
+ prefix_tag = 1;
binary = 1;
break;
case 'z':
}
#endif
+ if (prefix_tag == -1)
+ prefix_tag = HASH_ALGO_CKSUM;
+
if (prefix_tag && !binary)
{
/* This could be supported in a backwards compatible way
# Ensure abbreviations not supported for algorithm selection
returns_ 1 cksum -a sha22 </dev/null || fail=1
+# Ensure --tag -> --untagged transition resets binary indicator
+cksum --tag --untagged -a md5 /dev/null >out-1 || fail=1
+# --binary ignored in this edge case
+cksum --binary --tag --untagged -a md5 /dev/null >out-2 || fail=1
+# base case for comparison
+cksum --untagged -a md5 /dev/null >out || fail=1
+compare out out-1 || fail=1
+compare out out-2 || fail=1
+
Exit $fail