diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-10-30 22:40:35 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-10-30 22:40:35 -0700 |
commit | a529fc9d83295fdf9418436b68d056162ba8231b (patch) | |
tree | 97cf66daca3b5e7efb927c7e37fc7515ec8b0ceb /tokenizer.cpp | |
parent | 173a6a71c03847158a434c3fd63e5759bf933239 (diff) |
Set of fixes for issues identified by cppcheck
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 67b35fff..980cac4c 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -136,42 +136,6 @@ int tok_has_next(tokenizer_t *tok) return tok->has_next; } -int tokenizer_t::line_number_of_character_at_offset(size_t offset) -{ - // we want to return (one plus) the number of newlines at offsets less than the given offset - // cached_lineno_count is the number of newlines at indexes less than cached_lineno_offset - const wchar_t *str = orig_buff; - if (! str) - return 0; - - // easy hack to handle 0 - if (offset == 0) - return 1; - - size_t i; - if (offset > cached_lineno_offset) - { - for (i = cached_lineno_offset; str[i] && i<offset; i++) - { - /* Add one for every newline we find in the range [cached_lineno_offset, offset) */ - if (str[i] == L'\n') - cached_lineno_count++; - } - cached_lineno_offset = i; //note: i, not offset, in case offset is beyond the length of the string - } - else if (offset < cached_lineno_offset) - { - /* Subtract one for every newline we find in the range [offset, cached_lineno_offset) */ - for (i = offset; i < cached_lineno_offset; i++) - { - if (str[i] == L'\n') - cached_lineno_count--; - } - cached_lineno_offset = offset; - } - return cached_lineno_count + 1; -} - /** Tests if this character can be a part of a string. The redirect ^ is allowed unless it's the first character. */ |