~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to lib/getopt1.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-10-19 00:00:09 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20111019000009-8p33w3wz4b1rdri0
Tags: 1.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
  - Depend on libssl-dev 0.9.8k-7ubuntu4 (LP: #503339)
* Dropped changes, superseded in Debian:
  - Keep build dependencies in main:
    + debian/control: remove info2man build-dep
    + debian/patches/series: disable wget-infopod_generated_manpage
  - Mark wget Multi-Arch: foreign, so packages that aren't of the same arch
    can depend on it.
* Pass --with-ssl=openssl; we don't want to use gnutls, there's no udeb for
  it.
* Add a second build pass for the udeb, so we can build without libidn.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* getopt_long and getopt_long_only entry points for GNU getopt.
2
 
   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006,2009
3
 
     Free Software Foundation, Inc.
 
2
   Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software
 
3
   Foundation, Inc.
4
4
   This file is part of the GNU C Library.
5
5
 
6
6
   This program is free software: you can redistribute it and/or modify
32
32
#include <stdlib.h>
33
33
#endif
34
34
 
35
 
#ifndef NULL
 
35
#ifndef NULL
36
36
#define NULL 0
37
37
#endif
38
38
 
39
39
int
40
40
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
41
 
             const struct option *long_options, int *opt_index)
 
41
             const struct option *long_options, int *opt_index)
42
42
{
43
43
  return _getopt_internal (argc, (char **) argv, options, long_options,
44
 
                           opt_index, 0, 0);
 
44
                           opt_index, 0, 0);
45
45
}
46
46
 
47
47
int
48
48
_getopt_long_r (int argc, char **argv, const char *options,
49
 
                const struct option *long_options, int *opt_index,
50
 
                struct _getopt_data *d)
 
49
                const struct option *long_options, int *opt_index,
 
50
                struct _getopt_data *d)
51
51
{
52
52
  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
53
 
                             0, 0, d);
 
53
                             0, d, 0);
54
54
}
55
55
 
56
56
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
60
60
 
61
61
int
62
62
getopt_long_only (int argc, char *__getopt_argv_const *argv,
63
 
                  const char *options,
64
 
                  const struct option *long_options, int *opt_index)
 
63
                  const char *options,
 
64
                  const struct option *long_options, int *opt_index)
65
65
{
66
66
  return _getopt_internal (argc, (char **) argv, options, long_options,
67
 
                           opt_index, 1, 0);
 
67
                           opt_index, 1, 0);
68
68
}
69
69
 
70
70
int
71
71
_getopt_long_only_r (int argc, char **argv, const char *options,
72
 
                     const struct option *long_options, int *opt_index,
73
 
                     struct _getopt_data *d)
 
72
                     const struct option *long_options, int *opt_index,
 
73
                     struct _getopt_data *d)
74
74
{
75
75
  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
76
 
                             1, 0, d);
 
76
                             1, d, 0);
77
77
}
78
78
 
79
79
 
93
93
      int option_index = 0;
94
94
      static const struct option long_options[] =
95
95
      {
96
 
        {"add", 1, 0, 0},
97
 
        {"append", 0, 0, 0},
98
 
        {"delete", 1, 0, 0},
99
 
        {"verbose", 0, 0, 0},
100
 
        {"create", 0, 0, 0},
101
 
        {"file", 1, 0, 0},
102
 
        {0, 0, 0, 0}
 
96
        {"add", 1, 0, 0},
 
97
        {"append", 0, 0, 0},
 
98
        {"delete", 1, 0, 0},
 
99
        {"verbose", 0, 0, 0},
 
100
        {"create", 0, 0, 0},
 
101
        {"file", 1, 0, 0},
 
102
        {0, 0, 0, 0}
103
103
      };
104
104
 
105
105
      c = getopt_long (argc, argv, "abc:d:0123456789",
106
 
                       long_options, &option_index);
 
106
                       long_options, &option_index);
107
107
      if (c == -1)
108
 
        break;
 
108
        break;
109
109
 
110
110
      switch (c)
111
 
        {
112
 
        case 0:
113
 
          printf ("option %s", long_options[option_index].name);
114
 
          if (optarg)
115
 
            printf (" with arg %s", optarg);
116
 
          printf ("\n");
117
 
          break;
118
 
 
119
 
        case '0':
120
 
        case '1':
121
 
        case '2':
122
 
        case '3':
123
 
        case '4':
124
 
        case '5':
125
 
        case '6':
126
 
        case '7':
127
 
        case '8':
128
 
        case '9':
129
 
          if (digit_optind != 0 && digit_optind != this_option_optind)
130
 
            printf ("digits occur in two different argv-elements.\n");
131
 
          digit_optind = this_option_optind;
132
 
          printf ("option %c\n", c);
133
 
          break;
134
 
 
135
 
        case 'a':
136
 
          printf ("option a\n");
137
 
          break;
138
 
 
139
 
        case 'b':
140
 
          printf ("option b\n");
141
 
          break;
142
 
 
143
 
        case 'c':
144
 
          printf ("option c with value `%s'\n", optarg);
145
 
          break;
146
 
 
147
 
        case 'd':
148
 
          printf ("option d with value `%s'\n", optarg);
149
 
          break;
150
 
 
151
 
        case '?':
152
 
          break;
153
 
 
154
 
        default:
155
 
          printf ("?? getopt returned character code 0%o ??\n", c);
156
 
        }
 
111
        {
 
112
        case 0:
 
113
          printf ("option %s", long_options[option_index].name);
 
114
          if (optarg)
 
115
            printf (" with arg %s", optarg);
 
116
          printf ("\n");
 
117
          break;
 
118
 
 
119
        case '0':
 
120
        case '1':
 
121
        case '2':
 
122
        case '3':
 
123
        case '4':
 
124
        case '5':
 
125
        case '6':
 
126
        case '7':
 
127
        case '8':
 
128
        case '9':
 
129
          if (digit_optind != 0 && digit_optind != this_option_optind)
 
130
            printf ("digits occur in two different argv-elements.\n");
 
131
          digit_optind = this_option_optind;
 
132
          printf ("option %c\n", c);
 
133
          break;
 
134
 
 
135
        case 'a':
 
136
          printf ("option a\n");
 
137
          break;
 
138
 
 
139
        case 'b':
 
140
          printf ("option b\n");
 
141
          break;
 
142
 
 
143
        case 'c':
 
144
          printf ("option c with value `%s'\n", optarg);
 
145
          break;
 
146
 
 
147
        case 'd':
 
148
          printf ("option d with value `%s'\n", optarg);
 
149
          break;
 
150
 
 
151
        case '?':
 
152
          break;
 
153
 
 
154
        default:
 
155
          printf ("?? getopt returned character code 0%o ??\n", c);
 
156
        }
157
157
    }
158
158
 
159
159
  if (optind < argc)
160
160
    {
161
161
      printf ("non-option ARGV-elements: ");
162
162
      while (optind < argc)
163
 
        printf ("%s ", argv[optind++]);
 
163
        printf ("%s ", argv[optind++]);
164
164
      printf ("\n");
165
165
    }
166
166