- open (IN, $filetypes) || error("$filetypes: $!");
- while (<IN>) {
- chomp;
- if (/^\$ext\((.*)\)=(.*)$/) {
- $ext2lang{$_}=$1 foreach $1, split ' ', $2;
+ my $f;
+ if (!open($f, $config{filetypes_conf})) {
+ warn($config{filetypes_conf}.": ".$!);
+ return 0;
+ };
+
+ local $/=undef;
+ my $config=<$f>;
+ close $f;
+
+ # highlight >= 3.2 format (bind-style)
+ while ($config=~m/Lang\s*=\s*\"([^"]+)\"[,\s]+Extensions\s*=\s*{([^}]+)}/sg) {
+ my $lang=$1;
+ foreach my $bit (split ',', $2) {
+ $bit=~s/.*"(.*)".*/$1/s;
+ $ext2lang{$bit}=$lang;
+ }
+ }
+
+ # highlight < 3.2 format
+ if (! keys %ext2lang) {
+ foreach (split("\n", $config)) {
+ if (/^\$ext\((.*)\)=(.*)$/) {
+ $ext2lang{$_}=$1 foreach $1, split ' ', $2;
+ }