| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#ifdef HAVE_CONFIG_H |
|---|
| 25 |
#include <config.h> |
|---|
| 26 |
#endif |
|---|
| 27 |
|
|---|
| 28 |
#include <stdio.h> |
|---|
| 29 |
|
|---|
| 30 |
#ifdef HAVE_STDLIB_H |
|---|
| 31 |
#include <stdlib.h> |
|---|
| 32 |
#endif |
|---|
| 33 |
|
|---|
| 34 |
#ifdef HAVE_STRING_H |
|---|
| 35 |
#include <string.h> |
|---|
| 36 |
#endif |
|---|
| 37 |
|
|---|
| 38 |
#include <ctype.h> |
|---|
| 39 |
#include <assert.h> |
|---|
| 40 |
#include "getopt.h" |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
#ifndef SEEK_END |
|---|
| 44 |
#define SEEK_END 2 |
|---|
| 45 |
#endif |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
#ifdef PROTOTYPES |
|---|
| 50 |
#define P_(x) x |
|---|
| 51 |
#else |
|---|
| 52 |
#define P_(x) () |
|---|
| 53 |
#endif |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0) |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
#ifndef max |
|---|
| 62 |
#define max(X, Y) ((X) > (Y) ? (X) : (Y)) |
|---|
| 63 |
#define min(X, Y) ((X) < (Y) ? (X) : (Y)) |
|---|
| 64 |
#endif |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
#define READ_CHUNK_SIZE (100 * 1024) |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
#if defined(__MSDOS__) |
|---|
| 73 |
#define PATH_LIST_SEPARATOR ';' |
|---|
| 74 |
#define FILENAME_EQ(X,Y) (strcasecmp(X,Y) == 0) |
|---|
| 75 |
#else |
|---|
| 76 |
#if defined(WINDOWSNT) |
|---|
| 77 |
#define PATH_LIST_SEPARATOR ';' |
|---|
| 78 |
#define FILENAME_EQ(X,Y) (stricmp(X,Y) == 0) |
|---|
| 79 |
#else |
|---|
| 80 |
#define PATH_LIST_SEPARATOR ':' |
|---|
| 81 |
#define FILENAME_EQ(X,Y) (streq(X,Y)) |
|---|
| 82 |
#endif |
|---|
| 83 |
#endif |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
#define DEFAULT_OUTFILE "BROWSE" |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
#define EBROWSE_FILE_VERSION "ebrowse 5.0" |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
#define TREE_HEADER_STRUCT "[ebrowse-hs " |
|---|
| 98 |
#define TREE_STRUCT "[ebrowse-ts " |
|---|
| 99 |
#define MEMBER_STRUCT "[ebrowse-ms " |
|---|
| 100 |
#define BROWSE_STRUCT "[ebrowse-bs " |
|---|
| 101 |
#define CLASS_STRUCT "[ebrowse-cs " |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
#define GLOBALS_NAME "*Globals*" |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
enum token |
|---|
| 111 |
{ |
|---|
| 112 |
YYEOF = 0, |
|---|
| 113 |
CSTRING = 256, |
|---|
| 114 |
CCHAR, |
|---|
| 115 |
CINT, |
|---|
| 116 |
CFLOAT, |
|---|
| 117 |
|
|---|
| 118 |
ELLIPSIS, |
|---|
| 119 |
LSHIFTASGN, |
|---|
| 120 |
RSHIFTASGN, |
|---|
| 121 |
ARROWSTAR, |
|---|
| 122 |
IDENT, |
|---|
| 123 |
DIVASGN, |
|---|
| 124 |
INC, |
|---|
| 125 |
ADDASGN, |
|---|
| 126 |
DEC, |
|---|
| 127 |
ARROW, |
|---|
| 128 |
SUBASGN, |
|---|
| 129 |
MULASGN, |
|---|
| 130 |
MODASGN, |
|---|
| 131 |
LOR, |
|---|
| 132 |
ORASGN, |
|---|
| 133 |
LAND, |
|---|
| 134 |
ANDASGN, |
|---|
| 135 |
XORASGN, |
|---|
| 136 |
POINTSTAR, |
|---|
| 137 |
DCOLON, |
|---|
| 138 |
EQ, |
|---|
| 139 |
NE, |
|---|
| 140 |
LE, |
|---|
| 141 |
LSHIFT, |
|---|
| 142 |
GE, |
|---|
| 143 |
RSHIFT, |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
#undef BOOL |
|---|
| 148 |
#undef TRUE |
|---|
| 149 |
#undef FALSE |
|---|
| 150 |
|
|---|
| 151 |
ASM, |
|---|
| 152 |
AUTO, |
|---|
| 153 |
BREAK, |
|---|
| 154 |
CASE, |
|---|
| 155 |
CATCH, |
|---|
| 156 |
CHAR, |
|---|
| 157 |
CLASS, |
|---|
| 158 |
CONST, |
|---|
| 159 |
CONTINUE, |
|---|
| 160 |
DEFAULT, |
|---|
| 161 |
DELETE, |
|---|
| 162 |
DO, |
|---|
| 163 |
DOUBLE, |
|---|
| 164 |
ELSE, |
|---|
| 165 |
ENUM, |
|---|
| 166 |
EXTERN, |
|---|
| 167 |
FLOAT, |
|---|
| 168 |
FOR, |
|---|
| 169 |
FRIEND, |
|---|
| 170 |
GOTO, |
|---|
| 171 |
IF, |
|---|
| 172 |
T_INLINE, |
|---|
| 173 |
INT, |
|---|
| 174 |
LONG, |
|---|
| 175 |
NEW, |
|---|
| 176 |
OPERATOR, |
|---|
| 177 |
PRIVATE, |
|---|
| 178 |
PROTECTED, |
|---|
| 179 |
PUBLIC, |
|---|
| 180 |
REGISTER, |
|---|
| 181 |
RETURN, |
|---|
| 182 |
SHORT, |
|---|
| 183 |
SIGNED, |
|---|
| 184 |
SIZEOF, |
|---|
| 185 |
STATIC, |
|---|
| 186 |
STRUCT, |
|---|
| 187 |
SWITCH, |
|---|
| 188 |
TEMPLATE, |
|---|
| 189 |
THIS, |
|---|
| 190 |
THROW, |
|---|
| 191 |
TRY, |
|---|
| 192 |
TYPEDEF, |
|---|
| 193 |
UNION, |
|---|
| 194 |
UNSIGNED, |
|---|
| 195 |
VIRTUAL, |
|---|
| 196 |
VOID, |
|---|
| 197 |
VOLATILE, |
|---|
| 198 |
WHILE, |
|---|
| 199 |
MUTABLE, |
|---|
| 200 |
BOOL, |
|---|
| 201 |
TRUE, |
|---|
| 202 |
FALSE, |
|---|
| 203 |
SIGNATURE, |
|---|
| 204 |
NAMESPACE, |
|---|
| 205 |
EXPLICIT, |
|---|
| 206 |
TYPENAME, |
|---|
| 207 |
CONST_CAST, |
|---|
| 208 |
DYNAMIC_CAST, |
|---|
| 209 |
REINTERPRET_CAST, |
|---|
| 210 |
STATIC_CAST, |
|---|
| 211 |
TYPEID, |
|---|
| 212 |
USING, |
|---|
| 213 |
WCHAR |
|---|
| 214 |
}; |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
enum sc |
|---|
| 219 |
{ |
|---|
| 220 |
SC_UNKNOWN, |
|---|
| 221 |
SC_MEMBER, |
|---|
| 222 |
SC_STATIC, |
|---|
| 223 |
SC_FRIEND, |
|---|
| 224 |
SC_TYPE |
|---|
| 225 |
}; |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
enum visibility |
|---|
| 230 |
{ |
|---|
| 231 |
V_PUBLIC, |
|---|
| 232 |
V_PROTECTED, |
|---|
| 233 |
V_PRIVATE |
|---|
| 234 |
}; |
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
#define F_VIRTUAL 1 |
|---|
| 239 |
#define F_INLINE 2 |
|---|
| 240 |
#define F_CONST 4 |
|---|
| 241 |
#define F_PURE 8 |
|---|
| 242 |
#define F_MUTABLE 16 |
|---|
| 243 |
#define F_TEMPLATE 32 |
|---|
| 244 |
#define F_EXPLICIT 64 |
|---|
| 245 |
#define F_THROW 128 |
|---|
| 246 |
#define F_EXTERNC 256 |
|---|
| 247 |
#define F_DEFINE 512 |
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
#define SET_FLAG(F, FLAG) ((F) |= (FLAG)) |
|---|
| 252 |
#define HAS_FLAG(F, FLAG) (((F) & (FLAG)) != 0) |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
struct member |
|---|
| 257 |
{ |
|---|
| 258 |
struct member *next; |
|---|
| 259 |
struct member *anext; |
|---|
| 260 |
struct member **list; |
|---|
| 261 |
unsigned param_hash; |
|---|
| 262 |
int vis; |
|---|
| 263 |
int flags; |
|---|
| 264 |
char *regexp; |
|---|
| 265 |
char *filename; |
|---|
| 266 |
int pos; |
|---|
| 267 |
char *def_regexp; |
|---|
| 268 |
char *def_filename; |
|---|
| 269 |
int def_pos; |
|---|
| 270 |
char name[1]; |
|---|
| 271 |
}; |
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
struct link |
|---|
| 277 |
{ |
|---|
| 278 |
struct sym *sym; |
|---|
| 279 |
struct link *next; |
|---|
| 280 |
}; |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
struct alias |
|---|
| 285 |
{ |
|---|
| 286 |
struct alias *next; |
|---|
| 287 |
struct sym *namesp; |
|---|
| 288 |
struct link *aliasee; |
|---|
| 289 |
char name[1]; |
|---|
| 290 |
}; |
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
struct sym |
|---|
| 296 |
{ |
|---|
| 297 |
int flags; |
|---|
| 298 |
unsigned char visited; |
|---|
| 299 |
struct sym *next; |
|---|
| 300 |
struct link *subs; |
|---|
| 301 |
struct link *supers; |
|---|
| 302 |
struct member *vars; |
|---|
| 303 |
struct member *fns; |
|---|
| 304 |
struct member *static_vars; |
|---|
| 305 |
struct member *static_fns; |
|---|
| 306 |
struct member *friends; |
|---|
| 307 |
struct member *types; |
|---|
| 308 |
char *regexp; |
|---|
| 309 |
int pos; |
|---|
| 310 |
char *filename; |
|---|
| 311 |
char *sfilename; |
|---|
| 312 |
struct sym *namesp; |
|---|
| 313 |
char name[1]; |
|---|
| 314 |
}; |
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
#define P_DEFN 1 |
|---|
| 320 |
#define P_DECL 2 |
|---|
| 321 |
|
|---|
| 322 |
int info_where; |
|---|
| 323 |
struct sym *info_cls = NULL; |
|---|
| 324 |
struct member *info_member = NULL; |
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
int info_position = -1; |
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 |
struct option options[] = |
|---|
| 335 |
{ |
|---|
| 336 |
{"append", no_argument, NULL, 'a'}, |
|---|
| 337 |
{"files", required_argument, NULL, 'f'}, |
|---|
| 338 |
{"help", no_argument, NULL, -2}, |
|---|
| 339 |
{"min-regexp-length", required_argument, NULL, 'm'}, |
|---|
| 340 |
{"max-regexp-length", required_argument, NULL, 'M'}, |
|---|
| 341 |
{"no-nested-classes", no_argument, NULL, 'n'}, |
|---|
| 342 |
{"no-regexps", no_argument, NULL, 'x'}, |
|---|
| 343 |
{"no-structs-or-unions", no_argument, NULL, 's'}, |
|---|
| 344 |
{"output-file", required_argument, NULL, 'o'}, |
|---|
| 345 |
{"position-info", required_argument, NULL, 'p'}, |
|---|
| 346 |
{"search-path", required_argument, NULL, 'I'}, |
|---|
| 347 |
{"verbose", no_argument, NULL, 'v'}, |
|---|
| 348 |
{"version", no_argument, NULL, -3}, |
|---|
| 349 |
{"very-verbose", no_argument, NULL, 'V'}, |
|---|
| 350 |
{NULL, 0, NULL, 0} |
|---|
| 351 |
}; |
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
unsigned yyival; |
|---|
| 356 |
char *yytext; |
|---|
| 357 |
char *yytext_end; |
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
FILE *yyout; |
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 |
|
|---|
| 365 |
int yyline; |
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
char *filename; |
|---|
| 370 |
|
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
char is_ident[255]; |
|---|
| 375 |
char is_digit[255]; |
|---|
| 376 |
char is_white[255]; |
|---|
| 377 |
|
|---|
| 378 |
#define IDENTP(C) is_ident[(unsigned char) (C)] |
|---|
| 379 |
#define DIGITP(C) is_digit[(unsigned char) (C)] |
|---|
| 380 |
#define WHITEP(C) is_white[(unsigned char) (C)] |
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
int f_append; |
|---|
| 385 |
int f_verbose; |
|---|
| 386 |
int f_very_verbose; |
|---|
| 387 |
int f_structs = 1; |
|---|
| 388 |
int f_regexps = 1; |
|---|
| 389 |
int f_nested_classes = 1; |
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
int min_regexp = 5; |
|---|
| 396 |
int max_regexp = 50; |
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
char *inbuffer; |
|---|
| 401 |
char *in; |
|---|
| 402 |
int inbuffer_size; |
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
#define BUFFER_POS() (in - inbuffer) |
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
char *string_start; |
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
#define TABLE_SIZE 1001 |
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
struct sym *class_table[TABLE_SIZE]; |
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
struct member *member_table[TABLE_SIZE]; |
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
struct alias *namespace_alias_table[TABLE_SIZE]; |
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
struct sym *global_symbols; |
|---|
| 437 |
|
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
struct sym *current_namespace; |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
struct sym *all_namespaces; |
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
struct sym **namespace_stack; |
|---|
| 449 |
int namespace_stack_size; |
|---|
| 450 |
int namespace_sp; |
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
int tk = -1; |
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
struct kw |
|---|
| 459 |
{ |
|---|
| 460 |
char *name; |
|---|
| 461 |
int tk; |
|---|
| 462 |
struct kw *next; |
|---|
| 463 |
}; |
|---|
| 464 |
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
#define KEYWORD_TABLE_SIZE 1001 |
|---|
| 468 |
struct kw *keyword_table[KEYWORD_TABLE_SIZE]; |
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
struct search_path |
|---|
| 473 |
{ |
|---|
| 474 |
char *path; |
|---|
| 475 |
struct search_path *next; |
|---|
| 476 |
}; |
|---|
| 477 |
|
|---|
| 478 |
struct search_path *search_path; |
|---|
| 479 |
struct search_path *search_path_tail; |
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
int yylex P_ ((void)); |
|---|
| 484 |
void yyparse P_ ((void)); |
|---|
| 485 |
void re_init_parser P_ ((void)); |
|---|
| 486 |
char *token_string P_ ((int)); |
|---|
| 487 |
char *matching_regexp P_ ((void)); |
|---|
| 488 |
void init_sym P_ ((void)); |
|---|
| 489 |
struct sym *add_sym P_ ((char *, struct sym *)); |
|---|
| 490 |
void add_link P_ ((struct sym *, struct sym *)); |
|---|
| 491 |
void add_member_defn P_ ((struct sym *, char *, char *, |
|---|
| 492 |
int, unsigned, int, int, int)); |
|---|
| 493 |
void add_member_decl P_ ((struct sym *, char *, char *, int, |
|---|
| 494 |
unsigned, int, int, int, int)); |
|---|
| 495 |
void dump_roots P_ ((FILE *)); |
|---|
| 496 |
void *xmalloc P_ ((int)); |
|---|
| 497 |
void xfree P_ ((void *)); |
|---|
| 498 |
void add_global_defn P_ ((char *, char *, int, unsigned, int, int, int)); |
|---|
| 499 |
void add_global_decl P_ ((char *, char *, int, unsigned, int, int, int)); |
|---|
| 500 |
void add_define P_ ((char *, char *, int)); |
|---|
| 501 |
void mark_inherited_virtual P_ ((void)); |
|---|
| 502 |
void leave_namespace P_ ((void)); |
|---|
| 503 |
void enter_namespace P_ ((char *)); |
|---|
| 504 |
void register_namespace_alias P_ ((char *, struct link *)); |
|---|
| 505 |
void insert_keyword P_ ((char *, int)); |
|---|
| 506 |
void re_init_scanner P_ ((void)); |
|---|
| 507 |
void init_scanner P_ ((void)); |
|---|
| 508 |
void usage P_ ((int)); |
|---|
| 509 |
void version P_ ((void)); |
|---|
| 510 |
void process_file P_ ((char *)); |
|---|
| 511 |
void add_search_path P_ ((char *)); |
|---|
| 512 |
FILE *open_file P_ ((char *)); |
|---|
| 513 |
int process_pp_line P_ ((void)); |
|---|
| 514 |
int dump_members P_ ((FILE *, struct member *)); |
|---|
| 515 |
void dump_sym P_ ((FILE *, struct sym *)); |
|---|
| 516 |
int dump_tree P_ ((FILE *, struct sym *)); |
|---|
| 517 |
struct member *find_member P_ ((struct sym *, char *, int, int, unsigned)); |
|---|
| 518 |
struct member *add_member P_ ((struct sym *, char *, int, int, unsigned)); |
|---|
| 519 |
void mark_virtual P_ ((struct sym *)); |
|---|
| 520 |
void mark_virtual P_ ((struct sym *)); |
|---|
| 521 |
struct sym *make_namespace P_ ((char *, struct sym *)); |
|---|
| 522 |
char *sym_scope P_ ((struct sym *)); |
|---|
| 523 |
char *sym_scope_1 P_ ((struct sym *)); |
|---|
| 524 |
int skip_to P_ ((int)); |
|---|
| 525 |
void skip_matching P_ ((void)); |
|---|
| 526 |
void member P_ ((struct sym *, int)); |
|---|
| 527 |
void class_body P_ ((struct sym *, int)); |
|---|
| 528 |
void class_definition P_ ((struct sym *, int, int, int)); |
|---|
| 529 |
void declaration P_ ((int)); |
|---|
| 530 |
unsigned parm_list P_ ((int *)); |
|---|
| 531 |
char *operator_name P_ ((int *)); |
|---|
| 532 |
struct sym *parse_classname P_ ((void)); |
|---|
| 533 |
struct sym *parse_qualified_ident_or_type P_ ((char **)); |
|---|
| 534 |
void parse_qualified_param_ident_or_type P_ ((char **)); |
|---|
| 535 |
int globals P_ ((int)); |
|---|
| 536 |
void yyerror P_ ((char *, char *)); |
|---|
| 537 |
void usage P_ ((int)) NO_RETURN; |
|---|
| 538 |
void version P_ (()) NO_RETURN; |
|---|
| 539 |
|
|---|
| 540 |
|
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 |
void |
|---|
| 550 |
yyerror (format, s) |
|---|
| 551 |
char *format, *s; |
|---|
| 552 |
{ |
|---|
| 553 |
fprintf (stderr, "%s:%d: ", filename, yyline); |
|---|
| 554 |
fprintf (stderr, format, s); |
|---|
| 555 |
putc ('\n', stderr); |
|---|
| 556 |
} |
|---|
| 557 |
|
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
void * |
|---|
| 563 |
xmalloc (nbytes) |
|---|
| 564 |
int nbytes; |
|---|
| 565 |
{ |
|---|
| 566 |
void *p = malloc (nbytes); |
|---|
| 567 |
if (p == NULL) |
|---|
| 568 |
{ |
|---|
| 569 |
yyerror ("out of memory", NULL); |
|---|
| 570 |
exit (EXIT_FAILURE); |
|---|
| 571 |
} |
|---|
| 572 |
return p; |
|---|
| 573 |
} |
|---|
| 574 |
|
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
void * |
|---|
| 579 |
xrealloc (p, sz) |
|---|
| 580 |
void *p; |
|---|
| 581 |
int sz; |
|---|
| 582 |
{ |
|---|
| 583 |
p = realloc (p, sz); |
|---|
| 584 |
if (p == NULL) |
|---|
| 585 |
{ |
|---|
| 586 |
yyerror ("out of memory", NULL); |
|---|
| 587 |
exit (EXIT_FAILURE); |
|---|
| 588 |
} |
|---|
| 589 |
return p; |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
void |
|---|
| 596 |
xfree (p) |
|---|
| 597 |
void *p; |
|---|
| 598 |
{ |
|---|
| 599 |
if (p) |
|---|
| 600 |
free (p); |
|---|
| 601 |
} |
|---|
| 602 |
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 |
char * |
|---|
| 608 |
xstrdup (s) |
|---|
| 609 |
char *s; |
|---|
| 610 |
{ |
|---|
| 611 |
if (s) |
|---|
| 612 |
s = strcpy (xmalloc (strlen (s) + 1), s); |
|---|
| 613 |
return s; |
|---|
| 614 |
} |
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
|
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 |
|
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
|
|---|
| 625 |
void |
|---|
| 626 |
init_sym () |
|---|
| 627 |
{ |
|---|
| 628 |
global_symbols = add_sym (GLOBALS_NAME, |
|---|