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
+1 -1
View File
@@ -34,7 +34,7 @@ ntester_LDADD = ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ..
benchmark_SOURCES = benchmark.cc
benchmark_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I../protobufs -I$(srcdir)/../frontend -I$(srcdir)/../crypto $(BOOST_CPPFLAGS) -I$(srcdir)/../network
benchmark_LDADD = ../frontend/terminaloverlay.o ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../protobufs/libmoshprotos.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a -lutil -lm $(BOOST_LDFLAGS) $(protobuf_LIBS)
benchmark_LDADD = ../frontend/terminaloverlay.o ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../protobufs/libmoshprotos.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../util/libmoshutil.a -lutil -lm $(BOOST_LDFLAGS) $(protobuf_LIBS)
if COND_THIRD_LIBSTDDJB
benchmark_CPPFLAGS += -I$(top_srcdir)/third/libstddjb
benchmark_LDADD += $(top_builddir)/third/libstddjb/libstddjb.a
+3 -11
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,6 +46,7 @@ extern "C" {
#include "completeterminal.h"
#include "user.h"
#include "terminaloverlay.h"
#include "locale_utils.h"
const int ITERATIONS = 100000;
@@ -63,16 +63,8 @@ int main( void )
Complete local_terminal( 80, 24 );
/* Adopt native 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();
for ( int i = 0; i < ITERATIONS; i++ ) {
/* type a character */
+3 -10
View File
@@ -26,7 +26,6 @@
#include <poll.h>
#include <string.h>
#include <locale.h>
#include <langinfo.h>
#include <wchar.h>
#include <assert.h>
#include <wctype.h>
@@ -41,6 +40,7 @@
#include "parser.h"
#include "swrite.h"
#include "locale_utils.h"
const size_t buf_size = 1024;
@@ -55,15 +55,8 @@ int main( int argc __attribute__((unused)),
int master;
struct termios saved_termios, raw_termios, child_termios;
if ( NULL == setlocale( LC_ALL, "" ) ) {
perror( "setlocale" );
exit( 1 );
}
if ( strcmp( nl_langinfo( CODESET ), "UTF-8" ) != 0 ) {
fprintf( stderr, "stm requires a UTF-8 locale.\n" );
exit( 1 );
}
set_native_locale();
assert_utf8_locale();
if ( tcgetattr( STDIN_FILENO, &saved_termios ) < 0 ) {
perror( "tcgetattr" );
+3 -10
View File
@@ -26,7 +26,6 @@
#include <poll.h>
#include <string.h>
#include <locale.h>
#include <langinfo.h>
#include <wchar.h>
#include <assert.h>
#include <wctype.h>
@@ -50,6 +49,7 @@
#include "completeterminal.h"
#include "swrite.h"
#include "fatal_assert.h"
#include "locale_utils.h"
extern "C" {
#include "selfpipe.h"
@@ -64,15 +64,8 @@ int main( void )
int master;
struct termios saved_termios, raw_termios, child_termios;
if ( NULL == setlocale( LC_ALL, "" ) ) {
perror( "setlocale" );
exit( 1 );
}
if ( strcmp( nl_langinfo( CODESET ), "UTF-8" ) != 0 ) {
fprintf( stderr, "stm requires a UTF-8 locale.\n" );
exit( 1 );
}
set_native_locale();
assert_utf8_locale();
if ( tcgetattr( STDIN_FILENO, &saved_termios ) < 0 ) {
perror( "tcgetattr" );