From 73a21b6f495e16707ede460a2c9d8f1474bb4d93 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 9 Jun 2011 13:21:27 +0300 Subject: [PATCH] Style update: spaces around assignments --- source/base.cpp | 6 ++-- source/buffered.cpp | 46 +++++++++++++------------- source/console.cpp | 38 ++++++++++----------- source/eventdispatcher.cpp | 12 +++---- source/file.cpp | 68 +++++++++++++++++++------------------- source/file.h | 8 ++--- source/filtered.h | 6 ++-- source/memory.cpp | 38 ++++++++++----------- source/mode.h | 12 +++---- source/pipe.cpp | 56 +++++++++++++++---------------- source/poll.cpp | 54 +++++++++++++++--------------- source/poll.h | 10 +++--- source/utils.cpp | 4 +-- 13 files changed, 179 insertions(+), 179 deletions(-) diff --git a/source/base.cpp b/source/base.cpp index 4556b73..3c9923d 100644 --- a/source/base.cpp +++ b/source/base.cpp @@ -21,10 +21,10 @@ bool Base::getline(string &line) while(1) { - int c=get(); + int c = get(); if(c==-1 || c=='\n') break; - line+=c; + line += c; } return !eof_flag || !line.empty(); @@ -59,7 +59,7 @@ Base::Base(): void Base::set_events(PollEvent e) { - events=e; + events = e; signal_events_changed.emit(events); } diff --git a/source/buffered.cpp b/source/buffered.cpp index 32688db..b8a2dbe 100644 --- a/source/buffered.cpp +++ b/source/buffered.cpp @@ -22,7 +22,7 @@ Buffered::Buffered(Base &b, unsigned s): end(buf), cur_op(M_NONE) { - mode=below.get_mode(); + mode = below.get_mode(); below.signal_flush_required.connect(sigc::mem_fun(this, &Buffered::flush)); } @@ -32,7 +32,7 @@ unsigned Buffered::put(char c) if(end(end-begin), size); + len = min(static_cast(end-begin), size); memcpy(data, begin, len); - begin+=len; - ret+=len; + begin += len; + ret += len; } else // Read the rest directly from the underlying object - ret+=below.read(data, size); + ret += below.read(data, size); - eof_flag=(below.eof() && begin==end); + eof_flag = (below.eof() && begin==end); return ret; } diff --git a/source/console.cpp b/source/console.cpp index f606a09..e860436 100644 --- a/source/console.cpp +++ b/source/console.cpp @@ -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 diff --git a/source/eventdispatcher.cpp b/source/eventdispatcher.cpp index d7e367c..02330ec 100644 --- a/source/eventdispatcher.cpp +++ b/source/eventdispatcher.cpp @@ -17,12 +17,12 @@ EventDispatcher::EventDispatcher() void EventDispatcher::add(Base &obj) { - SlotMap::iterator i=objects.find(&obj); + SlotMap::iterator i = objects.find(&obj); if(i==objects.end()) { - i=objects.insert(SlotMap::value_type(&obj, Slot(&obj))).first; - i->second.evch_conn=obj.signal_events_changed.connect(sigc::bind(sigc::mem_fun(this, &EventDispatcher::object_events_changed), &obj)); - i->second.del_conn=obj.signal_deleted.connect(sigc::bind(sigc::mem_fun(this, &EventDispatcher::object_deleted), &obj)); + i = objects.insert(SlotMap::value_type(&obj, Slot(&obj))).first; + i->second.evch_conn = obj.signal_events_changed.connect(sigc::bind(sigc::mem_fun(this, &EventDispatcher::object_events_changed), &obj)); + i->second.del_conn = obj.signal_deleted.connect(sigc::bind(sigc::mem_fun(this, &EventDispatcher::object_deleted), &obj)); if(obj.get_events()) poller.set_object(obj, obj.get_events()); @@ -31,7 +31,7 @@ void EventDispatcher::add(Base &obj) void EventDispatcher::remove(Base &obj) { - SlotMap::iterator i=objects.find(&obj); + SlotMap::iterator i = objects.find(&obj); if(i!=objects.end()) { i->second.evch_conn.disconnect(); @@ -72,7 +72,7 @@ void EventDispatcher::object_deleted(Base *obj) void EventDispatcher::dispatch() { - const Poller::SlotSeq &result=poller.get_result(); + const Poller::SlotSeq &result = poller.get_result(); for(Poller::SlotSeq::const_iterator i=result.begin(); i!=result.end(); ++i) i->object->event(i->events); } diff --git a/source/file.cpp b/source/file.cpp index 6ef3388..0b153cf 100644 --- a/source/file.cpp +++ b/source/file.cpp @@ -34,62 +34,62 @@ File::File(const string &fn, Mode m, CreateMode cm) if(cm&~(C_CREATE|C_TRUNCATE)) throw InvalidParameterValue("Invalid create mode"); - mode=m; + mode = m; #ifdef WIN32 - int flags=0; - int create_flags=OPEN_EXISTING; + int flags = 0; + int create_flags = OPEN_EXISTING; if(mode&M_READ) - flags|=GENERIC_READ; + flags |= GENERIC_READ; else if(mode&M_WRITE) { - flags|=GENERIC_WRITE; + flags |= GENERIC_WRITE; switch(static_cast(cm)) { - case C_NONE: create_flags=OPEN_EXISTING; break; - case C_CREATE: create_flags=OPEN_ALWAYS; break; - case C_TRUNCATE: create_flags=TRUNCATE_EXISTING; break; - case C_CREATE+C_TRUNCATE: create_flags=CREATE_ALWAYS; break; + case C_NONE: create_flags = OPEN_EXISTING; break; + case C_CREATE: create_flags = OPEN_ALWAYS; break; + case C_TRUNCATE: create_flags = TRUNCATE_EXISTING; break; + case C_CREATE+C_TRUNCATE: create_flags = CREATE_ALWAYS; break; } } - handle=CreateFile(fn.c_str(), flags, 0, 0, create_flags, FILE_ATTRIBUTE_NORMAL, 0); + handle = CreateFile(fn.c_str(), flags, 0, 0, create_flags, FILE_ATTRIBUTE_NORMAL, 0); if(handle==INVALID_HANDLE_VALUE) { - int err=GetLastError(); + int err = GetLastError(); if(err==ERROR_FILE_NOT_FOUND) throw FileNotFound("Can't find file "+fn, fn); else throw SystemError(format("Can't open file '%s'", fn), GetLastError()); } #else - int flags=0; + int flags = 0; switch(mode&M_RDWR) { - case M_READ: flags|=O_RDONLY; break; - case M_WRITE: flags|=O_WRONLY; break; - case M_RDWR: flags|=O_RDWR; break; + case M_READ: flags |= O_RDONLY; break; + case M_WRITE: flags |= O_WRONLY; break; + case M_RDWR: flags |= O_RDWR; break; default:; } if(mode&M_WRITE) { if(cm&C_CREATE) - flags|=O_CREAT; + flags |= O_CREAT; if(cm&C_TRUNCATE) - flags|=O_TRUNC; + flags |= O_TRUNC; } if(mode&M_APPEND) - flags|=O_APPEND; + flags |= O_APPEND; if(mode&M_NONBLOCK) - flags|=O_NONBLOCK; + flags |= O_NONBLOCK; - handle=::open(fn.c_str(), flags, 0666); + handle = ::open(fn.c_str(), flags, 0666); if(handle==-1) { - int err=errno; + int err = errno; if(err==ENOENT) throw FileNotFound("Can't find file "+fn, fn); else @@ -119,7 +119,7 @@ void File::close() ::close(handle); #endif - handle=MSP_IO_INVALID_HANDLE; + handle = MSP_IO_INVALID_HANDLE; signal_closed.emit(); } @@ -131,11 +131,11 @@ void File::set_block(bool b) { check_access(M_NONE); - mode=(mode&~M_NONBLOCK); + mode = (mode&~M_NONBLOCK); if(b) - mode=(mode|M_NONBLOCK); + mode = (mode|M_NONBLOCK); #ifndef WIN32 - int flags=fcntl(handle, F_GETFD); + int flags = fcntl(handle, F_GETFD); fcntl(handle, F_SETFL, (flags&O_NONBLOCK)|(b?0:O_NONBLOCK)); #endif } @@ -163,18 +163,18 @@ int File::seek(int off, SeekType st) signal_flush_required.emit(); - int type=sys_seek_type(st); + int type = sys_seek_type(st); #ifdef WIN32 - DWORD ret=SetFilePointer(handle, off, 0, type); + DWORD ret = SetFilePointer(handle, off, 0, type); if(ret==INVALID_SET_FILE_POINTER) throw SystemError("Seek failed", GetLastError()); #else - int ret=lseek(handle, off, type); + int ret = lseek(handle, off, type); if(ret==-1) throw SystemError("Seek failed", errno); #endif - eof_flag=false; + eof_flag = false; return ret; } @@ -187,11 +187,11 @@ int File::tell() const check_access(M_NONE); #ifdef WIN32 - DWORD ret=SetFilePointer(handle, 0, 0, FILE_CURRENT); + DWORD ret = SetFilePointer(handle, 0, 0, FILE_CURRENT); if(ret==INVALID_SET_FILE_POINTER) throw SystemError("Tell failed", GetLastError()); #else - int ret=lseek(handle, 0, SEEK_CUR); + int ret = lseek(handle, 0, SEEK_CUR); if(ret==-1) throw SystemError("Tell failed", errno); #endif @@ -236,7 +236,7 @@ unsigned File::do_write(const char *buf, unsigned size) if(WriteFile(handle, buf, size, &ret, 0)==0) throw SystemError("Writing to file failed", GetLastError()); #else - int ret=::write(handle, buf, size); + int ret = ::write(handle, buf, size); if(ret==-1) { if(errno==EAGAIN) @@ -269,7 +269,7 @@ unsigned File::do_read(char *buf, unsigned size) if(ReadFile(handle, buf, size, &ret, 0)==0) throw SystemError("Reading from file failed", GetLastError()); #else - int ret=::read(handle, buf, size); + int ret = ::read(handle, buf, size); if(ret==-1) { if(errno==EAGAIN) @@ -281,7 +281,7 @@ unsigned File::do_read(char *buf, unsigned size) if(ret==0) { - eof_flag=true; + eof_flag = true; signal_end_of_file.emit(); } diff --git a/source/file.h b/source/file.h index 4e86e29..16f2dcb 100644 --- a/source/file.h +++ b/source/file.h @@ -26,12 +26,12 @@ class File: public Base public: enum CreateMode { - C_NONE=0, - C_CREATE=1, - C_TRUNCATE=2 + C_NONE = 0, + C_CREATE = 1, + C_TRUNCATE = 2 }; - File(const std::string &, Mode=M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE)); + File(const std::string &, Mode = M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE)); void close(); diff --git a/source/filtered.h b/source/filtered.h index e3ff219..ff8577a 100644 --- a/source/filtered.h +++ b/source/filtered.h @@ -19,8 +19,8 @@ private: { Filtered &f; - Activator(Filtered &f_): f(f_) { f.active=true; } - ~Activator() { f.active=false; } + Activator(Filtered &f_): f(f_) { f.active = true; } + ~Activator() { f.active = false; } }; F filter; @@ -28,7 +28,7 @@ private: public: Filtered(): filter(*this), active(false) { } - ~Filtered() { active=true; } + ~Filtered() { active = true; } template Filtered(A0 a0): B(a0), filter(*this), active(false) { } diff --git a/source/memory.cpp b/source/memory.cpp index c44554a..80dde27 100644 --- a/source/memory.cpp +++ b/source/memory.cpp @@ -27,7 +27,7 @@ Memory::Memory(char *b, char *e) Memory::Memory(const char *cd, unsigned s) { - char *d=const_cast(cd); + char *d = const_cast(cd); init(d, d+s, M_READ); } @@ -38,25 +38,25 @@ Memory::Memory(const char *b, const char *e) void Memory::init(char *b, char *e, Mode m) { - begin=b; - end=e; - pos=begin; - mode=m; + begin = b; + end = e; + pos = begin; + mode = m; } unsigned Memory::put(char c) { check_mode(M_WRITE); - *pos++=c; + *pos++ = c; return 1; } bool Memory::getline(string &line) { - char *nl=find(pos, end, '\n'); + char *nl = find(pos, end, '\n'); line.assign(pos, nl); - bool result=(nl!=pos); - pos=nl; + bool result = (nl!=pos); + pos = nl; return result; } @@ -64,7 +64,7 @@ int Memory::get() { if(pos==end) { - eof_flag=true; + eof_flag = true; return -1; } @@ -75,18 +75,18 @@ unsigned Memory::seek(int off, SeekType type) { char *new_pos; if(type==S_BEG) - new_pos=begin+off; + new_pos = begin+off; else if(type==S_CUR) - new_pos=pos+off; + new_pos = pos+off; else if(type==S_END) - new_pos=end+off; + new_pos = end+off; else throw InvalidParameterValue("Invalid seek type"); if(new_posend) throw InvalidParameterValue("Invalid seek offset"); - pos=new_pos; + pos = new_pos; return pos-begin; } @@ -99,9 +99,9 @@ unsigned Memory::do_write(const char *buf, unsigned size) { check_mode(M_WRITE); - size=min(size, end-pos); + size = min(size, end-pos); memcpy(pos, buf, size); - pos+=size; + pos += size; return size; } @@ -109,13 +109,13 @@ unsigned Memory::do_read(char *buf, unsigned size) { if(pos==end) { - eof_flag=true; + eof_flag = true; return 0; } - size=min(size, end-pos); + size = min(size, end-pos); memcpy(buf, pos, size); - pos+=size; + pos += size; return size; } diff --git a/source/mode.h b/source/mode.h index c58ecb0..d807e5f 100644 --- a/source/mode.h +++ b/source/mode.h @@ -12,12 +12,12 @@ namespace IO { enum Mode { - M_NONE=0, - M_READ=1, - M_WRITE=2, - M_RDWR=M_READ|M_WRITE, - M_APPEND=4, - M_NONBLOCK=8 + M_NONE = 0, + M_READ = 1, + M_WRITE = 2, + M_RDWR = M_READ|M_WRITE, + M_APPEND = 4, + M_NONBLOCK = 8 }; inline Mode operator|(Mode m, Mode n) diff --git a/source/pipe.cpp b/source/pipe.cpp index 696abe5..bd90527 100644 --- a/source/pipe.cpp +++ b/source/pipe.cpp @@ -20,25 +20,25 @@ namespace IO { Pipe::Pipe() { #ifdef WIN32 - string name=format("\\\\.\\pipe\\%u.%p", GetCurrentProcessId(), this); - handle[0]=CreateNamedPipe(name.c_str(), PIPE_ACCESS_INBOUND|FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 1024, 1024, 0, 0); + string name = format("\\\\.\\pipe\\%u.%p", GetCurrentProcessId(), this); + handle[0] = CreateNamedPipe(name.c_str(), PIPE_ACCESS_INBOUND|FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 1024, 1024, 0, 0); if(handle[0]==INVALID_HANDLE_VALUE) throw SystemError("Unable to create pipe", GetLastError()); - handle[1]=CreateFile(name.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + handle[1] = CreateFile(name.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(handle[1]==INVALID_HANDLE_VALUE) { - unsigned err=GetLastError(); + unsigned err = GetLastError(); CloseHandle(handle[0]); throw SystemError("Unable to create pipe", err); } - overlapped=0; - event=CreateEvent(0, true, false, 0); - buf_size=1024; - buffer=new char[buf_size]; - buf_avail=0; - buf_next=buffer; + overlapped = 0; + event = CreateEvent(0, true, false, 0); + buf_size = 1024; + buffer = new char[buf_size]; + buf_avail = 0; + buf_next = buffer; #else if(pipe(handle)==-1) throw SystemError("Unable to create pipe", errno); @@ -49,14 +49,14 @@ Pipe::Pipe() void Pipe::set_block(bool b) { - mode=(mode&~M_NONBLOCK); + mode = (mode&~M_NONBLOCK); if(b) - mode=(mode|M_NONBLOCK); + mode = (mode|M_NONBLOCK); #ifndef WIN32 - int flags=fcntl(handle[0], F_GETFD); + int flags = fcntl(handle[0], F_GETFD); fcntl(handle[0], F_SETFL, (flags&O_NONBLOCK)|(b?0:O_NONBLOCK)); - flags=fcntl(handle[1], F_GETFD); + flags = fcntl(handle[1], F_GETFD); fcntl(handle[1], F_SETFL, (flags&O_NONBLOCK)|(b?0:O_NONBLOCK)); #endif } @@ -81,23 +81,23 @@ Handle Pipe::get_event_handle() #ifdef WIN32 if(!overlapped && !buf_avail) { - overlapped=new OVERLAPPED; + overlapped = new OVERLAPPED; memset(overlapped, 0, sizeof(OVERLAPPED)); - overlapped->hEvent=event; + overlapped->hEvent = event; DWORD ret; - buf_next=buffer; + buf_next = buffer; if(!ReadFile(handle[0], buffer, buf_size, &ret, overlapped)) { - unsigned err=GetLastError(); + unsigned err = GetLastError(); if(err!=ERROR_IO_PENDING) throw SystemError("Failed to start an overlapped read", err); } else { - buf_avail=ret; + buf_avail = ret; delete overlapped; - overlapped=0; + overlapped = 0; SetEvent(event); } } @@ -123,7 +123,7 @@ unsigned Pipe::do_write(const char *buf, unsigned size) if(!WriteFile(handle[1], buf, size, &ret, 0)) throw SystemError("Writing to pipe failed", GetLastError()); #else - int ret=::write(handle[1], buf, size); + int ret = ::write(handle[1], buf, size); if(ret==-1) { if(errno==EAGAIN) @@ -152,21 +152,21 @@ unsigned Pipe::do_read(char *buf, unsigned size) throw SystemError("Reading from pipe failed", GetLastError()); else { - buf_avail+=ret; + buf_avail += ret; delete overlapped; - overlapped=0; + overlapped = 0; } } - unsigned ret=min(buf_avail, size); + unsigned ret = min(buf_avail, size); memcpy(buf, buf_next, ret); - buf_next+=ret; - buf_avail-=ret; + buf_next += ret; + buf_avail -= ret; // Initiate another overlapped read in case someone is polling us get_event_handle(); #else - int ret=::read(handle[0], buf, size); + int ret = ::read(handle[0], buf, size); if(ret==-1) { if(errno==EAGAIN) @@ -178,7 +178,7 @@ unsigned Pipe::do_read(char *buf, unsigned size) if(ret==0) { - eof_flag=true; + eof_flag = true; signal_end_of_file.emit(); } diff --git a/source/poll.cpp b/source/poll.cpp index 659e238..49e4887 100644 --- a/source/poll.cpp +++ b/source/poll.cpp @@ -18,18 +18,18 @@ using namespace Msp::IO; inline int sys_poll_event(PollEvent event) { - int result=0; + int result = 0; if(event&~(P_INPUT|P_PRIO|P_OUTPUT)) throw InvalidParameterValue("Invalid poll events"); #ifndef WIN32 if(event&P_INPUT) - result|=POLLIN; + result |= POLLIN; if(event&P_PRIO) - result|=POLLPRI; + result |= POLLPRI; if(event&P_OUTPUT) - result|=POLLOUT; + result |= POLLOUT; #endif return result; @@ -37,20 +37,20 @@ inline int sys_poll_event(PollEvent event) inline PollEvent poll_event_from_sys(int event) { - PollEvent result=P_NONE; + PollEvent result = P_NONE; #ifdef WIN32 // Stop the compiler from complaining about unused parameter - event=event; + event = event; #else if(event&POLLIN) - result=result|P_INPUT; + result = result|P_INPUT; if(event&POLLPRI) - result=result|P_PRIO; + result = result|P_PRIO; if(event&POLLOUT) - result=result|P_OUTPUT; + result = result|P_OUTPUT; if(event&POLLERR) - result=result|P_ERROR; + result = result|P_ERROR; #endif return result; @@ -60,9 +60,9 @@ inline PollEvent do_poll(Base &obj, PollEvent pe, int timeout) { #ifdef WIN32 if(timeout<0) - timeout=INFINITE; + timeout = INFINITE; - DWORD ret=WaitForSingleObject(obj.get_event_handle(), timeout); + DWORD ret = WaitForSingleObject(obj.get_event_handle(), timeout); if(ret==WAIT_OBJECT_0) return pe; else if(ret==WAIT_FAILED) @@ -70,9 +70,9 @@ inline PollEvent do_poll(Base &obj, PollEvent pe, int timeout) return P_NONE; #else - pollfd pfd={obj.get_event_handle(), sys_poll_event(pe), 0}; + pollfd pfd = {obj.get_event_handle(), sys_poll_event(pe), 0}; - int ret=::poll(&pfd, 1, timeout); + int ret = ::poll(&pfd, 1, timeout); if(ret==-1) { if(errno==EINTR) @@ -100,15 +100,15 @@ void Poller::set_object(Base &obj, PollEvent ev) if(ev) obj.get_event_handle(); - SlotMap::iterator i=objects.find(&obj); + SlotMap::iterator i = objects.find(&obj); if(i!=objects.end()) { if(ev) - i->second.events=ev; + i->second.events = ev; else objects.erase(i); - pfd_dirty=true; + pfd_dirty = true; } else if(ev) { @@ -118,7 +118,7 @@ void Poller::set_object(Base &obj, PollEvent ev) #endif objects.insert(SlotMap::value_type(&obj, Slot(&obj, ev))); - pfd_dirty=true; + pfd_dirty = true; } } @@ -143,14 +143,14 @@ void Poller::rebuild_pfd() for(SlotMap::iterator i=objects.begin(); i!=objects.end(); ++i) { - p.fd=i->second.object->get_event_handle(); + p.fd = i->second.object->get_event_handle(); #ifndef WIN32 - p.events=sys_poll_event(i->second.events); + p.events = sys_poll_event(i->second.events); #endif pfd.push_back(p); } - pfd_dirty=false; + pfd_dirty = false; } int Poller::do_poll(int timeout) @@ -162,12 +162,12 @@ int Poller::do_poll(int timeout) #ifdef WIN32 if(timeout<0) - timeout=INFINITE; + timeout = INFINITE; - DWORD ret=WaitForMultipleObjects(pfd.size(), &pfd.front().fd, false, timeout); + DWORD ret = WaitForMultipleObjects(pfd.size(), &pfd.front().fd, false, timeout); if(/*ret>=WAIT_OBJECT_0 &&*/ retsecond.object, i->second.events)); @@ -178,7 +178,7 @@ int Poller::do_poll(int timeout) return 0; #else - int ret=::poll(&pfd.front(), pfd.size(), timeout); + int ret = ::poll(&pfd.front(), pfd.size(), timeout); if(ret==-1) { if(errno==EINTR) @@ -187,8 +187,8 @@ int Poller::do_poll(int timeout) throw SystemError("Poll failed", errno); } - int n=ret; - SlotMap::iterator j=objects.begin(); + int n = ret; + SlotMap::iterator j = objects.begin(); for(std::vector::iterator i=pfd.begin(); (i!=pfd.end() && n>0); ++i,++j) if(i->revents) { diff --git a/source/poll.h b/source/poll.h index 3bc1470..3566b92 100644 --- a/source/poll.h +++ b/source/poll.h @@ -23,11 +23,11 @@ class Base; enum PollEvent { - P_NONE=0, - P_INPUT=1, - P_PRIO=2, - P_OUTPUT=4, - P_ERROR=8 + P_NONE = 0, + P_INPUT = 1, + P_PRIO = 2, + P_OUTPUT = 4, + P_ERROR = 8 }; inline PollEvent operator|(PollEvent e, PollEvent f) diff --git a/source/utils.cpp b/source/utils.cpp index 8ce5bf3..1905fe0 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -12,9 +12,9 @@ namespace IO { unsigned read_all(Base &obj, char *buf, unsigned size) { - unsigned pos=0; + unsigned pos = 0; while(pos