1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* This file is part of GDBM, the GNU data base manager.
Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation,
Inc.
GDBM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GDBM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
#include "autoconf.h"
#include "gdbmdefs.h"
#include "gdbm.h"
#include "gdbmapp.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
/* Position in input file */
struct point
{
char *file; /* file name */
unsigned line; /* line number */
unsigned col; /* column number */
};
/* Location in input file */
struct locus
{
struct point beg, end;
};
typedef struct locus gdbm_yyltype_t;
#define YYLTYPE gdbm_yyltype_t
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
{ \
if (N) \
{ \
(Current).beg = YYRHSLOC(Rhs, 1).beg; \
(Current).end = YYRHSLOC(Rhs, N).end; \
} \
else \
{ \
(Current).beg = YYRHSLOC(Rhs, 0).end; \
(Current).end = (Current).beg; \
} \
} \
while (0)
#define YY_LOCATION_PRINT(File, Loc) \
do \
{ \
if ((Loc).beg.col == 0) \
fprintf (File, "%s:%u", \
(Loc).beg.file, \
(Loc).beg.line); \
else if (strcmp ((Loc).beg.file, (Loc).end.file)) \
fprintf (File, "%s:%u.%u-%s:%u.%u", \
(Loc).beg.file, \
(Loc).beg.line, (Loc).beg.col, \
(Loc).end.file, \
(Loc).end.line, (Loc).end.col); \
else if ((Loc).beg.line != (Loc).end.line) \
fprintf (File, "%s:%u.%u-%u.%u", \
(Loc).beg.file, \
(Loc).beg.line, (Loc).beg.col, \
(Loc).end.line, (Loc).end.col); \
else if ((Loc).beg.col != (Loc).end.col) \
fprintf (File, "%s:%u.%u-%u", \
(Loc).beg.file, \
(Loc).beg.line, (Loc).beg.col, \
(Loc).end.col); \
else \
fprintf (File, "%s:%u.%u", \
(Loc).beg.file, \
(Loc).beg.line, \
(Loc).beg.col); \
} \
while (0)
void vparse_error (struct locus *loc, const char *fmt, va_list ap);
void parse_error (struct locus *loc, const char *fmt, ...);
void syntax_error (const char *fmt, ...);
void print_prompt (void);
void setsource (const char *filename, FILE *file);
extern int interactive;
/* Argument to a command handler */
struct gdbmarg
{
struct gdbmarg *next;
char *string;
};
/* List of arguments */
struct gdbmarglist
{
struct gdbmarg *head, *tail;
};
void gdbmarglist_init (struct gdbmarglist *, struct gdbmarg *);
void gdbmarglist_add (struct gdbmarglist *, struct gdbmarg *);
void gdbmarglist_free (struct gdbmarglist *lst);
struct gdbmarg *gdbmarg_new (char *);
int run_command (const char *verb, struct gdbmarglist *arglist);
|