This repository was archived by the owner on Oct 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ use strict ;
2+ use warnings ;
3+
4+ use File ::Slurp ;
5+ use File ::Basename ;
6+ use File ::Spec ::Functions ;
7+
8+ my $root = $ENV {'SASS_LIBSASS_PATH' } || catfile(dirname($0 ), '..' );
9+
10+ sub process($)
11+ {
12+
13+ my $count = 0 ;
14+ my ($file ) = @_ ;
15+
16+ my $cpp = read_file($file , { binmode => ':raw' });
17+
18+ my $org = $cpp ;
19+
20+ my $re_decl = qr /(?:const \s *)?\w +(?:\:\:\w +)*(?:\s *[\*\&])?/;
21+ my $re_val = qr /\w +(?:\(\))?(?:(?:->|\. )\w+(?:\(\))?)*/;
22+
23+ $cpp =~ s/for\s*\(\s*($re_decl)\s*(\w+)\s*:\s*(\(\*?$re_val\)|$re_val)\s*\)\s*{/
24+ $count ++;
25+ "for (auto __$2 = $3.begin(); __$2 != $3.end(); ++__$2) { $1 $2 = *(__$2); ";
26+ /gex;
27+
28+ return if $org eq $cpp || $count == 0 ;
29+
30+ warn sprintf "made %02d replacements in %s\n" , $count , $file ;
31+
32+ write_file($file , { binmode => ':raw' }, $cpp );
33+
34+ }
35+
36+ my $rv = opendir(my $dh , catfile($root , "src" ));
37+ die "not found " , catfile($root , "src" ) unless $rv ;
38+ while (my $entry = readdir($dh )) {
39+ next if $entry eq "." || $entry eq ".." ;
40+ next unless $entry =~ m /\. [hc]pp$/;
41+ process (catfile($root , "src" , $entry ));
42+ }
You can’t perform that action at this time.
0 commit comments