]> git.tdb.fi Git - libs/core.git/blobdiff - source/console.cpp
Style update: spaces around assignments
[libs/core.git] / source / console.cpp
index f606a09fcceb64406500dac6c00d9b532b108244..e860436bc4ea6c8b7150b5634ebb805c5a390010 100644 (file)
@@ -30,17 +30,17 @@ Console::Console(unsigned n)
        if(n>2)
                throw InvalidParameterValue("Invalid parameter for Console::Console");
 
-       mode=(n==0 ? M_READ : M_WRITE);
+       mode = (n==0 ? M_READ : M_WRITE);
 
 #ifdef WIN32
        switch(n)
        {
-       case 0: handle=GetStdHandle(STD_INPUT_HANDLE); break;
-       case 1: handle=GetStdHandle(STD_OUTPUT_HANDLE); break;
-       case 2: handle=GetStdHandle(STD_ERROR_HANDLE); break;
+       case 0: handle = GetStdHandle(STD_INPUT_HANDLE); break;
+       case 1: handle = GetStdHandle(STD_OUTPUT_HANDLE); break;
+       case 2: handle = GetStdHandle(STD_ERROR_HANDLE); break;
        }
 #else
-       handle=n;
+       handle = n;
 
        if(handle==0)
                tcgetattr(handle, &orig_attr);
@@ -64,8 +64,8 @@ void Console::set_block(bool b)
        // XXX Dunno how to do this in win32
        (void)b;
 #else
-       int flags=fcntl(0, F_GETFL);
-       flags=(flags&~O_NONBLOCK) | (b?0:O_NONBLOCK);
+       int flags = fcntl(0, F_GETFL);
+       flags = (flags&~O_NONBLOCK) | (b?0:O_NONBLOCK);
        fcntl(0, F_SETFL, flags);
 #endif
 }
@@ -82,7 +82,7 @@ void Console::set_local_echo(bool e)
 #else
        termios t;
        tcgetattr(0, &t);
-       t.c_lflag=(t.c_lflag&~ECHO) | (e?ECHO:0);
+       t.c_lflag = (t.c_lflag&~ECHO) | (e?ECHO:0);
        tcsetattr(0, TCSADRAIN, &t);
 #endif
 }
@@ -100,7 +100,7 @@ void Console::set_line_buffer(bool l)
        // XXX ICANON does more than just set line buffering, may need a bit more thought
        termios t;
        tcgetattr(0, &t);
-       t.c_lflag=(t.c_lflag&~ICANON) | (l?ICANON:0);
+       t.c_lflag = (t.c_lflag&~ICANON) | (l?ICANON:0);
        tcsetattr(0, TCSADRAIN, &t);
 #endif
 }
@@ -112,13 +112,13 @@ void Console::get_size(unsigned &rows, unsigned &cols)
 
 #ifdef WIN32
        // XXX Figure out how to do this
-       rows=24;
-       cols=80;
+       rows = 24;
+       cols = 80;
 #else
        struct winsize wsz;
        ioctl(handle, TIOCGWINSZ, &wsz);
-       rows=wsz.ws_row;
-       cols=wsz.ws_col;
+       rows = wsz.ws_row;
+       cols = wsz.ws_col;
 #endif
 }
 
@@ -137,7 +137,7 @@ unsigned Console::do_write(const char *buf, unsigned len)
        if(!WriteFile(handle, buf, len, &ret, 0))
                throw SystemError("Writing to console failed", GetLastError());
 #else
-       int ret=::write(handle, buf, len);
+       int ret = ::write(handle, buf, len);
        if(ret==-1)
                throw SystemError("Writing to console failed", errno);
 #endif
@@ -155,7 +155,7 @@ unsigned Console::do_read(char *buf, unsigned len)
        if(!ReadFile(handle, buf, len, &ret, 0))
                throw SystemError("Reading from console failed", GetLastError());
 #else
-       int ret=::read(handle, buf, len);
+       int ret = ::read(handle, buf, len);
        if(ret==-1)
        {
                if(errno==EAGAIN)
@@ -164,7 +164,7 @@ unsigned Console::do_read(char *buf, unsigned len)
                        throw SystemError("Reading from console failed", errno);
        }
        else if(ret==0)
-               eof_flag=true;
+               eof_flag = true;
 #endif
 
        return ret;
@@ -186,9 +186,9 @@ Console &Console::instance(unsigned n)
        throw InvalidParameterValue("Unknown Console instance requested");
 }
 
-Console &cin=Console::instance(0);
-Console &cout=Console::instance(1);
-Console &cerr=Console::instance(2);
+Console &cin = Console::instance(0);
+Console &cout = Console::instance(1);
+Console &cerr = Console::instance(2);
 
 } // namespace IO
 } // namespace Msp