parser.c (245382) | parser.c (248980) |
---|---|
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[] = "@(#)parser.c 8.7 (Berkeley) 5/16/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[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/parser.c 245382 2013-01-13 19:26:33Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/parser.c 248980 2013-04-01 17:18:22Z jilles $"); |
40 41#include <stdlib.h> 42#include <unistd.h> 43#include <stdio.h> 44 45#include "shell.h" 46#include "parser.h" 47#include "nodes.h" --- 66 unchanged lines hidden (view full) --- 114static union node *command(void); 115static union node *simplecmd(union node **, union node *); 116static union node *makename(void); 117static void parsefname(void); 118static void parseheredoc(void); 119static int peektoken(void); 120static int readtoken(void); 121static int xxreadtoken(void); | 40 41#include <stdlib.h> 42#include <unistd.h> 43#include <stdio.h> 44 45#include "shell.h" 46#include "parser.h" 47#include "nodes.h" --- 66 unchanged lines hidden (view full) --- 114static union node *command(void); 115static union node *simplecmd(union node **, union node *); 116static union node *makename(void); 117static void parsefname(void); 118static void parseheredoc(void); 119static int peektoken(void); 120static int readtoken(void); 121static int xxreadtoken(void); |
122static int readtoken1(int, char const *, char *, int); | 122static int readtoken1(int, const char *, const char *, int); |
123static int noexpand(char *); 124static void synexpect(int) __dead2; 125static void synerror(const char *) __dead2; 126static void setprompt(int); 127 128 129static void * 130parser_temp_alloc(size_t len) --- 847 unchanged lines hidden (view full) --- 978parsebackq(char *out, struct nodelist **pbqlist, 979 int oldstyle, int dblquote, int quoted) 980{ 981 struct nodelist **nlpp; 982 union node *n; 983 char *volatile str; 984 struct jmploc jmploc; 985 struct jmploc *const savehandler = handler; | 123static int noexpand(char *); 124static void synexpect(int) __dead2; 125static void synerror(const char *) __dead2; 126static void setprompt(int); 127 128 129static void * 130parser_temp_alloc(size_t len) --- 847 unchanged lines hidden (view full) --- 978parsebackq(char *out, struct nodelist **pbqlist, 979 int oldstyle, int dblquote, int quoted) 980{ 981 struct nodelist **nlpp; 982 union node *n; 983 char *volatile str; 984 struct jmploc jmploc; 985 struct jmploc *const savehandler = handler; |
986 int savelen; | 986 size_t savelen; |
987 int saveprompt; 988 const int bq_startlinno = plinno; 989 char *volatile ostr = NULL; 990 struct parsefile *const savetopfile = getcurrentfile(); 991 struct heredoc *const saveheredoclist = heredoclist; 992 struct heredoc *here; 993 994 str = NULL; --- 300 unchanged lines hidden (view full) --- 1295 */ 1296 1297#define CHECKEND() {goto checkend; checkend_return:;} 1298#define PARSEREDIR() {goto parseredir; parseredir_return:;} 1299#define PARSESUB() {goto parsesub; parsesub_return:;} 1300#define PARSEARITH() {goto parsearith; parsearith_return:;} 1301 1302static int | 987 int saveprompt; 988 const int bq_startlinno = plinno; 989 char *volatile ostr = NULL; 990 struct parsefile *const savetopfile = getcurrentfile(); 991 struct heredoc *const saveheredoclist = heredoclist; 992 struct heredoc *here; 993 994 str = NULL; --- 300 unchanged lines hidden (view full) --- 1295 */ 1296 1297#define CHECKEND() {goto checkend; checkend_return:;} 1298#define PARSEREDIR() {goto parseredir; parseredir_return:;} 1299#define PARSESUB() {goto parsesub; parsesub_return:;} 1300#define PARSEARITH() {goto parsearith; parsearith_return:;} 1301 1302static int |
1303readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs) | 1303readtoken1(int firstc, char const *initialsyntax, const char *eofmark, 1304 int striptabs) |
1304{ 1305 int c = firstc; 1306 char *out; 1307 int len; 1308 char line[EOFMARKLEN + 1]; 1309 struct nodelist *bqlist; 1310 int quotef; 1311 int newvarnest; --- 204 unchanged lines hidden (view full) --- 1516checkend: { 1517 if (eofmark) { 1518 if (striptabs) { 1519 while (c == '\t') 1520 c = pgetc(); 1521 } 1522 if (c == *eofmark) { 1523 if (pfgets(line, sizeof line) != NULL) { | 1305{ 1306 int c = firstc; 1307 char *out; 1308 int len; 1309 char line[EOFMARKLEN + 1]; 1310 struct nodelist *bqlist; 1311 int quotef; 1312 int newvarnest; --- 204 unchanged lines hidden (view full) --- 1517checkend: { 1518 if (eofmark) { 1519 if (striptabs) { 1520 while (c == '\t') 1521 c = pgetc(); 1522 } 1523 if (c == *eofmark) { 1524 if (pfgets(line, sizeof line) != NULL) { |
1524 char *p, *q; | 1525 const char *p, *q; |
1525 1526 p = line; 1527 for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); 1528 if ((*p == '\0' || *p == '\n') && *q == '\0') { 1529 c = PEOF; 1530 if (*p == '\n') { 1531 plinno++; 1532 needprompt = doprompt; --- 500 unchanged lines hidden (view full) --- 2033 else 2034 ps[i] = *fmt; 2035 ps[i] = '\0'; 2036 return (ps); 2037} 2038 2039 2040const char * | 1526 1527 p = line; 1528 for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); 1529 if ((*p == '\0' || *p == '\n') && *q == '\0') { 1530 c = PEOF; 1531 if (*p == '\n') { 1532 plinno++; 1533 needprompt = doprompt; --- 500 unchanged lines hidden (view full) --- 2034 else 2035 ps[i] = *fmt; 2036 ps[i] = '\0'; 2037 return (ps); 2038} 2039 2040 2041const char * |
2041expandstr(char *ps) | 2042expandstr(const char *ps) |
2042{ 2043 union node n; 2044 struct jmploc jmploc; 2045 struct jmploc *const savehandler = handler; 2046 const int saveprompt = doprompt; 2047 struct parsefile *const savetopfile = getcurrentfile(); 2048 struct parser_temp *const saveparser_temp = parser_temp; 2049 const char *result = NULL; --- 32 unchanged lines hidden --- | 2043{ 2044 union node n; 2045 struct jmploc jmploc; 2046 struct jmploc *const savehandler = handler; 2047 const int saveprompt = doprompt; 2048 struct parsefile *const savetopfile = getcurrentfile(); 2049 struct parser_temp *const saveparser_temp = parser_temp; 2050 const char *result = NULL; --- 32 unchanged lines hidden --- |