Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/childwnd.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c index 582f3c0c177..704299be837 100644 --- a/programs/regedit/childwnd.c +++ b/programs/regedit/childwnd.c @@ -32,12 +32,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(regedit); ChildWnd* g_pChildWnd; static int last_split;
-static const WCHAR wszLastKey[] = {'L','a','s','t','K','e','y',0}; -static const WCHAR wszKeyName[] = {'S','o','f','t','w','a','r','e','\', - 'M','i','c','r','o','s','o','f','t','\', - 'W','i','n','d','o','w','s','\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', - 'A','p','p','l','e','t','s','\','R','e','g','e','d','i','t',0}; +static const WCHAR wszLastKey[] = L"LastKey"; +static const WCHAR wszKeyName[] = L"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit";
/******************************************************************************* * Local module support methods @@ -58,11 +54,7 @@ static LPCWSTR GetRootKeyName(HKEY hRootKey) if(hRootKey == HKEY_DYN_DATA) return reg_class_namesW[INDEX_HKEY_DYN_DATA]; else - { - static const WCHAR unknown_key[] = {'U','N','K','N','O','W','N',' ','H','K','E','Y',',',' ', - 'P','L','E','A','S','E',' ','R','E','P','O','R','T',0}; - return unknown_key; - } + return L"Unknown HKEY. Please report."; }
static void draw_splitbar(HWND hWnd, int x)
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/edit.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index 3f99626dd23..b808c38c51c 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -85,15 +85,12 @@ static void WINAPIV error_code_messagebox(HWND hwnd, unsigned int msg_id, ...)
static BOOL change_dword_base(HWND hwndDlg, BOOL toHex) { - static const WCHAR percent_u[] = {'%','u',0}; - static const WCHAR percent_x[] = {'%','x',0}; - WCHAR buf[128]; DWORD val;
if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf))) return FALSE; - if (!swscanf(buf, toHex ? percent_u : percent_x, &val)) return FALSE; - wsprintfW(buf, toHex ? percent_x : percent_u, val); + if (!swscanf(buf, toHex ? L"%u" : L"%x", &val)) return FALSE; + wsprintfW(buf, toHex ? L"%x" : L"%u", val); return SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf); }
@@ -281,10 +278,9 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED); } } else if ( type == REG_DWORD ) { - static const WCHAR x[] = {'%','x',0}; DWORD value = *((DWORD*)stringValueData); stringValueData = heap_xrealloc(stringValueData, 64); - wsprintfW(stringValueData, x, value); + wsprintfW(stringValueData, L"%x", value); if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc) == IDOK) { DWORD val; CHAR* valueA = GetMultiByteString(stringValueData);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/framewnd.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 7a1507bb54e..88f05420675 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(regedit); * Global and Local Variables: */
-static const WCHAR favoritesKey[] = {'S','o','f','t','w','a','r','e','\','M','i','c','r','o','s','o','f','t','\','W','i','n','d','o','w','s','\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\','A','p','p','l','e','t','s','\','R','e','g','E','d','i','t','\','F','a','v','o','r','i','t','e','s',0}; +static const WCHAR favoritesKey[] = L"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites"; static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */ static WCHAR favoriteName[128]; static WCHAR searchString[128]; @@ -420,13 +420,12 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAMEW *pofn)
if (FilterBuffer[0] == 0) { - static const WCHAR filterW[] = {'%','s','%','c','*','.','r','e','g','%','c','%','s','%','c','*','.','r','e','g','%','c','%','s','%','c','*','.','*','%','c',0}; WCHAR filter_reg[MAX_PATH], filter_reg4[MAX_PATH], filter_all[MAX_PATH];
LoadStringW(hInst, IDS_FILEDIALOG_FILTER_REG, filter_reg, MAX_PATH); LoadStringW(hInst, IDS_FILEDIALOG_FILTER_REG4, filter_reg4, MAX_PATH); LoadStringW(hInst, IDS_FILEDIALOG_FILTER_ALL, filter_all, MAX_PATH); - swprintf( FilterBuffer, ARRAY_SIZE(FilterBuffer), filterW, + swprintf( FilterBuffer, ARRAY_SIZE(FilterBuffer), L"%s%c*.reg%c%s%c*.reg%c%s%c*.*%c", filter_reg, 0, 0, filter_reg4, 0, 0, filter_all, 0, 0 ); } pofn->lpstrFilter = FilterBuffer; @@ -442,10 +441,8 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAMEW *pofn)
static BOOL import_registry_filename(LPWSTR filename) { - static const WCHAR rb_mode[] = {'r','b',0}; - BOOL Success; - FILE* reg_file = _wfopen(filename, rb_mode); + FILE* reg_file = _wfopen(filename, L"rb");
if(!reg_file) return FALSE; @@ -1018,8 +1015,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case ID_HELP_HELPTOPICS: { - const WCHAR help_regedit[] = {'r','e','g','e','d','i','t',0}; - WinHelpW(hWnd, help_regedit, HELP_FINDER, 0); + WinHelpW(hWnd, L"regedit", HELP_FINDER, 0); break; } case ID_HELP_ABOUT: @@ -1059,11 +1055,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - static const WCHAR captionW[] = {'r','e','g','e','d','i','t',' ','c','h','i','l','d',' ','w','i','n','d','o','w',0}; - switch (message) { case WM_CREATE: - CreateWindowExW(0, szChildClass, captionW, WS_CHILD | WS_VISIBLE, + CreateWindowExW(0, szChildClass, L"regedit child window", WS_CHILD | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, NULL, hInst, 0); LoadStringW(hInst, IDS_EXPAND, expandW, ARRAY_SIZE(expandW)); @@ -1099,8 +1093,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; case WM_DESTROY: { - const WCHAR help_regedit[] = {'r','e','g','e','d','i','t',0}; - WinHelpW(hWnd, help_regedit, HELP_QUIT, 0); + WinHelpW(hWnd, L"regedit", HELP_QUIT, 0); PostQuitMessage(0); } default:
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/hexedit.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/programs/regedit/hexedit.c b/programs/regedit/hexedit.c index 7322a86e1f7..8227f201c29 100644 --- a/programs/regedit/hexedit.c +++ b/programs/regedit/hexedit.c @@ -55,8 +55,6 @@ typedef struct tagHEXEDIT_INFO INT nScrollPos; /* first visible line */ } HEXEDIT_INFO;
-const WCHAR szHexEditClass[] = {'H','e','x','E','d','i','t',0}; - static inline LRESULT HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw);
static inline BYTE hexchar_to_byte(WCHAR ch) @@ -73,16 +71,13 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
static LPWSTR HexEdit_GetLineText(int offset, BYTE *pData, LONG cbData, LONG pad) { - static const WCHAR percent_04xW[] = {'%','0','4','X',' ',' ',0}; - static const WCHAR percent_02xW[] = {'%','0','2','X',' ',0}; - WCHAR *lpszLine = heap_xalloc((6 + cbData * 3 + pad * 3 + DIV_SPACES + cbData + 1) * sizeof(WCHAR)); LONG i;
- wsprintfW(lpszLine, percent_04xW, offset); + wsprintfW(lpszLine, L"%04X ", offset);
for (i = 0; i < cbData; i++) - wsprintfW(lpszLine + 6 + i*3, percent_02xW, pData[offset + i]); + wsprintfW(lpszLine + 6 + i*3, L"%02X ", pData[offset + i]); for (i = 0; i < pad * 3; i++) lpszLine[6 + cbData * 3 + i] = ' ';
@@ -645,7 +640,7 @@ void HexEdit_Register(void) wndClass.cbWndExtra = sizeof(HEXEDIT_INFO *); wndClass.hCursor = LoadCursorW(0, (const WCHAR *)IDC_IBEAM); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wndClass.lpszClassName = szHexEditClass; + wndClass.lpszClassName = L"HexEdit";
RegisterClassW(&wndClass); }
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/listview.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index 0132cfb8db8..50157eb12ef 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -112,10 +112,9 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz { DWORD value = *(DWORD *)data; WCHAR buf[64]; - WCHAR format[] = {'0','x','%','0','8','x',' ','(','%','u',')',0}; if (type == REG_DWORD_BIG_ENDIAN) value = RtlUlongByteSwap(value); - wsprintfW(buf, format, value, value); + wsprintfW(buf, L"0x%08x (%u)", value, value); ListView_SetItemTextW(hwndLV, index, 2, buf); break; } @@ -130,9 +129,8 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz unsigned int i; BYTE *pData = data; WCHAR *strBinary = heap_xalloc(size * sizeof(WCHAR) * 3 + sizeof(WCHAR)); - WCHAR format[] = {'%','0','2','X',' ',0}; for (i = 0; i < size; i++) - wsprintfW( strBinary + i*3, format, pData[i] ); + wsprintfW( strBinary + i*3, L"%02X ", pData[i] ); strBinary[size * 3] = 0; ListView_SetItemTextW(hwndLV, index, 2, strBinary); heap_free(strBinary); @@ -242,17 +240,16 @@ static BOOL CreateListColumns(HWND hWndListView) void OnGetDispInfo(NMLVDISPINFOW *plvdi) { static WCHAR buffer[200]; - static WCHAR reg_szT[] = {'R','E','G','_','S','Z',0}, - reg_expand_szT[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}, - reg_binaryT[] = {'R','E','G','_','B','I','N','A','R','Y',0}, - reg_dwordT[] = {'R','E','G','_','D','W','O','R','D',0}, - reg_dword_big_endianT[] = {'R','E','G','_','D','W','O','R','D','_', - 'B','I','G','_','E','N','D','I','A','N',0}, - reg_multi_szT[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0}, - reg_linkT[] = {'R','E','G','_','L','I','N','K',0}, - reg_resource_listT[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','L','I','S','T',0}, - reg_noneT[] = {'R','E','G','_','N','O','N','E',0}, - emptyT[] = {0}; + static WCHAR reg_szT[] = L"REG_SZ", + reg_expand_szT[] = L"REG_EXPAND_SZ", + reg_binaryT[] = L"REG_BINARY", + reg_dwordT[] = L"REG_DWORD", + reg_dword_big_endianT[] = L"REG_DWORD_BIG_ENDIAN", + reg_multi_szT[] = L"REG_MULTI_SZ", + reg_linkT[] = L"REG_LINK", + reg_resource_listT[] = L"REG_RESOURCE_LIST", + reg_noneT[] = L"REG_NONE", + emptyT[] = L"";
plvdi->item.pszText = NULL; plvdi->item.cchTextMax = 0; @@ -295,8 +292,7 @@ void OnGetDispInfo(NMLVDISPINFOW *plvdi) break; default: { - WCHAR fmt[] = {'0','x','%','x',0}; - wsprintfW(buffer, fmt, data_type); + wsprintfW(buffer, L"0x%x", data_type); plvdi->item.pszText = buffer; break; } @@ -348,14 +344,13 @@ HWND CreateListView(HWND hwndParent, UINT id) { RECT rcClient; HWND hwndLV; - WCHAR ListView[] = {'L','i','s','t',' ','V','i','e','w',0};
/* prepare strings */ LoadStringW(hInst, IDS_REGISTRY_VALUE_NOT_SET, g_szValueNotSet, ARRAY_SIZE(g_szValueNotSet));
/* Get the dimensions of the parent window's client area, and create the list view control. */ GetClientRect(hwndParent, &rcClient); - hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, ListView, + hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, L"List View", WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS, 0, 0, rcClient.right, rcClient.bottom, hwndParent, ULongToHandle(id), hInst, NULL);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/regedit.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/programs/regedit/regedit.c b/programs/regedit/regedit.c index d2e27340300..6a50a63226f 100644 --- a/programs/regedit/regedit.c +++ b/programs/regedit/regedit.c @@ -107,16 +107,14 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i) switch (action) { case ACTION_ADD: { WCHAR *filename = argv[*i]; - WCHAR hyphen[] = {'-',0}; WCHAR *realname = NULL; FILE *reg_file;
- if (!lstrcmpW(filename, hyphen)) + if (!lstrcmpW(filename, L"-")) reg_file = stdin; else { int size; - WCHAR rb_mode[] = {'r','b',0};
size = SearchPathW(NULL, filename, NULL, 0, NULL, NULL); if (size > 0) @@ -130,11 +128,10 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i) heap_free(realname); return; } - reg_file = _wfopen(realname, rb_mode); + reg_file = _wfopen(realname, L"rb"); if (reg_file == NULL) { - WCHAR regedit[] = {'r','e','g','e','d','i','t',0}; - _wperror(regedit); + _wperror(L"regedit"); output_message(STRING_CANNOT_OPEN_FILE, filename); heap_free(realname); return;
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/treeview.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/programs/regedit/treeview.c b/programs/regedit/treeview.c index 15a51360a30..5ba4628681a 100644 --- a/programs/regedit/treeview.c +++ b/programs/regedit/treeview.c @@ -543,12 +543,12 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName) { TVINSERTSTRUCTW tvins; HTREEITEM hRoot; - static WCHAR hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}, - hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}, - hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}, - hku[] = {'H','K','E','Y','_','U','S','E','R','S',0}, - hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0}, - hkdd[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0}; + static WCHAR hkcr[] = L"HKEY_CLASSES_ROOT", + hkcu[] = L"HKEY_CURRENT_USER", + hklm[] = L"HKEY_LOCAL_MACHINE", + hku[] = L"HKEY_USERS", + hkcc[] = L"HKEY_CURRENT_CONFIG", + hkdd[] = L"HKEY_DYN_DATA";
tvins.u.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM; /* Set the text of the item. */ @@ -694,11 +694,10 @@ HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, UINT id) { RECT rcClient; HWND hwndTV; - WCHAR TreeView[] = {'T','r','e','e',' ','V','i','e','w',0};
/* Get the dimensions of the parent window's client area, and create the tree view control. */ GetClientRect(hwndParent, &rcClient); - hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, TreeView, + hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, L"Tree View", WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS | TVS_SHOWSELALWAYS, 0, 0, rcClient.right, rcClient.bottom,
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/main.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/programs/regedit/main.c b/programs/regedit/main.c index e0f89255461..99706b531d5 100644 --- a/programs/regedit/main.c +++ b/programs/regedit/main.c @@ -34,16 +34,9 @@ WCHAR g_pszDefaultValueName[64];
BOOL ProcessCmdLine(WCHAR *cmdline);
-static const WCHAR hkey_local_machine[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}; -static const WCHAR hkey_users[] = {'H','K','E','Y','_','U','S','E','R','S',0}; -static const WCHAR hkey_classes_root[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}; -static const WCHAR hkey_current_config[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0}; -static const WCHAR hkey_current_user[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}; -static const WCHAR hkey_dyn_data[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0}; - -const WCHAR *reg_class_namesW[] = {hkey_local_machine, hkey_users, - hkey_classes_root, hkey_current_config, - hkey_current_user, hkey_dyn_data +const WCHAR *reg_class_namesW[] = {L"HKEY_LOCAL_MACHINE", L"HKEY_USERS", + L"HKEY_CLASSES_ROOT", L"HKEY_CURRENT_CONFIG", + L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA" };
/******************************************************************************* @@ -56,13 +49,11 @@ HWND hStatusBar; HMENU hMenuFrame; HMENU hPopupMenus = 0; UINT nClipboardFormat; -const WCHAR strClipboardFormat[] = {'T','O','D','O',':',' ','S','E','T',' ','C','O','R','R','E','C','T',' ','F','O','R','M','A','T',0}; -
#define MAX_LOADSTRING 100 WCHAR szTitle[MAX_LOADSTRING]; -const WCHAR szFrameClass[] = {'R','e','g','E','d','i','t','_','R','e','g','E','d','i','t',0}; -const WCHAR szChildClass[] = {'R','E','G','E','D','I','T',0}; +const WCHAR szChildClass[] = L"REGEDIT"; +const WCHAR szFrameClass[] = L"RegEdit_RegEdit";
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { @@ -96,7 +87,7 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) /* register our hex editor control */ HexEdit_Register();
- nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat); + nClipboardFormat = RegisterClipboardFormatW(L"TODO: Set correct format");
hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/regproc.c | 83 +++++++++++++------------------------- 1 file changed, 28 insertions(+), 55 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 5bb991865e6..9dea3ebd446 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -331,18 +331,13 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line) { struct data_type { const WCHAR *tag; int len; int type; int parse_type; };
- static const WCHAR quote[] = {'"'}; - static const WCHAR hex[] = {'h','e','x',':'}; - static const WCHAR dword[] = {'d','w','o','r','d',':'}; - static const WCHAR hexp[] = {'h','e','x','('}; - static const struct data_type data_types[] = { - /* tag len type parse type */ - { quote, 1, REG_SZ, REG_SZ }, - { hex, 4, REG_BINARY, REG_BINARY }, - { dword, 6, REG_DWORD, REG_DWORD }, - { hexp, 4, -1, REG_BINARY }, /* REG_NONE, REG_EXPAND_SZ, REG_MULTI_SZ */ - { NULL, 0, 0, 0 } + /* tag len type parse type */ + { L""", 1, REG_SZ, REG_SZ }, + { L"hex:", 4, REG_BINARY, REG_BINARY }, + { L"dword:", 6, REG_DWORD, REG_DWORD }, + { L"hex(", 4, -1, REG_BINARY }, /* REG_NONE, REG_EXPAND_SZ, REG_MULTI_SZ */ + { NULL, 0, 0, 0 } };
const struct data_type *ptr; @@ -542,21 +537,17 @@ enum reg_versions {
static enum reg_versions parse_file_header(const WCHAR *s) { - static const WCHAR header_31[] = {'R','E','G','E','D','I','T',0}; - static const WCHAR header_40[] = {'R','E','G','E','D','I','T','4',0}; - static const WCHAR header_50[] = {'W','i','n','d','o','w','s',' ', - 'R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ', - 'V','e','r','s','i','o','n',' ','5','.','0','0',0}; + static const WCHAR header_31[] = L"REGEDIT";
while (*s == ' ' || *s == '\t') s++;
if (!lstrcmpW(s, header_31)) return REG_VERSION_31;
- if (!lstrcmpW(s, header_40)) + if (!lstrcmpW(s, L"REGEDIT4")) return REG_VERSION_40;
- if (!lstrcmpW(s, header_50)) + if (!lstrcmpW(s, L"Windows Registry Editor Version 5.00")) return REG_VERSION_50;
/* The Windows version accepts registry file headers beginning with "REGEDIT" and ending @@ -610,13 +601,13 @@ static WCHAR *header_state(struct parser *parser, WCHAR *pos) static WCHAR *parse_win31_line_state(struct parser *parser, WCHAR *pos) { WCHAR *line, *value; - static WCHAR hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T'}; + static WCHAR hkcr[] = L"HKEY_CLASSES_ROOT"; unsigned int key_end = 0;
if (!(line = get_line(parser->file))) return NULL;
- if (wcsncmp(line, hkcr, ARRAY_SIZE(hkcr))) + if (wcsncmp(line, hkcr, lstrlenW(hkcr))) return line;
/* get key name */ @@ -1037,8 +1028,7 @@ static WCHAR *get_lineW(FILE *fp)
while (next) { - static const WCHAR line_endings[] = {'\r','\n',0}; - WCHAR *p = wcspbrk(line, line_endings); + WCHAR *p = wcspbrk(line, L"\r\n"); if (!p) { size_t len, count; @@ -1207,15 +1197,14 @@ static WCHAR *REGPROC_escape_string(WCHAR *str, size_t str_len, size_t *line_len
static size_t export_value_name(FILE *fp, WCHAR *name, size_t len, BOOL unicode) { - static const WCHAR quoted_fmt[] = {'"','%','s','"','=',0}; - static const WCHAR default_name[] = {'@','=',0}; + static const WCHAR default_name[] = L"@="; size_t line_len;
if (name && *name) { WCHAR *str = REGPROC_escape_string(name, len, &line_len); WCHAR *buf = heap_xalloc((line_len + 4) * sizeof(WCHAR)); - line_len = swprintf(buf, line_len + 4, quoted_fmt, str); + line_len = swprintf(buf, line_len + 4, L""%s"=", str); REGPROC_write_line(fp, buf, unicode); heap_free(buf); heap_free(str); @@ -1233,28 +1222,24 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size) { size_t len = 0, line_len; WCHAR *str; - static const WCHAR fmt[] = {'"','%','s','"',0};
if (size) len = size / sizeof(WCHAR) - 1; str = REGPROC_escape_string(data, len, &line_len); *buf = heap_xalloc((line_len + 3) * sizeof(WCHAR)); - swprintf(*buf, line_len + 3, fmt, str); + swprintf(*buf, line_len + 3, L""%s"", str); heap_free(str); }
static void export_dword_data(WCHAR **buf, DWORD *data) { - static const WCHAR fmt[] = {'d','w','o','r','d',':','%','0','8','x',0}; - *buf = heap_xalloc(15 * sizeof(WCHAR)); - swprintf(*buf, 15, fmt, *data); + swprintf(*buf, 15, L"dword:%08x", *data); }
static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode) { - static const WCHAR hex[] = {'h','e','x',':',0}; - static const WCHAR hexp_fmt[] = {'h','e','x','(','%','x',')',':',0}; + static const WCHAR hex[] = L"hex:"; size_t line_len;
if (type == REG_BINARY) @@ -1265,7 +1250,7 @@ static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode) else { WCHAR *buf = heap_xalloc(15 * sizeof(WCHAR)); - line_len = swprintf(buf, 15, hexp_fmt, type); + line_len = swprintf(buf, 15, L"hex(%x):", type); REGPROC_write_line(fp, buf, unicode); heap_free(buf); } @@ -1278,8 +1263,6 @@ static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode) static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len, void *data, DWORD size, BOOL unicode) { - static const WCHAR fmt[] = {'%','0','2','x',0}; - static const WCHAR hex_concat[] = {'\','\r','\n',' ',' ',0}; size_t num_commas, i, pos;
line_len += export_hex_data_type(fp, type, unicode); @@ -1294,7 +1277,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len,
for (i = 0, pos = 0; i < size; i++) { - pos += swprintf(*buf + pos, 3, fmt, ((BYTE *)data)[i]); + pos += swprintf(*buf + pos, 3, L"%02x", ((BYTE *)data)[i]); if (i == num_commas) break; (*buf)[pos++] = ','; (*buf)[pos] = 0; @@ -1303,7 +1286,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len, if (line_len >= MAX_HEX_CHARS) { REGPROC_write_line(fp, *buf, unicode); - REGPROC_write_line(fp, hex_concat, unicode); + REGPROC_write_line(fp, L"\\r\n ", unicode); line_len = 2; pos = 0; } @@ -1312,9 +1295,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len,
static void export_newline(FILE *fp, BOOL unicode) { - static const WCHAR newline[] = {'\r','\n',0}; - - REGPROC_write_line(fp, newline, unicode); + REGPROC_write_line(fp, L"\r\n", unicode); }
static void export_data(FILE *fp, WCHAR *value_name, DWORD value_len, DWORD type, @@ -1356,21 +1337,19 @@ static void export_data(FILE *fp, WCHAR *value_name, DWORD value_len, DWORD type static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len) { WCHAR *subkey_path; - static const WCHAR fmt[] = {'%','s','\','%','s',0};
subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR)); - swprintf(subkey_path, path_len + subkey_len + 2, fmt, path, subkey_name); + swprintf(subkey_path, path_len + subkey_len + 2, L"%s\%s", path, subkey_name);
return subkey_path; }
static void export_key_name(FILE *fp, WCHAR *name, BOOL unicode) { - static const WCHAR fmt[] = {'\r','\n','[','%','s',']','\r','\n',0}; WCHAR *buf;
buf = heap_xalloc((lstrlenW(name) + 7) * sizeof(WCHAR)); - swprintf(buf, lstrlenW(name) + 7, fmt, name); + swprintf(buf, lstrlenW(name) + 7, L"\r\n[%s]\r\n", name); REGPROC_write_line(fp, buf, unicode); heap_free(buf); } @@ -1453,22 +1432,18 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode) static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) { FILE *file; - static const WCHAR hyphen[] = {'-',0};
- if (!lstrcmpW(file_name, hyphen)) + if (!lstrcmpW(file_name, L"-")) { file = stdout; _setmode(_fileno(file), _O_BINARY); } else { - static const WCHAR wb_mode[] = {'w','b',0}; - - file = _wfopen(file_name, wb_mode); + file = _wfopen(file_name, L"wb"); if (!file) { - static const WCHAR regedit[] = {'r','e','g','e','d','i','t',0}; - _wperror(regedit); + _wperror(L"regedit"); error_exit(STRING_CANNOT_OPEN_FILE, file_name); } } @@ -1476,12 +1451,10 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) if (unicode) { static const BYTE bom[] = {0xff,0xfe}; - static const WCHAR header[] = {'W','i','n','d','o','w','s',' ', - 'R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ', - 'V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n'}; + static const WCHAR header[] = L"Windows Registry Editor Version 5.00\r\n";
fwrite(bom, sizeof(BYTE), ARRAY_SIZE(bom), file); - fwrite(header, sizeof(WCHAR), ARRAY_SIZE(header), file); + fwrite(header, sizeof(WCHAR), lstrlenW(header), file); } else fputs("REGEDIT4\r\n", file);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/main.c | 2 +- programs/regedit/main.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/programs/regedit/main.c b/programs/regedit/main.c index 99706b531d5..664821f6a5d 100644 --- a/programs/regedit/main.c +++ b/programs/regedit/main.c @@ -53,7 +53,7 @@ UINT nClipboardFormat; #define MAX_LOADSTRING 100 WCHAR szTitle[MAX_LOADSTRING]; const WCHAR szChildClass[] = L"REGEDIT"; -const WCHAR szFrameClass[] = L"RegEdit_RegEdit"; +static const WCHAR szFrameClass[] = L"RegEdit_RegEdit";
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { diff --git a/programs/regedit/main.h b/programs/regedit/main.h index ae034405646..d32000f78ac 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -96,7 +96,6 @@ extern HFONT hFont; extern enum OPTION_FLAGS Options;
extern WCHAR szTitle[]; -extern const WCHAR szFrameClass[]; extern const WCHAR szChildClass[]; extern const WCHAR szHexEditClass[]; extern WCHAR g_pszDefaultValueName[];
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/main.c | 2 +- programs/regedit/main.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/programs/regedit/main.c b/programs/regedit/main.c index 664821f6a5d..ecc06a5280e 100644 --- a/programs/regedit/main.c +++ b/programs/regedit/main.c @@ -51,7 +51,7 @@ HMENU hPopupMenus = 0; UINT nClipboardFormat;
#define MAX_LOADSTRING 100 -WCHAR szTitle[MAX_LOADSTRING]; +static WCHAR szTitle[MAX_LOADSTRING]; const WCHAR szChildClass[] = L"REGEDIT"; static const WCHAR szFrameClass[] = L"RegEdit_RegEdit";
diff --git a/programs/regedit/main.h b/programs/regedit/main.h index d32000f78ac..29ecb433916 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -95,7 +95,6 @@ extern HMENU hPopupMenus; extern HFONT hFont; extern enum OPTION_FLAGS Options;
-extern WCHAR szTitle[]; extern const WCHAR szChildClass[]; extern const WCHAR szHexEditClass[]; extern WCHAR g_pszDefaultValueName[];
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/regedit/main.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/programs/regedit/main.h b/programs/regedit/main.h index 29ecb433916..6ad7835e4df 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -96,7 +96,6 @@ extern HFONT hFont; extern enum OPTION_FLAGS Options;
extern const WCHAR szChildClass[]; -extern const WCHAR szHexEditClass[]; extern WCHAR g_pszDefaultValueName[];
extern DWORD g_columnToSort;