]> Creatis software - clitk.git/blob - utilities/gengetopt/yyerror.cc
auto generate dicom file UIDs when new series/study is specified
[clitk.git] / utilities / gengetopt / yyerror.cc
1 /*
2 This file is licensed to you under the license specified in the included file
3 `LICENSE'. Look there for further details.
4 */
5
6
7 /*
8   Called by yyparse on error.
9  */
10
11 #include "yyerror.h"
12
13 #include <stdio.h>
14 #include <string.h>
15 #include <iostream>
16
17 extern int gengetopt_count_line;
18 extern char * gengetopt_input_filename;
19
20 extern int tokenpos;
21 extern char linebuf[];
22 extern char *yytext;
23
24 using namespace std;
25
26 void
27 yyerror (const char *s)
28 {
29   const char *source =
30     (gengetopt_input_filename ? gengetopt_input_filename : "gengetopt");
31
32   fprintf (stderr, "%s:%d: %s %s\n", source, gengetopt_count_line, s, yytext);
33
34   if (/*!linebuf || */!strlen(linebuf))
35     return;
36
37   fprintf (stderr, "%s:%d: %s\n", source, gengetopt_count_line, linebuf);
38   fprintf (stderr, "%s:%d: %*s\n", source, gengetopt_count_line,
39            tokenpos + 1, "^");
40 }
41
42 void
43 yyerror (gengetopt_option *opt, const char *s)
44 {
45   const char *source =
46     (opt->filename ? opt->filename : "gengetopt");
47
48   cerr << source << ":" << opt->linenum << ": " << s << endl;
49 }