main.c revision 7ab03f887ff62508a7f59fd9c235aaeb3e17866a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2014 Gary Mills
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/* Copyright 1976, Bell Telephone Laboratories, Inc. */
#include <string.h>
#include "once.h"
#include "sgs.h"
#include <locale.h>
#include <limits.h>
static void get1core(void);
static void free1core(void);
static void get2core(void);
static void free2core(void);
static void get3core(void);
#ifdef DEBUG
static void free3core(void);
#endif
int
{
int i;
int c;
char *ypath;
#ifdef DEBUG
#else
#endif
switch (c) {
#ifdef DEBUG
case 'd':
debug++;
break;
case 'y':
break;
#endif
case 'V':
(const char *)SGU_PKG,
(const char *)SGU_REL);
break;
case 'Q':
"lex: -Q should be followed by [y/n]");
break;
case 'Y':
sizeof ("/nceucform") + 1);
error("No available memory "
"for directory name.");
else
break;
case 'c':
break;
case 't':
break;
case 'v':
report = 1;
break;
case 'n':
report = 0;
break;
case 'w':
case 'W':
woption = 1;
handleeuc = 1;
widecio = 1;
break;
case 'e':
case 'E':
eoption = 1;
handleeuc = 1;
widecio = 0;
break;
default:
"Usage: lex [-ewctvnV] [-Y directory] "
"[-Q(y/n)] [file]\n");
exit(1);
}
}
"You may not specify both -w and -e simultaneously.");
}
if (no_input) {
/* XCU4: recognize "-" file operand for stdin */
else {
}
} else
/* may be gotten: def, subs, sname, schar, ccl, dchar */
(void) gch();
/* may be gotten: name, left, right, nullstr, parent */
get1core();
sname[1] = 0;
/* XCU4: %x exclusive start */
exclusive[0] = 0;
if (!handleeuc) {
/*
* Set ZCH and ncg to their default values
* as they may be needed to handle %t directive.
*/
}
/* may be disposed of: def, subs, dchar */
if (yyparse())
if (handleeuc) {
"Too complex rules -- requires too many char groups.");
sortcgidtbl();
}
repbycgid(); /* Call this even in ASCII compat. mode. */
/*
* maybe get:
* tmpstat, foll, positions, gotof, nexts,
* nchar, state, atable, sfall, cpackflg
*/
free1core();
get2core();
ptail();
mkmatch();
#ifdef DEBUG
if (debug)
pccl();
#endif
sect = ENDSECTION;
if (tptr > 0)
#ifdef DEBUG
if (debug)
pfoll();
#endif
cgoto();
#ifdef DEBUG
if (debug) {
for (i = 0; i <= stnum; i++)
stprt(i);
}
#endif
/*
* may be disposed of:
* positions, tmpstat, foll, state, name,
* left, right, parent, ccl, schar, sname
* maybe get: verify, advance, stoff
*/
free2core();
get3core();
layout();
/*
* may be disposed of:
* verify, advance, stoff, nexts, nchar,
* gotof, atable, ccpackflg, sfall
*/
#ifdef DEBUG
free3core();
#endif
if (handleeuc) {
if (ratfor)
error("Ratfor is not supported by -w or -e option.");
}
else
if (report == 1)
statistics();
return (0); /* success return code */
}
static void
get1core(void)
{
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/* XCU4: exclusive start array */
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
error("Too little core to begin");
}
static void
free1core(void)
{
}
static void
get2core(void)
{
int i;
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
error("Too little core for state generation");
for (i = 0; i <= tptr; i++)
foll[i] = 0;
}
static void
free2core(void)
{
/* XCU4: exclusive start array */
}
static void
get3core(void)
{
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
/*LINTED: E_BAD_PTR_CAST_ALIGN*/
error("Too little core for final packing");
}
#ifdef DEBUG
static void
free3core(void)
{
}
#endif
BYTE *
myalloc(int a, int b)
{
BYTE *i;
i = calloc(a, b);
if (i == 0)
warning("calloc returns a 0");
return (i);
}
void
yyerror(char *s)
{
}