Stability theory for solitary-wave solutions of scalar field equations