Deleted Added
full compact
eval.c (268927) eval.c (272575)
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/sh/eval.c 268927 2014-07-20 20:29:09Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/eval.c 272575 2014-10-05 21:51:36Z jilles $");
40
41#include <paths.h>
42#include <signal.h>
43#include <stdlib.h>
44#include <unistd.h>
45#include <sys/resource.h>
46#include <sys/wait.h> /* For WIFSIGNALED(status) */
47#include <errno.h>

--- 263 unchanged lines hidden (view full) ---

311static void
312evalloop(union node *n, int flags)
313{
314 int status;
315
316 loopnest++;
317 status = 0;
318 for (;;) {
40
41#include <paths.h>
42#include <signal.h>
43#include <stdlib.h>
44#include <unistd.h>
45#include <sys/resource.h>
46#include <sys/wait.h> /* For WIFSIGNALED(status) */
47#include <errno.h>

--- 263 unchanged lines hidden (view full) ---

311static void
312evalloop(union node *n, int flags)
313{
314 int status;
315
316 loopnest++;
317 status = 0;
318 for (;;) {
319 evaltree(n->nbinary.ch1, EV_TESTED);
319 if (!evalskip)
320 evaltree(n->nbinary.ch1, EV_TESTED);
320 if (evalskip) {
321 if (evalskip) {
321skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
322 if (evalskip == SKIPCONT && --skipcount <= 0) {
322 evalskip = 0;
323 continue;
324 }
325 if (evalskip == SKIPBREAK && --skipcount <= 0)
326 evalskip = 0;
327 if (evalskip == SKIPRETURN)
328 status = exitstatus;
329 break;
330 }
331 if (n->type == NWHILE) {
332 if (exitstatus != 0)
333 break;
334 } else {
335 if (exitstatus == 0)
336 break;
337 }
338 evaltree(n->nbinary.ch2, flags);
339 status = exitstatus;
323 evalskip = 0;
324 continue;
325 }
326 if (evalskip == SKIPBREAK && --skipcount <= 0)
327 evalskip = 0;
328 if (evalskip == SKIPRETURN)
329 status = exitstatus;
330 break;
331 }
332 if (n->type == NWHILE) {
333 if (exitstatus != 0)
334 break;
335 } else {
336 if (exitstatus == 0)
337 break;
338 }
339 evaltree(n->nbinary.ch2, flags);
340 status = exitstatus;
340 if (evalskip)
341 goto skipping;
342 }
343 loopnest--;
344 exitstatus = status;
345}
346
347
348
349static void

--- 293 unchanged lines hidden (view full) ---

643{
644 int pip[2];
645 struct job *jp;
646 struct stackmark smark;
647 struct jmploc jmploc;
648 struct jmploc *savehandler;
649 struct localvar *savelocalvars;
650
341 }
342 loopnest--;
343 exitstatus = status;
344}
345
346
347
348static void

--- 293 unchanged lines hidden (view full) ---

642{
643 int pip[2];
644 struct job *jp;
645 struct stackmark smark;
646 struct jmploc jmploc;
647 struct jmploc *savehandler;
648 struct localvar *savelocalvars;
649
651 setstackmark(&smark);
652 result->fd = -1;
653 result->buf = NULL;
654 result->nleft = 0;
655 result->jp = NULL;
656 if (n == NULL) {
657 exitstatus = 0;
650 result->fd = -1;
651 result->buf = NULL;
652 result->nleft = 0;
653 result->jp = NULL;
654 if (n == NULL) {
655 exitstatus = 0;
658 goto out;
656 return;
659 }
657 }
658 setstackmark(&smark);
660 exitstatus = oexitstatus;
661 if (is_valid_fast_cmdsubst(n)) {
662 savelocalvars = localvars;
663 localvars = NULL;
664 forcelocal++;
665 savehandler = handler;
666 if (setjmp(jmploc.loc)) {
667 if (exception == EXERROR || exception == EXEXEC)

--- 25 unchanged lines hidden (view full) ---

693 close(pip[1]);
694 }
695 evaltree(n, EV_EXIT);
696 }
697 close(pip[1]);
698 result->fd = pip[0];
699 result->jp = jp;
700 }
659 exitstatus = oexitstatus;
660 if (is_valid_fast_cmdsubst(n)) {
661 savelocalvars = localvars;
662 localvars = NULL;
663 forcelocal++;
664 savehandler = handler;
665 if (setjmp(jmploc.loc)) {
666 if (exception == EXERROR || exception == EXEXEC)

--- 25 unchanged lines hidden (view full) ---

692 close(pip[1]);
693 }
694 evaltree(n, EV_EXIT);
695 }
696 close(pip[1]);
697 result->fd = pip[0];
698 result->jp = jp;
699 }
701out:
702 popstackmark(&smark);
703 TRACE(("evalbackcmd done: fd=%d buf=%p nleft=%d jp=%p\n",
704 result->fd, result->buf, result->nleft, result->jp));
705}
706
707static int
708mustexpandto(const char *argtext, const char *mask)
709{

--- 680 unchanged lines hidden ---
700 popstackmark(&smark);
701 TRACE(("evalbackcmd done: fd=%d buf=%p nleft=%d jp=%p\n",
702 result->fd, result->buf, result->nleft, result->jp));
703}
704
705static int
706mustexpandto(const char *argtext, const char *mask)
707{

--- 680 unchanged lines hidden ---