I've created this code which hopefully will make glossing a lot easier, the first input decides the order of a Transcription, Phonemic reading, Phonetic reading, and Gloss, and uses the input to generate the in text gloss in the order and format I want. When compiling, the resulting pdf has a large space inserted between the text before the gloss and the gloss generated by the command. I've made this code based off of a code which does mass replacement a la egreg's beautiful code answer in: How to do multiple string replacements?. Anything I'm missing that would cause this large gap?
\documentclass[a4paper]{article}
\usepackage{xstring}
\usepackage{tipa}
\newcommand{\glossstep}[2]{
\expandafter\StrSubstitute\expandafter{\x}{#1}{#2}[\x]}
\newcommand{\totalgloss}[5][T P A Q]{
\noexpandarg
\StrSubstitute{#1}{T}{\textit{#2}}[\x]
\glossstep{P}{/\textipa{#3}/}
\glossstep{A}{[\textipa{#4}]}
\glossstep{G}{#5}
\glossstep{Q}{`#5'}
\glossstep{S}{\textsc{#5}}
\x}
\begin{document}
. . . the plural form is \totalgloss[T A Q]{sargata}{sar\;Gan+ta}{sar\;Gata}{wives} which as you can see is . . .
\end{document}