By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,934 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,934 IT Pros & Developers. It's quick & easy.

Find data type of structure members of a C file

P: 3
Hi,

I am completely new to perl.
what i want to do is to find if a specific data type is used inside the structure definitions in a C header file.

Expand|Select|Wrap|Line Numbers
  1. perl -ne 'print if /struct[^(].*{/ .. /}/' header.h | grep long
something like this will give an output provided the structure is defined like
Expand|Select|Wrap|Line Numbers
  1. struct tag {
in one single line
but i need to get the result even if the pattern is in multiple lines
like
Expand|Select|Wrap|Line Numbers
  1. struct tag 
  2. {


I need two things infact, one is to find if a specific type is used in any of the structure definitions.
two is to replace a specific type with a new type in all structure definitions.




Thank you,
Regards
Vishnu
Dec 19 '08 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
try adding the 's' option to the end of the regexp:

/struct[^(].*{/ .. /}/s

that way '.' can match a newline
Dec 19 '08 #2

P: 3
Hay Kevin thanks for your reply.
i tried /s but it is not working. :-(
Dec 21 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
Well, that is my only suggestion.
Dec 22 '08 #4

P: 3
@KevinADC
i think i will try concatenating multiple lines and searching in it. i might have to write some code in perl. lets see.
Dec 22 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.