SOURCES: coreutils-getgid.patch --help needs to be working
arekm
arekm at pld-linux.org
Fri Aug 8 21:27:24 CEST 2008
Author: arekm Date: Fri Aug 8 19:27:24 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
--help needs to be working
---- Files affected:
SOURCES:
coreutils-getgid.patch (1.8 -> 1.9)
---- Diffs:
================================================================
Index: SOURCES/coreutils-getgid.patch
diff -u SOURCES/coreutils-getgid.patch:1.8 SOURCES/coreutils-getgid.patch:1.9
--- SOURCES/coreutils-getgid.patch:1.8 Fri Aug 8 21:15:21 2008
+++ SOURCES/coreutils-getgid.patch Fri Aug 8 21:27:19 2008
@@ -81,7 +81,7 @@
diff -Nur coreutils-4.5.3.orig/src/getgid.c coreutils-4.5.3/src/getgid.c
--- coreutils-4.5.3.orig/src/getgid.c Thu Jan 1 01:00:00 1970
+++ coreutils-4.5.3/src/getgid.c Sun Oct 27 21:52:01 2002
-@@ -0,0 +1,80 @@
+@@ -0,0 +1,106 @@
+/* getgid - print GID of given group
+ Copyright (C) 1999 Artur Frysiak <wiget at pld-linux.org>
+
@@ -102,7 +102,10 @@
+#include <config.h>
+#include <grp.h>
+#include <sys/types.h>
++#include <getopt.h>
+#include "system.h"
++#include "quote.h"
++#include "error.h"
+
+#define PROGRAM_NAME "getgid"
+
@@ -111,6 +114,13 @@
+/* The name by which this program was run. */
+char *program_name;
+
++static struct option const longopts[] =
++{
++ {GETOPT_HELP_OPTION_DECL},
++ {GETOPT_VERSION_OPTION_DECL},
++ {NULL, 0, NULL, 0}
++};
++
+void
+usage (int status)
+{
@@ -137,7 +147,7 @@
+int main(int argc, char **argv)
+{
+ struct group *gr;
-+ int retval;
++ int optc;
+
+ initialize_main (&argc, &argv);
+ program_name = argv[0];
@@ -148,18 +158,34 @@
+
+ atexit (close_stdout);
+
-+ if (argc > 1) {
-+ gr = getgrnam(argv[1]);
-+ if (gr) {
-+ printf("%d\n",gr->gr_gid);
-+ retval = 0;
-+ } else {
-+ retval = 1;
++ while ((optc = getopt_long (argc, argv, "+", longopts, NULL)) != -1) {
++ switch (optc) {
++ case_GETOPT_HELP_CHAR;
++ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
++ default:
++ usage (EXIT_FAILURE);
+ }
-+ } else {
-+ usage(retval);
+ }
-+ return (retval ? EXIT_FAILURE : EXIT_SUCCESS);
++
++ if (argc < optind + 1)
++ {
++ error (0, 0, _("missing operand"));
++ usage (EXIT_FAILURE);
++ }
++
++ if (optind + 2 < argc)
++ {
++ error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
++ usage (EXIT_FAILURE);
++ }
++
++ gr = getgrnam(argv[optind]);
++ if (gr == NULL) {
++ error (0, 0, _("cannot find group name %s"), quote(argv[optind]));
++ exit(EXIT_FAILURE);
++ } else
++ printf("%lu\n", (unsigned long int) gr->gr_gid);
++ exit(EXIT_SUCCESS);
+}
+
--- coreutils-4.5.3/po/POTFILES.in.orig Mon Jul 1 23:26:55 2002
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/coreutils-getgid.patch?r1=1.8&r2=1.9&f=u
More information about the pld-cvs-commit
mailing list