[101] | 1 | #! /usr/bin/perl
|
---|
| 2 | #
|
---|
| 3 | # TOPPERS Software
|
---|
| 4 | # Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
| 5 | #
|
---|
| 6 | # Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | # Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | # Copyright (C) 2004-2007 by Embedded and Real-Time Systems Laboratory
|
---|
| 9 | # Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | #
|
---|
| 11 | # ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
| 12 | # Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
| 13 | # ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
| 14 | # (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 15 | # \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 16 | # XR[hÉÜÜêĢ鱯D
|
---|
| 17 | # (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 18 | # pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 19 | gip
|
---|
| 20 | # Ò}j
|
---|
| 21 | AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
|
---|
| 22 | # Ì³ÛØKèðfÚ·é±ÆD
|
---|
| 23 | # (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 24 | # pūȢ`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 25 | # ÆD
|
---|
| 26 | # (a) Äzzɺ¤hL
|
---|
| 27 | gipÒ}j
|
---|
| 28 | AÈÇjÉCãLÌ
|
---|
| 29 | # ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
|
---|
| 30 | # (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 31 | # ñ·é±ÆD
|
---|
| 32 | # (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 33 | # Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 34 | # ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
| 35 | # RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
| 36 | # ÆÓ·é±ÆD
|
---|
| 37 | #
|
---|
| 38 | # {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 39 | # æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
| 40 | # ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
| 41 | # AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
| 42 | # ÌÓCðíÈ¢D
|
---|
| 43 | #
|
---|
| 44 | # @(#) $Id: applyrename 332 2007-07-17 12:15:37Z hiro $
|
---|
| 45 | #
|
---|
| 46 |
|
---|
| 47 | #
|
---|
| 48 | # t@CÉl[ðKp·é
|
---|
| 49 | #
|
---|
| 50 | sub applyrename
|
---|
| 51 | {
|
---|
| 52 | local($infile) = @_;
|
---|
| 53 | local($outfile) = $infile.".new";
|
---|
| 54 | local($line);
|
---|
| 55 |
|
---|
| 56 | open(INFILE, "< ".$infile) || die;
|
---|
| 57 | open(OUTFILE, "> ".$outfile) || die;
|
---|
| 58 |
|
---|
| 59 | while ($line = <INFILE>) {
|
---|
| 60 | $line =~ s/\b(_?)($syms)\b/$1_kernel_$2/gc;
|
---|
| 61 | print OUTFILE $line;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | close(INFILE);
|
---|
| 65 | close(OUTFILE);
|
---|
| 66 |
|
---|
| 67 | if (`cmp $infile $outfile`) {
|
---|
| 68 | rename($infile, $infile.".bak");
|
---|
| 69 | rename($outfile, $infile);
|
---|
| 70 | print STDERR "Modified: ",$infile,"\n";
|
---|
| 71 | }
|
---|
| 72 | else {
|
---|
| 73 | unlink($outfile);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | #
|
---|
| 78 | # G[`FbN
|
---|
| 79 | #
|
---|
| 80 | if ($#ARGV < 1) {
|
---|
| 81 | die "Usage: appyrename <prefix> <filelist>\n";
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | #
|
---|
| 85 | # ú»
|
---|
| 86 | #
|
---|
| 87 | @syms = ();
|
---|
| 88 | $name = $ARGV[0];
|
---|
| 89 |
|
---|
| 90 | #
|
---|
| 91 | # V{XgðÇÝÞ
|
---|
| 92 | #
|
---|
| 93 | $deffile = $name."_rename.def";
|
---|
| 94 | open(INFILE, $deffile) || die "Cannot open $deffile";
|
---|
| 95 | while ($line = <INFILE>) {
|
---|
| 96 | chomp $line;
|
---|
| 97 | if ($line =~ /^#(.*)$/) {
|
---|
| 98 | # do nothing
|
---|
| 99 | }
|
---|
| 100 | elsif ($line =~ /^INCLUDE[ \t]+(.*)$/) {
|
---|
| 101 | # do nothing
|
---|
| 102 | }
|
---|
| 103 | elsif ($line ne "") {
|
---|
| 104 | @syms = (@syms, $line)
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | close(INFILE);
|
---|
| 108 |
|
---|
| 109 | #
|
---|
| 110 | # ³K\»ðìé
|
---|
| 111 | #
|
---|
| 112 | $syms = join("|", @syms);
|
---|
| 113 |
|
---|
| 114 | #
|
---|
| 115 | # t@CÉl[ðKp·é
|
---|
| 116 | #
|
---|
| 117 | shift @ARGV;
|
---|
| 118 | foreach $infile (@ARGV) {
|
---|
| 119 | # t@CÅȯêÎXLbv
|
---|
| 120 | next unless (-f $infile);
|
---|
| 121 |
|
---|
| 122 | applyrename($infile) if ($infile ne $deffile);
|
---|
| 123 | }
|
---|