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

Side by Side Diff: src/plugin/PluginUtil.cpp

Issue 29332775: Issue #1234 - Remove 'CString' From 'ToLowerString()' (Closed)
Patch Set: Created Dec. 15, 2015, 9:10 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 std::wstring GetLocationUrl(IWebBrowser2& browser) 46 std::wstring GetLocationUrl(IWebBrowser2& browser)
47 { 47 {
48 ATL::CComBSTR locationUrl; 48 ATL::CComBSTR locationUrl;
49 if (FAILED(browser.get_LocationURL(&locationUrl)) || !locationUrl) 49 if (FAILED(browser.get_LocationURL(&locationUrl)) || !locationUrl)
50 { 50 {
51 return std::wstring(); 51 return std::wstring();
52 } 52 }
53 return std::wstring(locationUrl, locationUrl.Length()); 53 return std::wstring(locationUrl, locationUrl.Length());
54 } 54 }
55 55
56 /**
57 * \par Implementation Note
58 * This function '_wcslwr()' uses the current locale to determine case.
sergei 2015/12/16 10:32:44 I don't think we need this line because it's alrea
Eric 2015/12/16 13:53:26 It's not the same. The header says is it uses the
59 * This is the same function used within 'CStringW::MakeLower()', which this f unction replaces.
sergei 2015/12/16 10:32:44 The comment on this line is not necessary to be in
Eric 2015/12/16 13:53:26 I wavered on this one. I had decided to leave it i
60 */
56 std::wstring ToLowerString(const std::wstring& s) 61 std::wstring ToLowerString(const std::wstring& s)
57 { 62 {
58 return ToWstring(ToCString(s).MakeLower()); 63 std::wstring lower(s); // copy the argument
64 /*
65 * C++11 provides that 'c_str()' returns the internal array in which the strin g holds its value.
66 * Thus we can modify in-place after casting away the 'const' modifier from 'c _str()'.
67 *
68 * C++11 also provides that 'c_str()' return a null-terminated string.
69 * On the other hand, '_wcslwr_s' throws an assertion failure saying that it's not null-terminated.
70 * So we're using the "insecure" version and suppressing the deprecation warni ng.
sergei 2015/12/16 10:32:44 Although "insecure" version might work good becaus
Eric 2015/12/16 13:53:26 I had tried it once and it had failed. It turns ou
71 */
72 #pragma warning (push)
73 #pragma warning(disable : 4996)
74 _wcslwr(const_cast<wchar_t*>(lower.data()));
sergei 2015/12/16 10:32:45 What about returning of an empty string in case of
Eric 2015/12/16 13:53:26 The tests aren't returning an error code, now that
sergei 2015/12/16 15:53:16 Still I would like to check the return value and h
Eric 2015/12/16 16:38:06 Don't need to. According to the documentation, it
75 #pragma warning (pop)
76 return lower;
59 } 77 }
60 78
OLDNEW

Powered by Google App Engine
This is Rietveld