C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 11th, 2012, 12:06 AM
itismohit itismohit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 itismohit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m
Reputation Power: 0
Automated code modification for adherence to coding guidelines.

Hello,

I have this task to restructure and clean huge amounts of code, including removal of junk code, changing functions/variables names to adhere to naming conventions and similar changes.
Can you please let me know of any tools which can help me automate it as much as possible.

I came across coccinelle. Just wondering what are the other better options ?

Thanks,
Mohit

Reply With Quote
  #2  
Old October 11th, 2012, 05:43 AM
mitakeet's Avatar
mitakeet mitakeet is offline
I'm Baaaaaaack!
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 5,538 mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level)mitakeet User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 38 m 46 sec
Reputation Power: 242
While there might be something out there, I haven't seen anything and I have done this a time or twain in the past. Cleaning up code is a huge pain in the ***, I don't envy you your task. If you know unambiguously that the code is built into a finite (and small) number of end products (libraries, executables, etc) then you could try what I have done a number of times and simply start removing chunks of code from the code base and rebuilding. Tedious, I know, particularly if the code base is huge. Once, several years ago, I tried to do some semi-automated analysis by using 'ctags' and 'nm' to find code in the repo that wasn't also in any of the binaries with a bit of success. As I recall (it was some 3 years ago at a different company) I took the output of one (nm, I believe) and 'diffed' it with the other to reveal the bits that were not the same, then started to remove those chunks from the repo and rebuilding. Of course, if no one is using some of your binaries (as was the case for me and ultimately why I stopped bothering) then this 'trick' won't really help.

As for formatting, there are 'beautifiers' that can handle that aspect, I seem to recall something called 'bcpp' (or 'bc' for C code). I _think_ it would also modify comments for you as well, but it was quite a while ago when I played with it regularly.

As for bringing variables, etc. into compliance, find and replace is your only friend here and it is quite possibly only a fair weather friend. If past developers didn't provide any sort of scope tags in their naming conventions (I personally _like_ that aspect of Hungarian Notation, though have since given up taking the data type to the name, for the most part, since modern IDEs will identify the type for you with mouse hover) then a wide-scale find and replace will likely cause more heartburn than it treats. While some IDEs will allow for find and replace in a selected block of code, another alternative is to copy the function/method to a temporary file, do find/replace there, then copy back. Again, quite tedious.

An important note here: doing any sort of wholesale changes like this _without_ a comprehensive suite of regression tests is just asking for problems. Just because something compiles does _not_ mean that it functions correctly!
__________________

My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Automated code modification for adherence to coding guidelines.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap