wrc.c 16.6 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
2
 * Copyright 1994 Martin von Loewis
Austin English's avatar
Austin English committed
3
 * Copyright 1998 Bertho A. Stultiens (BS)
4
 * Copyright 2003 Dimitrie O. Paun
Alexandre Julliard's avatar
Alexandre Julliard committed
5
 *
6 7 8 9 10 11 12 13 14 15 16 17
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
 *
Alexandre Julliard's avatar
Alexandre Julliard committed
20 21
 */

22
#include "config.h"
23
#include "wine/port.h"
24

Alexandre Julliard's avatar
Alexandre Julliard committed
25 26
#include <stdio.h>
#include <stdlib.h>
27 28 29
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
30 31 32
#include <string.h>
#include <assert.h>
#include <ctype.h>
33
#include <signal.h>
34 35 36
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
37 38 39 40 41 42 43 44

#include "wrc.h"
#include "utils.h"
#include "readres.h"
#include "dumpres.h"
#include "genres.h"
#include "newstruc.h"
#include "parser.h"
45
#include "wine/wpp.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
46

47 48 49 50 51 52
#ifdef WORDS_BIGENDIAN
#define ENDIAN	"big"
#else
#define ENDIAN	"little"
#endif

53
static const char usage[] =
54
	"Usage: wrc [options...] [infile[.rc|.res]]\n"
55 56 57 58
	"   -b, --target=TARGET        Specify target CPU and platform when cross-compiling\n"
	"   -D, --define id[=val]      Define preprocessor identifier id=val\n"
	"   --debug=nn                 Set debug level to 'nn'\n"
	"   -E                         Preprocess only\n"
59
	"   --endianness=e             Set output byte-order e={n[ative], l[ittle], b[ig]}\n"
60 61 62 63 64 65 66 67 68 69 70 71
	"                              (win32 only; default is " ENDIAN "-endian)\n"
	"   -F TARGET                  Synonym for -b for compatibility with windres\n"
	"   -fo FILE                   Synonym for -o for compatibility with windres\n"
	"   -h, --help                 Prints this summary\n"
	"   -i, --input=FILE           The name of the input file\n"
	"   -I, --include-dir=PATH     Set include search dir to path (multiple -I allowed)\n"
	"   -J, --input-format=FORMAT  The input format (either `rc' or `rc16')\n"
	"   -l, --language=LANG        Set default language to LANG (default is neutral {0, 0})\n"
	"   -m16, -m32, -m64           Build for 16-bit, 32-bit resp. 64-bit platforms\n"
	"   --no-use-temp-file         Ignored for compatibility with windres\n"
	"   --nostdinc                 Disables searching the standard include path\n"
	"   -o, --output=FILE          Output to file (default is infile.res)\n"
72
	"   -O, --output-format=FORMAT The output format (`po', `pot', `res', or `res16`)\n"
73
	"   --pedantic                 Enable pedantic warnings\n"
74
	"   --po-dir=DIR               Directory containing po files for translations\n"
75 76 77 78 79 80 81
	"   --preprocessor             Specifies the preprocessor to use, including arguments\n"
	"   -r                         Ignored for compatibility with rc\n"
	"   -U, --undefine id          Undefine preprocessor identifier id\n"
	"   --use-temp-file            Ignored for compatibility with windres\n"
	"   -v, --verbose              Enable verbose mode\n"
	"   --verify-translations      Check the status of the various translations\n"
	"   --version                  Print version and exit\n"
Alexandre Julliard's avatar
Alexandre Julliard committed
82 83 84 85 86
	"Input is taken from stdin if no sourcefile specified.\n"
	"Debug level 'n' is a bitmask with following meaning:\n"
	"    * 0x01 Tell which resource is parsed (verbose mode)\n"
	"    * 0x02 Dump internal structures\n"
	"    * 0x04 Create a parser trace (yydebug=1)\n"
87 88 89
	"    * 0x08 Preprocessor messages\n"
	"    * 0x10 Preprocessor lex messages\n"
	"    * 0x20 Preprocessor yacc trace\n"
Alexandre Julliard's avatar
Alexandre Julliard committed
90
	"If no input filename is given and the output name is not overridden\n"
91
	"with -o, then the output is written to \"wrc.tab.res\"\n"
Alexandre Julliard's avatar
Alexandre Julliard committed
92 93
	;

94
static const char version_string[] = "Wine Resource Compiler version " PACKAGE_VERSION "\n"
95
			"Copyright 1998-2000 Bertho A. Stultiens\n"
Alexandre Julliard's avatar
Alexandre Julliard committed
96 97 98 99 100 101 102 103 104
			"          1994 Martin von Loewis\n";

/*
 * Set if compiling in 32bit mode (default).
 */
int win32 = 1;

/*
 * debuglevel == DEBUGLEVEL_NONE	Don't bother
Austin English's avatar
Austin English committed
105
 * debuglevel & DEBUGLEVEL_CHAT		Say what's done
Alexandre Julliard's avatar
Alexandre Julliard committed
106 107
 * debuglevel & DEBUGLEVEL_DUMP		Dump internal structures
 * debuglevel & DEBUGLEVEL_TRACE	Create parser trace
108 109 110
 * debuglevel & DEBUGLEVEL_PPMSG	Preprocessor messages
 * debuglevel & DEBUGLEVEL_PPLEX	Preprocessor lex trace
 * debuglevel & DEBUGLEVEL_PPTRACE	Preprocessor yacc trace
Alexandre Julliard's avatar
Alexandre Julliard committed
111 112 113 114 115 116 117 118 119 120 121 122
 */
int debuglevel = DEBUGLEVEL_NONE;

/*
 * Recognize win32 keywords if set (-w 32 enforces this),
 * otherwise set with -e option.
 */
int extensions = 1;

/*
 * Language setting for resources (-l option)
 */
123
static language_t *defaultlanguage;
Alexandre Julliard's avatar
Alexandre Julliard committed
124 125 126 127 128 129 130
language_t *currentlanguage = NULL;

/*
 * Set when extra warnings should be generated (-W option)
 */
int pedantic = 0;

131 132 133 134 135
/*
 * The output byte-order of resources (set with -B)
 */
int byteorder = WRC_BO_NATIVE;

136 137 138 139 140 141
/*
 * Set when _only_ to run the preprocessor (-E option)
 */
int preprocess_only = 0;

/*
142
 * Set when _not_ to run the preprocessor (-P cat option)
143 144 145
 */
int no_preprocess = 0;

146 147
int check_utf8 = 1;  /* whether to check for valid utf8 */

148 149
static int pointer_size = sizeof(void *);

150 151
static int verify_translations_mode;

152
static char *output_name;	/* The name given by the -o option */
153
char *input_name = NULL;	/* The name given on the command-line */
154
static char *temp_name = NULL;	/* Temporary file for preprocess pipe */
155 156 157

int line_number = 1;		/* The current line */
int char_number = 1;		/* The current char pos within the line */
Alexandre Julliard's avatar
Alexandre Julliard committed
158 159 160

char *cmdline;			/* The entire commandline */

161
int parser_debug, yy_flex_debug;
162

Alexandre Julliard's avatar
Alexandre Julliard committed
163 164 165
resource_t *resource_top;	/* The top of the parsed resources */

int getopt (int argc, char *const *argv, const char *optstring);
166
static void cleanup_files(void);
167
static void segvhandler(int sig);
Alexandre Julliard's avatar
Alexandre Julliard committed
168

169 170 171 172 173
enum long_options_values
{
    LONG_OPT_NOSTDINC = 1,
    LONG_OPT_TMPFILE,
    LONG_OPT_NOTMPFILE,
174
    LONG_OPT_PO_DIR,
175 176 177
    LONG_OPT_PREPROCESSOR,
    LONG_OPT_VERSION,
    LONG_OPT_DEBUG,
178
    LONG_OPT_ENDIANNESS,
179 180 181 182
    LONG_OPT_PEDANTIC,
    LONG_OPT_VERIFY_TRANSL
};

183
static const char short_options[] =
184
	"b:D:Ef:F:hi:I:J:l:m:o:O:rU:v";
185
static const struct option long_options[] = {
186 187
	{ "debug", 1, NULL, LONG_OPT_DEBUG },
	{ "define", 1, NULL, 'D' },
188
	{ "endianness", 1, NULL, LONG_OPT_ENDIANNESS },
189 190 191 192 193 194 195 196 197 198
	{ "help", 0, NULL, 'h' },
	{ "include-dir", 1, NULL, 'I' },
	{ "input", 1, NULL, 'i' },
	{ "input-format", 1, NULL, 'J' },
	{ "language", 1, NULL, 'l' },
	{ "no-use-temp-file", 0, NULL, LONG_OPT_NOTMPFILE },
	{ "nostdinc", 0, NULL, LONG_OPT_NOSTDINC },
	{ "output", 1, NULL, 'o' },
	{ "output-format", 1, NULL, 'O' },
	{ "pedantic", 0, NULL, LONG_OPT_PEDANTIC },
199
	{ "po-dir", 1, NULL, LONG_OPT_PO_DIR },
200 201 202 203 204 205 206 207
	{ "preprocessor", 1, NULL, LONG_OPT_PREPROCESSOR },
	{ "target", 1, NULL, 'F' },
	{ "undefine", 1, NULL, 'U' },
	{ "use-temp-file", 0, NULL, LONG_OPT_TMPFILE },
	{ "verbose", 0, NULL, 'v' },
	{ "verify-translations", 0, NULL, LONG_OPT_VERIFY_TRANSL },
	{ "version", 0, NULL, LONG_OPT_VERSION },
	{ NULL, 0, NULL, 0 }
208 209
};

210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
static void set_version_defines(void)
{
    char *version = xstrdup( PACKAGE_VERSION );
    char *major, *minor, *patchlevel;
    char buffer[100];

    if ((minor = strchr( version, '.' )))
    {
        major = version;
        *minor++ = 0;
        if ((patchlevel = strchr( minor, '.' ))) *patchlevel++ = 0;
    }
    else  /* pre 0.9 version */
    {
        major = NULL;
        patchlevel = version;
    }
    sprintf( buffer, "__WRC__=%s", major ? major : "0" );
    wpp_add_cmdline_define(buffer);
    sprintf( buffer, "__WRC_MINOR__=%s", minor ? minor : "0" );
    wpp_add_cmdline_define(buffer);
    sprintf( buffer, "__WRC_PATCHLEVEL__=%s", patchlevel ? patchlevel : "0" );
    wpp_add_cmdline_define(buffer);
    free( version );
}

236 237 238 239 240 241
/* clean things up when aborting on a signal */
static void exit_on_signal( int sig )
{
    exit(1);  /* this will call the atexit functions */
}

242 243 244 245 246 247 248 249
/* load a single input file */
static int load_file( const char *input_name, const char *output_name )
{
    int ret;

    /* Run the preprocessor on the input */
    if(!no_preprocess)
    {
250 251 252 253
        FILE *output;
        int ret, fd;
        char *name;

254 255 256 257 258
        /*
         * Preprocess the input to a temp-file, or stdout if
         * no output was given.
         */

259
        if (preprocess_only)
260
        {
261 262 263 264 265 266 267 268 269 270 271 272
            if (output_name)
            {
                if (!(output = fopen( output_name, "w" )))
                    fatal_perror( "Could not open %s for writing", output_name );
                ret = wpp_parse( input_name, output );
                fclose( output );
            }
            else ret = wpp_parse( input_name, stdout );

            if (ret) return ret;
            output_name = NULL;
            exit(0);
273 274
        }

275
        if (output_name && output_name[0]) name = strmake( "%s.XXXXXX", output_name );
276
        else name = xstrdup( "wrc.XXXXXX" );
277

278 279
        if ((fd = mkstemps( name, 0 )) == -1)
            error("Could not generate a temp name from %s\n", name);
280

281 282 283
        temp_name = name;
        if (!(output = fdopen(fd, "wt")))
            error("Could not open fd %s for writing\n", name);
284

285 286 287 288
        ret = wpp_parse( input_name, output );
        fclose( output );
        if (ret) return ret;
        input_name = name;
289 290
    }

291 292
    /* Reset the language */
    currentlanguage = dup_language( defaultlanguage );
293
    check_utf8 = 1;
294

295 296 297 298 299 300 301 302
    /* Go from .rc to .res */
    chat("Starting parse\n");

    if(!(parser_in = fopen(input_name, "rb")))
        fatal_perror("Could not open %s for input", input_name);

    ret = parser_parse();
    fclose(parser_in);
303
    parser_lex_destroy();
304 305 306 307 308
    if (temp_name)
    {
        unlink( temp_name );
        temp_name = NULL;
    }
309
    free( currentlanguage );
310 311 312
    return ret;
}

313 314 315 316 317 318 319
static void set_target( const char *target )
{
    char *p, *cpu = xstrdup( target );

    /* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
    if (!(p = strchr( cpu, '-' ))) error( "Invalid target specification '%s'\n", target );
    *p = 0;
320 321
    if (!strcmp( cpu, "amd64" ) || !strcmp( cpu, "x86_64" ) ||
        !strcmp( cpu, "ia64" ) || !strcmp( cpu, "aarch64" ))
322 323 324 325 326
        pointer_size = 8;
    else
        pointer_size = 4;
    free( cpu );
}
327

Alexandre Julliard's avatar
Alexandre Julliard committed
328 329 330 331
int main(int argc,char *argv[])
{
	extern char* optarg;
	extern int   optind;
332 333
	int optc;
	int opti = 0;
334
	int stdinc = 1;
Alexandre Julliard's avatar
Alexandre Julliard committed
335
	int lose = 0;
336
	int nb_files = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
337 338
	int i;
	int cmdlen;
339
        int po_mode = 0;
340
        char *po_dir = NULL;
341
        char **files = xmalloc( argc * sizeof(*files) );
Alexandre Julliard's avatar
Alexandre Julliard committed
342

343
	signal(SIGSEGV, segvhandler);
344 345 346 347 348
        signal( SIGTERM, exit_on_signal );
        signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
        signal( SIGHUP, exit_on_signal );
#endif
349

350
	/* Set the default defined stuff */
351
        set_version_defines();
352
	wpp_add_cmdline_define("RC_INVOKED=1");
353 354
	/* Microsoft RC always searches current directory */
	wpp_add_include_path(".");
355

Alexandre Julliard's avatar
Alexandre Julliard committed
356 357 358 359 360
	/* First rebuild the commandline to put in destination */
	/* Could be done through env[], but not all OS-es support it */
	cmdlen = 4; /* for "wrc " */
	for(i = 1; i < argc; i++)
		cmdlen += strlen(argv[i]) + 1;
361
	cmdline = xmalloc(cmdlen);
Alexandre Julliard's avatar
Alexandre Julliard committed
362 363 364 365 366 367 368 369
	strcpy(cmdline, "wrc ");
	for(i = 1; i < argc; i++)
	{
		strcat(cmdline, argv[i]);
		if(i < argc-1)
			strcat(cmdline, " ");
	}

370
	while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF)
Alexandre Julliard's avatar
Alexandre Julliard committed
371 372 373
	{
		switch(optc)
		{
374
		case LONG_OPT_NOSTDINC:
375 376
			stdinc = 0;
			break;
377
		case LONG_OPT_TMPFILE:
378
			if (debuglevel) warning("--use-temp-file option not yet supported, ignored.\n");
379
			break;
380
		case LONG_OPT_NOTMPFILE:
381 382
			if (debuglevel) warning("--no-use-temp-file option not yet supported, ignored.\n");
			break;
383 384 385
		case LONG_OPT_PO_DIR:
			po_dir = xstrdup( optarg );
			break;
386
		case LONG_OPT_PREPROCESSOR:
387 388 389
			if (strcmp(optarg, "cat") == 0) no_preprocess = 1;
			else fprintf(stderr, "-P option not yet supported, ignored.\n");
			break;
390
		case LONG_OPT_VERSION:
391 392
			printf(version_string);
			exit(0);
393
			break;
394
		case LONG_OPT_DEBUG:
395 396
			debuglevel = strtol(optarg, NULL, 0);
			break;
397
		case LONG_OPT_ENDIANNESS:
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
			switch(optarg[0])
			{
			case 'n':
			case 'N':
				byteorder = WRC_BO_NATIVE;
				break;
			case 'l':
			case 'L':
				byteorder = WRC_BO_LITTLE;
				break;
			case 'b':
			case 'B':
				byteorder = WRC_BO_BIG;
				break;
			default:
413
				fprintf(stderr, "Byte ordering must be n[ative], l[ittle] or b[ig]\n");
414 415 416
				lose++;
			}
			break;
417
		case LONG_OPT_PEDANTIC:
418 419
			pedantic = 1;
			wpp_set_pedantic(1);
Alexandre Julliard's avatar
Alexandre Julliard committed
420
			break;
421
		case LONG_OPT_VERIFY_TRANSL:
422 423
			verify_translations_mode = 1;
			break;
Alexandre Julliard's avatar
Alexandre Julliard committed
424
		case 'D':
425
			wpp_add_cmdline_define(optarg);
Alexandre Julliard's avatar
Alexandre Julliard committed
426
			break;
427 428 429
		case 'E':
			preprocess_only = 1;
			break;
430
		case 'b':
431
		case 'F':
432
			set_target( optarg );
433
			break;
434 435 436
		case 'h':
			printf(usage);
			exit(0);
437
		case 'i':
438
			files[nb_files++] = optarg;
439
			break;
Alexandre Julliard's avatar
Alexandre Julliard committed
440
		case 'I':
441 442 443 444
			wpp_add_include_path(optarg);
			break;
		case 'J':
			if (strcmp(optarg, "rc16") == 0)  extensions = 0;
445
			else if (strcmp(optarg, "rc")) error("Output format %s not supported.\n", optarg);
446
			break;
Alexandre Julliard's avatar
Alexandre Julliard committed
447 448 449 450
		case 'l':
			{
				int lan;
				lan = strtol(optarg, NULL, 0);
451
				if (get_language_codepage(PRIMARYLANGID(lan), SUBLANGID(lan)) == -1)
452
					error("Language %04x is not supported\n", lan);
453
				defaultlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
Alexandre Julliard's avatar
Alexandre Julliard committed
454 455
			}
			break;
456 457 458 459 460
                case 'm':
			if (!strcmp( optarg, "16" )) win32 = 0;
			else if (!strcmp( optarg, "32" )) { win32 = 1; pointer_size = 4; }
			else if (!strcmp( optarg, "64" )) { win32 = 1; pointer_size = 8; }
			break;
461 462 463 464
		case 'f':
			if (*optarg != 'o') error("Unknown option: -f%s\n",  optarg);
			optarg++;
			/* fall through */
Alexandre Julliard's avatar
Alexandre Julliard committed
465
		case 'o':
466 467 468 469
			if (!output_name) output_name = strdup(optarg);
			else error("Too many output files.\n");
			break;
		case 'O':
470 471 472
			if (strcmp(optarg, "po") == 0) po_mode = 1;
			else if (strcmp(optarg, "pot") == 0) po_mode = 2;
			else if (strcmp(optarg, "res16") == 0) win32 = 0;
473
			else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
474
			break;
475 476 477 478 479 480
		case 'r':
			/* ignored for compatibility with rc */
			break;
		case 'U':
			wpp_del_define(optarg);
			break;
481 482 483
		case 'v':
			debuglevel = DEBUGLEVEL_CHAT;
			break;
Alexandre Julliard's avatar
Alexandre Julliard committed
484 485 486 487 488 489 490 491 492 493 494 495
		default:
			lose++;
			break;
		}
	}

	if(lose)
	{
		fprintf(stderr, usage);
		return 1;
	}

496 497 498 499 500 501
	if (win32)
	{
		wpp_add_cmdline_define("_WIN32=1");
		if (pointer_size == 8) wpp_add_cmdline_define("_WIN64=1");
	}

502 503 504 505 506 507
	/* If we do need to search standard includes, add them to the path */
	if (stdinc)
	{
		wpp_add_include_path(INCLUDEDIR"/msvcrt");
		wpp_add_include_path(INCLUDEDIR"/windows");
	}
508

Alexandre Julliard's avatar
Alexandre Julliard committed
509 510 511
	/* Kill io buffering when some kind of debuglevel is enabled */
	if(debuglevel)
	{
512 513
		setbuf(stdout, NULL);
		setbuf(stderr, NULL);
Alexandre Julliard's avatar
Alexandre Julliard committed
514 515
	}

516
	parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
517
	yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
518 519 520 521

        wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
                       (debuglevel & DEBUGLEVEL_PPTRACE) != 0,
                       (debuglevel & DEBUGLEVEL_PPMSG) != 0 );
Alexandre Julliard's avatar
Alexandre Julliard committed
522 523

	/* Check if the user set a language, else set default */
524 525
	if(!defaultlanguage)
		defaultlanguage = new_language(0, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
526

527
	atexit(cleanup_files);
Alexandre Julliard's avatar
Alexandre Julliard committed
528

529
        while (optind < argc) files[nb_files++] = argv[optind++];
530

531
        for (i = 0; i < nb_files; i++)
532
        {
533
            input_name = files[i];
534 535
            if (load_file( input_name, output_name )) exit(1);
        }
536
	/* stdin special case. NULL means "stdin" for wpp. */
537
        if (nb_files == 0 && load_file( NULL, output_name )) exit(1);
Alexandre Julliard's avatar
Alexandre Julliard committed
538

539 540
	if(debuglevel & DEBUGLEVEL_DUMP)
		dump_resources(resource_top);
Alexandre Julliard's avatar
Alexandre Julliard committed
541

542 543 544 545 546
	if(verify_translations_mode)
	{
		verify_translations(resource_top);
		exit(0);
	}
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
	if (po_mode)
	{
            if (po_mode == 2)  /* pot file */
            {
                if (!output_name)
                {
                    output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
                    strcat( output_name, ".pot" );
                }
                write_pot_file( output_name );
            }
            else write_po_files( output_name );
            output_name = NULL;
            exit(0);
	}
562
        add_translations( po_dir );
563

564 565
	/* Convert the internal lists to binary data */
	resources2res(resource_top);
Alexandre Julliard's avatar
Alexandre Julliard committed
566

567
	chat("Writing .res-file\n");
568 569 570 571 572
        if (!output_name)
        {
            output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
            strcat(output_name, ".res");
        }
573
	write_resfile(output_name, resource_top);
574
	output_name = NULL;
Alexandre Julliard's avatar
Alexandre Julliard committed
575 576 577 578 579

	return 0;
}


580
static void cleanup_files(void)
581
{
582 583
	if (output_name) unlink(output_name);
	if (temp_name) unlink(temp_name);
584
}
Alexandre Julliard's avatar
Alexandre Julliard committed
585

586 587 588 589 590 591 592
static void segvhandler(int sig)
{
	fprintf(stderr, "\n%s:%d: Oops, segment violation\n", input_name, line_number);
	fflush(stdout);
	fflush(stderr);
	abort();
}