Formatting and style updates

This commit is contained in:
ridiculousfish 2013-05-05 02:33:17 -07:00
parent d4c881791f
commit 2da81b0ae7
18 changed files with 115 additions and 79 deletions

View file

@ -100,23 +100,46 @@ static int hex_to_bin(const wchar_t &c)
{ {
switch (c) switch (c)
{ {
case L'0': return 0; case L'0':
case L'1': return 1; return 0;
case L'2': return 2; case L'1':
case L'3': return 3; return 1;
case L'4': return 4; case L'2':
case L'5': return 5; return 2;
case L'6': return 6; case L'3':
case L'7': return 7; return 3;
case L'8': return 8; case L'4':
case L'9': return 9; return 4;
case L'a': case L'A': return 10; case L'5':
case L'b': case L'B': return 11; return 5;
case L'c': case L'C': return 12; case L'6':
case L'd': case L'D': return 13; return 6;
case L'e': case L'E': return 14; case L'7':
case L'f': case L'F': return 15; return 7;
default: return -1; case L'8':
return 8;
case L'9':
return 9;
case L'a':
case L'A':
return 10;
case L'b':
case L'B':
return 11;
case L'c':
case L'C':
return 12;
case L'd':
case L'D':
return 13;
case L'e':
case L'E':
return 14;
case L'f':
case L'F':
return 15;
default:
return -1;
} }
} }
@ -124,15 +147,24 @@ static int octal_to_bin(wchar_t c)
{ {
switch (c) switch (c)
{ {
case L'0': return 0; case L'0':
case L'1': return 1; return 0;
case L'2': return 2; case L'1':
case L'3': return 3; return 1;
case L'4': return 4; case L'2':
case L'5': return 5; return 2;
case L'6': return 6; case L'3':
case L'7': return 7; return 3;
default: return -1; case L'4':
return 4;
case L'5':
return 5;
case L'6':
return 6;
case L'7':
return 7;
default:
return -1;
} }
} }

View file

@ -49,7 +49,7 @@ enum
*/ */
struct event_t struct event_t
{ {
public: public:
/** Type of event */ /** Type of event */
int type; int type;

View file

@ -590,7 +590,8 @@ void exec(parser_t &parser, job_t *j)
CHECK(j,); CHECK(j,);
CHECK_BLOCK(); CHECK_BLOCK();
if (no_exec) { if (no_exec)
{
exec_no_exec(parser, j); exec_no_exec(parser, j);
return; return;
} }

View file

@ -1785,7 +1785,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
} }
else else
{ {
if (! (flags & ACCEPT_INCOMPLETE)) if (!(flags & ACCEPT_INCOMPLETE))
{ {
out->push_back(completion_t(next_str)); out->push_back(completion_t(next_str));
} }
@ -1793,7 +1793,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
} }
// Hack to un-expand tildes (see #647) // Hack to un-expand tildes (see #647)
if (! (flags & EXPAND_SKIP_HOME_DIRECTORIES)) if (!(flags & EXPAND_SKIP_HOME_DIRECTORIES))
{ {
unexpand_tildes(input, out); unexpand_tildes(input, out);
} }

View file

@ -1377,9 +1377,12 @@ void highlight_shell(const wcstring &buff, std::vector<int> &color, size_t pos,
for (size_t i=0; i < buff.size(); i++) for (size_t i=0; i < buff.size(); i++)
{ {
int &current_val = color.at(i); int &current_val = color.at(i);
if (current_val >= 0) { if (current_val >= 0)
{
last_val = current_val; last_val = current_val;
} else { }
else
{
current_val = last_val; //note - this writes into the vector current_val = last_val; //note - this writes into the vector
} }
} }

View file

@ -70,7 +70,7 @@ class history_output_buffer_t
return s ? strlen(s) : 0; return s ? strlen(s) : 0;
} }
public: public:
/* Add a bit more to HISTORY_OUTPUT_BUFFER_SIZE because we flush once we've exceeded that size */ /* Add a bit more to HISTORY_OUTPUT_BUFFER_SIZE because we flush once we've exceeded that size */
history_output_buffer_t() : buffer(HISTORY_OUTPUT_BUFFER_SIZE + 128, '\0'), offset(0) history_output_buffer_t() : buffer(HISTORY_OUTPUT_BUFFER_SIZE + 128, '\0'), offset(0)

12
io.h
View file

@ -3,13 +3,13 @@
#include <vector> #include <vector>
#if __cplusplus > 199711L #if __cplusplus > 199711L
// C++11 // C++11
#include <memory> #include <memory>
using std::shared_ptr; using std::shared_ptr;
#else #else
// C++03 // C++03
#include <tr1/memory> #include <tr1/memory>
using std::tr1::shared_ptr; using std::tr1::shared_ptr;
#endif #endif
/** /**

View file

@ -1006,7 +1006,7 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag
if (do_escape) if (do_escape)
{ {
/* Respect COMPLETE_DONT_ESCAPE_TILDES */ /* Respect COMPLETE_DONT_ESCAPE_TILDES */
bool no_tilde = !! (flags & COMPLETE_DONT_ESCAPE_TILDES); bool no_tilde = !!(flags & COMPLETE_DONT_ESCAPE_TILDES);
escaped = escape(val, ESCAPE_ALL | ESCAPE_NO_QUOTED | (no_tilde ? ESCAPE_NO_TILDE : 0)); escaped = escape(val, ESCAPE_ALL | ESCAPE_NO_QUOTED | (no_tilde ? ESCAPE_NO_TILDE : 0));
sb.append(escaped); sb.append(escaped);
move_cursor = wcslen(escaped); move_cursor = wcslen(escaped);

View file

@ -294,7 +294,7 @@ int make_fd_nonblocking(int fd)
{ {
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
int err = 0; int err = 0;
if (! (flags & O_NONBLOCK)) if (!(flags & O_NONBLOCK))
{ {
err = fcntl(fd, F_SETFL, flags | O_NONBLOCK); err = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
} }