var.c (217847) | var.c (218306) |
---|---|
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 217847 2011-01-25 20:56:18Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/var.c 218306 2011-02-04 22:47:55Z jilles $"); |
40 41#include <unistd.h> 42#include <stdlib.h> 43#include <paths.h> 44 45/* 46 * Shell variables. 47 */ --- 108 unchanged lines hidden (view full) --- 156 } 157 } 158} 159#endif 160 161 162/* 163 * This routine initializes the builtin variables. It is called when the | 40 41#include <unistd.h> 42#include <stdlib.h> 43#include <paths.h> 44 45/* 46 * Shell variables. 47 */ --- 108 unchanged lines hidden (view full) --- 156 } 157 } 158} 159#endif 160 161 162/* 163 * This routine initializes the builtin variables. It is called when the |
164 * shell is initialized and again when a shell procedure is spawned. | 164 * shell is initialized. |
165 */ 166 167void 168initvar(void) 169{ 170 char ppid[20]; 171 const struct varinit *ip; 172 struct var *vp; --- 364 unchanged lines hidden (view full) --- 537 if (vp->flags & VEXPORT) 538 *ep++ = vp->text; 539 } 540 *ep = NULL; 541 return env; 542} 543 544 | 165 */ 166 167void 168initvar(void) 169{ 170 char ppid[20]; 171 const struct varinit *ip; 172 struct var *vp; --- 364 unchanged lines hidden (view full) --- 537 if (vp->flags & VEXPORT) 538 *ep++ = vp->text; 539 } 540 *ep = NULL; 541 return env; 542} 543 544 |
545/* 546 * Called when a shell procedure is invoked to clear out nonexported 547 * variables. It is also necessary to reallocate variables of with 548 * VSTACK set since these are currently allocated on the stack. 549 */ 550 551MKINIT void shprocvar(void); 552 553#ifdef mkinit 554SHELLPROC { 555 shprocvar(); 556} 557#endif 558 559void 560shprocvar(void) 561{ 562 struct var **vpp; 563 struct var *vp, **prev; 564 565 for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { 566 for (prev = vpp ; (vp = *prev) != NULL ; ) { 567 if ((vp->flags & VEXPORT) == 0) { 568 *prev = vp->next; 569 if ((vp->flags & VTEXTFIXED) == 0) 570 ckfree(vp->text); 571 if ((vp->flags & VSTRFIXED) == 0) 572 ckfree(vp); 573 } else { 574 if (vp->flags & VSTACK) { 575 vp->text = savestr(vp->text); 576 vp->flags &=~ VSTACK; 577 } 578 prev = &vp->next; 579 } 580 } 581 } 582 initvar(); 583} 584 585 | |
586static int 587var_compare(const void *a, const void *b) 588{ 589 const char *const *sa, *const *sb; 590 591 sa = a; 592 sb = b; 593 /* --- 353 unchanged lines hidden --- | 545static int 546var_compare(const void *a, const void *b) 547{ 548 const char *const *sa, *const *sb; 549 550 sa = a; 551 sb = b; 552 /* --- 353 unchanged lines hidden --- |