Deleted Added
full compact
var.c (293392) var.c (293635)
1/*-
2 * Copyright (c) 1991, 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[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1991, 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[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/sh/var.c 293392 2016-01-07 23:13:20Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/var.c 293635 2016-01-10 16:31:28Z jilles $");
40
41#include <unistd.h>
42#include <stdlib.h>
43#include <paths.h>
44
45/*
46 * Shell variables.
47 */

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

786 * Called after a function returns.
787 */
788
789void
790poplocalvars(void)
791{
792 struct localvar *lvp;
793 struct var *vp;
40
41#include <unistd.h>
42#include <stdlib.h>
43#include <paths.h>
44
45/*
46 * Shell variables.
47 */

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

786 * Called after a function returns.
787 */
788
789void
790poplocalvars(void)
791{
792 struct localvar *lvp;
793 struct var *vp;
794 int islocalevar;
794
795 INTOFF;
796 while ((lvp = localvars) != NULL) {
797 localvars = lvp->next;
798 vp = lvp->vp;
799 if (vp == NULL) { /* $- saved */
800 memcpy(optval, lvp->text, sizeof optval);
801 ckfree(lvp->text);
802 optschanged();
803 } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
804 (void)unsetvar(vp->text);
805 } else {
795
796 INTOFF;
797 while ((lvp = localvars) != NULL) {
798 localvars = lvp->next;
799 vp = lvp->vp;
800 if (vp == NULL) { /* $- saved */
801 memcpy(optval, lvp->text, sizeof optval);
802 ckfree(lvp->text);
803 optschanged();
804 } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
805 (void)unsetvar(vp->text);
806 } else {
807 islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
808 localevar(lvp->text);
806 if ((vp->flags & VTEXTFIXED) == 0)
807 ckfree(vp->text);
808 vp->flags = lvp->flags;
809 vp->text = lvp->text;
809 if ((vp->flags & VTEXTFIXED) == 0)
810 ckfree(vp->text);
811 vp->flags = lvp->flags;
812 vp->text = lvp->text;
813 if (vp->func)
814 (*vp->func)(vp->text + vp->name_len + 1);
815 if (islocalevar) {
816 change_env(vp->text, vp->flags & VEXPORT &&
817 (vp->flags & VUNSET) == 0);
818 setlocale(LC_ALL, "");
819 updatecharset();
820 }
810 }
811 ckfree(lvp);
812 }
813 INTON;
814}
815
816
817int

--- 137 unchanged lines hidden ---
821 }
822 ckfree(lvp);
823 }
824 INTON;
825}
826
827
828int

--- 137 unchanged lines hidden ---