File: fix_indent.pl

package info (click to toggle)
prrte 3.0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,132 kB
  • sloc: ansic: 80,431; sh: 4,289; perl: 3,195; makefile: 1,829; lex: 352; python: 239
file content (59 lines) | stat: -rwxr-xr-x 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
#                         University Research and Technology
#                         Corporation.  All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
#                         of Tennessee Research Foundation.  All rights
#                         reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
#                         University of Stuttgart.  All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
#                         All rights reserved.
# Copyright (c) 2016      Intel, Inc.  All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
#To keep brian happy

use Text::Tabs;

if (scalar(@ARGV) != 1) {
    print "We need a source tree path\n";
    exit(3);
}

$source_path = @ARGV[0];

open(HEADERS, "find $source_path -name *.h |");
while(<HEADERS>) {
    open(TEMP, ">temp.txt");
    $file_name = $_;
    print $file_name;
    open(FILE, "$file_name");
    my @lines_with_tabs = <FILE>;
    close(FILE);
    my @expanded_lines = expand(@lines_with_tabs);
    print TEMP join("\n",@expanded_lines),"\n";
    close(TEMP);
    system("mv temp.txt $file_name");
}
close(HEADERS);

open(SOURCES, "find $source_path -name *.c |");
while(<SOURCES>) {
    open(TEMP, ">temp.txt");
    $file_name = $_;
    print $file_name;
    open(FILE, "$file_name");
    my @lines_with_tabs = <FILE>;
    close(FILE);
    my @expanded_lines = expand(@lines_with_tabs);
    print TEMP join("\n",@expanded_lines),"\n";
    close(TEMP);
    system("mv temp.txt $file_name");
}
close(SOURCES);