Nonlinear theory of the long-wavelength external m=1 mode in screw pinches and tokamaks