• Mauro Carvalho Chehab's avatar
    [media] drx-j: Remove typedefs in drxj.c · 60d3603b
    Mauro Carvalho Chehab authored
    Remove three typedefs from drxj.c, using the following script:
    
    use File::Find;
    use strict;
    
    my $dir = shift or die "need a dir";
    my $type = shift or die "need type";
    my $var = shift or die "need var";
    
    sub handle_file {
    	my $file = shift;
    
    	my $out;
    
    	open IN, $file or die "can't open $file";
    	$out .= $_ while (<IN>);
    	close IN;
    
    	$out =~ s/\btypedef\s+($type)\s+\{([\d\D]+?)\s*\}\s+\b($var)[^\;]+\;/$type $var \{\2\};/;
    
            # This replaces the typedef declaration for a simple struct declaration - style 1
    
            # This replaces the typedef declaration for a simple struct declaration - style 2
    
    	# Replace struct occurrences
    
    	$out =~ s,\b($var)_t\s+,$type \1 ,g;
    	$out =~ s,\bp_*($var)_t\s+,$type \1 *,g;
    	$out =~ s,\b($var)_t\b,$type \1,g;
    	$out =~ s,\bp_*($var)_t\b,$type \1 *,g;
    
    	open OUT, ">$file" or die "can't open $file";
    	print OUT $out;
    	close OUT;
    }
    
    sub parse_dir {
    	my $file = $File::Find::name;
    
    	return if (!($file =~ /.[ch]$/));
    
    	handle_file $file;
    }
    
    find({wanted => \&parse_dir, no_chdir => 1}, $dir);
    Acked-by: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
    60d3603b
drxj.c 594 KB