X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fa2py.c;h=286f7cc106a35ff0b16c2662c7eb969b19a420ff;hb=17bede5aef4d3e8265e4332c36f8bace338be70f;hp=1c7fd0ac96e82bb02ecba133f0a0abbfc23f4bfb;hpb=4cec2b33f0aa04d807b9b31c6b4212fe462cd7d4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/a2py.c b/x2p/a2py.c index 1c7fd0a..286f7cc 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -1,12 +1,10 @@ -/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $ +/* a2py.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, * 2000, 2001, 2002, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: a2py.c,v $ */ #if defined(OS2) || defined(WIN32) || defined(NETWARE) @@ -20,8 +18,8 @@ #endif #include "util.h" -char *filename; -char *myname; +const char *filename; +const char *myname; int checkers = 0; @@ -61,7 +59,7 @@ usage() #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; @@ -119,7 +117,7 @@ main(register int argc, register char **argv, register char **env) /* open script */ - if (argv[0] == Nullch) { + if (argv[0] == NULL) { #if defined(OS2) || defined(WIN32) || defined(NETWARE) if ( isatty(fileno(stdin)) ) usage(); @@ -128,14 +126,13 @@ main(register int argc, register char **argv, register char **env) } filename = savestr(argv[0]); - filename = savestr(argv[0]); if (strEQ(filename,"-")) argv[0] = ""; if (!*argv[0]) rsfp = stdin; else rsfp = fopen(argv[0],"r"); - if (rsfp == Nullfp) + if (rsfp == NULL) fatal("Awk script \"%s\" doesn't seem to exist.\n",filename); /* init tokener */ @@ -256,10 +253,10 @@ yylex(void) if (!rsfp) RETURN(0); line++; - if ((s = str_gets(linestr, rsfp)) == Nullch) { + if ((s = str_gets(linestr, rsfp)) == NULL) { if (rsfp != stdin) fclose(rsfp); - rsfp = Nullfp; + rsfp = NULL; s = str_get(linestr); RETURN(0); } @@ -431,7 +428,7 @@ yylex(void) } for (d = s; isALPHA(*s) || isDIGIT(*s) || *s == '_'; ) s++; - split_to_array = set_array_base = TRUE; + split_to_array = TRUE; if (d != s) { yylval = string(d,s-d); @@ -467,8 +464,6 @@ yylex(void) case 'a': case 'A': SNARFWORD; - if (strEQ(d,"ARGC")) - set_array_base = TRUE; if (strEQ(d,"ARGV")) { yylval=numary(string("ARGV",0)); XOP(VAR); @@ -564,7 +559,7 @@ yylex(void) 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")) @@ -601,7 +596,6 @@ yylex(void) if (strEQ(d,"in")) XTERM(IN); if (strEQ(d,"index")) { - set_array_base = TRUE; XTERM(INDEX); } if (strEQ(d,"int")) { @@ -647,7 +641,6 @@ yylex(void) case 'm': case 'M': SNARFWORD; if (strEQ(d,"match")) { - set_array_base = TRUE; XTERM(MATCH); } if (strEQ(d,"m")) @@ -656,7 +649,7 @@ yylex(void) case 'n': case 'N': SNARFWORD; if (strEQ(d,"NF")) - do_chop = do_split = split_to_array = set_array_base = TRUE; + do_chop = do_split = split_to_array = TRUE; if (strEQ(d,"next")) { saw_line_op = TRUE; XTERM(NEXT); @@ -668,14 +661,14 @@ yylex(void) 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); @@ -703,8 +696,8 @@ yylex(void) case 'r': case 'R': SNARFWORD; if (strEQ(d,"RS")) { - d = "/"; saw_RS = TRUE; + ID("/"); } if (strEQ(d,"rand")) { yylval = ORAND; @@ -722,11 +715,9 @@ yylex(void) case 's': case 'S': SNARFWORD; if (strEQ(d,"split")) { - set_array_base = TRUE; XOP(SPLIT); } if (strEQ(d,"substr")) { - set_array_base = TRUE; XTERM(SUBSTR); } if (strEQ(d,"sub")) @@ -745,7 +736,7 @@ yylex(void) XTERM(FUN1); } if (strEQ(d,"SUBSEP")) { - d = ";"; + ID(";"); } if (strEQ(d,"sin")) { yylval = OSIN; @@ -880,7 +871,7 @@ scanpat(register char *s) } void -yyerror(char *s) +yyerror(const char *s) { fprintf(stderr,"%s in file %s at line %d\n", s,filename,line); @@ -923,7 +914,7 @@ scannum(register char *s) } int -string(char *ptr, int len) +string(const char *ptr, int len) { int retval = mop; @@ -1207,7 +1198,6 @@ numary(int arg) str_cat(key,"[]"); hstore(symtab,key->str_ptr,str_make("1")); str_free(key); - set_array_base = TRUE; return arg; }