Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/plugin/PluginUserSettings.cpp

Issue 29330618: Issue #1234 - Eliminate CString from PluginSettings.* and PluginUserSettings.* (Closed)
Left Patch Set: Created Nov. 20, 2015, 6:37 p.m.
Right Patch Set: address comments Created Nov. 25, 2015, 5:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginSettings.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 if (pDispparams->rgvarg[0].vt != VT_BSTR || pDispparams->rgvarg[1].vt != VT_BSTR) 177 if (pDispparams->rgvarg[0].vt != VT_BSTR || pDispparams->rgvarg[1].vt != VT_BSTR)
178 { 178 {
179 return DISP_E_TYPEMISMATCH; 179 return DISP_E_TYPEMISMATCH;
180 } 180 }
181 if (pVarResult) 181 if (pVarResult)
182 { 182 {
183 CComBSTR key = pDispparams->rgvarg[0].bstrVal; 183 CComBSTR key = pDispparams->rgvarg[0].bstrVal;
184 CComBSTR section = pDispparams->rgvarg[1].bstrVal; 184 CComBSTR section = pDispparams->rgvarg[1].bstrVal;
185 Dictionary* dictionary = Dictionary::GetInstance(); 185 Dictionary* dictionary = Dictionary::GetInstance();
186 std::wstring message = dictionary->Lookup(ToUtf8String(std::wstring(se ction)), ToUtf8String(std::wstring(key))); 186 std::wstring message = dictionary->Lookup(
sergei 2015/11/25 09:27:08 Nit: strictly speaking we should use the length ob
Eric 2015/11/25 17:31:02 Done. There are a few other places where we need
sergei 2015/11/26 11:06:18 Sure, feel free to create the issue for it.
187 ToUtf8String(std::wstring(section, ::SysStringLen(section))),
188 ToUtf8String(std::wstring(key, ::SysStringLen(key)))
189 );
187 190
188 pVarResult->vt = VT_BSTR; 191 pVarResult->vt = VT_BSTR;
189 pVarResult->bstrVal = SysAllocString(message.c_str()); 192 pVarResult->bstrVal = SysAllocString(message.c_str());
190 } 193 }
191 } 194 }
192 break; 195 break;
193 case dispatchID_GetLanguageCount: 196 case dispatchID_GetLanguageCount:
194 { 197 {
195 if (pDispparams->cArgs != 0) 198 if (pDispparams->cArgs != 0)
196 { 199 {
(...skipping 18 matching lines...) Expand all
215 { 218 {
216 return DISP_E_TYPEMISMATCH; 219 return DISP_E_TYPEMISMATCH;
217 } 220 }
218 if (pVarResult) 221 if (pVarResult)
219 { 222 {
220 int index = pDispparams->rgvarg[0].lVal; 223 int index = pDispparams->rgvarg[0].lVal;
221 224
222 auto languageTitleList = settings->GetFilterLanguageTitleList(); 225 auto languageTitleList = settings->GetFilterLanguageTitleList();
223 226
224 if (index < 0 || index >= static_cast<int>(languageTitleList.size()) ) 227 if (index < 0 || index >= static_cast<int>(languageTitleList.size()) )
225 return DISP_E_BADINDEX; 228 return DISP_E_EXCEPTION;
Oleksandr 2015/11/25 03:22:07 Nit: unrelated change.
sergei 2015/11/25 09:27:09 I would not mind to commit it but it's likely not
Eric 2015/11/25 17:31:02 It fixes a defect, actually. Rather than bicker ov
226 229
227 std::wstring language; 230 std::wstring language;
228 231
229 int loopIndex = 0; 232 int loopIndex = 0;
230 for (auto it = languageTitleList.begin(); it != languageTitleList.end( ); ++it) 233 for (auto it = languageTitleList.begin(); it != languageTitleList.end( ); ++it)
231 { 234 {
232 if (loopIndex == index) 235 if (loopIndex == index)
233 { 236 {
234 language = it->first; 237 language = it->first;
235 break; 238 break;
(...skipping 16 matching lines...) Expand all
252 { 255 {
253 return DISP_E_TYPEMISMATCH; 256 return DISP_E_TYPEMISMATCH;
254 } 257 }
255 if (pVarResult) 258 if (pVarResult)
256 { 259 {
257 int index = pDispparams->rgvarg[0].lVal; 260 int index = pDispparams->rgvarg[0].lVal;
258 261
259 auto languageTitleList = settings->GetFilterLanguageTitleList(); 262 auto languageTitleList = settings->GetFilterLanguageTitleList();
260 263
261 if (index < 0 || index >= static_cast<int>(languageTitleList.size()) ) 264 if (index < 0 || index >= static_cast<int>(languageTitleList.size()) )
262 return DISP_E_BADINDEX; 265 return DISP_E_EXCEPTION;
Oleksandr 2015/11/25 03:22:08 Nit: unrelated change.
263 266
264 std::wstring languageTitle; 267 std::wstring languageTitle;
265 int loopIndex = 0; 268 int loopIndex = 0;
266 for (auto it = languageTitleList.begin(); it != languageTitleList.end( ); ++it) 269 for (auto it = languageTitleList.begin(); it != languageTitleList.end( ); ++it)
267 { 270 {
268 if (loopIndex == index) 271 if (loopIndex == index)
269 { 272 {
270 languageTitle = it->second; 273 languageTitle = it->second;
271 break; 274 break;
272 } 275 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return DISP_E_MEMBERNOTFOUND; 444 return DISP_E_MEMBERNOTFOUND;
442 break; 445 break;
443 } 446 }
444 } 447 }
445 catch (...) 448 catch (...)
446 { 449 {
447 return E_FAIL; 450 return E_FAIL;
448 } 451 }
449 return S_OK; 452 return S_OK;
450 } 453 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld