| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/udev_linux/udev.h" | 5 #include "device/udev_linux/udev.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "device/udev_linux/udev_loader.h" | 8 #include "device/udev_linux/udev_loader.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const char* key) { | 164 const char* key) { |
| 165 return StringOrEmptyIfNull(udev_device_get_sysattr_value(udev_device, key)); | 165 return StringOrEmptyIfNull(udev_device_get_sysattr_value(udev_device, key)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 std::string UdevDecodeString(const std::string& encoded) { | 168 std::string UdevDecodeString(const std::string& encoded) { |
| 169 std::string decoded; | 169 std::string decoded; |
| 170 const size_t size = encoded.size(); | 170 const size_t size = encoded.size(); |
| 171 for (size_t i = 0; i < size; ++i) { | 171 for (size_t i = 0; i < size; ++i) { |
| 172 char c = encoded[i]; | 172 char c = encoded[i]; |
| 173 if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') { | 173 if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') { |
| 174 c = (HexDigitToInt(encoded[i + 2]) << 4) + | 174 c = (base::HexDigitToInt(encoded[i + 2]) << 4) + |
| 175 HexDigitToInt(encoded[i + 3]); | 175 base::HexDigitToInt(encoded[i + 3]); |
| 176 i += 3; | 176 i += 3; |
| 177 } | 177 } |
| 178 decoded.push_back(c); | 178 decoded.push_back(c); |
| 179 } | 179 } |
| 180 return decoded; | 180 return decoded; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace device | 183 } // namespace device |
| OLD | NEW |