#include "spice.h"
#include "misc.h"
#include "cpdefs.h"
#include <sys/types.h>
Go to the source code of this file.
Definition at line 157 of file glob.c.
167 for (s =
string; *s; s++) {
177 fprintf(
cp_err,
"Error: missing }.\n");
187 for (wl = words; wl; wl = wl->
wl_next)
188 for (w = nwl; w; w = w->
wl_next) {
199 for (wl = words; wl; wl = wl->
wl_next)
struct wordlist * wl_next
static wordlist * brac2()
Definition at line 211 of file glob.c.
222 (void)
strcpy(buf,
string);
226 if ((*s ==
cp_ccurl) && (nb == 0)) {
237 fprintf(
cp_err,
"Error: missing }.\n");
246 string += s - buf + 1;
static char buf[MAXPROMPT]
static wordlist * brac1()
static wordlist* bracexpand |
( |
char * |
string | ) |
|
|
static |
Definition at line 130 of file glob.c.
142 for (w = wl; w; w = w->
wl_next) {
static wordlist * brac1()
struct wordlist * wl_next
Definition at line 65 of file glob.c.
74 if (list ==
NULL)
return;
78 for (wl = wlist; wl; wl = wl->
wl_next) {
93 for (wl = wlist; wl; wl = wl->
wl_next)
113 for (wl = wlist; wl; wl = wl->
wl_next) {
static wordlist * bracexpand()
static wordlist * globexpand()
struct wordlist * wl_next
char * cp_tildexpand(char *string)
bool cp_globmatch |
( |
char * |
p, |
|
|
char * |
s |
|
) |
| |
Definition at line 594 of file glob.c.
598 char schar, pchar, bc, fc;
610 for (
s--; *
s !=
'\0';
s++)
615 else if (pchar ==
cp_huh) {
631 if ((bchar && !except) ||
638 if (fc <= schar && schar <= *
p++)
648 fprintf(
cp_err,
"Error: missing ].\n");
653 else if (pchar ==
'\0') {
660 if (
strip(pchar) != schar)
bool cp_globmatch(char *p, char *s)
void cp_pathfix |
( |
char * |
buf | ) |
|
Definition at line 496 of file glob.c.
502 int bcnt = 0, ecnt = 0;
506 if (*t ==
'/' || *t ==
'\\') {
512 else if (*t ==
'.') {
517 if (bcnt++ < 8) *s++ = *t++;
521 if (ecnt++ < 4) *s++ = *t++;
static char buf[MAXPROMPT]
char * index(char *s, char c) const
char * cp_tildexpand(char *string)
char* cp_tildexpand |
( |
char * |
string | ) |
|
Definition at line 477 of file glob.c.
487 return (
copy(
string));
static char * tilde_expand()
static wordlist* globexpand |
( |
char * |
string | ) |
|
|
static |
Definition at line 260 of file glob.c.
271 #if defined(HAVE_DIRENT_H) || defined(HAVE_SYS_DIR_H) 280 if (*point == DIR_TERM) {
282 poss[0] =
copy(DIR_PATHSEP);
284 else if (point[0] ==
'.' && point[1] ==
'.' && point[2] == DIR_TERM) {
285 poss[0] =
copy(
"..");
289 else if (point[1] ==
':') {
291 if (point[0] == DIR_TERM) {
293 poss[0] =
copy(
"?:\\");
296 poss[0] =
copy(
"?:.");
301 poss[0] =
copy(DIR_CWD);
306 (void)
strcpy(buf, point);
307 s = strchr(buf, DIR_TERM);
310 #if defined(HAVE_DIRENT_H) || defined(HAVE_SYS_DIR_H) 312 if (!poss[i] || (poss[i][0] ==
'\0'))
315 wdir = opendir(poss[i]);
323 while ((de = readdir(wdir)) !=
NULL)
331 "Too many arguments.\n");
336 (void)
strcpy(poss[j] + 1, poss[i]);
337 (void) strcat(poss[j] + 1, DIR_PATHSEP);
338 (void) strcat(poss[j] + 1, de->d_name);
342 (void) closedir(wdir);
355 for (j = 0; poss[i][j] = poss[i][j+1]; j++);
356 if (strchr(point, DIR_TERM)) {
357 point = strchr(point, DIR_TERM) + 1;
364 for (i = j = 0; i <
MAXWORDS; i++) {
365 if (!poss[i])
continue;
378 qsort((
char *) poss, j,
sizeof (
char *),
380 (
int(*)(
const void*,
const void*))
sortcmp);
385 for (i = 0; i < j; i++) {
391 wl->wl_next->wl_prev = wl;
394 wl->wl_word =
pcanon(poss[i]);
403 wl->wl_word =
copy(
string);
406 fprintf(
cp_err,
"%s: no match.\n",
string);
static char buf[MAXPROMPT]
int bzero(char *ptr, int num)
bool cp_globmatch(char *p, char *s)
static bool noglobs |
( |
char * |
string | ) |
|
|
static |
static char* pcanon |
( |
char * |
string | ) |
|
|
static |
Definition at line 421 of file glob.c.
427 s = p =
tmalloc(strlen(
string) + 1);
430 if (!strncmp(
string, DIR_CWD,
sizeof(DIR_CWD) - 1)
431 && (*(
string + 1) == DIR_TERM)) {
436 if (*
string == DIR_TERM) {
438 while (*++
string == DIR_TERM);
442 if (*(s - 1) == DIR_TERM)
static int sortcmp |
( |
char ** |
s1, |
|
|
char ** |
s2 |
|
) |
| |
|
static |
static char* tilde_expand |
( |
| ) |
|
|
static |
static char* tilde_expand |
( |
char * |
string | ) |
|
|
static |
Definition at line 542 of file glob.c.
555 while (*
string && isspace(*
string))
563 if (!*
string || *
string ==
'/') {
564 pw = getpwuid(getuid());
569 while ((c = *
string) && c !=
'/')
586 return (
copy(
string));
static char buf[MAXPROMPT]