LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-25-2005, 09:52 PM   #1
anandss2004
LQ Newbie
 
Registered: Oct 2005
Location: Japan
Posts: 6

Rep: Reputation: 0
Ignoring difference of { and }


this may be a simple problem, but i need few ideas,
--------------
Old coding style:

if(a) __call_function

New coding style needed:

if(a) {
__call_function
}

---------------
When finish with this change, how to test that all changes have been done correctly. Two things, 1. there is no extra change dne except needed. 2. Every where the required change have been done.

I have find two find option which help my job,

$diff -c a.c a-new.c
***************
*** 1,4 ****
! if(a) {
! __call_function
! }
!
--- 1 ----
! if(a) __call_function

$diff -I '}' a.c a-new.c
1,4c1
< if(a) {
< __call_function
< }
<
---
> if(a) __call_function


But please let me know if there could be simpler approach.


thanks in advance
 
Old 10-28-2005, 06:19 PM   #2
Ygrex
Member
 
Registered: Nov 2004
Location: Russia (St.Petersburg)
Distribution: Debian
Posts: 666

Rep: Reputation: 68
Perhaps if you express what do you want
more clear you would get the answer more
quickly

It is a kind of ambigous. Do you want
to see differences between two files in
a more simple form? I know a universal
'diff' invokation for any case

diff -duraN

I do not remember all options but I
always use this form. If you want
something else, please ask.
 
Old 10-30-2005, 07:39 PM   #3
anandss2004
LQ Newbie
 
Registered: Oct 2005
Location: Japan
Posts: 6

Original Poster
Rep: Reputation: 0
yes, You are right,

I tell you the story behind it.

In my source code there is no {} brackets for single line 'if' statement, but in order to match some coding style and conventions, I have to put {} for each single line if statement now.

That is why , I want a command with option whicn will help me to see the difference between old file and new file with {} brackets as minimum as possible.

If the difference is minumum i can scan the difference quickly.
 
Old 10-31-2005, 06:09 PM   #4
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: LFS-Version SVN-20091202, Arch 2009.08
Posts: 1,496

Rep: Reputation: 68
I think the diff command would be your best bet.
 
Old 11-01-2005, 02:44 PM   #5
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
Didn't used very much but there is a program called 'indent' which has many many parameters and formats your source code according to these.

If you could find a set of parameters to match your coding style... you could apply it and be sure it is ok.
 
Old 11-01-2005, 06:03 PM   #6
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
>> If the difference is minumum i can scan the difference quickly.

so you only want to see the lines involving an if statement that was changed?

maybe piping diff through grep would help you? like a
`diff file_1 file_2 | grep if`
though that would only show you you the start of the if statement.. you could use regular expressions with grep, that would probably help more.
 
Old 11-01-2005, 08:05 PM   #7
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
If you want to see more lines 'around' the diff you could use
Code:
diff --context=2 file1 file2
 
Old 11-01-2005, 08:11 PM   #8
anandss2004
LQ Newbie
 
Registered: Oct 2005
Location: Japan
Posts: 6

Original Poster
Rep: Reputation: 0
Yeah!

Thanks to every body, who have replied to my question, i think i can make out some solution using all the inputs.

if i face any problem while going ahead, i will let you all know again.

thank
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ignoring dependencies ergo_sum Linux - Newbie 1 04-03-2005 07:05 PM
Ignoring bad checksums (!) antares Linux - Software 2 08-21-2004 06:33 AM
ignoring drive Y: Johng Linux - Software 2 12-14-2003 03:09 PM
up2date is ignoring me nattybumpo Linux - Networking 1 04-24-2003 02:38 AM
GNU tar ignoring -X? akohlsmith Linux - General 0 07-12-2002 09:57 AM


All times are GMT -5. The time now is 04:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration