SCCS-vsn: bin/csh/dol.c 5.15
-static char sccsid[] = "@(#)dol.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)dol.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
* words within this expansion, the count of remaining words, and the
* information about any : modifier which is being applied.
*/
* words within this expansion, the count of remaining words, and the
* information about any : modifier which is being applied.
*/
+#define MAXWLEN (BUFSIZ - 4)
+#define MAXMOD MAXWLEN /* This cannot overflow */
static Char *dolp; /* Remaining chars from this word */
static Char **dolnxt; /* Further words */
static int dolcnt; /* Count of further words */
static Char *dolp; /* Remaining chars from this word */
static Char **dolnxt; /* Further words */
static int dolcnt; /* Count of further words */
-static Char dolmod; /* : modifier character */
+static Char dolmod[MAXMOD]; /* : modifier character */
+static int dolnmod; /* Number of modifiers */
static int dolmcnt; /* :gx -> 10000, else 1 */
static void Dfix2 __P((Char **));
static int dolmcnt; /* :gx -> 10000, else 1 */
static void Dfix2 __P((Char **));
-#define MAXWLEN (BUFSIZ - 4)
/*
* Pack up more characters in this word
*/
/*
* Pack up more characters in this word
*/
char tnp;
Char wbuf[BUFSIZ];
char tnp;
Char wbuf[BUFSIZ];
c = sc = DgetC(0);
if (c == '{')
c = DgetC(0); /* sc is { to take } later */
c = sc = DgetC(0);
if (c == '{')
c = DgetC(0); /* sc is { to take } later */
* it. The actual function of the 'q' causes filename expansion not to
* be done on the interpolated value.
*/
* it. The actual function of the 'q' causes filename expansion not to
* be done on the interpolated value.
*/
+ dolmod[dolnmod++] = 'q';
dolmcnt = 10000;
setDolp(wbuf);
goto eatbrac;
dolmcnt = 10000;
setDolp(wbuf);
goto eatbrac;
c = DgetC(0);
if (c == ':') {
c = DgetC(0);
if (c == ':') {
- c = DgetC(0), dolmcnt = 1;
- if (c == 'g')
- c = DgetC(0), dolmcnt = 10000;
- if (!any("htrqxe", c))
- stderror(ERR_BADMOD, c);
- dolmod = c;
- if (c == 'q')
- dolmcnt = 10000;
+ do {
+ c = DgetC(0), dolmcnt = 1;
+ if (c == 'g')
+ c = DgetC(0), dolmcnt = 10000;
+ if (!any("htrqxe", c))
+ stderror(ERR_BADMOD, c);
+ dolmod[dolnmod++] = c;
+ if (c == 'q')
+ dolmcnt = 10000;
+ }
+ while ((c = DgetC(0)) == ':');
+ unDredc(c);
register Char *cp;
{
register Char *dp;
register Char *cp;
{
register Char *dp;
- if (dolmod == 0 || dolmcnt == 0) {
+ if (dolnmod == 0 || dolmcnt == 0) {
- dp = domod(cp, dolmod);
+ dp = cp = Strsave(cp);
+ for (i = 0; i < dolnmod; i++)
+ if ((dp = domod(cp, dolmod[i]))) {
+ xfree((ptr_t) cp);
+ cp = dp;
+ dolmcnt--;
+ }
+ else {
+ dp = cp;
+ break;
+ }
+
addla(dp);
xfree((ptr_t) dp);
}
addla(dp);
xfree((ptr_t) dp);
}
dolp = STRNULL;
if (seterr)
stderror(ERR_OLD);
dolp = STRNULL;
if (seterr)
stderror(ERR_OLD);