view tools/incpri.pl @ 911:785b2bd38982

should fix compile time constant in gcc on linux
author kono
date Wed, 09 Apr 2014 14:39:32 +0900
parents 3e3cf02297e4
children
line wrap: on
line source

#!/usr/bin/perl

# /************************************************************************
# ** Copyright (C) 2006 Shinji Kono
# ** 連絡先: 琉球大学情報工学科 河野 真治  
# ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
# **
# **    このソースのいかなる複写,改変,修正も許諾します。ただし、
# **    その際には、誰が貢献したを示すこの部分を残すこと。
# **    再配布や雑誌の付録などの問い合わせも必要ありません。
# **    営利利用も上記に反しない範囲で許可します。
# **    バイナリの配布の際にはversion messageを保存することを条件とします。
# **    このプログラムについては特に何の保証もしない、悪しからず。
# **
# **    Everyone is permitted to do anything on this program 
# **    including copying, modifying, improving,
# **    as long as you don't try to pretend that you wrote it.
# **    i.e., the above copyright notice has to appear in all copies.  
# **    Binary distribution requires original version messages.
# **    You don't have to ask before copying, redistribution or publishing.
# **    THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
# ***********************************************************************/
for(@ARGV) {
    my $filename = $_;
    rename($filename,$filename.".bak");
    open(IN,"<$filename.bak");
    open(OUT,">$filename");
    $d = "0000";
    while(<IN>) {
       s/fprintf\(([^,]+,)\"\#\d+\:/fprintf\($1\"\#$d\:/;
       s/fprintf\(([^,]+,)\"([^#])/fprintf\($1\"\#$d\:$2/;
       s/printf\(\"\#\d+\:/printf\(\"\#$d\:/;
       s/printf\(\"([^#])/printf\(\"\#$d\:$1/;
       $d++;
       print OUT;
    }
}