pool *p; /* Allocation pool */
struct elt *sp; /* Stack pointer for list */
dstr path; /* Current path string */
+ dstr link; /* Symbolic link target string */
};
/*----- Static variables --------------------------------------------------*/
pool *pp;
struct stat st;
unsigned bad = 0;
- dstr buf = DSTR_INIT;
int i;
/* --- Initialize the state --- */
state->p = pp;
state->sp = (/*unconst*/ struct elt *)&rootnode;
dstr_create(&state->path);
+ dstr_create(&state->link);
/* --- Try to find the current directory --- */
/* --- Resolve the link --- */
- dstr_reset(&buf);
- dstr_ensure(&buf, st.st_size + 1);
- if ((i = readlink(state->path.buf, buf.buf, buf.sz)) < 0) {
+ dstr_reset(&state->link);
+ dstr_ensure(&state->link, st.st_size + 1);
+ if ((i = readlink(state->path.buf,
+ state->link.buf, state->link.sz)) < 0) {
report(cp, CP_ERROR, 0, state->path.buf, "can't readlink: %e");
bad |= CP_ERROR;
break;
}
- buf.buf[i] = 0;
- report(cp, CP_SYMLINK, 2, state->path.buf, "symlink -> `%s'", buf.buf);
+ state->link.buf[i] = 0;
+ report(cp, CP_SYMLINK, 2, state->path.buf,
+ "symlink -> `%s'", state->link.buf);
/* --- Handle sticky parents --- *
*
/* --- Sort out what to do from here --- */
- if (buf.buf[0] == '/')
+ if (state->link.buf[0] == '/')
popall(state);
else
pop(state);
- ee = splitpath(state, buf.buf, ee);
+ ee = splitpath(state, state->link.buf, ee);
continue;
}
}
dstr_destroy(&state->path);
- dstr_destroy(&buf);
+ dstr_destroy(&state->link);
pool_destroy(state->p);
return (bad);
}