-e 's/^yynewerror://' \
-e 's/^ goto yynewerror;//' \
-e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \
+ -e 's/^\(char \*yyname\[\]\)/const \1/' \
+ -e 's/^\(char \*yyrule\[\]\)/const \1/' \
+ -e 's/^\( register\) \(char \*yys;\)/\1 const \2/' \
< y.tab.c > a2p.c
FORCE:
#endif
#define YYMAXTOKEN 306
#if YYDEBUG
-char *yyname[] = {
+const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
"':'","';'","'<'",0,"'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"DELETE","ASGNOP","OROR","ANDAND","NUMBER","VAR","SUBSTR","INDEX","MATCHOP",
"RELOP","OR","STRING","UMINUS","NOT","INCR","DECR","FIELD","VFIELD","SVFIELD",
};
-char *yyrule[] = {
+const char *yyrule[] = {
"$accept : program",
"program : junk hunks",
"begin : BEGIN '{' maybe states '}' junk",
{
register int yym, yyn, yystate;
#if YYDEBUG
- register char *yys;
+ register const char *yys;
if ((yys = getenv("YYDEBUG")))
{
#define OSTAR 88
#ifdef DOINIT
-char *opname[] = {
+const char *opname[] = {
"0",
"PROG",
"JUNK",
"89"
};
#else
-extern char *opname[];
+extern const char *opname[];
#endif
EXT int mop INIT(1);
/* A string is TRUE if not "" or "0". */
#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
-EXT char *Yes INIT("1");
-EXT char *No INIT("");
+EXT const char *Yes INIT("1");
+EXT const char *No INIT("");
#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
EXT STR *Str;
int rememberargs ( int arg );
char * scannum ( char *s );
char * scanpat ( char *s );
-int string ( char *ptr, int len );
-void yyerror ( char *s );
+int string ( const char *ptr, int len );
+void yyerror ( const char *s );
int yylex ( void );
EXT int line INIT(0);
#endif
#include "util.h"
-char *filename;
-char *myname;
+const char *filename;
+const char *myname;
int checkers = 0;
#endif
int
-main(register int argc, register char **argv, register char **env)
+main(register int argc, register const char **argv, register const char **env)
{
register STR *str;
int i;
}
filename = savestr(argv[0]);
- filename = savestr(argv[0]);
if (strEQ(filename,"-"))
argv[0] = "";
if (!*argv[0])
else if (strEQ(d,"function"))
XTERM(FUNCTION);
if (strEQ(d,"FILENAME"))
- d = "ARGV";
+ ID("ARGV");
if (strEQ(d,"foreach"))
*d = toUPPER(*d);
else if (strEQ(d,"format"))
SNARFWORD;
if (strEQ(d,"ORS")) {
saw_ORS = TRUE;
- d = "\\";
+ ID("\\");
}
if (strEQ(d,"OFS")) {
saw_OFS = TRUE;
- d = ",";
+ ID(",");
}
if (strEQ(d,"OFMT")) {
- d = "#";
+ ID("#");
}
if (strEQ(d,"open"))
*d = toUPPER(*d);
case 'r': case 'R':
SNARFWORD;
if (strEQ(d,"RS")) {
- d = "/";
saw_RS = TRUE;
+ ID("/");
}
if (strEQ(d,"rand")) {
yylval = ORAND;
XTERM(FUN1);
}
if (strEQ(d,"SUBSEP")) {
- d = ";";
+ ID(";");
}
if (strEQ(d,"sin")) {
yylval = OSIN;
}
void
-yyerror(char *s)
+yyerror(const char *s)
{
fprintf(stderr,"%s in file %s at line %d\n",
s,filename,line);
}
int
-string(char *ptr, int len)
+string(const char *ptr, int len)
{
int retval = mop;
register char *s;
if (!str)
- return "";
+ return (char *)""; /* probably safe - won't be written to */
GROWSTR(&(str->str_ptr), &(str->str_len), 24);
s = str->str_ptr;
if (str->str_nok) {
}
void
-str_nset(register STR *str, register char *ptr, register int len)
+str_nset(register STR *str, register const char *ptr, register int len)
{
GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
memcpy(str->str_ptr,ptr,len);
}
void
-str_set(register STR *str, register char *ptr)
+str_set(register STR *str, register const char *ptr)
{
register int len;
}
void
-str_ncat(register STR *str, register char *ptr, register int len)
+str_ncat(register STR *str, register const char *ptr, register int len)
{
if (!(str->str_pok))
str_2ptr(str);
}
void
-str_cat(register STR *str, register char *ptr)
+str_cat(register STR *str, register const char *ptr)
{
register int len;
}
STR *
-str_make(char *s)
+str_make(const char *s)
{
register STR *str = str_new(0);
EXT long tmps_max INIT(-1);
char * str_2ptr ( STR *str );
-void str_cat ( STR *str, char *ptr );
+void str_cat ( STR *str, const char *ptr );
void str_free ( STR *str );
char * str_gets ( STR *str, FILE *fp );
int str_len ( STR *str );
-STR * str_make ( char *s );
-void str_ncat ( STR *str, char *ptr, int len );
+STR * str_make ( const char *s );
+void str_ncat ( STR *str, const char *ptr, int len );
STR * str_new ( int len );
-void str_nset ( STR *str, char *ptr, int len );
+void str_nset ( STR *str, const char *ptr, int len );
void str_numset ( STR *str, double num );
void str_scat ( STR *dstr, STR *sstr );
-void str_set ( STR *str, char *ptr );
+void str_set ( STR *str, const char *ptr );
void str_sset ( STR *dstr, STR *sstr );
/* return ptr to little string in big string, NULL if not found */
char *
-instr(char *big, char *little)
+instr(char *big, const char *little)
{
- register char *t, *s, *x;
+ register char *t, *x;
+ register const char *s;
for (t = big; *t; t++) {
for (x=t,s=little; *s; x++,s++) {
/* copy a string to a safe spot */
char *
-savestr(char *str)
+savestr(const char *str)
{
register char * const newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1));
char * cpy2 ( char *to, char *from, int delim );
char * cpytill ( char *to, char *from, int delim );
void growstr ( char **strptr, int *curlen, int newlen );
-char * instr ( char *big, char *little );
-char * savestr ( char *str );
+char * instr ( char *big, const char *little );
+char * savestr ( const char *str );
void fatal ( const char *pat, ... );
void warn ( const char *pat, ... );
int prewalk ( int numit, int level, int node, int *numericptr );
bool saw_argv0 = FALSE;
bool saw_fh = FALSE;
int maxtmp = 0;
-char *lparen;
-char *rparen;
-char *limit;
+const char *lparen;
+const char *rparen;
+const char *limit;
STR *subs;
STR *curargs = Nullstr;
#ifdef NETWARE
char *savestr(char *str);
char *cpytill(register char *to, register char *from, register int delim);
-char *instr(char *big, char *little);
+char *instr(char *big, const char *little);
#endif
STR *
len = type >> 8;
type &= 255;
tmp3str = str_new(0);
- if (type == OSTR) {
+ {
+ const char *s;
+ if (type == OSTR) {
tmp2str=walk(1,level,ops[ops[node+2].ival+1].ival,&numarg,P_MIN);
for (t = tmp2str->str_ptr, d=tokenbuf; *t; d++,t++) {
if (*t == '&')
}
*d = '\0';
str_set(tmp2str,tokenbuf);
- s = (char *) (gsub ? "/g" : "/");
- }
- else {
+ s = (gsub ? "/g" : "/");
+ }
+ else {
tmp2str=walk(1,level,ops[node+2].ival,&numarg,P_MIN);
str_set(tmp3str,"($s_ = '\"'.(");
str_scat(tmp3str,tmp2str);
str_cat(tmp3str,").'\"') =~ s/&/\\$&/g, ");
str_set(tmp2str,"eval $s_");
- s = (char *) (gsub ? "/ge" : "/e");
+ s = (gsub ? "/ge" : "/e");
i++;
+ }
+ str_cat(tmp2str,s);
}
- str_cat(tmp2str,s);
type = ops[ops[node+1].ival].ival;
len = type >> 8;
type &= 255;
break;
case OSTR:
tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- s = "'";
- for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) {
+ {
+ const char *s = "'";
+ for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) {
if (*t == '\'')
s = "\"";
else if (*t == '\\') {
}
}
*d = *t + 128;
+ }
+ *d = '\0';
+ str = str_new(0);
+ str_set(str,s);
+ str_cat(str,tokenbuf);
+ str_free(tmpstr);
+ str_cat(str,s);
}
- *d = '\0';
- str = str_new(0);
- str_set(str,s);
- str_cat(str,tokenbuf);
- str_free(tmpstr);
- str_cat(str,s);
break;
case ODEFINED:
prec = P_UNI;
}
tmpstr = walk(1+(type==OPRINT),level,ops[node+1].ival,&numarg,P_MIN);
if (!*tmpstr->str_ptr && lval_field) {
- t = (char*)(saw_OFS ? "$," : "' '");
+ const char *t = (saw_OFS ? "$," : "' '");
if (split_to_array) {
sprintf(tokenbuf,"join(%s,@Fld)",t);
str_cat(tmpstr,tokenbuf);
tmpstr = str_new(0);
if (!tmpstr->str_ptr || !*tmpstr->str_ptr) {
if (lval_field) {
- t = (char*)(saw_OFS ? "$," : "' '");
+ const char *t = (saw_OFS ? "$," : "' '");
if (split_to_array) {
sprintf(tokenbuf,"join(%s,@Fld)",t);
str_cat(tmpstr,tokenbuf);