Q:

Calculating $\int_{-\infty}^{\infty}\frac{\sin(ax)}{x}\, dx$ using complex analysis

I am going over my complex analysis lecture notes and there is an
example about calculating $$\int_{-\infty}^{\infty}\frac{\sin(ax)}{x}\, dx$$
that I don't understand.
The solution in the notes starts like this:
Denote $C$ as the path from$-R$ to $R$ on the $x$-axis (where
$R>0$ is real). Denote $C_{R}$ as the semi-circle (anti-clockwise)
that goes from $R$ to $-R$.
$$\int_{-R}^{R}\frac{\sin(az)}{z}\, dz=\int_{C}\frac{\sin(az)}{z}\, dz=\int_{C}\frac{e^{aiz}-e^{-aiz}}{2iz}=\frac{1}{2i}(\int_{C}\frac{e^{iaz}}{z}\, dz-\int_{C}\frac{e^{-aiz}}{z}\, dz)$$
Assume $a>0$:
$$e^{iaz}=e^{iaRe^{i\theta}}=e^{iaR\cos(\theta)}-e^{-iaR\sin(\theta)}$$
Thus $$\int_{C}\frac{e^{iaz}}{z}\, dz+\int_{C_{R}}\frac{e^{iaz}}{z}\, dz=2\pi iRes_{z=0}\left(\frac{e^{iaz}}{z}\right)=2\pi i$$
The next part claims that for $R\to\infty$:$\int_{C}\frac{e^{iaz}}{z}\, dz=2\pi i$
(I understand this part)
From here don't understand what going on in the notes, the sentences
claim that $$\int_{C}\frac{e^{-iaz}}{z}\, dz+\int_{C_{R}}\frac{-e^{iaz}}{z}\, dz=0$$
but I think that in a similar manner that sum is $2\pi iRes_{z=0}(\frac{e^{-iaz}}{z})$
which I believe to be $2\pi i\neq0$.
The next two sentences afterward say that $\lim_{R\to\infty}\int_{C}\frac{\sin(az)}{z}\, dz=\frac{1}{2i}\cdot2\pi i=\pi$
and that $$\int_{-\infty}^{\infty}\frac{\sin(ax)}{x}\, dx=\pi$$
Can someone please help me understand the part about the sum $$\int_{C}\frac{e^{-iaz}}{z}\, dz+\int_{C_{R}}\frac{-e^{iaz}}{z}\, dz$$
? I believe that there is a mistake here, I would also appreciate
help understanding the last two claims: $$\lim_{R\to\infty}\int_{C}\frac{\sin(az)}{z}\, dz=\pi$$
and that $$\int_{-\infty}^{\infty}\frac{\sin(ax)}{x}\, dx=\pi$$
EDIT: I read this couple more times, I now think that there is problem with the part after "assume $a>0$": $$e^{iaz}=e^{iaRe^{i\theta}}=e^{iaR\cos(\theta)}-e^{-iaR\sin(\theta)}$$
I think that the minus at the end should be $\cdot$ and that this is a typo in the notes, but I also think there should not be an $i$ in $e^{-iaR\sin(\theta)}$

A:

When you break up the integral like that, you end up integrating through poles.  That derivation makes no sense to me.
Notice that $\displaystyle \frac{\sin ax}{x} = \text{Im} \ \frac{e^{iax}}{x}$. 
What you should do is let $\displaystyle f(z) = \frac{e^{iaz}}{z}$ and integrate around the same contour but with a small half-circle of radius $r$ about the origin.
There are no poles inside of the contour, but when you let $r$ to go zero, it gives a contribution of $-i \pi$.

