/[bison]/bison/src/options.c
ViewVC logotype

Diff of /bison/src/options.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by akim, Mon Dec 10 09:06:27 2001 UTC revision 1.12 by akim, Sat Dec 29 14:21:06 2001 UTC
# Line 30  Line 30 
30  /* Shorts options.  */  /* Shorts options.  */
31  const char *shortopts = "yvegdhrltknVo:b:p:S:";  const char *shortopts = "yvegdhrltknVo:b:p:S:";
32    
 /* Long options.  */  
 struct option *longopts = NULL;  
   
 struct percent_table_struct *percent_table = NULL;  
   
33  /* A CLI option only.  /* A CLI option only.
34     Arguments is the policy: `no', `optional', `required'.     Arguments is the policy: `no', `optional', `required'.
35     OptionChar is the value given to the Var if the latter is specified.  */     OptionChar is the value given to the Var if the latter is specified.  */
# Line 135  const struct option_table_struct option_ Line 130  const struct option_table_struct option_
130    {0, 0, 0, 0, 0, 0}    {0, 0, 0, 0, 0, 0}
131  };  };
132    
133    
134  /*--------------------------------------------------------.  /*--------------------------------------------------------.
135  | Create the longoptions structure from the option_table, |  | Create the longoptions structure from the option_table, |
136  | for the getopt file.                                    |  | for the getopt file.                                    |
137  `--------------------------------------------------------*/  `--------------------------------------------------------*/
138  void  
139  create_long_option_table ()  struct option *
140    long_option_table_new ()
141  {  {
142      struct option *res = NULL;
143    int i = 0;    int i = 0;
144    int j = 0;    int j = 0;
145    int number_options;    int number_options;
# Line 151  create_long_option_table () Line 149  create_long_option_table ()
149          || option_table[i].access == opt_both)          || option_table[i].access == opt_both)
150        ++number_options;        ++number_options;
151    
152    longopts = XMALLOC (struct option, number_options + 1);    res = XMALLOC (struct option, number_options + 1);
153    for (i = 0; option_table[i].name; i++)    for (i = 0; option_table[i].name; i++)
154      if (option_table[i].access == opt_cmd_line      if (option_table[i].access == opt_cmd_line
155          || option_table[i].access == opt_both)          || option_table[i].access == opt_both)
156        {        {
157          /* Copy the struct information in the longoptions.  */          /* Copy the struct information in the longoptions.  */
158          longopts[j].name = option_table[i].name;          res[j].name = option_table[i].name;
159          longopts[j].has_arg = option_table[i].has_arg;          res[j].has_arg = option_table[i].has_arg;
160          /* When an options is declared having 'optional_argument' and          /* When an options is declared having 'optional_argument' and
161             a flag is specified to be set, the option is skipped on             a flag is specified to be set, the option is skipped on
162             command line. So we never use a flag when a command line             command line. So we never use a flag when a command line
163             option is declared 'optional_argument.  */             option is declared 'optional_argument.  */
164          if (longopts[j].has_arg == optional_argument)          if (res[j].has_arg == optional_argument)
165            longopts[j].flag = NULL;            res[j].flag = NULL;
166          else          else
167            longopts[j].flag = option_table[i].set_flag;            res[j].flag = option_table[i].set_flag;
168          longopts[j++].val = option_table[i].val;          res[j++].val = option_table[i].val;
169        }        }
170    longopts[number_options].name = NULL;    res[number_options].name = NULL;
171    longopts[number_options].has_arg = 0;    res[number_options].has_arg = 0;
172    longopts[number_options].flag = NULL;    res[number_options].flag = NULL;
173    longopts[number_options].val = 0;    res[number_options].val = 0;
174    
175      return res;
176  }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26