m4macs.c revision 9fb1159054bb89619213a7b2be87ea3bca25fcce
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <limits.h>
#include <unistd.h>
#include "m4.h"
static void mkpid(char *);
static void
{
"comment marker longer than %d chars"), MAXSYM);
}
static void
{
"quote marker longer than %d chars"), MAXSYM);
if (c <= 1 && !*l) {
l = L"`";
r = L"'";
} else if (c == 1) {
r = l;
}
}
static void
{
}
void
{
}
static void
{
wchar_t *s;
if (c < 1)
return;
s = ap[1];
if (is_alpha(*s) || *s == '_') {
s++;
while (is_alnum(*s) || *s == '_')
s++;
}
if (*s || s == ap[1])
}
static void
{
wchar_t *d;
while (c > 0)
while (*d)
putbak(*d++);
}
}
static void
{
int f;
if (f >= 10 || f < 0) {
ofx = f;
return;
}
ofx = f;
}
}
/* ARGSUSED */
static void
{
}
/* ARGSUSED */
static void
{
wchar_t t;
;
}
static void
{
int i;
if (c > 0)
while (c--) {
}
else
for (i = 0; i < hshsize; i++)
}
static void
{
while (*s++);
--s;
while (s > defnn) {
--s;
if (is_builtin(*s))
else {
}
}
}
static void
{
if (c > 0)
}
long evalval; /* return value from yacc stuff */
static void
{
extern int yyparse(void);
evalval = 0;
if (c > 0) {
if (yyparse() != 0)
"invalid expression"));
}
}
/*
* doexit
*
* Process m4exit macro.
*/
static void
{
}
static void
{
if (c < 3)
return;
while (c >= 3) {
return;
}
c -= 3;
ap += 3;
}
if (c > 0)
}
static void
{
if (c < 2)
return;
while (c >= 2) {
return;
}
c -= 2;
ap += 2;
}
if (c > 0)
}
static void
{
}
static void
{
if (ifx >= 9)
"input file nesting too deep (9)"));
--ifx;
if (noisy)
"can't open file"));
} else {
}
}
}
static void
{
}
static void
{
int i;
for (i = 0; *subj; ++i)
pbnum((long)i);
return;
}
pbnum((long)-1);
}
static int
{
while (*substr)
return (0);
return (1);
}
static void
{
}
static void
{
char *path;
if (c > 0) {
}
}
static void
{
int i;
for (i = 1; i <= c; ++i)
}
static void
{
}
static void
{
if (c <= 1)
return;
for (;;) {
if (c <= 1)
break;
pbstr(L",");
}
}
static void
{
}
static void
{
return;
}
static void
{
sysrval = 0;
if (c > 0) {
}
}
/* ARGSUSED */
static void
{
}
static void
{
if (c < 1)
return;
wchar_t *i;
for (i = fr; *i; ++i) {
if (*source == *i)
break;
if (*to)
++to;
}
if (*i) {
if (*to)
} else
}
}
static void
{
trace = 0;
while (c > 0)
}
static void
{
while (c > 0)
}
void
{
int i;
for (i = 1; i <= c; ++i)
;
}
int
{
return (0);
else {
}
return (1);
}
static void
{
int i;
if (c <= 0)
for (i = 1; i < 10; i++)
else
while (--c >= 0)
}
/*
* dowrap
*
* Process m4wrap macro.
*/
static void
{
/* store m4wrap string */
/* add this entry to the front of the list of Wrap entries */
}
static void
{
char *s = as;
char *l;
char *first_X;
unsigned xcnt = 0;
char my_pid[32];
int pid_len;
int i = 0;
/*
* Count number of X.
*/
l = &s[strlen(s)-1];
while (l != as) {
if (*l == 'X') {
first_X = l;
l--;
xcnt++;
} else if (xcnt == 0)
l--;
else {
break;
}
}
/*
* 1) If there is no X in the passed string,
* then it just return the passed string.
* 2) If the length of the continuous right most X's of
* the string is shorter than the length of pid,
* then right most X's will be substitued with
* upper digits of pid.
* 3) If the length of the continuous right most X's of
* the string is equat to the length of pid,
* then X's will be replaced with pid.
* 4) If the lenght of the continuous right most X's of
* the string is longer than the length of pid,
* then X's will have leading 0 followed by
* pid.
*/
/*
* If there were no X, don't do anything.
*/
if (xcnt == 0)
return;
/*
* Get pid
*/
*first_X++ = '0';
xcnt--;
}
}
/*
* Copy pid
*/
while (i != xcnt)
}
dochcom, L"changecom",
docq, L"changequote",
dodecr, L"decr",
dodef, L"define",
dodefn, L"defn",
dodiv, L"divert",
dodivnum, L"divnum",
dodnl, L"dnl",
dodump, L"dumpdef",
doerrp, L"errprint",
doeval, L"eval",
doexit, L"m4exit",
doif, L"ifelse",
doifdef, L"ifdef",
doincl, L"include",
doincr, L"incr",
doindex, L"index",
dolen, L"len",
domake, L"maketemp",
dopopdef, L"popdef",
dopushdef, L"pushdef",
doshift, L"shift",
dosincl, L"sinclude",
dosubstr, L"substr",
dosyscmd, L"syscmd",
dosysval, L"sysval",
dotransl, L"translit",
dotroff, L"traceoff",
dotron, L"traceon",
doundef, L"undefine",
doundiv, L"undivert",
dowrap, L"m4wrap",
0, 0
};