Simplify wxMacConvertNewlines helper functions

One is not used at all, two are only used in one place. Make the remaining
two return a wxString instead of taking a wxString pointer parameter.
This commit is contained in:
Paul Cornett
2017-10-01 10:44:35 -07:00
parent 37e29d3451
commit 0b2ec56ae3
5 changed files with 29 additions and 61 deletions

View File

@@ -24,46 +24,17 @@
#include <CoreFoundation/CoreFoundation.h>
void wxMacConvertNewlines13To10( char * data )
{
char * buf = data ;
while( (buf=strchr(buf,0x0d)) != NULL )
{
*buf = 0x0a ;
buf++ ;
}
}
void wxMacConvertNewlines13To10( wxChar16 * data )
{
for ( ; *data; ++data )
{
if ( *data == 0x0d )
*data = 0x0a;
}
}
void wxMacConvertNewlines10To13( char * data )
{
char * buf = data ;
while( (buf=strchr(buf,0x0a)) != NULL )
{
*buf = 0x0d ;
buf++ ;
}
}
const wxString sCR((wxChar)13);
const wxString sLF((wxChar)10);
void wxMacConvertNewlines13To10( wxString * data )
wxString wxMacConvertNewlines13To10(const wxString& data)
{
data->Replace( sCR,sLF);
return wxString(data)->Replace(sCR, sLF);
}
void wxMacConvertNewlines10To13( wxString * data )
wxString wxMacConvertNewlines10To13(const wxString& data)
{
data->Replace( sLF,sCR);
return wxString(data)->Replace(sLF, sCR);
}
wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding)
@@ -614,8 +585,7 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN
}
else
{
wxString str = st ;
wxMacConvertNewlines13To10( &str ) ;
wxString str(wxMacConvertNewlines13To10(st));
#if wxUSE_UNICODE
#if wxUSE_UNICODE_WCHAR
// native = wchar_t 4 bytes for us
@@ -700,8 +670,7 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN
#endif
delete[] buf ;
wxMacConvertNewlines10To13( &result);
return result ;
return wxMacConvertNewlines10To13(result);
}
wxString wxCFStringRef::AsString(wxFontEncoding encoding) const