Subversion Repositories SvarDOS

Rev

Rev 535 | Rev 990 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 535 Rev 536
Line 74... Line 74...
74
    if ((*s < '0') || (*s > '9')) {
74
    if ((*s < '0') || (*s > '9')) {
75
      i = 0xffff;
75
      i = 0xffff;
76
    } else {
76
    } else {
77
      atous(&i, s);
77
      atous(&i, s);
78
    }
78
    }
-
 
79
    /* move s to command */
79
    JMP_NEXT_ARG(s);
80
    JMP_NEXT_ARG(s);
80
    if (*s == 0) goto SYNTAX_ERR;
-
 
81
    /* is errorlevel matching? */
81
    /* is errorlevel matching? */
82
    if (i <= *rmod_exitcode) negflag ^= 1;
82
    if (i <= *rmod_exitcode) negflag ^= 1;
83
    if (negflag) goto EXEC_S_CMD;
83
    goto EXEC_S_CMD_IF_NEGFLAG_SET;
84
    return(CMD_OK);
-
 
85
  }
84
  }
86
 
85
 
87
  /* IF EXIST fname (or wildcard)
86
  /* IF EXIST fname (or wildcard)
88
   * TODO: checking for a file on an empty diskette drive should NOT lead bother
87
   * TODO: checking for a file on an empty diskette drive should NOT lead bother
89
   *       the user with the stupid 'retry, abort, fail' query! */
88
   *       the user with the stupid 'retry, abort, fail' query! */
Line 91... Line 90...
91
    struct DTA *dta = (void *)(0x80); /* default dta location */
90
    struct DTA *dta = (void *)(0x80); /* default dta location */
92
    JMP_NEXT_ARG(s);
91
    JMP_NEXT_ARG(s);
93
    /* copy filename to buffer */
92
    /* copy filename to buffer */
94
    for (i = 0; (s[i] != ' ') && (s[i] != 0); i++) p->BUFFER[i] = s[i];
93
    for (i = 0; (s[i] != ' ') && (s[i] != 0); i++) p->BUFFER[i] = s[i];
95
    p->BUFFER[i] = 0;
94
    p->BUFFER[i] = 0;
96
    /* move s to exec command */
95
    /* move s to command */
97
    JMP_NEXT_ARG(s);
96
    JMP_NEXT_ARG(s);
98
    if (*s == 0) goto SYNTAX_ERR;
97
    if (*s == 0) goto SYNTAX_ERR; /* check now to avoid moving the diskette drive if syntax bad anyway */
99
    /* does file exist? */
98
    /* does file exist? */
100
    if (findfirst(dta, p->BUFFER, 0) == 0) negflag ^= 1;
99
    if (findfirst(dta, p->BUFFER, 0) == 0) negflag ^= 1;
101
    if (negflag) goto EXEC_S_CMD;
100
    goto EXEC_S_CMD_IF_NEGFLAG_SET;
102
    return(CMD_OK);
-
 
103
  }
101
  }
104
 
102
 
-
 
103
  /* IF str1==str2 ? (and if that's not it, then it's a syntax error) */
-
 
104
  if (strstr(s, "==") != NULL) {
-
 
105
    /* copy first argument to BUFF, until first '=' or space */
-
 
106
    for (i = 0; (s[i] != '=') && (s[i] != ' '); i++) p->BUFFER[i] = s[i];
105
  /* TODO IF str1==str2 */
107
    /* 1st arg cannot be empty */
-
 
108
    if (i == 0) goto SYNTAX_ERR;
-
 
109
    /* terminate buff string and move s forward to the equality char (or space) */
-
 
110
    p->BUFFER[i++] = 0;
106
 
111
    s += i;
-
 
112
    while (*s == ' ') s++;
-
 
113
    /* if second char is not a '=' then syntax error (equality sign is not
-
 
114
     * allowed in first string) */
-
 
115
    if (*s != '=') goto SYNTAX_ERR;
-
 
116
    /* skip all trailing equality chars (MSDOS accepts many of them, ie all
-
 
117
     * these are fine: "dupa==dupa", "dupa===dupa", "dupa====dupa", etc) */
-
 
118
    while (*s == '=') s++;
-
 
119
    while (*s == ' ') s++; /* skip any leading spaces */
-
 
120
    /* move along until space or NULL terminator, checking equality */
-
 
121
    for (i = 0; (p->BUFFER[i] != 0) && (p->BUFFER[i] == s[i]); i++);
-
 
122
    if ((p->BUFFER[i] == 0) && (s[i] == ' ')) negflag ^= 1;
107
  SYNTAX_ERR:
123
    JMP_NEXT_ARG(s);
-
 
124
    goto EXEC_S_CMD_IF_NEGFLAG_SET;
-
 
125
  }
108
 
126
 
109
  /* invalid syntax */
127
  /* invalid syntax */
-
 
128
  SYNTAX_ERR:
110
  outputnl("Syntax error");
129
  outputnl("Syntax error");
111
 
-
 
112
  return(CMD_FAIL);
130
  return(CMD_FAIL);
113
 
131
 
114
  /* let's exec command (write it to start of cmdline and parse again) */
132
  /* let's exec command (write it to start of cmdline and parse again) */
115
  EXEC_S_CMD:
133
  EXEC_S_CMD_IF_NEGFLAG_SET:
-
 
134
  if (*s == 0) goto SYNTAX_ERR;
-
 
135
  if (negflag == 0) return(CMD_OK);
116
  memmove((void *)(p->cmdline), s, strlen(s) + 1);  /* cmdline and s share the same memory! */
136
  memmove((void *)(p->cmdline), s, strlen(s) + 1);  /* cmdline and s share the same memory! */
117
  return(CMD_CHANGED);
137
  return(CMD_CHANGED);
118
}
138
}