Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a text file test.txt which contains :
inst_f1
inst_f2
inst_f3
inst_f4
.
.
.
.
inst_fn
where inst_f1.... inst_fn are particular function type used in a given cpp file
I have to read the file test.txt line by line
Suppose the First fn is inst_f1. I have to find the fn in which this fn is called from the cpp
and so on
for eg: the contents of cpp file are
void clas_name :: rvvd_inst_into_tabl
( void )
{
rvvd_call_tabl()
}
void clas_name :: rvvd_call_tabl
( void )
{
rvvd_chck_tabl()
}
void clas_name :: rvvd_chck_tabl
( void )
{
inst_f1()
}So the flow would be
inst_f1 <<--- rvvd_chck_tabl <<---- rvvd_call_tabl <<----- rvvd_inst_into_tabl
and I have to keep all things dynamic ie ( Number of Fncs in test.txt will change for diff cpp class)Your Suggestions appreciated
Thanks
-Ultimatix

Interesting problem ......
#!/bin/ksh
# reverse the cppfile sed '1!G;h;$!d' cpp.file > tmp.cpp.file mystring="" ft=0 while read line do # look for lines ending with () if echo "$line"|egrep "\(\)$" > /dev/null then if [[ $ft -eq 0 ]] then ft=1 mystring=${line} else mystring="${mystring} <<--- ${line}" fi continue fi # look for lines with :: if echo "$line"|egrep "::" > /dev/null then # 3rd field is the function set - $(IFS=":"; echo ${line}) if [[ $ft -eq 0 ]] then ft=1 mystring=$3 else mystring="${mystring} <<--- $3}" fi fi done < tmp.cpp.file echo $mystring

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |