MCPcopy Index your code
hub / github.com/RsyncProject/rsync / glob_match

Function glob_match

util1.c:656–702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654} glob;
655
656static void glob_match(char *arg, int abpos, int fbpos)
657{
658 int len;
659 char *slash;
660
661 while (*arg == '.' && arg[1] == '/') {
662 if (fbpos < 0) {
663 ENSURE_MEMSPACE(glob.filt_buf, char, glob.fbsize, glob.absize);
664 memcpy(glob.filt_buf, glob.arg_buf, abpos + 1);
665 fbpos = abpos;
666 }
667 ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, abpos + 3);
668 glob.arg_buf[abpos++] = *arg++;
669 glob.arg_buf[abpos++] = *arg++;
670 glob.arg_buf[abpos] = '\0';
671 }
672 if ((slash = strchr(arg, '/')) != NULL) {
673 *slash = '\0';
674 len = slash - arg;
675 } else
676 len = strlen(arg);
677 if (strpbrk(arg, "*?[")) {
678 struct dirent *di;
679 DIR *d;
680
681 if (!(d = opendir(abpos ? glob.arg_buf : ".")))
682 return;
683 while ((di = readdir(d)) != NULL) {
684 char *dname = d_name(di);
685 if (dname[0] == '.' && (dname[1] == '\0'
686 || (dname[1] == '.' && dname[2] == '\0')))
687 continue;
688 if (!wildmatch(arg, dname))
689 continue;
690 call_glob_match(dname, strlen(dname), 1,
691 slash ? arg + len + 1 : NULL,
692 abpos, fbpos);
693 }
694 closedir(d);
695 } else {
696 call_glob_match(arg, len, 0,
697 slash ? arg + len + 1 : NULL,
698 abpos, fbpos);
699 }
700 if (slash)
701 *slash = '/';
702}
703
704static inline void call_glob_match(const char *name, int len, int from_glob,
705 char *arg, int abpos, int fbpos)

Callers 2

call_glob_matchFunction · 0.85
glob_expandFunction · 0.85

Calls 4

strpbrkFunction · 0.85
d_nameFunction · 0.85
wildmatchFunction · 0.85
call_glob_matchFunction · 0.85

Tested by

no test coverage detected