diff --git a/src/md5sum.c b/src/md5sum.c index ae429ae..bb6650f 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -169,7 +169,6 @@ static const char *const prefixes[] = "SHA512 ", "SHA384 " }; - void usage (int status) @@ -655,8 +654,8 @@ digest_check (const char *checkfile_name) && (!strict || n_improperly_formatted_lines == 0)); } -static void -print_filename(char *file) +static void +print_filename (char *file) { size_t i; /* Translate each NEWLINE byte to the string, "\\n", @@ -680,15 +679,11 @@ print_filename(char *file) } } -static void -bsd_print_filename(char *file) +static void +bsd_print_filename (const char *file) { - size_t i; - - for (i = 0; i < strlen (file); ++i) - { - putchar(file[i]); - } + /* TODO: Escape in BSD compatible fashion. */ + fputs (file, stdout); } int @@ -716,7 +711,7 @@ main (int argc, char **argv) so that processes running in parallel do not intersperse their output. */ setvbuf (stdout, NULL, _IOLBF, 0); - while ((opt = getopt_long (argc, argv, "bctwl", long_options, NULL)) != -1) + while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1) switch (opt) { case 'b': @@ -815,19 +810,19 @@ main (int argc, char **argv) { if (prefix_tag) { - if(!file_is_binary) - putchar(' '); - printf("%s", prefixes[PREFIX_INDEX]); - putchar('('); - bsd_print_filename(file); - printf(") = "); + if (!file_is_binary) + putchar (' '); + fputs (prefixes[PREFIX_INDEX], stdout); + putchar ('('); + bsd_print_filename (file); + fputs (") = ", stdout); } size_t i; /* Output a leading backslash if the file name contains a newline or backslash. */ - if ((strchr (file, '\n') || strchr (file, '\\')) && !prefix_tag) + if (!prefix_tag && (strchr (file, '\n') || strchr (file, '\\'))) putchar ('\\'); for (i = 0; i < (digest_hex_bytes / 2); ++i) @@ -842,7 +837,7 @@ main (int argc, char **argv) else putchar (' '); - print_filename(file); + print_filename (file); } putchar ('\n');