From 60b216790193f1b6741676b55e63e71bcde8516c Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Sun, 15 Nov 2020 23:11:14 +0100 Subject: [PATCH] riched20: Use wide-char string literals. Signed-off-by: Michael Stefaniuc Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/riched20/editor.c | 18 ++++++------------ dlls/riched20/paint.c | 6 ++---- dlls/riched20/para.c | 15 +++++---------- dlls/riched20/richole.c | 3 +-- dlls/riched20/run.c | 3 +-- dlls/riched20/table.c | 6 ++---- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 2f7383e59a1..985bcc3d573 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -244,9 +244,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); static BOOL ME_RegisterEditorClass(HINSTANCE); static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars); - -static const WCHAR REListBox20W[] = {'R','E','L','i','s','t','B','o','x','2','0','W', 0}; -static const WCHAR REComboBox20W[] = {'R','E','C','o','m','b','o','B','o','x','2','0','W', 0}; static HCURSOR hLeft; BOOL me_debug = FALSE; @@ -2222,8 +2219,6 @@ static DWORD CALLBACK ME_ReadFromHGLOBALRTF(DWORD_PTR dwCookie, LPBYTE lpBuff, L return 0; } -static const WCHAR rtfW[] = {'R','i','c','h',' ','T','e','x','t',' ','F','o','r','m','a','t',0}; - static HRESULT paste_rtf(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) { EDITSTREAM es; @@ -2278,7 +2273,7 @@ static struct paste_format const WCHAR *name; } paste_formats[] = { - {{ -1, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, paste_rtf, rtfW }, + {{ -1, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, paste_rtf, L"Rich Text Format" }, {{ CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, paste_text }, {{ CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF }, paste_emf }, {{ 0 }} @@ -3273,9 +3268,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) UnregisterClassA(RICHEDIT_CLASS20A, 0); UnregisterClassA("RichEdit50A", 0); if (ME_ListBoxRegistered) - UnregisterClassW(REListBox20W, 0); + UnregisterClassW(L"REListBox20W", 0); if (ME_ComboBoxRegistered) - UnregisterClassW(REComboBox20W, 0); + UnregisterClassW(L"REComboBox20W", 0); LookupCleanup(); HeapDestroy (me_heap); release_typelib(); @@ -5149,7 +5144,6 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, { ME_Run *run, *next_run; const WCHAR *pStart = buffer; - const WCHAR cr_lf[] = {'\r', '\n', 0}; const WCHAR *str; int nLen; @@ -5172,7 +5166,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, * also uses this function. */ srcChars -= min(nLen, srcChars); nLen = 2; - str = cr_lf; + str = L"\r\n"; } else { @@ -5290,7 +5284,7 @@ LRESULT WINAPI REExtendedRegisterClass(void) { wcW.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS; wcW.lpfnWndProc = REListWndProc; - wcW.lpszClassName = REListBox20W; + wcW.lpszClassName = L"REListBox20W"; if (RegisterClassW(&wcW)) ME_ListBoxRegistered = TRUE; } @@ -5298,7 +5292,7 @@ LRESULT WINAPI REExtendedRegisterClass(void) { wcW.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW; wcW.lpfnWndProc = REComboWndProc; - wcW.lpszClassName = REComboBox20W; + wcW.lpszClassName = L"REComboBox20W"; if (RegisterClassW(&wcW)) ME_ComboBoxRegistered = TRUE; } diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index ffb50d5ceff..2db3a4ea2c1 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -972,10 +972,9 @@ static void draw_paragraph( ME_Context *c, ME_Paragraph *para ) } if (me_debug) { - static const WCHAR wszRowDebug[] = {'r','o','w','[','%','d',']',0}; WCHAR buf[128]; POINT pt = c->pt; - wsprintfW(buf, wszRowDebug, no); + wsprintfW( buf, L"row[%d]", no ); pt.y = 12+y; ME_DebugWrite(c->hDC, &pt, buf); } @@ -1006,12 +1005,11 @@ static void draw_paragraph( ME_Context *c, ME_Paragraph *para ) } if (me_debug) { - static const WCHAR wszRunDebug[] = {'[','%','d',':','%','x',']',' ','%','l','s',0}; WCHAR buf[2560]; POINT pt; pt.x = c->pt.x + run->pt.x; pt.y = c->pt.y + para->pt.y + run->pt.y; - wsprintfW(buf, wszRunDebug, no, p->member.run.nFlags, get_text( &p->member.run, 0 )); + wsprintfW( buf, L"[%d:%x] %ls", no, p->member.run.nFlags, get_text( &p->member.run, 0 )); ME_DebugWrite(c->hDC, &pt, buf); } break; diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index cb98218aeab..29624e6c1df 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -150,7 +150,6 @@ ME_Row *para_end_row( ME_Paragraph *para ) void ME_MakeFirstParagraph(ME_TextEditor *editor) { - static const WCHAR cr_lf[] = {'\r','\n',0}; ME_Context c; CHARFORMAT2W cf; const CHARFORMATW *host_cf; @@ -202,7 +201,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) } eol_len = editor->bEmulateVersion10 ? 2 : 1; - para->text = ME_MakeStringN( cr_lf, eol_len ); + para->text = ME_MakeStringN( L"\r\n", eol_len ); run = run_create( style, MERF_ENDPARA ); run->nCharOfs = 0; @@ -280,7 +279,6 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num ) /* max 4 Roman letters (representing '8') / decade + '(' + ')' */ ME_String *str = ME_MakeStringEmpty( 20 + 2 ); WCHAR *p; - static const WCHAR fmtW[] = {'%', 'd', 0}; static const WORD letter_base[] = { 1, 26, 26 * 26, 26 * 26 * 26 }; /* roman_base should start on a '5' not a '1', otherwise the 'total' code will need adjusting. 'N' and 'O' are what MS uses for 5000 and 10000, their version doesn't work well above 30000, @@ -309,7 +307,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num ) { case PFN_ARABIC: default: - p += swprintf( p, 20, fmtW, num ); + p += swprintf( p, 20, L"%d", num ); break; case PFN_LCLETTER: @@ -393,9 +391,6 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) { ME_Style *style; CHARFORMAT2W cf; - static const WCHAR bullet_font[] = {'S','y','m','b','o','l',0}; - static const WCHAR bullet_str[] = {0xb7, 0}; - static const WCHAR spaceW[] = {' ', 0}; SIZE sz; if (!para->fmt.wNumbering) return; @@ -409,7 +404,7 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) { cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_CHARSET; - memcpy( cf.szFaceName, bullet_font, sizeof(bullet_font) ); + lstrcpyW( cf.szFaceName, L"Symbol" ); cf.bCharSet = SYMBOL_CHARSET; style = ME_ApplyStyle( c->editor, style, &cf ); } @@ -426,13 +421,13 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) if (para->fmt.wNumbering != PFN_BULLET) para->para_num.text = para_num_get_str( para, para_num_get_num( para ) ); else - para->para_num.text = ME_MakeStringConst( bullet_str, 1 ); + para->para_num.text = ME_MakeStringConst( L"\x00b7", 1 ); } select_style( c, para->para_num.style ); GetTextExtentPointW( c->hDC, para->para_num.text->szData, para->para_num.text->nLen, &sz ); para->para_num.width = sz.cx; - GetTextExtentPointW( c->hDC, spaceW, 1, &sz ); + GetTextExtentPointW( c->hDC, L" ", 1, &sz ); para->para_num.width += sz.cx; } diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 5d73731dedb..bedeefe9a63 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -3004,9 +3004,8 @@ static void textfont_reset_to_default(ITextFontImpl *font) font->props[id].l = GetSystemDefaultLCID(); break; case FONT_NAME: { - static const WCHAR sysW[] = {'S','y','s','t','e','m',0}; SysFreeString(font->props[id].str); - font->props[id].str = SysAllocString(sysW); + font->props[id].str = SysAllocString(L"System"); break; } case FONT_WEIGHT: diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index fdda43ba51a..e099c0be6dc 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -665,7 +665,6 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visu SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, int startx, int *pAscent, int *pDescent) { - static const WCHAR spaceW[] = {' ',0}; SIZE size; nLen = min( nLen, run->len ); @@ -673,7 +672,7 @@ SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, i if (run->nFlags & MERF_ENDPARA) { nLen = min( nLen, 1 ); - ME_GetTextExtent(c, spaceW, nLen, run->style, &size); + ME_GetTextExtent( c, L" ", nLen, run->style, &size ); } else if (para->nFlags & MEPF_COMPLEX) { diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c index 0ce5a2c32c0..c3823e3b493 100644 --- a/dlls/riched20/table.c +++ b/dlls/riched20/table.c @@ -54,8 +54,6 @@ #include "editor.h" #include "rtf.h" -static const WCHAR cr_lf[] = {'\r', '\n', 0}; - static ME_Paragraph* table_insert_end_para( ME_TextEditor *editor, ME_Cursor *cursor, const WCHAR *eol_str, int eol_len, int para_flags ) { @@ -75,7 +73,7 @@ ME_Paragraph* table_insert_row_start( ME_TextEditor *editor, ME_Cursor *cursor ) { ME_Paragraph *para; - para = table_insert_end_para( editor, cursor, cr_lf, 2, MEPF_ROWSTART ); + para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWSTART ); return para_prev( para ); } @@ -122,7 +120,7 @@ ME_Paragraph* table_insert_row_end( ME_TextEditor *editor, ME_Cursor *cursor ) { ME_Paragraph *para; - para = table_insert_end_para( editor, cursor, cr_lf, 2, MEPF_ROWEND ); + para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWEND ); return para_prev( para ); }