Cstrings is a lightweight software tool designed for C code that facilitates internationalization.
One of the most appealing features of this tool is its ability to build up message bases incrementally, making it an ideal option for developers who prefer to take things step-by-step. The software can be used to modify C source code so that literal strings are replaced by generated #define symbols. It's also worth noting that string literals on #include and #define lines and in comments are skipped.
When no filenames are given, standard input is filtered to standard output. However, if you do provide filenames, and appropriate write permissions are present, each file will be replaced by its converted result. The program is signal-safe thanks to the replace function being done with a link(2).
It's important to bear in mind that this feature can be risky if you don't check the filtered version first to ensure it's what you really want. The software also includes the ability to limit string filtering to specific line numbers or ranges of line numbers, with the -r option. A range of the form "-" is taken to signify all lines from line to EOF. A range of the form "-" signifies all lines from the start of file to line.
Furthermore, any range or number may be preceded by '!', which causes filtering to be suppressed for the designated lines. If the first character of a range option is '!', the filtering is assumed initially to be on for all lines, rather than off. The -t option sets the template used to generate string labels, with "Gd" being the default. The template is sprintf'ed with a sequence number as an argument.
Other noteworthy features include the -m option for setting a minimum string length, with a default of 3. The -c option suppresses the normal action and instead generates a list of strings that would otherwise be #define-ized. This can help you anticipate the effects of a substitution without having to look at the whole source file.
An important limitation of this tool is that it makes no effort to be intelligent about duplicate strings, and it doesn't handle quoted quotes within strings. This is something you'll need to bear in mind.
In terms of updates, this version uses mkstemp(3) rather than tempnam(3) for security reasons, and source RPMs no longer depend on --define myversion. Overall, this lightweight tool is ideal for programmers who want a less intrusive way of internationalizing C code.
Version 2.3.1: N/A