• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/ksh-23/ksh/src/lib/libcmd/

Lines Matching refs:np

141 #define numeric(np)	((np)->type&T_NUM)
185 static int getnode(State_t* state, Node_t *np)
207 np->num = (ep = strpbrk(cp, ep)) ? (ep - cp + 1) : 0;
208 np->type = T_NUM;
217 np->num = strlen(cp);
218 np->type = T_NUM;
225 if (!(np->str = *state->arglist++))
227 np->type = T_STR;
260 np->type = T_STR;
261 np->str = sp;
268 tok = expr_or(state, np);
274 np->type = T_STR;
275 np->str = cp;
278 np->num = strtol(np->str,&ep,10);
280 np->type |= T_NUM;
294 static int expr_cond(State_t* state, Node_t *np)
296 register int tok = getnode(state, np);
306 if (np->type&T_STR)
307 cp = np->str;
309 sfsprintf(cp=state->buf,sizeof(state->buf),"%d",np->num);
310 np->num = 0;
311 np->type = T_NUM;
318 np->type = T_STR;
321 np->str = cp + match[1].rm_so;
322 np->str[match[1].rm_eo - match[1].rm_so] = 0;
323 np->num = strtol(np->str,&cp,10);
324 if (cp!=np->str && *cp==0)
325 np->type |= T_NUM;
328 np->str = "";
331 np->num = match[0].rm_eo - match[0].rm_so;
337 np->str = "";
338 np->type = T_STR;
345 static int expr_mult(State_t* state, Node_t *np)
347 register int tok = expr_cond(state, np);
354 if (!numeric(np) || !numeric(&rp))
361 np->num *= rp.num;
364 np->num /= rp.num;
367 np->num %= rp.num;
369 np->type = T_NUM;
374 static int expr_add(State_t* state, Node_t *np)
376 register int tok = expr_mult(state, np);
383 if (!numeric(np) || !numeric(&rp))
386 np->num -= rp.num;
388 np->num += rp.num;
389 np->type = T_NUM;
394 static int expr_cmp(State_t* state, Node_t *np)
396 register int tok = expr_add(state, np);
405 if (numeric(&rp) && numeric(np))
409 if (np->type&T_STR)
410 left = np->str;
412 sfsprintf(left=buff1,sizeof(buff1),"%d",np->num);
421 np->num = streq(left,right);
424 np->num = (strcoll(left,right)>0);
427 np->num = (strcoll(left,right)<0);
430 np->num = (strcoll(left,right)>=0);
433 np->num = (strcoll(left,right)<=0);
436 np->num = !streq(left,right);
439 np->num = (np->num==rp.num);
442 np->num = (np->num>rp.num);
445 np->num = (np->num<rp.num);
448 np->num = (np->num>=rp.num);
451 np->num = (np->num<=rp.num);
454 np->num = (np->num!=rp.num);
457 np->type = T_NUM;
462 static int expr_and(State_t* state, Node_t *np)
464 register int tok = expr_cmp(state, np);
471 np->num = 0;
472 np->type=T_NUM;
478 static int expr_or(State_t* state, Node_t *np)
480 register int tok = expr_and(state, np);
485 if ((numeric(np) && np->num==0) || *np->str==0)
486 *np = rp;