FreeBSD Bugzilla – Attachment 1542 Details for
Bug 5387
md5(1) does not use getopt(3)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.07 KB, created by
mph
on 1997-12-28 07:00:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
mph
Created:
1997-12-28 07:00:01 UTC
Size:
2.07 KB
patch
obsolete
>diff -Nru /usr/src/sbin/md5/md5.1 md5/md5.1 >--- /usr/src/sbin/md5/md5.1 Sat Sep 6 12:25:42 1997 >+++ md5/md5.1 Sat Dec 27 02:35:42 1997 >@@ -9,7 +9,7 @@ > .Op Fl p > .Op Fl t > .Op Fl x >-.Op Fl s Ns Ar string >+.Op Fl s Ar string > .Op Ar filename Ns Pq s > .Sh DESCRIPTION > .Nm >@@ -34,7 +34,7 @@ > .Ar filename Ns Pq s > must be the last objects on the command line. > .Bl -tag -width Fl >-.It Fl s Ns Ar string >+.It Fl s Ar string > prints a checksum of the given > .Dq string . > .It Fl p >diff -Nru /usr/src/sbin/md5/md5.c md5/md5.c >--- /usr/src/sbin/md5/md5.c Sat Sep 6 12:25:42 1997 >+++ md5/md5.c Sat Dec 27 02:34:14 1997 >@@ -40,6 +40,7 @@ > static void MDTimeTrial PROTO_LIST((void)); > static void MDTestSuite PROTO_LIST((void)); > static void MDFilter PROTO_LIST((int)); >+static void usage PROTO_LIST((void)); > > /* Main driver. > >@@ -58,25 +59,38 @@ > int i; > char *p; > char buf[33]; >+ extern char *optarg; >+ extern int optind; > >- if (argc > 1) >- for (i = 1; i < argc; i++) >- if (argv[i][0] == '-' && argv[i][1] == 's') >- MDString(argv[i] + 2); >- else if (strcmp(argv[i], "-t") == 0) >+ if (argc > 1) { >+ while ((i = getopt(argc, argv, "s:tpx")) != EOF) { >+ switch(i) { >+ case 's': >+ MDString(optarg); >+ break; >+ case 't': > MDTimeTrial(); >- else if (strcmp(argv[i], "-p") == 0) >+ break; >+ case 'p': > MDFilter(1); >- else if (strcmp(argv[i], "-x") == 0) >+ break; >+ case 'x': > MDTestSuite(); >- else { >- p = MD5File(argv[i],buf); >- if (!p) >- perror(argv[i]); >- else >- printf("MD5 (%s) = %s\n", argv[i], p); >+ break; >+ default: >+ usage(); > } >- else >+ } >+ >+ while (optind < argc) { >+ p = MD5File(argv[optind],buf); >+ if (!p) >+ perror(argv[optind]); >+ else >+ printf("MD5 (%s) = %s\n", argv[optind], p); >+ optind++; >+ } >+ } else > MDFilter(0); > > return (0); >@@ -174,4 +188,16 @@ > MD5Update(&context, buffer, len); > } > printf("%s\n", MD5End(&context,buf)); >+} >+ >+/* >+ * Displays a usage summary. >+ */ >+ >+static void >+usage(void) >+{ >+ (void)fprintf(stderr, >+ "usage: md5 [-p] [-t] [-x] [-s string] [filename(s)]\n"); >+ exit(1); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 5387
: 1542