我使用ident工具从源文件和编译文件中提取RCS关键字字符串。
它当然适用于源代码,也适用于GCC的C编译输出以及G77的fortran编译输出。
$ gcc -o c.out test.c
$ ident test.c c.out
test.c:
$Id: 63159761756 $
c.out:
$Id: 63159761756 $
$ g77 -o g77.out test.f
$ ident test.f g77.out
test.f:
$Id: 63159761756 $
g77.out:
$Id: 63159761756 $
$ gfortran -o gf.out test.f
$ ident test.f gf.out
test.f:
$Id: 63159761756 $
gf.out:
PROGRAM HELLO
CHARACTER*80 ID
ID =
*'@(#)$Id: 63159761756 $'
PRINT '(A)', 'Hello,fortran 77'
Print *, 'ID is ', ID
STOP
END
最佳答案
使用字符串常量,如
PROGRAM HELLO
PRINT '(A)', 'Hello,fortran 77'
Print *, 'ID is ',
+'@(#)$Id: ident.f,v 1.2 2015/02/24 14:20:49 ig25 Exp ig25 $'
STOP
END
PROGRAM HELLO
logical, volatile :: print_it = .false.
PRINT '(A)', 'Hello,fortran 77'
if (print_it) then
Print *, 'ID is ',
+'@(#)$Id: ident.f,v 1.2 2015/02/24 14:20:49 ig25 Exp ig25 $'
end if
STOP
END
https://stackoverflow.com/questions/28697620/