Commit Graph

54 Commits

Author SHA1 Message Date
Allan Odgaard
69c83e56df The ‘const’ keyword should be to the right of its type
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.

E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
2014-03-31 08:27:19 +07:00
Allan Odgaard
db13d4c1f9 Use std::string::back() instead of operator[] with size()-1 2014-03-31 08:27:18 +07:00
Allan Odgaard
c7ae7d1337 Add test for snippets with overlapping fields
See 4e1cdb4c9e for details.
2014-03-07 00:10:35 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
1781f4a605 Use proper iterate macro for temporary 2014-03-03 00:20:02 +07:00
Allan Odgaard
d843225d81 Lines increasing and decreasing indent no longer go below zero
Normally a line matched by both patterns will be decreased by one unit compared to the non-ignored lines immediately above and below. If however the line above was not indented, the line would in theory be decreased to -1 and thus just go back to zero indent for the line following it.
2013-11-08 00:38:53 +01:00
Allan Odgaard
558d7ee8b9 Don’t default placeholders with no default text as mirrors 2013-10-04 16:51:27 +02:00
Allan Odgaard
c5558d0574 Remove a few std::shared_ptr typedefs 2013-10-04 16:51:26 +02:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
27c054484e Allow “stop chars” when parsing a format string
This is useful when we have a format that embed format strings and we wish to use the format string parsers (to avoid an extra layer of escapes).
2013-08-28 15:27:42 +02:00
Allan Odgaard
e1230653f8 Support hex characters in format strings 2013-08-27 15:30:09 +02:00
Allan Odgaard
64663dd17f Allow creating non-capturing regexps 2013-08-25 21:13:06 +02:00
Allan Odgaard
36c5ff4288 Support ${var} in regexp part of format string transformations 2013-08-24 20:28:16 +02:00
Allan Odgaard
1e27f6bf47 Add ONIG_OPTION_NOTGPOS 2013-08-18 17:29:30 +02:00
Allan Odgaard
7350192d51 DFA nodes themselves should not dispose children
A DFA node may be disposed as part of DFA construction (because the node is redundant) and here it would have “next” pointers setup, which it should not follow in its destructor, since those nodes could still be used.

Fixes #1086
2013-08-14 10:41:30 +02:00
Allan Odgaard
5512d65ecf Remove some commented debug output blocks 2013-08-12 22:57:57 +02:00
Allan Odgaard
f7b9694e9f Fix linear destruction of DFA
This is a graph (not a tree) so we have to watch for cycles.
2013-08-12 22:57:57 +02:00
Allan Odgaard
a74bfcc206 Remove some uses of foreach() 2013-08-12 19:32:23 +02:00
Allan Odgaard
f008c49dab Dispose tree structure bottom-up to limit stack usage
With really long search strings, the recursive disposal of nodes would blow the stack
2013-08-10 13:14:55 +02:00
Allan Odgaard
267471d7bb Account for multi-byte characters when moving search position
Fixes #1070
2013-07-31 20:24:16 +02:00
Allan Odgaard
1467a0b44b Update testing system for regexp framework 2013-07-26 13:53:58 +02:00
Allan Odgaard
27eee5ed59 Remove oniguruma 5.9.2 files 2013-07-21 13:25:29 +02:00
Allan Odgaard
e0c7a3df57 Switch regexp library: oniguruma → onigmo 2013-07-21 13:25:29 +02:00
Allan Odgaard
81d065ab8e Use oniguruma’s default character type (OnigUChar)
This introduces a bunch of typecasts but means that less patching is required when updating the library.
2013-07-21 13:25:28 +02:00
Allan Odgaard
8987f3e483 Remove unused function: pattern_t::indices_for_group 2013-07-21 13:25:28 +02:00
Allan Odgaard
e49504a644 Remove unused member data 2013-05-06 14:51:32 +07:00
Allan Odgaard
45dc49eb29 Retire compiler workaround
Previously we could get a compiler error when using std::map<std::string, std::string>() as a default argument.
2013-03-16 17:49:49 +01:00
Allan Odgaard
0075b46c82 Introduce zeroIndentPattern
This will give the matched lines zero indent but without affecting the following lines.

Probably the only use-case for this is C preprocessor directives.
2013-03-13 12:38:12 +01:00
Allan Odgaard
d16f3bcc1e Use per-line indent patterns when estimating indent
This solves the problem where we need to estimate the current line’s indent, but the lines above it is a multi-line block comment. Previously we would fetch indent patterns based on the current scope, then find the first line above caret, for which the patterns can be used to estimate the indent. The problem is that the commented lines without comment markers would be treated as code, and used for the indent.

With the new approach, we can set different patterns for ‘comment.block’ (the C bundle already does this), which basically ignore all the lines, which will cause TextMate to use the code above the comment to estimate indent.

This commit closes textmate/c.tmbundle#3 and also closes textmate/php.tmbundle#24.
2013-03-13 12:38:12 +01:00
Allan Odgaard
b139ac5097 Change push_back → emplace_back (C++11)
This is mainly motivated by readability, so I only did a few select replacements.
2013-02-08 11:20:35 +01:00
Allan Odgaard
9eb4044fdb Switch to simpler regexp::search 2013-02-08 11:20:35 +01:00
Allan Odgaard
8b8e02d6da Add minimal tests for regex::search 2013-02-08 11:20:35 +01:00
Allan Odgaard
a8f1c9ef06 Add convenience API for searching std::string 2013-02-08 11:20:34 +01:00
Allan Odgaard
0ee796d7a7 Implement regexp::match_t::operator[]
This can be used to access the n’th capture (as a std::string). If there is no capture, NULL_STR is returned.
2013-02-08 11:20:34 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
10b794bb96 Creating empty glob_list_t matches everything
This is more than creating a glob_list_t containing just ‘*’, as the latter does not match hidden files, so it is more like ‘{*,.*}’, which is a bit arcane, so I think it’s better to allow using an empty list in cases where you wish to match everything (but the API accepts a glob list for filtering purposes).
2013-01-16 04:42:51 +01:00
Allan Odgaard
a0c4af64bd Remove trailing whitespace
Only removed from non-empty lines.
2012-09-25 14:16:50 +02:00
Allan Odgaard
0f3861fec7 Retire custom begin/endof functions
We can now use std::begin/end although for containers we explicitly call the member functions.
2012-09-20 12:22:21 +02:00
Allan Odgaard
ec4ac60ae4 Add glob test: ‘*.ext’ doesn’t match ‘.ext’
I wasn’t sure if this was really desired, but it mimics bash.
2012-09-16 11:41:23 +02:00
Allan Odgaard
015d6a2a23 Add glob_list_t type
This can be used to manage a list of accept/reject globs.
2012-09-12 18:30:36 +02:00
Allan Odgaard
e8837fcf9f Improve glob matching
1. The * and ** operators will now match a dot if not at the beginning of a path component. E.g. ‘main*’ will match ‘main.cc’.
2. When negating a glob, the * and ** operators will include dot files. E.g. ‘!cache/**’ will match (reject) ‘cache/.DS_Store’.
3. The ** operator no longer needs a trailing slash. E.g. ‘src/**.cc’ will match ‘src/main.cc’ and ‘src/sys/util.cc’.
2012-09-12 18:30:35 +02:00
Allan Odgaard
2ab6f4bfc8 Introduce an “extend selection” find option
This will find (forwards or backwards) but preserve the existing selection.

Presently if the current selection is a zero-width selection (i.e. caret) then we still preserve it. This might not be desired, but one could imagine “extend selection” used with a regular expression which use a look-around assertion (resulting in zero-width matches).
2012-09-06 23:10:55 +02:00
Allan Odgaard
0e96a04d76 Remove compatibility checks
Since we now require 10.7 we don’t need all of this. Keeping it around is just noise that can lead to confusion about code paths.
2012-08-29 16:02:29 +02:00
Allan Odgaard
cbe91ff831 Assume compiler support for explicit keyword
Since we require a fairly recent clang for other features, there is no reason to test for this one.
2012-08-29 14:27:35 +02:00
Jacob Bandes-Storch
d4ce498f60 Use 64-bit: numeric type fixes
Unfortunately a printf precision specifier (‘%.*s’) can not come with a width specifier so we have to cast to int. The width specifier ‘t’ is used for ptrdiff_t.
The int → NSInteger change fixed a bug with popup menu positioning, but there was no associated warning or error. It's possible there are more such bugs that we haven't found yet!
2012-08-28 21:32:47 +02:00
Jacob Bandes-Storch
b675c78909 Use libc++: avoid incomplete types where needed 2012-08-28 20:17:29 +02:00
Jacob Bandes-Storch
0fcb4c2d2c Use libc++: don’t rely on implicit conversions 2012-08-28 20:10:55 +02:00
Jacob Bandes-Storch
e3aa997b06 Use libc++: replace std::tr1 with std 2012-08-28 13:30:20 +02:00
Allan Odgaard
13026c70ca Add format_string::escape
This produces a string where all format string characters have been properly escaped.
2012-08-25 00:57:48 +02:00