Deleted Added
full compact
expand.c (83676) expand.c (90111)
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

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

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
40#endif
41static const char rcsid[] =
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

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

34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38#if 0
39static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
40#endif
41static const char rcsid[] =
42 "$FreeBSD: head/bin/sh/expand.c 83676 2001-09-19 20:16:38Z tegge $";
42 "$FreeBSD: head/bin/sh/expand.c 90111 2002-02-02 06:50:57Z imp $";
43#endif /* not lint */
44
45#include <sys/types.h>
46#include <sys/time.h>
47#include <sys/stat.h>
48#include <errno.h>
49#include <dirent.h>
50#include <unistd.h>

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

90
91
92char *expdest; /* output of current string */
93struct nodelist *argbackq; /* list of back quote expressions */
94struct ifsregion ifsfirst; /* first struct in list of ifs regions */
95struct ifsregion *ifslastp; /* last struct in list */
96struct arglist exparg; /* holds expanded arg list */
97
43#endif /* not lint */
44
45#include <sys/types.h>
46#include <sys/time.h>
47#include <sys/stat.h>
48#include <errno.h>
49#include <dirent.h>
50#include <unistd.h>

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

90
91
92char *expdest; /* output of current string */
93struct nodelist *argbackq; /* list of back quote expressions */
94struct ifsregion ifsfirst; /* first struct in list of ifs regions */
95struct ifsregion *ifslastp; /* last struct in list */
96struct arglist exparg; /* holds expanded arg list */
97
98STATIC void argstr __P((char *, int));
99STATIC char *exptilde __P((char *, int));
100STATIC void expbackq __P((union node *, int, int));
101STATIC int subevalvar __P((char *, char *, int, int, int, int));
102STATIC char *evalvar __P((char *, int));
103STATIC int varisset __P((char *, int));
104STATIC void varvalue __P((char *, int, int));
105STATIC void recordregion __P((int, int, int));
106STATIC void removerecordregions __P((int));
107STATIC void ifsbreakup __P((char *, struct arglist *));
108STATIC void expandmeta __P((struct strlist *, int));
109STATIC void expmeta __P((char *, char *));
110STATIC void addfname __P((char *));
111STATIC struct strlist *expsort __P((struct strlist *));
112STATIC struct strlist *msort __P((struct strlist *, int));
113STATIC int pmatch __P((char *, char *, int));
114STATIC char *cvtnum __P((int, char *));
115STATIC int collate_range_cmp __P((int, int));
98STATIC void argstr(char *, int);
99STATIC char *exptilde(char *, int);
100STATIC void expbackq(union node *, int, int);
101STATIC int subevalvar(char *, char *, int, int, int, int);
102STATIC char *evalvar(char *, int);
103STATIC int varisset(char *, int);
104STATIC void varvalue(char *, int, int);
105STATIC void recordregion(int, int, int);
106STATIC void removerecordregions(int);
107STATIC void ifsbreakup(char *, struct arglist *);
108STATIC void expandmeta(struct strlist *, int);
109STATIC void expmeta(char *, char *);
110STATIC void addfname(char *);
111STATIC struct strlist *expsort(struct strlist *);
112STATIC struct strlist *msort(struct strlist *, int);
113STATIC int pmatch(char *, char *, int);
114STATIC char *cvtnum(int, char *);
115STATIC int collate_range_cmp(int, int);
116
116
117STATIC int collate_range_cmp (c1, c2)
118 int c1, c2;
117STATIC int
118collate_range_cmp (int c1, int c2)
119{
120 static char s1[2], s2[2];
121 int ret;
122
123 c1 &= UCHAR_MAX;
124 c2 &= UCHAR_MAX;
125 if (c1 == c2)
126 return (0);
127 s1[0] = c1;
128 s2[0] = c2;
129 if ((ret = strcoll(s1, s2)) != 0)
130 return (ret);
131 return (c1 - c2);
132}
133
134/*
135 * Expand shell variables and backquotes inside a here document.
119{
120 static char s1[2], s2[2];
121 int ret;
122
123 c1 &= UCHAR_MAX;
124 c2 &= UCHAR_MAX;
125 if (c1 == c2)
126 return (0);
127 s1[0] = c1;
128 s2[0] = c2;
129 if ((ret = strcoll(s1, s2)) != 0)
130 return (ret);
131 return (c1 - c2);
132}
133
134/*
135 * Expand shell variables and backquotes inside a here document.
136 * union node *arg the document
137 * int fd; where to write the expanded version
136 */
137
138void
138 */
139
140void
139expandhere(arg, fd)
140 union node *arg; /* the document */
141 int fd; /* where to write the expanded version */
142 {
141expandhere(union node *arg, int fd)
142{
143 herefd = fd;
144 expandarg(arg, (struct arglist *)NULL, 0);
145 xwrite(fd, stackblock(), expdest - stackblock());
146}
147
148
149/*
150 * Perform variable substitution and command substitution on an argument,
151 * placing the resulting list of arguments in arglist. If EXP_FULL is true,
152 * perform splitting and file name expansion. When arglist is NULL, perform
153 * here document expansion.
154 */
155
156void
143 herefd = fd;
144 expandarg(arg, (struct arglist *)NULL, 0);
145 xwrite(fd, stackblock(), expdest - stackblock());
146}
147
148
149/*
150 * Perform variable substitution and command substitution on an argument,
151 * placing the resulting list of arguments in arglist. If EXP_FULL is true,
152 * perform splitting and file name expansion. When arglist is NULL, perform
153 * here document expansion.
154 */
155
156void
157expandarg(arg, arglist, flag)
158 union node *arg;
159 struct arglist *arglist;
160 int flag;
157expandarg(union node *arg, struct arglist *arglist, int flag)
161{
162 struct strlist *sp;
163 char *p;
164
165 argbackq = arg->narg.backquote;
166 STARTSTACKSTR(expdest);
167 ifsfirst.next = NULL;
168 ifslastp = NULL;

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

208
209/*
210 * Perform variable and command substitution. If EXP_FULL is set, output CTLESC
211 * characters to allow for further processing. Otherwise treat
212 * $@ like $* since no splitting will be performed.
213 */
214
215STATIC void
158{
159 struct strlist *sp;
160 char *p;
161
162 argbackq = arg->narg.backquote;
163 STARTSTACKSTR(expdest);
164 ifsfirst.next = NULL;
165 ifslastp = NULL;

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

205
206/*
207 * Perform variable and command substitution. If EXP_FULL is set, output CTLESC
208 * characters to allow for further processing. Otherwise treat
209 * $@ like $* since no splitting will be performed.
210 */
211
212STATIC void
216argstr(p, flag)
217 char *p;
218 int flag;
213argstr(char *p, int flag)
219{
220 char c;
221 int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */
222 int firsteq = 1;
223
224 if (*p == '~' && (flag & (EXP_TILDE | EXP_VARTILDE)))
225 p = exptilde(p, flag);
226 for (;;) {

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

272 default:
273 STPUTC(c, expdest);
274 }
275 }
276breakloop:;
277}
278
279STATIC char *
214{
215 char c;
216 int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */
217 int firsteq = 1;
218
219 if (*p == '~' && (flag & (EXP_TILDE | EXP_VARTILDE)))
220 p = exptilde(p, flag);
221 for (;;) {

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

267 default:
268 STPUTC(c, expdest);
269 }
270 }
271breakloop:;
272}
273
274STATIC char *
280exptilde(p, flag)
281 char *p;
282 int flag;
275exptilde(char *p, int flag)
283{
284 char c, *startp = p;
285 struct passwd *pw;
286 char *home;
287 int quotes = flag & (EXP_FULL | EXP_CASE);
288
289 while ((c = *p) != '\0') {
290 switch(c) {

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

322 return (p);
323lose:
324 *p = c;
325 return (startp);
326}
327
328
329STATIC void
276{
277 char c, *startp = p;
278 struct passwd *pw;
279 char *home;
280 int quotes = flag & (EXP_FULL | EXP_CASE);
281
282 while ((c = *p) != '\0') {
283 switch(c) {

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

315 return (p);
316lose:
317 *p = c;
318 return (startp);
319}
320
321
322STATIC void
330removerecordregions(endoff)
331 int endoff;
323removerecordregions(int endoff)
332{
333 if (ifslastp == NULL)
334 return;
335
336 if (ifsfirst.endoff > endoff) {
337 while (ifsfirst.next != NULL) {
338 struct ifsregion *ifsp;
339 INTOFF;

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

366 ifslastp->endoff = endoff;
367}
368
369/*
370 * Expand arithmetic expression. Backup to start of expression,
371 * evaluate, place result in (backed up) result, adjust string position.
372 */
373void
324{
325 if (ifslastp == NULL)
326 return;
327
328 if (ifsfirst.endoff > endoff) {
329 while (ifsfirst.next != NULL) {
330 struct ifsregion *ifsp;
331 INTOFF;

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

358 ifslastp->endoff = endoff;
359}
360
361/*
362 * Expand arithmetic expression. Backup to start of expression,
363 * evaluate, place result in (backed up) result, adjust string position.
364 */
365void
374expari(flag)
375 int flag;
366expari(int flag)
376{
377 char *p, *start;
378 int result;
379 int begoff;
380 int quotes = flag & (EXP_FULL | EXP_CASE);
381 int quoted;
382
383

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

426}
427
428
429/*
430 * Expand stuff in backwards quotes.
431 */
432
433STATIC void
367{
368 char *p, *start;
369 int result;
370 int begoff;
371 int quotes = flag & (EXP_FULL | EXP_CASE);
372 int quoted;
373
374

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

417}
418
419
420/*
421 * Expand stuff in backwards quotes.
422 */
423
424STATIC void
434expbackq(cmd, quoted, flag)
435 union node *cmd;
436 int quoted;
437 int flag;
425expbackq(union node *cmd, int quoted, int flag)
438{
439 struct backcmd in;
440 int i;
441 char buf[128];
442 char *p;
443 char *dest = expdest;
444 struct ifsregion saveifs, *savelastp;
445 struct nodelist *saveargbackq;

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

502 stackblock() + startloc));
503 expdest = dest;
504 INTON;
505}
506
507
508
509STATIC int
426{
427 struct backcmd in;
428 int i;
429 char buf[128];
430 char *p;
431 char *dest = expdest;
432 struct ifsregion saveifs, *savelastp;
433 struct nodelist *saveargbackq;

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

490 stackblock() + startloc));
491 expdest = dest;
492 INTON;
493}
494
495
496
497STATIC int
510subevalvar(p, str, strloc, subtype, startloc, varflags)
511 char *p;
512 char *str;
513 int strloc;
514 int subtype;
515 int startloc;
516 int varflags;
498subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
499 int varflags)
517{
518 char *startp;
519 char *loc = NULL;
520 char *q;
521 int c = 0;
522 int saveherefd = herefd;
523 struct nodelist *saveargbackq = argbackq;
524 int amount;

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

633
634
635/*
636 * Expand a variable, and return a pointer to the next character in the
637 * input string.
638 */
639
640STATIC char *
500{
501 char *startp;
502 char *loc = NULL;
503 char *q;
504 int c = 0;
505 int saveherefd = herefd;
506 struct nodelist *saveargbackq = argbackq;
507 int amount;

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

616
617
618/*
619 * Expand a variable, and return a pointer to the next character in the
620 * input string.
621 */
622
623STATIC char *
641evalvar(p, flag)
642 char *p;
643 int flag;
624evalvar(char *p, int flag)
644{
645 int subtype;
646 int varflags;
647 char *var;
648 char *val;
649 int patloc;
650 int c;
651 int set;

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

799
800
801
802/*
803 * Test whether a specialized variable is set.
804 */
805
806STATIC int
625{
626 int subtype;
627 int varflags;
628 char *var;
629 char *val;
630 int patloc;
631 int c;
632 int set;

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

780
781
782
783/*
784 * Test whether a specialized variable is set.
785 */
786
787STATIC int
807varisset(name, nulok)
808 char *name;
809 int nulok;
788varisset(char *name, int nulok)
810{
811
812 if (*name == '!')
813 return backgndpid != -1;
814 else if (*name == '@' || *name == '*') {
815 if (*shellparam.p == NULL)
816 return 0;
817

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

843
844
845
846/*
847 * Add the value of a specialized variable to the stack string.
848 */
849
850STATIC void
789{
790
791 if (*name == '!')
792 return backgndpid != -1;
793 else if (*name == '@' || *name == '*') {
794 if (*shellparam.p == NULL)
795 return 0;
796

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

822
823
824
825/*
826 * Add the value of a specialized variable to the stack string.
827 */
828
829STATIC void
851varvalue(name, quoted, allow_split)
852 char *name;
853 int quoted;
854 int allow_split;
830varvalue(char *name, int quoted, int allow_split)
855{
856 int num;
857 char *p;
858 int i;
859 extern int oexitstatus;
860 char sep;
861 char **ap;
862 char const *syntax;

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

937
938
939/*
940 * Record the the fact that we have to scan this region of the
941 * string for IFS characters.
942 */
943
944STATIC void
831{
832 int num;
833 char *p;
834 int i;
835 extern int oexitstatus;
836 char sep;
837 char **ap;
838 char const *syntax;

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

913
914
915/*
916 * Record the the fact that we have to scan this region of the
917 * string for IFS characters.
918 */
919
920STATIC void
945recordregion(start, end, nulonly)
946 int start;
947 int end;
948 int nulonly;
921recordregion(int start, int end, int nulonly)
949{
950 struct ifsregion *ifsp;
951
952 if (ifslastp == NULL) {
953 ifsp = &ifsfirst;
954 } else {
955 ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion));
956 ifslastp->next = ifsp;

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

965
966
967/*
968 * Break the argument string into pieces based upon IFS and add the
969 * strings to the argument list. The regions of the string to be
970 * searched for IFS characters have been stored by recordregion.
971 */
972STATIC void
922{
923 struct ifsregion *ifsp;
924
925 if (ifslastp == NULL) {
926 ifsp = &ifsfirst;
927 } else {
928 ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion));
929 ifslastp->next = ifsp;

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

938
939
940/*
941 * Break the argument string into pieces based upon IFS and add the
942 * strings to the argument list. The regions of the string to be
943 * searched for IFS characters have been stored by recordregion.
944 */
945STATIC void
973ifsbreakup(string, arglist)
974 char *string;
975 struct arglist *arglist;
976 {
946ifsbreakup(char *string, struct arglist *arglist)
947{
977 struct ifsregion *ifsp;
978 struct strlist *sp;
979 char *start;
980 char *p;
981 char *q;
982 char *ifs;
983 int ifsspc;
984 int nulonly;

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

1063 * Expand shell metacharacters. At this point, the only control characters
1064 * should be escapes. The results are stored in the list exparg.
1065 */
1066
1067char *expdir;
1068
1069
1070STATIC void
948 struct ifsregion *ifsp;
949 struct strlist *sp;
950 char *start;
951 char *p;
952 char *q;
953 char *ifs;
954 int ifsspc;
955 int nulonly;

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

1034 * Expand shell metacharacters. At this point, the only control characters
1035 * should be escapes. The results are stored in the list exparg.
1036 */
1037
1038char *expdir;
1039
1040
1041STATIC void
1071expandmeta(str, flag)
1072 struct strlist *str;
1073 int flag __unused;
1042expandmeta(struct strlist *str, int flag __unused)
1074{
1075 char *p;
1076 struct strlist **savelastp;
1077 struct strlist *sp;
1078 char c;
1079 /* TODO - EXP_REDIR */
1080
1081 while (str) {

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

1119}
1120
1121
1122/*
1123 * Do metacharacter (i.e. *, ?, [...]) expansion.
1124 */
1125
1126STATIC void
1043{
1044 char *p;
1045 struct strlist **savelastp;
1046 struct strlist *sp;
1047 char c;
1048 /* TODO - EXP_REDIR */
1049
1050 while (str) {

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

1088}
1089
1090
1091/*
1092 * Do metacharacter (i.e. *, ?, [...]) expansion.
1093 */
1094
1095STATIC void
1127expmeta(enddir, name)
1128 char *enddir;
1129 char *name;
1130 {
1096expmeta(char *enddir, char *name)
1097{
1131 char *p;
1132 char *q;
1133 char *start;
1134 char *endname;
1135 int metaflag;
1136 struct stat statb;
1137 DIR *dirp;
1138 struct dirent *dp;

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

1250}
1251
1252
1253/*
1254 * Add a file name to the list.
1255 */
1256
1257STATIC void
1098 char *p;
1099 char *q;
1100 char *start;
1101 char *endname;
1102 int metaflag;
1103 struct stat statb;
1104 DIR *dirp;
1105 struct dirent *dp;

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

1217}
1218
1219
1220/*
1221 * Add a file name to the list.
1222 */
1223
1224STATIC void
1258addfname(name)
1259 char *name;
1260 {
1225addfname(char *name)
1226{
1261 char *p;
1262 struct strlist *sp;
1263
1264 p = stalloc(strlen(name) + 1);
1265 scopy(name, p);
1266 sp = (struct strlist *)stalloc(sizeof *sp);
1267 sp->text = p;
1268 *exparg.lastp = sp;
1269 exparg.lastp = &sp->next;
1270}
1271
1272
1273/*
1274 * Sort the results of file name expansion. It calculates the number of
1275 * strings to sort and then calls msort (short for merge sort) to do the
1276 * work.
1277 */
1278
1279STATIC struct strlist *
1227 char *p;
1228 struct strlist *sp;
1229
1230 p = stalloc(strlen(name) + 1);
1231 scopy(name, p);
1232 sp = (struct strlist *)stalloc(sizeof *sp);
1233 sp->text = p;
1234 *exparg.lastp = sp;
1235 exparg.lastp = &sp->next;
1236}
1237
1238
1239/*
1240 * Sort the results of file name expansion. It calculates the number of
1241 * strings to sort and then calls msort (short for merge sort) to do the
1242 * work.
1243 */
1244
1245STATIC struct strlist *
1280expsort(str)
1281 struct strlist *str;
1282 {
1246expsort(struct strlist *str)
1247{
1283 int len;
1284 struct strlist *sp;
1285
1286 len = 0;
1287 for (sp = str ; sp ; sp = sp->next)
1288 len++;
1289 return msort(str, len);
1290}
1291
1292
1293STATIC struct strlist *
1248 int len;
1249 struct strlist *sp;
1250
1251 len = 0;
1252 for (sp = str ; sp ; sp = sp->next)
1253 len++;
1254 return msort(str, len);
1255}
1256
1257
1258STATIC struct strlist *
1294msort(list, len)
1295 struct strlist *list;
1296 int len;
1259msort(struct strlist *list, int len)
1297{
1298 struct strlist *p, *q = NULL;
1299 struct strlist **lpp;
1300 int half;
1301 int n;
1302
1303 if (len <= 1)
1304 return list;

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

1334
1335
1336
1337/*
1338 * Returns true if the pattern matches the string.
1339 */
1340
1341int
1260{
1261 struct strlist *p, *q = NULL;
1262 struct strlist **lpp;
1263 int half;
1264 int n;
1265
1266 if (len <= 1)
1267 return list;

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

1297
1298
1299
1300/*
1301 * Returns true if the pattern matches the string.
1302 */
1303
1304int
1342patmatch(pattern, string, squoted)
1343 char *pattern;
1344 char *string;
1345 int squoted; /* string might have quote chars */
1346 {
1305patmatch(char *pattern, char *string, int squoted)
1306{
1347#ifdef notdef
1348 if (pattern[0] == '!' && pattern[1] == '!')
1349 return 1 - pmatch(pattern + 2, string);
1350 else
1351#endif
1352 return pmatch(pattern, string, squoted);
1353}
1354
1355
1356STATIC int
1307#ifdef notdef
1308 if (pattern[0] == '!' && pattern[1] == '!')
1309 return 1 - pmatch(pattern + 2, string);
1310 else
1311#endif
1312 return pmatch(pattern, string, squoted);
1313}
1314
1315
1316STATIC int
1357pmatch(pattern, string, squoted)
1358 char *pattern;
1359 char *string;
1360 int squoted;
1361 {
1317pmatch(char *pattern, char *string, int squoted)
1318{
1362 char *p, *q;
1363 char c;
1364
1365 p = pattern;
1366 q = string;
1367 for (;;) {
1368 switch (c = *p++) {
1369 case '\0':

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

1477
1478
1479
1480/*
1481 * Remove any CTLESC characters from a string.
1482 */
1483
1484void
1319 char *p, *q;
1320 char c;
1321
1322 p = pattern;
1323 q = string;
1324 for (;;) {
1325 switch (c = *p++) {
1326 case '\0':

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

1434
1435
1436
1437/*
1438 * Remove any CTLESC characters from a string.
1439 */
1440
1441void
1485rmescapes(str)
1486 char *str;
1442rmescapes(char *str)
1487{
1488 char *p, *q;
1489
1490 p = str;
1491 while (*p != CTLESC && *p != CTLQUOTEMARK) {
1492 if (*p++ == '\0')
1493 return;
1494 }

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

1507
1508
1509
1510/*
1511 * See if a pattern matches in a case statement.
1512 */
1513
1514int
1443{
1444 char *p, *q;
1445
1446 p = str;
1447 while (*p != CTLESC && *p != CTLQUOTEMARK) {
1448 if (*p++ == '\0')
1449 return;
1450 }

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

1463
1464
1465
1466/*
1467 * See if a pattern matches in a case statement.
1468 */
1469
1470int
1515casematch(pattern, val)
1516 union node *pattern;
1517 char *val;
1518 {
1471casematch(union node *pattern, char *val)
1472{
1519 struct stackmark smark;
1520 int result;
1521 char *p;
1522
1523 setstackmark(&smark);
1524 argbackq = pattern->narg.backquote;
1525 STARTSTACKSTR(expdest);
1526 ifslastp = NULL;

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

1532 return result;
1533}
1534
1535/*
1536 * Our own itoa().
1537 */
1538
1539STATIC char *
1473 struct stackmark smark;
1474 int result;
1475 char *p;
1476
1477 setstackmark(&smark);
1478 argbackq = pattern->narg.backquote;
1479 STARTSTACKSTR(expdest);
1480 ifslastp = NULL;

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

1486 return result;
1487}
1488
1489/*
1490 * Our own itoa().
1491 */
1492
1493STATIC char *
1540cvtnum(num, buf)
1541 int num;
1542 char *buf;
1543 {
1494cvtnum(int num, char *buf)
1495{
1544 char temp[32];
1545 int neg = num < 0;
1546 char *p = temp + 31;
1547
1548 temp[31] = '\0';
1549
1550 do {
1551 *--p = num % 10 + '0';
1552 } while ((num /= 10) != 0);
1553
1554 if (neg)
1555 *--p = '-';
1556
1557 while (*p)
1558 STPUTC(*p++, buf);
1559 return buf;
1560}
1496 char temp[32];
1497 int neg = num < 0;
1498 char *p = temp + 31;
1499
1500 temp[31] = '\0';
1501
1502 do {
1503 *--p = num % 10 + '0';
1504 } while ((num /= 10) != 0);
1505
1506 if (neg)
1507 *--p = '-';
1508
1509 while (*p)
1510 STPUTC(*p++, buf);
1511 return buf;
1512}