]> git.pld-linux.org Git - packages/coreutils.git/commitdiff
--help needs to be working
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Fri, 8 Aug 2008 19:27:19 +0000 (19:27 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    coreutils-getgid.patch -> 1.9

coreutils-getgid.patch

index b835dd374a99246a774ce99edd4a9a9df0a856ad..c8525ae98f7acb91a1c3cd958ff5844a4678dc55 100644 (file)
@@ -81,7 +81,7 @@ diff -Nur coreutils-4.5.3.orig/man/pl/getgid.1 coreutils-4.5.3/man/pl/getgid.1
 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@pld-linux.org>
 +
@@ -102,7 +102,10 @@ diff -Nur coreutils-4.5.3.orig/src/getgid.c coreutils-4.5.3/src/getgid.c
 +#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 @@ diff -Nur coreutils-4.5.3.orig/src/getgid.c coreutils-4.5.3/src/getgid.c
 +/* 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 @@ diff -Nur coreutils-4.5.3.orig/src/getgid.c coreutils-4.5.3/src/getgid.c
 +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 @@ diff -Nur coreutils-4.5.3.orig/src/getgid.c coreutils-4.5.3/src/getgid.c
 +
 +      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
This page took 0.033226 seconds and 4 git commands to generate.