Deleted Added
full compact
parser.c (200956) parser.c (201053)
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 200956 2009-12-24 18:41:14Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/parser.c 201053 2009-12-27 18:04:05Z jilles $");
40
41#include <stdlib.h>
42#include <unistd.h>
43
44#include "shell.h"
45#include "parser.h"
46#include "nodes.h"
47#include "expand.h" /* defines rmescapes() */

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

108STATIC void parsefname(void);
109STATIC void parseheredoc(void);
110STATIC int peektoken(void);
111STATIC int readtoken(void);
112STATIC int xxreadtoken(void);
113STATIC int readtoken1(int, char const *, char *, int);
114STATIC int noexpand(char *);
115STATIC void synexpect(int);
40
41#include <stdlib.h>
42#include <unistd.h>
43
44#include "shell.h"
45#include "parser.h"
46#include "nodes.h"
47#include "expand.h" /* defines rmescapes() */

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

108STATIC void parsefname(void);
109STATIC void parseheredoc(void);
110STATIC int peektoken(void);
111STATIC int readtoken(void);
112STATIC int xxreadtoken(void);
113STATIC int readtoken1(int, char const *, char *, int);
114STATIC int noexpand(char *);
115STATIC void synexpect(int);
116STATIC void synerror(char *);
116STATIC void synerror(const char *);
117STATIC void setprompt(int);
118
119
120/*
121 * Read and parse a command. Returns NEOF on end of file. (NULL is a
122 * valid parse tree indicating a blank line.)
123 */
124

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

1542 } else {
1543 fmtstr(msg, 64, "%s unexpected", tokname[lasttoken]);
1544 }
1545 synerror(msg);
1546}
1547
1548
1549STATIC void
117STATIC void setprompt(int);
118
119
120/*
121 * Read and parse a command. Returns NEOF on end of file. (NULL is a
122 * valid parse tree indicating a blank line.)
123 */
124

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

1542 } else {
1543 fmtstr(msg, 64, "%s unexpected", tokname[lasttoken]);
1544 }
1545 synerror(msg);
1546}
1547
1548
1549STATIC void
1550synerror(char *msg)
1550synerror(const char *msg)
1551{
1552 if (commandname)
1553 outfmt(&errout, "%s: %d: ", commandname, startlinno);
1554 outfmt(&errout, "Syntax error: %s\n", msg);
1555 error((char *)NULL);
1556}
1557
1558STATIC void

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

1574 * should be added here.
1575 */
1576char *
1577getprompt(void *unused __unused)
1578{
1579 static char ps[PROMPTLEN];
1580 char *fmt;
1581 int i, j, trim;
1551{
1552 if (commandname)
1553 outfmt(&errout, "%s: %d: ", commandname, startlinno);
1554 outfmt(&errout, "Syntax error: %s\n", msg);
1555 error((char *)NULL);
1556}
1557
1558STATIC void

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

1574 * should be added here.
1575 */
1576char *
1577getprompt(void *unused __unused)
1578{
1579 static char ps[PROMPTLEN];
1580 char *fmt;
1581 int i, j, trim;
1582 static char internal_error[] = "<internal prompt error>";
1582
1583 /*
1584 * Select prompt format.
1585 */
1586 switch (whichprompt) {
1587 case 0:
1583
1584 /*
1585 * Select prompt format.
1586 */
1587 switch (whichprompt) {
1588 case 0:
1588 fmt = "";
1589 fmt = nullstr;
1589 break;
1590 case 1:
1591 fmt = ps1val();
1592 break;
1593 case 2:
1594 fmt = ps2val();
1595 break;
1596 default:
1590 break;
1591 case 1:
1592 fmt = ps1val();
1593 break;
1594 case 2:
1595 fmt = ps2val();
1596 break;
1597 default:
1597 return "<internal prompt error>";
1598 return internal_error;
1598 }
1599
1600 /*
1601 * Format prompt string.
1602 */
1603 for (i = 0; (i < 127) && (*fmt != '\0'); i++, fmt++)
1604 if (*fmt == '\\')
1605 switch (*++fmt) {

--- 70 unchanged lines hidden ---
1599 }
1600
1601 /*
1602 * Format prompt string.
1603 */
1604 for (i = 0; (i < 127) && (*fmt != '\0'); i++, fmt++)
1605 if (*fmt == '\\')
1606 switch (*++fmt) {

--- 70 unchanged lines hidden ---