Anyone remember the old Unix
xstr command? Basically this could extract string literals from a piece of C source code, and put them in a separate header file, replacing the string literals with references to a string array in the header file.
I've been digging high and low for a perl module that is capable of parsing, and modifying C source code "on the fly" and generate a new .c file for use during the compilation process. I use perl quite regularly in my build process and I thought that it would be easily up to the task...
Essentially I'm trying to reproduce the behaviour of the old unix xstr command, but have found VERY little in terms of useful code.
At the moment, I'm using a while(<FILE>) and a silly regex to try to extract and replace the strings, but I'm not getting all syntactical cases of string literals in the C code.
Has anyone attempted this before, or have a port of xstr to perl, or know of decent regex, or perl module that is up to this task. I've dug through CPAN but without much success...
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.