summaryrefslogtreecommitdiffstats
path: root/lib/getopt1.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:35 +0000
commit2ed1dcfa30b3967f7d6df74fba78ce23ed065497 (patch)
tree8ff5a74b07bf976cd88df2460e1c9cafb27f050a /lib/getopt1.c
parentReleasing progress-linux version 5.6.1+really5.4.5-1~progress7.99u1. (diff)
downloadxz-utils-2ed1dcfa30b3967f7d6df74fba78ce23ed065497.tar.xz
xz-utils-2ed1dcfa30b3967f7d6df74fba78ce23ed065497.zip
Merging upstream version 5.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/getopt1.c')
-rw-r--r--lib/getopt1.c62
1 files changed, 27 insertions, 35 deletions
diff --git a/lib/getopt1.c b/lib/getopt1.c
index da5d533..5cb3b91 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -1,41 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
+ Copyright (C) 1987-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1, or (at your option)
- any later version.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
-#ifdef _LIBC
-# include <getopt.h>
-#else
-# include <config.h>
-# include "getopt.h"
-#endif
-#include "getopt_int.h"
-
-#include <stdio.h>
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
+#ifndef _LIBC
+# ifdef HAVE_CONFIG_H
+# include <config.h>
+# endif
#endif
-#ifndef NULL
-#define NULL 0
-#endif
+#include "getopt.h"
+#include "getopt_int.h"
int
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
@@ -51,7 +42,7 @@ _getopt_long_r (int argc, char **argv, const char *options,
struct _getopt_data *d)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
- 0, 0, d);
+ 0, d, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -74,13 +65,14 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
struct _getopt_data *d)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
- 1, 0, d);
+ 1, d, 0);
}
#ifdef TEST
#include <stdio.h>
+#include <stdlib.h>
int
main (int argc, char **argv)
@@ -92,7 +84,7 @@ main (int argc, char **argv)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
- static struct option long_options[] =
+ static const struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
@@ -142,11 +134,11 @@ main (int argc, char **argv)
break;
case 'c':
- printf ("option c with value `%s'\n", optarg);
+ printf ("option c with value '%s'\n", optarg);
break;
case 'd':
- printf ("option d with value `%s'\n", optarg);
+ printf ("option d with value '%s'\n", optarg);
break;
case '?':