summaryrefslogtreecommitdiff
path: root/archivers/pax
diff options
context:
space:
mode:
authorgrant <grant@pkgsrc.org>2003-06-23 13:39:01 +0000
committergrant <grant@pkgsrc.org>2003-06-23 13:39:01 +0000
commit0732ea5855f562a614be5b80816624ba5fc6c13b (patch)
tree617540c4268bb4f7b22e599da6340396599dbaaa /archivers/pax
parentf004eee342ec5e597b1049c5ced6e720f71fc932 (diff)
downloadpkgsrc-0732ea5855f562a614be5b80816624ba5fc6c13b.tar.gz
sync with -current rev 1.17
Diffstat (limited to 'archivers/pax')
-rw-r--r--archivers/pax/files/getoldopt.c55
1 files changed, 11 insertions, 44 deletions
diff --git a/archivers/pax/files/getoldopt.c b/archivers/pax/files/getoldopt.c
index 1fe9d649d5a..9f595ff984c 100644
--- a/archivers/pax/files/getoldopt.c
+++ b/archivers/pax/files/getoldopt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getoldopt.c,v 1.1.1.1 2003/06/23 11:46:22 grant Exp $ */
+/* $NetBSD: getoldopt.c,v 1.2 2003/06/23 13:39:01 grant Exp $ */
/*
* Plug-compatible replacement for getopt() for parsing tar-like
@@ -16,7 +16,7 @@
#endif
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: getoldopt.c,v 1.1.1.1 2003/06/23 11:46:22 grant Exp $");
+__RCSID("$NetBSD: getoldopt.c,v 1.2 2003/06/23 13:39:01 grant Exp $");
#endif /* not lint */
#include <getopt.h>
@@ -33,53 +33,20 @@ getoldopt(int argc, char **argv, const char *optstring,
struct option *longopts, int *idx)
{
static char *key; /* Points to next keyletter */
- static char use_getopt; /* !=0 if argv[1][0] was '-' */
- char c;
- char *place;
-
- optarg = NULL;
+ static char argv1[64];
if (key == NULL) { /* First time */
if (argc < 2) return -1;
key = argv[1];
- if (*key == '-')
- use_getopt++;
- else
- optind = 2;
- }
-
- if (use_getopt) {
- if (longopts != NULL) {
- return getopt_long(argc, argv, optstring,
- longopts, idx);
- } else {
- return getopt(argc, argv, optstring);
- }
- }
-
- c = *key++;
- if (c == '\0') {
- key--;
- return -1;
- }
- place = strchr(optstring, c);
-
- if (place == NULL || c == ':') {
- fprintf(stderr, "%s: unknown option %c\n", argv[0], c);
- return('?');
+ if (*key != '-')
+ (void)snprintf(argv[1] = argv1, sizeof(argv1), "-%s",
+ key);
}
- place++;
- if (*place == ':') {
- if (optind < argc) {
- optarg = argv[optind];
- optind++;
- } else {
- fprintf(stderr, "%s: %c argument missing\n",
- argv[0], c);
- return('?');
- }
+ if (longopts != NULL) {
+ return getopt_long(argc, argv, optstring,
+ longopts, idx);
+ } else {
+ return getopt(argc, argv, optstring);
}
-
- return(c);
}