* $Log: a2py.c,v $
*/
-#if defined(OS2) || defined(WIN32)
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
#if defined(WIN32)
#include <io.h>
#endif
+#if defined(NETWARE)
+#include "../netware/clibstuf.h"
+#endif
#include "../patchlevel.h"
#endif
#include "util.h"
int oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5);
STR *walk(int useval, int level, register int node, int *numericptr, int minprec);
-#if defined(OS2) || defined(WIN32)
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
static void usage(void);
static void
int i;
STR *tmpstr;
+ #ifdef NETWARE
+ fnInitGpfGlobals(); /* For importing the CLIB calls in place of Watcom calls */
+ #endif /* NETWARE */
+
myname = argv[0];
linestr = str_new(80);
str = str_new(0); /* first used for -I flags */
for (argc--,argv++; argc; argc--,argv++) {
if (argv[0][0] != '-' || !argv[0][1])
break;
- reswitch:
switch (argv[0][1]) {
#ifdef DEBUGGING
case 'D':
case 0:
break;
default:
-#if defined(OS2) || defined(WIN32)
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
fprintf(stderr, "Unrecognized switch: %s\n",argv[0]);
usage();
#else
/* open script */
if (argv[0] == Nullch) {
-#if defined(OS2) || defined(WIN32)
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
if ( isatty(fileno(stdin)) )
usage();
#endif
"The operation I've selected may be wrong for the operand types.\n");
}
exit(0);
+ /* by ANSI specs return is needed. This also shuts up VC++ and his warnings */
+ return(0);
}
#define RETURN(retval) return (bufptr = s,retval)
retry:
#if YYDEBUG
- if (yydebug)
+ if (yydebug) {
if (strchr(s,'\n'))
fprintf(stderr,"Tokener at %s",s);
else
fprintf(stderr,"Tokener at %s\n",s);
+ }
#endif
switch (*s) {
default:
s++;
XTERM('}');
case '}':
- for (d = s + 1; isspace(*d); d++) ;
+ for (d = s + 1; isSPACE(*d); d++) ;
if (!*d)
s = d - 1;
*s = 127;
#define SNARFWORD \
d = tokenbuf; \
- while (isalpha(*s) || isdigit(*s) || *s == '_') \
+ while (isALPHA(*s) || isDIGIT(*s) || *s == '_') \
*d++ = *s++; \
*d = '\0'; \
d = tokenbuf; \
ID("0");
}
do_split = TRUE;
- if (isdigit(*s)) {
- for (d = s; isdigit(*s); s++) ;
+ if (isDIGIT(*s)) {
+ for (d = s; isDIGIT(*s); s++) ;
yylval = string(d,s-d);
tmp = atoi(d);
if (tmp > maxfld)
XTERM(FUN1);
}
if (strEQ(d,"chdir"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"crypt"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"chop"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"chmod"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"chown"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'd': case 'D':
SNARFWORD;
if (strEQ(d,"delete"))
XTERM(DELETE);
if (strEQ(d,"die"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'e': case 'E':
SNARFWORD;
XTERM(FUN1);
}
if (strEQ(d,"elsif"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"eq"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"eval"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"eof"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"each"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"exec"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'f': case 'F':
SNARFWORD;
if (strEQ(d,"FS")) {
saw_FS++;
if (saw_FS == 1 && in_begin) {
- for (d = s; *d && isspace(*d); d++) ;
+ for (d = s; *d && isSPACE(*d); d++) ;
if (*d == '=') {
- for (d++; *d && isspace(*d); d++) ;
+ for (d++; *d && isSPACE(*d); d++) ;
if (*d == '"' && d[2] == '"')
const_FS = d[1];
}
if (strEQ(d,"FILENAME"))
d = "ARGV";
if (strEQ(d,"foreach"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"format"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"fork"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"fh"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'g': case 'G':
SNARFWORD;
if (strEQ(d,"gsub"))
XTERM(GSUB);
if (strEQ(d,"ge"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"gt"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"goto"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"gmtime"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'h': case 'H':
SNARFWORD;
if (strEQ(d,"hex"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'i': case 'I':
SNARFWORD;
case 'j': case 'J':
SNARFWORD;
if (strEQ(d,"join"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'k': case 'K':
SNARFWORD;
if (strEQ(d,"keys"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"kill"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'l': case 'L':
SNARFWORD;
XTERM(FUN1);
}
if (strEQ(d,"last"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"local"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"lt"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"le"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"locatime"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"link"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'm': case 'M':
SNARFWORD;
XTERM(MATCH);
}
if (strEQ(d,"m"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'n': case 'N':
SNARFWORD;
XTERM(NEXT);
}
if (strEQ(d,"ne"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'o': case 'O':
SNARFWORD;
d = "#";
}
if (strEQ(d,"open"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"ord"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"oct"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'p': case 'P':
SNARFWORD;
XTERM(PRINTF);
}
if (strEQ(d,"push"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"pop"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'q': case 'Q':
SNARFWORD;
if (strEQ(d,"return"))
XTERM(RET);
if (strEQ(d,"reset"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"redo"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"rename"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 's': case 'S':
SNARFWORD;
XTERM(FUN1);
}
if (strEQ(d,"s"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"shift"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"select"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"seek"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"stat"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"study"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"sleep"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"symlink"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"sort"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 't': case 'T':
SNARFWORD;
if (strEQ(d,"tr"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"tell"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"time"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"times"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'u': case 'U':
SNARFWORD;
if (strEQ(d,"until"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"unless"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"umask"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"unshift"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"unlink"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"utime"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'v': case 'V':
SNARFWORD;
if (strEQ(d,"values"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'w': case 'W':
SNARFWORD;
if (strEQ(d,"while"))
XTERM(WHILE);
if (strEQ(d,"write"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
else if (strEQ(d,"wait"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'x': case 'X':
SNARFWORD;
if (strEQ(d,"x"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'y': case 'Y':
SNARFWORD;
if (strEQ(d,"y"))
- *d = toupper(*d);
+ *d = toUPPER(*d);
ID(d);
case 'z': case 'Z':
SNARFWORD;
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': case '0' : case '.':
d = tokenbuf;
- while (isdigit(*s)) {
+ while (isDIGIT(*s)) {
*d++ = *s++;
}
if (*s == '.') {
- if (isdigit(s[1])) {
+ if (isDIGIT(s[1])) {
*d++ = *s++;
- while (isdigit(*s)) {
+ while (isDIGIT(*s)) {
*d++ = *s++;
}
}
*d++ = *s++;
if (*s == '+' || *s == '-')
*d++ = *s++;
- while (isdigit(*s))
+ while (isDIGIT(*s))
*d++ = *s++;
}
*d = '\0';
s++;
}
else if (*s == '\n') {
- for (t = s+1; isspace(*t & 127); t++) ;
+ for (t = s+1; isSPACE(*t & 127); t++) ;
t--;
- while (isspace(*t & 127) && *t != '\n') t--;
+ while (isSPACE(*t & 127) && *t != '\n') t--;
if (*t == '\n' && t-s > 1) {
if (s[-1] == '{')
s--;
if (pos > 78) { /* split a long line? */
*d-- = '\0';
newpos = 0;
- for (t = tokenbuf; isspace(*t & 127); t++) {
+ for (t = tokenbuf; isSPACE(*t & 127); t++) {
if (*t == '\t')
newpos += 8;
else
{
int type;
STR *str;
- int numargs;
+ int numargs = 0;
if (!arg)
return prevargs;