- hash_ptr(stdin, hashval);
- print_hash(hash_length, hashval, NULL);
- } else {
- int i;
-
- for (i = optind; i < argc; i++) {
- if (!strcmp(argv[i], "-")) {
- hash_ptr(stdin, hashval);
- print_hash(hash_length, hashval, NULL);
- } else {
- FILE *stream = bb_xfopen(argv[i], "r");
- hash_ptr(stream, hashval);
- fclose(stream);
- print_hash(hash_length, hashval, argv[i]);
+ argv[argc] = "-";
+ }
+
+ while (optind < argc) {
+ FILE *stream;
+ unsigned char *file_ptr = argv[optind];
+
+ if ((file_ptr[0] == '-') && (file_ptr[1] == '\0')) {
+ stream = stdin;
+ } else {
+ stream = bb_wfopen(file_ptr, "r");
+ if (stream == NULL) {
+ return(EXIT_FAILURE);