expand.c (198454) | expand.c (200956) |
---|---|
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[] = "@(#)expand.c 8.5 (Berkeley) 5/15/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[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/expand.c 198454 2009-10-24 21:20:04Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/expand.c 200956 2009-12-24 18:41:14Z jilles $"); |
40 41#include <sys/types.h> 42#include <sys/time.h> 43#include <sys/stat.h> 44#include <errno.h> 45#include <dirent.h> 46#include <unistd.h> 47#include <pwd.h> --- 54 unchanged lines hidden (view full) --- 102STATIC void recordregion(int, int, int); 103STATIC void removerecordregions(int); 104STATIC void ifsbreakup(char *, struct arglist *); 105STATIC void expandmeta(struct strlist *, int); 106STATIC void expmeta(char *, char *); 107STATIC void addfname(char *); 108STATIC struct strlist *expsort(struct strlist *); 109STATIC struct strlist *msort(struct strlist *, int); | 40 41#include <sys/types.h> 42#include <sys/time.h> 43#include <sys/stat.h> 44#include <errno.h> 45#include <dirent.h> 46#include <unistd.h> 47#include <pwd.h> --- 54 unchanged lines hidden (view full) --- 102STATIC void recordregion(int, int, int); 103STATIC void removerecordregions(int); 104STATIC void ifsbreakup(char *, struct arglist *); 105STATIC void expandmeta(struct strlist *, int); 106STATIC void expmeta(char *, char *); 107STATIC void addfname(char *); 108STATIC struct strlist *expsort(struct strlist *); 109STATIC struct strlist *msort(struct strlist *, int); |
110STATIC int pmatch(char *, char *, int); | 110STATIC int pmatch(const char *, const char *, int); |
111STATIC char *cvtnum(int, char *); 112STATIC int collate_range_cmp(int, int); 113 114STATIC int 115collate_range_cmp(int c1, int c2) 116{ 117 static char s1[2], s2[2]; 118 --- 1214 unchanged lines hidden (view full) --- 1333 1334 1335 1336/* 1337 * Returns true if the pattern matches the string. 1338 */ 1339 1340int | 111STATIC char *cvtnum(int, char *); 112STATIC int collate_range_cmp(int, int); 113 114STATIC int 115collate_range_cmp(int c1, int c2) 116{ 117 static char s1[2], s2[2]; 118 --- 1214 unchanged lines hidden (view full) --- 1333 1334 1335 1336/* 1337 * Returns true if the pattern matches the string. 1338 */ 1339 1340int |
1341patmatch(char *pattern, char *string, int squoted) | 1341patmatch(const char *pattern, const char *string, int squoted) |
1342{ 1343#ifdef notdef 1344 if (pattern[0] == '!' && pattern[1] == '!') 1345 return 1 - pmatch(pattern + 2, string); 1346 else 1347#endif 1348 return pmatch(pattern, string, squoted); 1349} 1350 1351 1352STATIC int | 1342{ 1343#ifdef notdef 1344 if (pattern[0] == '!' && pattern[1] == '!') 1345 return 1 - pmatch(pattern + 2, string); 1346 else 1347#endif 1348 return pmatch(pattern, string, squoted); 1349} 1350 1351 1352STATIC int |
1353pmatch(char *pattern, char *string, int squoted) | 1353pmatch(const char *pattern, const char *string, int squoted) |
1354{ | 1354{ |
1355 char *p, *q; | 1355 const char *p, *q; |
1356 char c; 1357 1358 p = pattern; 1359 q = string; 1360 for (;;) { 1361 switch (c = *p++) { 1362 case '\0': 1363 goto breakloop; --- 31 unchanged lines hidden (view full) --- 1395 do { 1396 if (pmatch(p, q, squoted)) 1397 return 1; 1398 if (squoted && *q == CTLESC) 1399 q++; 1400 } while (*q++ != '\0'); 1401 return 0; 1402 case '[': { | 1356 char c; 1357 1358 p = pattern; 1359 q = string; 1360 for (;;) { 1361 switch (c = *p++) { 1362 case '\0': 1363 goto breakloop; --- 31 unchanged lines hidden (view full) --- 1395 do { 1396 if (pmatch(p, q, squoted)) 1397 return 1; 1398 if (squoted && *q == CTLESC) 1399 q++; 1400 } while (*q++ != '\0'); 1401 return 0; 1402 case '[': { |
1403 char *endp; | 1403 const char *endp; |
1404 int invert, found; 1405 char chr; 1406 1407 endp = p; 1408 if (*endp == '!' || *endp == '^') 1409 endp++; 1410 for (;;) { 1411 while (*endp == CTLQUOTEMARK) --- 87 unchanged lines hidden (view full) --- 1499 1500 1501 1502/* 1503 * See if a pattern matches in a case statement. 1504 */ 1505 1506int | 1404 int invert, found; 1405 char chr; 1406 1407 endp = p; 1408 if (*endp == '!' || *endp == '^') 1409 endp++; 1410 for (;;) { 1411 while (*endp == CTLQUOTEMARK) --- 87 unchanged lines hidden (view full) --- 1499 1500 1501 1502/* 1503 * See if a pattern matches in a case statement. 1504 */ 1505 1506int |
1507casematch(union node *pattern, char *val) | 1507casematch(union node *pattern, const char *val) |
1508{ 1509 struct stackmark smark; 1510 int result; 1511 char *p; 1512 1513 setstackmark(&smark); 1514 argbackq = pattern->narg.backquote; 1515 STARTSTACKSTR(expdest); --- 54 unchanged lines hidden --- | 1508{ 1509 struct stackmark smark; 1510 int result; 1511 char *p; 1512 1513 setstackmark(&smark); 1514 argbackq = pattern->narg.backquote; 1515 STARTSTACKSTR(expdest); --- 54 unchanged lines hidden --- |