riched20: Constify some variables.
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index ef8c9cd..f0f664c 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h
@@ -94,25 +94,25 @@ ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars); ME_String *ME_MakeStringR(WCHAR cRepeat, int nMaxChars); ME_String *ME_MakeStringB(int nMaxChars); -ME_String *ME_StrDup(ME_String *s); +ME_String *ME_StrDup(const ME_String *s); void ME_DestroyString(ME_String *s); -void ME_AppendString(ME_String *s1, ME_String *s2); -ME_String *ME_ConcatString(ME_String *s1, ME_String *s2); +void ME_AppendString(ME_String *s1, const ME_String *s2); +ME_String *ME_ConcatString(const ME_String *s1, const ME_String *s2); ME_String *ME_VSplitString(ME_String *orig, int nVPos); -int ME_IsWhitespaces(ME_String *s); -int ME_IsSplitable(ME_String *s); +int ME_IsWhitespaces(const ME_String *s); +int ME_IsSplitable(const ME_String *s); /* int ME_CalcSkipChars(ME_String *s); */ -int ME_StrLen(ME_String *s); -int ME_StrVLen(ME_String *s); -int ME_FindNonWhitespaceV(ME_String *s, int nVChar); +int ME_StrLen(const ME_String *s); +int ME_StrVLen(const ME_String *s); +int ME_FindNonWhitespaceV(const ME_String *s, int nVChar); int ME_FindWhitespaceV(ME_String *s, int nVChar); int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code); -int ME_GetCharFwd(ME_String *s, int nPos); /* get char starting from start */ -int ME_GetCharBack(ME_String *s, int nPos); /* get char starting from \0 */ -int ME_StrRelPos(ME_String *s, int nVChar, int *pRelChars); -int ME_StrRelPos2(ME_String *s, int nVChar, int nRelChars); +int ME_GetCharFwd(const ME_String *s, int nPos); /* get char starting from start */ +int ME_GetCharBack(const ME_String *s, int nPos); /* get char starting from \0 */ +int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars); +int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars); int ME_VPosToPos(ME_String *s, int nVPos); -int ME_PosToVPos(ME_String *s, int nPos); +int ME_PosToVPos(const ME_String *s, int nPos); void ME_StrDeleteV(ME_String *s, int nVChar, int nChars); /* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */ LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz); @@ -130,8 +130,8 @@ /* note: those two really return the first matching offset (starting from EOS)+1 * in other words, an offset of the first trailing white/black */ -int ME_ReverseFindNonWhitespaceV(ME_String *s, int nVChar); -int ME_ReverseFindWhitespaceV(ME_String *s, int nVChar); +int ME_ReverseFindNonWhitespaceV(const ME_String *s, int nVChar); +int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar); /* row.c */ ME_DisplayItem *ME_FindRowStart(ME_Context *c, ME_DisplayItem *run, int nRelPos); @@ -155,15 +155,15 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run); int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset); int ME_GetLastSplittablePlace(ME_Context *c, ME_Run *run); -int ME_CanJoinRuns(ME_Run *run1, ME_Run *run2); +int ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2); void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p); ME_DisplayItem *ME_SplitRun(ME_Context *c, ME_DisplayItem *item, int nChar); ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, int nChar); int ME_FindSplitPoint(ME_Context *c, POINT *pt, ME_Run *run, int desperate); void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run); ME_DisplayItem *ME_SplitFurther(ME_TextEditor *editor, ME_DisplayItem *run); -void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run); -SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen); +void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, ME_Run *run); +SIZE ME_GetRunSize(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen); void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor); void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppRun, int *pOfs); int ME_CharOfsFromRunOfs(ME_TextEditor *editor, ME_DisplayItem *pRun, int nOfs);
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 29fc309..1630653 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c
@@ -32,7 +32,7 @@ * * Returns 1 if two runs can be safely merged into one, 0 otherwise. */ -int ME_CanJoinRuns(ME_Run *run1, ME_Run *run2) +int ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) { if ((run1->nFlags | run2->nFlags) & MERF_NOJOIN) return 0; @@ -652,7 +652,7 @@ * Finds width, height, ascent and descent of a run, up to given character * (nLen). */ -static SIZE ME_GetRunSizeCommon(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen, +static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, int *pAscent, int *pDescent) { SIZE size; @@ -728,7 +728,7 @@ * Finds width and height (but not ascent and descent) of a part of the run * up to given character. */ -SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen) +SIZE ME_GetRunSize(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen) { int asc, desc; return ME_GetRunSizeCommon(c, para, run, nLen, &asc, &desc); @@ -741,7 +741,7 @@ * is calculated based on whole row's ascent and descent anyway, so no need * to use it here. */ -void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run) +void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, ME_Run *run) { if (run->nFlags & MERF_HIDDEN) run->nWidth = 0;
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c index 10f6239..2ec0092 100644 --- a/dlls/riched20/string.c +++ b/dlls/riched20/string.c
@@ -76,7 +76,7 @@ return s; } -ME_String *ME_StrDup(ME_String *s) +ME_String *ME_StrDup(const ME_String *s) { return ME_MakeStringN(s->szData, s->nLen); } @@ -87,7 +87,7 @@ FREE_OBJ(s); } -void ME_AppendString(ME_String *s1, ME_String *s2) +void ME_AppendString(ME_String *s1, const ME_String *s2) { if (s1->nLen+s2->nLen+1 <= s1->nBuffer) { lstrcpyW(s1->szData+s1->nLen, s2->szData); @@ -107,7 +107,7 @@ } } -ME_String *ME_ConcatString(ME_String *s1, ME_String *s2) +ME_String *ME_ConcatString(const ME_String *s1, const ME_String *s2) { ME_String *s = ALLOC_OBJ(ME_String); s->nLen = s1->nLen+s2->nLen; @@ -134,7 +134,7 @@ return s; } -int ME_IsWhitespaces(ME_String *s) +int ME_IsWhitespaces(const ME_String *s) { /* FIXME multibyte */ WCHAR *pos = s->szData; @@ -147,7 +147,7 @@ return 1; } -int ME_IsSplitable(ME_String *s) +int ME_IsSplitable(const ME_String *s) { WCHAR *pos = s->szData; WCHAR ch; @@ -173,18 +173,18 @@ } */ -int ME_StrLen(ME_String *s) { +int ME_StrLen(const ME_String *s) { return s->nLen; } -int ME_StrVLen(ME_String *s) { +int ME_StrVLen(const ME_String *s) { return s->nLen; } -int ME_StrRelPos(ME_String *s, int nVChar, int *pRelChars) +int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars) { int nRelChars = *pRelChars; - + TRACE("%s,%d,&%d\n", debugstr_w(s->szData), nVChar, *pRelChars); assert(*pRelChars); @@ -200,7 +200,7 @@ return nVChar; } -int ME_StrRelPos2(ME_String *s, int nVChar, int nRelChars) +int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars) { return ME_StrRelPos(s, nVChar, &nRelChars); } @@ -224,7 +224,7 @@ */ } -int ME_PosToVPos(ME_String *s, int nPos) +int ME_PosToVPos(const ME_String *s, int nPos) { if (!nPos) return 0; @@ -245,10 +245,10 @@ s->nLen -= (end_ofs - nVChar); } -int ME_GetCharFwd(ME_String *s, int nPos) +int ME_GetCharFwd(const ME_String *s, int nPos) { int nVPos = 0; - + assert(nPos < ME_StrLen(s)); if (nPos) nVPos = ME_StrRelPos2(s, nVPos, nPos); @@ -258,10 +258,10 @@ return -1; } -int ME_GetCharBack(ME_String *s, int nPos) +int ME_GetCharBack(const ME_String *s, int nPos) { int nVPos = ME_StrVLen(s); - + assert(nPos < ME_StrLen(s)); if (nPos) nVPos = ME_StrRelPos2(s, nVPos, -nPos); @@ -271,7 +271,7 @@ return -1; } -int ME_FindNonWhitespaceV(ME_String *s, int nVChar) { +int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) { int i; for (i = nVChar; i<s->nLen && ME_IsWSpace(s->szData[i]); i++) ; @@ -280,7 +280,7 @@ } /* note: returns offset of the first trailing whitespace */ -int ME_ReverseFindNonWhitespaceV(ME_String *s, int nVChar) { +int ME_ReverseFindNonWhitespaceV(const ME_String *s, int nVChar) { int i; for (i = nVChar; i>0 && ME_IsWSpace(s->szData[i-1]); i--) ; @@ -289,7 +289,7 @@ } /* note: returns offset of the first trailing nonwhitespace */ -int ME_ReverseFindWhitespaceV(ME_String *s, int nVChar) { +int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar) { int i; for (i = nVChar; i>0 && !ME_IsWSpace(s->szData[i-1]); i--) ;