strmerge(1int)strmerge(1int)Namestrmerge - batch string replacement
Syntaxstrmerge [ -m prefix ] [ -p patternfile ] [ -s string ] source-pro‐
gram...
Description
The command reads the strings specified in the message file produced by
and replaces those strings with calls to the message file in the source
program to create a new source program. The new version of source pro‐
gram has the same name as the input source program, with the prefix
nl_. For example, if the input source program is named the output
source program is named You use this command to replace hard-coded mes‐
sages (text strings identified by the command) with calls to the func‐
tion and to create a source message catalog file. The source message
catalog contains the text for each message extracted from your input
source program. The command names the file by appending .msf to the
name of the input source program. For example, the source message cata‐
log for the program is named You can use the source message catalog as
input to the command.
At run time, the program reads the message text from the message cata‐
log. By storing messages in a message catalog, instead of your pro‐
gram, you allow the text of messages to be translated to a new language
or modified without the source program being changed.
In the source-program argument, you name one or more source programs
for which you want strings replaced. The command does not replace mes‐
sages for source programs included using the directive. Therefore, you
might want a source program and all the source programs it includes on
a single command line.
You can create a patterns file (as specified by patternfile ) to con‐
trol how the command replaces text. The patterns file is divided into
several sections, each of which is identified by a keyword. The keyword
must start at the beginning of a new line, and its first character must
be a dollar sign ($). Following the identifier, you specify a number
of patterns. Each pattern begins on a new line and follows the regular
expression syntax you use in the editor. For more information on the
patterns file, see the reference page.
Options-m Add prefix to message numbers in the output source program and
source message catalog. You can use this prefix as a mnemonic.
You must process source message catalogs that contain number pre‐
fixes using the option. Message numbers will be in the form:
<prefix><msg_num>
Set numbers will be in the form:
S_<prefix><set_num>
If you process your input source program with this option, the
resulting source program and source message catalog may not be
portable. For more information, see the Guide to Developing
International Software.
-p Use patternfile to match strings in the input source program. By
default, the command searches for the pattern file in the current
directory, your home directory and finally
If you omit the option, the command uses a default patterns file
that is stored in
-s Write string at the top of the source message catalog. If you omit
the option, uses the string specified in the section of the pat‐
terns file.
Restrictions
You can specify only one rewrite string for all classes of pattern
matches.
The command does not verify if the message text file matches the source
file being rewritten.
The command does not replace strings to files included with directive.
You must run the command on these files separately.
Examples
The following produces a message file for a program called
% strextract -p c_patterns prog.c prog2.c
% vi prog.msg
% strmerge-p c_patterns prog.c prog2.c
% gencat prog.cat prog.msf
% vi nl_prog.c
% vi nl_prog2.c
% cc nl_prog.c nl_prog2.c -li
In this example, the command uses the file to determine which strings
to match. The input source programs are named and
If you need to remove any of the messages or extract one of the created
strings, edit the resulting message file, Under no conditions should
you add to this file. Doing so could result in unpredictable behavior.
You issue the command to replace the extracted strings with calls to
the message catalog. In response to this command, creates the source
message catalogs, and and the output source programs, and
Before compiling the source programs, you must edit and to include the
appropriate and function calls.
The command creates a message catalog and the command creates an exe‐
cutable program.
See Alsointro(3int), extract(1int), gencat(1int), strextract(1int),
trans(1int), regex(3), catopen(3int), catgets(3int), patterns(5int)
Guide to Developing International Software
strmerge(1int)