Left: | ||
Right: |
OLD | NEW |
---|---|
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 Loading... | |
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 * We call '_wcslwr_s()', which take C-style strings and uses the current loca le to determine case. | |
sergei
2015/12/16 15:53:16
It still can be just a one line comment "uses the
Eric
2015/12/16 16:38:07
That's reasonable.
| |
59 */ | |
56 std::wstring ToLowerString(const std::wstring& s) | 60 std::wstring ToLowerString(const std::wstring& s) |
57 { | 61 { |
58 return ToWstring(ToCString(s).MakeLower()); | 62 std::wstring lower(s); // Copy the argument |
63 /* | |
64 * C++11 provides that 'c_str()' returns the internal array in which the strin g holds its value. | |
65 * Thus we can modify in-place after casting away the 'const' modifier from 'c _str()'. | |
sergei
2015/12/16 15:53:16
These two lines are completely redundant.
Eric
2015/12/16 16:38:07
Just because you understand it already doesn't mea
Oleksandr
2016/01/05 22:59:00
From what I remember the consensus on comments is
Eric
2016/01/07 14:34:04
Done.
| |
66 * | |
67 * Documentation for '_wcslwr_s' https://msdn.microsoft.com/en-us/library/y889 wzfw.aspx | |
68 * This documentation is incorrect on an important point. | |
69 * Regarding parameter validation, it says "length of string" where it should say "length of buffer". | |
70 * The call below has argument "length + 1" to include the terminating null ch aracter in the buffer. | |
sergei
2015/12/16 15:53:16
It does say "Size of the buffer.", so these three
Eric
2015/12/16 16:38:07
It also says "size of string", and it does that (l
Oleksandr
2016/01/05 22:59:00
How about just a comment like:
//NOTE: second para
Eric
2016/01/07 14:34:04
It's not typical for documentation to be incorrect
| |
71 */ | |
72 _wcslwr_s(const_cast<wchar_t*>(lower.c_str()), lower.length() + 1); | |
73 return lower; | |
59 } | 74 } |
60 | 75 |
OLD | NEW |