~ubuntu-branches/ubuntu/quantal/gengetopt/quantal

« back to all changes in this revision

Viewing changes to src/parser.yy

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-09-26 10:27:31 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: package-import@ubuntu.com-20110926102731-vh42p0vriqz4kp3h
Tags: 2.22.5-1
* New upstream release:
  - correctly wraps and preprocess the specified usage string
  - handle escaped newline chars in the .ggo file correctly
  - initialize enum variables with a generated null value (makes
    the parser compilable in C++)
  - removed warnings in generated parser when only flags are used
* Fix gbp config file.
* Bump Standards.
* Drop unneeded dependency on dpkg (>= 1.15.4), stable has a newer version.
* Refresh patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <stdlib.h>
29
29
#include <string.h>
30
30
#include <stdio.h>
31
 
 
32
 
#include "my_sstream.h"
 
31
#include <string>
 
32
#include <sstream>
33
33
 
34
34
#include "acceptedvalues.h"
35
35
 
49
49
static int gengetopt_usage_given = 0;
50
50
static int gengetopt_description_given = 0;
51
51
 
 
52
/// the last option parsed
 
53
static gengetopt_option *current_option = 0;
 
54
 
52
55
extern int yylex (void) ;
53
56
 
54
57
//#define YYERROR_VERBOSE 1
55
58
 
 
59
using namespace std;
 
60
 
56
61
void check_result(int o, gengetopt_option *opt)
57
62
{
58
63
  if (o)
336
341
text
337
342
  : TOK_TEXT quoted_string
338
343
            {
339
 
  gengetopt_set_text($2);
 
344
                if (current_option) {
 
345
                        std::string current_option_text;
 
346
                        if (current_option->text_after) {
 
347
                                current_option_text = std::string(current_option->text_after) + $2;
 
348
                                current_option->text_after = strdup(current_option_text.c_str()); 
 
349
                        } else {
 
350
                                current_option->text_after = strdup($2);
 
351
                        }
 
352
                } else {
 
353
                                        gengetopt_set_text($2);
 
354
                                }
340
355
            }
341
356
        ;
342
357
 
385
400
              o = gengetopt_add_option ($5);
386
401
              check_result(o, $5);
387
402
              check_error;
 
403
              current_option = $5;
388
404
            }
389
405
        ;
390
406