<s>[INST] $\int \frac{dx}{1-\sin x+\cos x}$ Solve :$$ \int \frac{dx}{1-\sin x+\cos x} $$
I tried:
$$\int \frac{\text{dx}}{(1+\cos x)-\sin x} \times \frac{(1+\cos x)+\sin x}{(1+\cos x)+ \sin x} dx=\int \frac{1+\cos x+\sin x}{(1+\cos x)^2-(\sin x)^2}$$ $$=\int \frac{1+\cos x+\sin x}{1-\sin x^2+2 \cos x+\cos x^2}=\int \frac{1+\cos x+\sin x}{2 \cos x(\cos x+1)}$$ $$=\int (\frac{1}{2 \cos x}+ \frac{\sin x}{2 \cos x(\cos x+1)})dx=\frac{1}{2} \ln(\sec x+\tan x)+ \int \frac{\sin x}{2\cos x(\cos x+1)}dx$$
$ \cos x=u$ , $du=-\sin xdx$
$$\int \frac{-du}{2u(u+1)}= \frac{-1}{2} \int (\frac{1}{u}-\frac{1}{u+1})= \frac{-1}{2}(\ln(\cos x)-\ln(\cos x+1))$$
final answer : $$\frac{1}{2} \ln(\sec x+\tan x)-\frac{1}{2} \ln(\frac{\cos x}{1+\cos x})+ c$$
First: Is my answer right?
Second: Is there another approach or easier approach to solve this integral?  
 [/INST] My hint for your question:
$$\int \frac{dx}{1-\sin x+\cos x}$$
If I apply the $t-$substitution $t=\tan(\frac{x}{2})$ you will have $$\int \frac{dx}{1-\sin x+\cos x}=\int \frac{1}{-u+1}du$$
Using another $y-$substitution for last integral of the type $p=-y+1$ you will have:
$$\int \frac{1}{-u+1}du=\int -\frac{1}{p}dp$$
Hence remebering all substitutions $p=-u+1,\,t=\tan  (\frac{x}{2} )$ you will obtain 
$$\int \frac{dx}{1-\sin x+\cos x}=-\ln \left|-\tan \left(\frac{x}{2}\right)+1\right|+k, \quad k\in\mathbb R$$
</s>