Move some locale handling into one place

This commit is contained in:
Keegan McAllister
2012-03-14 07:10:54 -04:00
committed by Keith Winstein
parent 705dcb6483
commit 7ed5174aa7
11 changed files with 90 additions and 55 deletions
+2 -4
View File
@@ -24,6 +24,7 @@
#include "stmclient.h"
#include "crypto.h"
#include "locale_utils.h"
/* these need to be included last because of conflicting defines */
#include <curses.h>
@@ -106,10 +107,7 @@ int main( int argc, char *argv[] )
}
/* Adopt native locale */
if ( NULL == setlocale( LC_ALL, "" ) ) {
perror( "setlocale" );
exit( 1 );
}
set_native_locale();
try {
STMClient client( ip, port, key, predict_mode );
+3 -11
View File
@@ -21,7 +21,6 @@
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <langinfo.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
@@ -49,6 +48,7 @@ extern "C" {
#include "swrite.h"
#include "user.h"
#include "fatal_assert.h"
#include "locale_utils.h"
#if HAVE_PTY_H
#include <pty.h>
@@ -196,16 +196,8 @@ int main( int argc, char *argv[] )
}
/* Adopt implementation locale */
if ( NULL == setlocale( LC_ALL, "" ) ) {
perror( "setlocale" );
exit( 1 );
}
/* Verify locale calls for UTF-8 */
if ( strcmp( nl_langinfo( CODESET ), "UTF-8" ) != 0 ) {
fprintf( stderr, "mosh requires a UTF-8 locale.\n" );
exit( 1 );
}
set_native_locale();
assert_utf8_locale();
try {
return run_server( desired_ip, desired_port, command, colors );
+2 -6
View File
@@ -21,7 +21,6 @@
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <langinfo.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,16 +46,13 @@ extern "C" {
#include "completeterminal.h"
#include "user.h"
#include "fatal_assert.h"
#include "locale_utils.h"
#include "networktransport.cc"
void STMClient::init( void )
{
/* Verify locale calls for UTF-8 */
if ( strcmp( nl_langinfo( CODESET ), "UTF-8" ) != 0 ) {
fprintf( stderr, "mosh requires a UTF-8 locale.\n" );
exit( 1 );
}
assert_utf8_locale();
/* Verify terminal configuration */
if ( tcgetattr( STDIN_FILENO, &saved_termios ) < 0 ) {