Home | History | Annotate | Download | only in src

Lines Matching refs:tp

63 	struct tbl *tp = NULL;
150 tp = findcom(ap[0], FC_BI|FC_FUNC);
166 if (iosetup(*iowp, tp) < 0) {
172 if (tp && tp->type == CSHELL &&
173 (tp->flag & SPEC_BI))
182 rv = comexec(t, tp, (const char **)ap, flags, xerrok);
498 comexec(struct op *t, struct tbl * volatile tp, const char **ap,
541 while (tp && tp->type == CSHELL) {
544 if (tp->val.f == c_builtin) {
547 tp = NULL;
550 if ((tp = findcom(cp, FC_BI)) == NULL)
553 } else if (tp->val.f == c_exec) {
558 } else if (tp->val.f == c_command) {
594 } else if (tp->val.f == c_cat) {
613 } else if (tp->val.f == c_trap) {
619 tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC));
626 if (keepasn_ok && (!ap[0] || (tp && (tp->flag & KEEPASN))))
632 if (keepasn_ok && tp && tp->type == CFUNC &&
633 !(tp
666 } else if (!tp) {
672 tp = findcom(cp, fcflags);
675 switch (tp->type) {
679 rv = call_builtin(tp, (const char **)ap, null);
680 if (!keepasn_ok && tp->val.f == c_shift) {
692 if (!(tp->flag & ISSET)) {
695 if (!tp->u.fpath) {
696 rv = (tp->u2.errnov == ENOENT) ? 127 : 126;
699 cstrerror(tp->u2.errnov));
702 if (include(tp->u.fpath, 0, NULL, false) < 0) {
706 tp->u.fpath, cstrerror(rv));
713 "function not defined by", tp->u.fpath);
717 tp = ftp;
725 if (tp->flag & FKSH)
737 if (tp->flag & FKSH) {
744 Flag(FXTRACE) |= tp->flag & TRACE ? 1 : 0;
746 old_inuse = tp->flag & FINUSE;
747 tp->flag |= FINUSE;
751 execute(tp->val.t, flags & XERROK, NULL);
756 tp->flag = (tp->flag & ~FINUSE) | old_inuse;
762 if ((tp->flag & (FDELETE|FINUSE)) == FDELETE) {
763 if (tp->flag & ALLOC) {
764 tp->flag &= ~ALLOC;
765 tfree(tp->val.t, tp->areap);
767 tp->flag = 0;
792 if (!(tp->flag&ISSET)) {
793 if (tp->u2.errnov == ENOENT) {
799 cstrerror(tp->u2.errnov));
807 tp->val.s, KSH_RETURN_ERROR);
825 texec.str = tp->val.s;
839 scriptexec(struct op *tp, const char **ap)
856 *tp->args-- = tp->str;
859 if ((fd = open(tp->str, O_RDONLY)) >= 0) {
910 *tp->args-- = (char *)cp;
924 errorf("%s: not executable: magic %04X", tp->str, fd);
927 args.ro = tp->args;
934 errorf("%s: %s: %s", tp->str, sh, cstrerror(errno));
940 struct tbl *tp;
942 tp = ktsearch(&builtins, *wp, hash(*wp));
943 return (call_builtin(tp, wp, "shcomexec"));
954 struct tbl *tp = NULL;
957 tp = ktsearch(&l->funs, name, h);
958 if (tp)
961 tp = ktenter(&l->funs, name, h);
962 tp->flag = DEFINED;
963 tp->type = CFUNC;
964 tp->val.t = NULL;
968 return (tp);
979 struct tbl *tp;
986 if ((tp = ktsearch(&aliases, name, nhash)))
987 ktdelete(tp);
991 tp = findfunc(name, nhash, true);
993 mkssert(tp != NULL);
995 if (tp->flag & ISSET)
1001 if (tp->flag & FINUSE) {
1002 tp->name[0] = '\0';
1004 tp->flag &= ~DEFINED;
1005 tp->flag |= FDELETE;
1010 if (tp->flag & ALLOC) {
1011 tp->flag &= ~(ISSET|ALLOC);
1012 tfree(tp->val.t, tp->areap);
1017 ktdelete(tp);
1021 tp->val.t = tcopy(t->left, tp->areap);
1022 tp->flag |= (ISSET|ALLOC);
1024 tp->flag |= FKSH;
1035 struct tbl *tp;
1053 tp = ktenter(&builtins, name, hash(name));
1054 tp->flag = DEFINED | flag;
1055 tp->type = CSHELL;
1056 tp->val.f = func;
1070 struct tbl *tp = NULL, *tbi;
1089 tp = tbi;
1090 if (!tp && (flags & FC_FUNC)) {
1091 tp = findfunc(name, h, false);
1092 if (tp && !(tp->flag & ISSET)) {
1094 tp->u.fpath = NULL;
1095 tp->u2.errnov = ENOENT;
1097 tp->u.fpath = search_path(name, fpath, R_OK,
1098 &tp->u2.errnov);
1101 if (!tp && (flags & FC_REGBI) && tbi && (tbi->flag & REG_BI))
1102 tp = tbi;
1103 if (!tp && (flags & FC_UNREGBI) && tbi)
1104 tp = tbi;
1105 if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
1106 tp = ktsearch(&taliases, name, h);
1107 if (tp && (tp->flag & ISSET) &&
1108 ksh_access(tp->val.s, X_OK) != 0) {
1109 if (tp->flag & ALLOC) {
1110 tp->flag &= ~ALLOC;
1111 afree(tp->val.s, APERM);
1113 tp->flag &= ~ISSET;
1118 if ((!tp || (tp->type == CTALIAS && !(tp->flag&ISSET))) &&
1120 if (!tp) {
1122 tp = ktenter(&taliases, name, h);
1123 tp->type = CTALIAS;
1125 tp = &temp;
1126 tp->type = CEXEC;
1129 tp->flag = DEFINED;
1133 X_OK, &tp->u2.errnov);
1135 strdupx(tp->val.s, npath.ro, APERM);
1138 tp->flag |= ISSET|ALLOC;
1142 &tp->u2.errnov)) != NULL) {
1149 tp = &temp;
1150 tp->type = CFUNC;
1152 tp->flag = DEFINED;
1153 tp->u.fpath = npath.ro;
1156 return (tp);
1166 struct tbl *tp;
1169 for (ktwalk(&ts, &taliases); (tp = ktnext(&ts)) != NULL; )
1170 if ((tp->flag&ISSET) && (all || tp->val.s[0] != '/')) {
1171 if (tp->flag&ALLOC) {
1172 tp->flag &= ~(ALLOC|ISSET);
1173 afree(tp->val.s, APERM);
1175 tp->flag &= ~ISSET;
1260 call_builtin(struct tbl *tp, const char **wp, const char *where)
1264 if (!tp)
1267 builtin_flag = tp->flag;
1271 rv = (*tp->val.f)(wp);
1283 iosetup(struct ioword *iop, struct tbl *tp)
1414 else if (tp && tp->type == CSHELL && tp->val.f == c_exec) {