rem: done = 0; while (!done) { len = strcspn(tmp, ":"); if (len==0) done=1; path = wmalloc(len+flen+2); path = memcpy(path, tmp, len); path[len]=0; strcat(path, "/"); strcat(path, file); fullpath = wexpandpath(path); wfree(path); if (fullpath) { if (access(fullpath, F_OK)==0) { return fullpath; } wfree(fullpath); } tmp=&(tmp[len+1]); if (*tmp==0) break;
add: while (*tmp) { tmp = skipchar(tmp, ':'); if (*tmp==0) break; tmp2 = nextchar(tmp, ':'); len = tmp2 - tmp; path = wmalloc(len+flen+2); path = memcpy(path, tmp, len); path[len]=0; if (path[len-1] != '/') strcat(path, "/"); strcat(path, file); fullpath = wexpandpath(path); wfree(path); if (fullpath) { if (access(fullpath, F_OK)==0) { return fullpath; } wfree(fullpath); } tmp = tmp2;
context: wfindfile(char *paths, char *file){    char *path;    char *tmp;    int done;    int len, flen;    char *fullpath;    if (!file)	return NULL;        if (*file=='/' || *file=='~' || *file=='$' || !paths) {	if (access(file, F_OK)<0) {	    fullpath = wexpandpath(file);	    if (!fullpath)		return NULL;	    	    if (access(fullpath, F_OK)<0) {		wfree(fullpath);		return NULL;	    } else {		return fullpath;	    }	} else {	    return wstrdup(file);	}    }    flen = strlen(file);    tmp = paths;    done = 0;    while (!done) {	len = strcspn(tmp, ":");	if (len==0) done=1;	path = wmalloc(len+flen+2);	path = memcpy(path, tmp, len);	path[len]=0;	strcat(path, "/");	strcat(path, file);	fullpath = wexpandpath(path);	wfree(path);	if (fullpath) {	    if (access(fullpath, F_OK)==0) {		return fullpath;	    }	    wfree(fullpath);	}	tmp=&(tmp[len+1]);	if (*tmp==0) break;    }    return NULL;}