Fri Oct 29 17:04:48 2010 UTC ()
Initialized flag field in struct alias (Fixed PR/43281)


(stacktic)
diff -r1.12 -r1.13 src/bin/sh/alias.c

cvs diff -r1.12 -r1.13 src/bin/sh/alias.c (expand / switch to unified diff)

--- src/bin/sh/alias.c 2003/08/07 09:05:29 1.12
+++ src/bin/sh/alias.c 2010/10/29 17:04:48 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: alias.c,v 1.12 2003/08/07 09:05:29 agc Exp $ */ 1/* $NetBSD: alias.c,v 1.13 2010/10/29 17:04:48 stacktic Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Kenneth Almquist. 8 * Kenneth Almquist.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36#ifndef lint 36#ifndef lint
37#if 0 37#if 0
38static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95"; 38static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
39#else 39#else
40__RCSID("$NetBSD: alias.c,v 1.12 2003/08/07 09:05:29 agc Exp $"); 40__RCSID("$NetBSD: alias.c,v 1.13 2010/10/29 17:04:48 stacktic Exp $");
41#endif 41#endif
42#endif /* not lint */ 42#endif /* not lint */
43 43
44#include <stdlib.h> 44#include <stdlib.h>
45#include "shell.h" 45#include "shell.h"
46#include "input.h" 46#include "input.h"
47#include "output.h" 47#include "output.h"
48#include "error.h" 48#include "error.h"
49#include "memalloc.h" 49#include "memalloc.h"
50#include "mystring.h" 50#include "mystring.h"
51#include "alias.h" 51#include "alias.h"
52#include "options.h" /* XXX for argptr (should remove?) */ 52#include "options.h" /* XXX for argptr (should remove?) */
53#include "var.h" 53#include "var.h"
@@ -70,26 +70,27 @@ setalias(char *name, char *val) @@ -70,26 +70,27 @@ setalias(char *name, char *val)
70 for (ap = *app; ap; ap = ap->next) { 70 for (ap = *app; ap; ap = ap->next) {
71 if (equal(name, ap->name)) { 71 if (equal(name, ap->name)) {
72 INTOFF; 72 INTOFF;
73 ckfree(ap->val); 73 ckfree(ap->val);
74 ap->val = savestr(val); 74 ap->val = savestr(val);
75 INTON; 75 INTON;
76 return; 76 return;
77 } 77 }
78 } 78 }
79 /* not found */ 79 /* not found */
80 INTOFF; 80 INTOFF;
81 ap = ckmalloc(sizeof (struct alias)); 81 ap = ckmalloc(sizeof (struct alias));
82 ap->name = savestr(name); 82 ap->name = savestr(name);
 83 ap->flag = 0;
83 /* 84 /*
84 * XXX - HACK: in order that the parser will not finish reading the 85 * XXX - HACK: in order that the parser will not finish reading the
85 * alias value off the input before processing the next alias, we 86 * alias value off the input before processing the next alias, we
86 * dummy up an extra space at the end of the alias. This is a crock 87 * dummy up an extra space at the end of the alias. This is a crock
87 * and should be re-thought. The idea (if you feel inclined to help) 88 * and should be re-thought. The idea (if you feel inclined to help)
88 * is to avoid alias recursions. The mechanism used is: when 89 * is to avoid alias recursions. The mechanism used is: when
89 * expanding an alias, the value of the alias is pushed back on the 90 * expanding an alias, the value of the alias is pushed back on the
90 * input as a string and a pointer to the alias is stored with the 91 * input as a string and a pointer to the alias is stored with the
91 * string. The alias is marked as being in use. When the input 92 * string. The alias is marked as being in use. When the input
92 * routine finishes reading the string, it markes the alias not 93 * routine finishes reading the string, it markes the alias not
93 * in use. The problem is synchronization with the parser. Since 94 * in use. The problem is synchronization with the parser. Since
94 * it reads ahead, the alias is marked not in use before the 95 * it reads ahead, the alias is marked not in use before the
95 * resulting token(s) is next checked for further alias sub. The 96 * resulting token(s) is next checked for further alias sub. The