diff options
author | 2013-04-19 10:21:36 -0700 | |
---|---|---|
committer | 2013-04-19 10:24:33 -0700 | |
commit | 6b602a45890e10d990479bb87330967e0564c8e0 (patch) | |
tree | e136bc3436eedb1c85e9124a19b40af86b10ef5d | |
parent | 084542b943f067ca2a24a512807480353e6db073 (diff) |
Minor cleanup in syntax highlighting
-rw-r--r-- | highlight.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/highlight.cpp b/highlight.cpp index 488d7517..a084d8c9 100644 --- a/highlight.cpp +++ b/highlight.cpp @@ -1331,7 +1331,7 @@ void highlight_shell(const wcstring &buff, std::vector<int> &color, size_t pos, wchar_t * const subbuff = wcsdup(buff.c_str()); wchar_t * subpos = subbuff; - int done=0; + bool done = false; while (1) { @@ -1342,10 +1342,11 @@ void highlight_shell(const wcstring &buff, std::vector<int> &color, size_t pos, break; } + /* Note: This *end = 0 writes into subbuff! */ if (!*end) - done=1; + done = true; else - *end=0; + *end = 0; //our subcolors start at color + (begin-subbuff)+1 size_t start = begin - subbuff + 1, len = wcslen(begin + 1); @@ -1377,10 +1378,12 @@ void highlight_shell(const wcstring &buff, std::vector<int> &color, size_t pos, int last_val=0; for (size_t i=0; i < buff.size(); i++) { - if (color.at(i) >= 0) - last_val = color.at(i); - else - color.at(i) = last_val; + int ¤t_val = color.at(i); + if (current_val >= 0) { + last_val = current_val; + } else { + current_val = last_val; //note - this writes into the vector + } } /* |