Changeset 60154 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 23, 2016 11:29:21 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp
r60153 r60154 73 73 VECTOR_PTR(char *) mvecpszInterfaces; 74 74 } USBDeviceInfo; 75 76 77 78 /**79 * Purge string of non-UTF-8 encodings and control characters.80 *81 * @returns String length (excluding terminator).82 * @param psz The string to purge.83 */84 static size_t usbPurgeEncoding(char *psz)85 {86 /* Beat it into valid UTF-8 encoding. */87 RTStrPurgeEncoding(psz);88 89 /* Look for control characters. */90 size_t offSrc;91 for (offSrc = 0; ; offSrc++)92 {93 char ch = psz[offSrc];94 if (RT_UNLIKELY(RT_C_IS_CNTRL(ch)))95 {96 /* Found a control character! Replace tab by space and remove all others. */97 size_t offDst = offSrc;98 for (;; offSrc++)99 {100 ch = psz[offSrc];101 if (RT_C_IS_CNTRL(ch))102 {103 if (ch == '\t')104 ch = ' ';105 else106 continue;107 }108 psz[offDst++] = ch;109 if (ch == '\0')110 break;111 }112 return offDst - 1;113 }114 if (ch == '\0')115 break;116 }117 return offSrc - 1;118 }119 75 120 76 … … 442 398 if (psz) 443 399 { 444 usbPurgeEncoding(psz);400 USBLibPurgeEncoding(psz); 445 401 *ppsz = psz; 446 402 return VINF_SUCCESS; … … 1331 1287 if (cchRead > 0 && (size_t) cchRead < sizeof(szBuf)) 1332 1288 { 1333 usbPurgeEncoding(szBuf);1289 USBLibPurgeEncoding(szBuf); 1334 1290 pDev->pszProduct = RTStrDup(szBuf); 1335 1291 } … … 1338 1294 if (cchRead > 0 && (size_t) cchRead < sizeof(szBuf)) 1339 1295 { 1340 usbPurgeEncoding(szBuf);1296 USBLibPurgeEncoding(szBuf); 1341 1297 pDev->pszSerialNumber = RTStrDup(szBuf); 1342 1298 pDev->u64SerialHash = USBLibHashSerial(szBuf); … … 1346 1302 if (cchRead > 0 && (size_t) cchRead < sizeof(szBuf)) 1347 1303 { 1348 usbPurgeEncoding(szBuf);1304 USBLibPurgeEncoding(szBuf); 1349 1305 pDev->pszManufacturer = RTStrDup(szBuf); 1350 1306 }
Note:
See TracChangeset
for help on using the changeset viewer.