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
+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" );