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

Unified Diff: installer/src/installer-lib/process.cpp

Issue 4790070691233792: Case-insensitive string class (Closed)
Patch Set: Created March 30, 2014, 7:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: installer/src/installer-lib/process.cpp
===================================================================
--- a/installer/src/installer-lib/process.cpp
+++ b/installer/src/installer-lib/process.cpp
@@ -8,91 +8,6 @@
#include "process.h"
//-------------------------------------------------------
-// process_by_name_CI
-//-------------------------------------------------------
-process_by_name_CI::process_by_name_CI( const wchar_t * name )
- : name( name ), length( wcslen( name ) )
-{}
-
-bool process_by_name_CI::operator()( const PROCESSENTRY32W & process )
-{
- return 0 == wcsncmpi( process.szExeFile, name, length ) ;
-}
-
-//-------------------------------------------------------
-// process_by_any_exe_name_CI
-//-------------------------------------------------------
-bool process_by_any_exe_name_CI::operator()( const PROCESSENTRY32W & process )
-{
- return names.find( process.szExeFile ) != names.end() ;
-}
-
-//-------------------------------------------------------
-// wcscmpi
-//-------------------------------------------------------
-int wcscmpi( const wchar_t * s1, const wchar_t * s2 )
-{
- // Note: Equality of character sequences is case-insensitive in all predicates below.
- // Loop invariant: s1[0..j) == s2[0..j)
- const size_t LIMIT( 65535 ) ; // Runaway limit of 2^16 - 1 should be acceptably long.
- for ( size_t j = 0 ; j < LIMIT ; ++j )
- {
- wchar_t c1 = towupper( *s1++ ) ;
- wchar_t c2 = towupper( *s2++ ) ;
- if ( c1 != c2 )
- {
- // Map to -1/+1 because c2 - c1 may not fit into an 'int'.
- return ( c1 < c2 ) ? -1 : 1 ;
- }
- else
- {
- if ( c1 == L'\0' )
- {
- // Assert length( s1 ) == length( s2 ) == j
- // Assert strings are equal at length < n
- return 0 ;
- }
- }
- }
- // Assert j == LIMIT
- // Assert s1[0..LIMIT) == s2[0..LIMIT)
- // Both strings are longer than 64K, which violates the precondition
- throw std::runtime_error( "String arguments too long for wcscmpi" ) ;
-}
-
-//-------------------------------------------------------
-// wcsncmpi
-//-------------------------------------------------------
-int wcsncmpi( const wchar_t * s1, const wchar_t * s2, unsigned int n )
-{
- // Note: Equality of character sequences is case-insensitive in all predicates below.
- // Loop invariant: s1[0..j) == s2[0..j)
- for ( unsigned int j = 0 ; j < n ; ++j )
- {
- wchar_t c1 = towupper( *s1++ ) ;
- wchar_t c2 = towupper( *s2++ ) ;
- if ( c1 != c2 )
- {
- // Map to -1/+1 because c2 - c1 may not fit into an 'int'.
- return ( c1 < c2 ) ? -1 : 1 ;
- }
- else
- {
- if ( c1 == L'\0' )
- {
- // Assert length( s1 ) == length( s2 ) == j
- // Assert strings are equal at length < n
- return 0 ;
- }
- }
- }
- // Assert j == n
- // Assert s1[0..n) == s2[0..n)
- // The semantics of n-compare ignore everything after the first 'n' characters.
- return 0 ;
-}
-
-//-------------------------------------------------------
// creator_process
//-------------------------------------------------------
DWORD creator_process( HWND window )
@@ -132,7 +47,6 @@
handle = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ;
}
-
//-------------------------------------------------------
// send_message, send_endsession_messages
//-------------------------------------------------------

Powered by Google App Engine
This is Rietveld