mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
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
18 lines
640 B
C++
18 lines
640 B
C++
#include <text/tokenize.h>
|
|
|
|
static std::string replace_token (std::string const& str, char token, std::string const& replacement)
|
|
{
|
|
std::vector<std::string> v;
|
|
for(auto const& component : text::tokenize(str.begin(), str.end(), token))
|
|
v.push_back(component);
|
|
return text::join(v, replacement);
|
|
}
|
|
|
|
void test_tokenize ()
|
|
{
|
|
OAK_ASSERT_EQ(replace_token( "foo/bar", '/', " » "), "foo » bar" );
|
|
OAK_ASSERT_EQ(replace_token("/foo/bar", '/', " » "), " » foo » bar" );
|
|
OAK_ASSERT_EQ(replace_token( "foo/bar/", '/', " » "), "foo » bar » ");
|
|
OAK_ASSERT_EQ(replace_token("/foo/bar/", '/', " » "), " » foo » bar » ");
|
|
}
|