riched20: Simplified logic in ME_StrRelPos().

This commit is contained in:
Phil Krylov 2006-01-09 17:12:34 +01:00 committed by Alexandre Julliard
parent 3022ade359
commit 74aa295f55
1 changed files with 10 additions and 17 deletions

View File

@ -155,29 +155,22 @@ int ME_StrVLen(ME_String *s) {
return s->nLen;
}
/* FIXME we use widechars, not multibytes, inside, no need for complex logic anymore */
int ME_StrRelPos(ME_String *s, int nVChar, int *pRelChars)
{
int nRelChars = *pRelChars;
TRACE("%s,%d,&%d\n", debugstr_w(s->szData), nVChar, *pRelChars);
assert(*pRelChars);
if (!*pRelChars) return nVChar;
if (*pRelChars>0)
{
while(nVChar<s->nLen && *pRelChars>0)
{
nVChar++;
(*pRelChars)--;
}
if (!nRelChars)
return nVChar;
}
while(nVChar>0 && *pRelChars<0)
{
nVChar--;
(*pRelChars)++;
}
if (nRelChars>0)
nRelChars = min(*pRelChars, s->nLen - nVChar);
else
nRelChars = max(*pRelChars, -nVChar);
nVChar += nRelChars;
*pRelChars -= nRelChars;
return nVChar;
}