The spectral function for Sturm–Liouville problems where the potential is of Wigner–von Neumann type or slowly decaying