  We perform factorization of the most general distribution in semileptonic B
-> X_u decays and we resum the threshold logarithms to next-to-leading order.
  From this (triple-differential) distribution, any other distribution is
obtained by integration. As an application of our method, we derive simple
analytical expressions for a few distributions, resummed to leading
approximation. It is shown that the shape function can be directly determined
by measuring the distribution in m_X^2/E_X^2, not in m_X^2/m_B^2. We compute
the resummed hadron energy spectrum, which has a ``Sudakov shoulder'', and we
show how the distribution in the singular region is related to the shape
function. We also present an improved formula for the photon spectrum in B->X_s
gamma which includes soft-gluon resummation and non-leading operators in the
effective hamiltonian. We explicitly show that the same non-perturbative
function - namely the shape function - controls the non-perturbative effects in
all the distributions in the semi-leptonic and in the rare decay.
