Hi monks!

I am more into C than perl - (sorry, but I have to) - and feel like I need the power of perl now.

I have a large set of C source files, and need to empty out all the function bodies - but just the bodies. Everything else should be left untouched.

Does anybody know a quick way to do that?

I read the C::Scan library and it can extract quite a lot of structures out of a c file. The thing is, not to delete anything, except the function bodies. Ok, it offers structs like:

defines_args fdecls, etc. and one would be able to print those. But the order is important, and the printed output should include everything.

I need to change this:

#define IN_LIBXML #include "libxml.h" struct _xmlLink { struct _xmlLink *next; struct _xmlLink *prev; void *data; }; static int xmlLinkCompare(const void *data0, const void *data1); static int xmlLinkCompare(const void *data0, const void *data1) { if (data0 < data1) return (-1); else if (data0 == data1) return (0); return (1); }

-----------

into:

#define IN_LIBXML #include "libxml.h" struct _xmlLink { struct _xmlLink *next; struct _xmlLink *prev; void *data; }; static int xmlLinkCompare(const void *data0, const void *data1); static int xmlLinkCompare(const void *data0, const void *data1) { }

Any suggestions??

Frank


In reply to empty out C function bodies by biocc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.