1 diff -ur gettext-0.10.35/src/xgettext.c gettext-0.10.35-dml/src/xgettext.c
2 --- gettext-0.10.35/src/xgettext.c Wed Apr 29 18:57:50 1998
3 +++ gettext-0.10.35-dml/src/xgettext.c Sat Jan 13 00:40:22 2001
5 NULL, /* comment_special */
9 +struct dml_parser_state {
18 + message_list_ty *mlp;
23 + struct dml_parser_state *ctx;
36 + if (strcmp(ctx->filename, "-") == 0) {
37 + ctx->filename = xstrdup(_("standard input"));
42 + if (ctx->filename[0] == '/') {
43 + ctx->in = fopen(ctx->filename, "r");
45 + error(EXIT_FAILURE, errno, _("\
46 +error while opening \"%s\" for reading"),
48 + ctx->filename = xstrdup(ctx->filename);
52 + len2 = strlen(ctx->filename);
54 + dir = dir_list_nth(j);
56 + error(EXIT_FAILURE, ENOENT, _("\
57 +error while opening \"%s\" for reading"), ctx->filename);
59 + if (dir[0] == '.' && dir[1] == '\0')
60 + new_name = xstrdup(ctx->filename);
63 + new_name = xmalloc(len1 + len2 + 2);
64 + stpcpy(stpcpy(stpcpy(new_name, dir), "/"), ctx->filename);
67 + ctx->in = fopen(new_name, "r");
68 + if (ctx->in != NULL)
71 + if (errno != ENOENT)
72 + error(EXIT_FAILURE, errno, _("\
73 +error while opening \"%s\" for reading"), new_name);
77 + ctx->filename = new_name;
80 +static void dml_remember_a_message(ctx)
81 + struct dml_parser_state *ctx;
89 + /* See whether we shall exclude this message. */
90 + if (exclude != NULL && message_list_search(exclude, msgid) != NULL)
93 + /* See if we have seen this message before. */
94 + mp = message_list_search(ctx->mlp, msgid);
96 + static lex_pos_ty pos = { __FILE__, __LINE__ };
98 + /* Allocate a new message and append the message to the list. */
99 + mp = message_alloc(xstrdup(msgid));
100 + /* Do not free msgid. */
101 + message_list_append(ctx->mlp, mp);
103 + /* Construct the msgstr from the prefix and suffix, otherwise use the
105 + if (msgstr_prefix) {
106 + msgstr = (char *) xmalloc(strlen(msgstr_prefix)
108 + + strlen(msgstr_suffix) +
111 + (stpcpy(msgstr, msgstr_prefix), msgid),
115 + message_variant_append(mp, MESSAGE_DOMAIN_DEFAULT, msgstr,
116 + strlen(msgstr) + 1, &pos);
118 + mp->is_c_format = no;
119 + mp->do_wrap = yes; /* By default we wrap. Is it ok? */
122 + /* Remember where we saw this msgid. */
124 + message_comment_filepos(mp, ctx->filename, ctx->line);
127 +/* Read a string until '}}' is found. */
130 + struct dml_parser_state *ctx;
132 + int c, last_brace = 0;
134 + ctx->seen = ctx->line;
138 + c = fgetc(ctx->in);
140 + error(EXIT_FAILURE, 0, _("%s:%d: unmatched {{"),
141 + ctx->filename, ctx->seen);
151 + if (ctx->bufpos == ctx->buflen) {
152 + if (ctx->buflen == 0)
154 + ctx->buf = xrealloc(ctx->buf, ctx->buflen *= 2);
156 + ctx->buf[ctx->bufpos++] = c;
159 + /* remove last } */
160 + ctx->buf[--ctx->bufpos] = 0;
161 + dml_remember_a_message(ctx);
164 +/* We don't really bother scanning the shell syntax.
165 + We just hunt for strings in {{ }}
168 +scanner_dml(filename, mlp)
170 + message_list_ty *mlp;
172 + struct dml_parser_state ctx;
175 + ctx.filename = filename;
177 + dml_open_file(&ctx);
180 + while ((c = fgetc(ctx.in)) != EOF)
182 + ((c = fgetc(ctx.in)) == EOF || c == '{'))
184 + else if (c == '\n')
189 + dml_get_string(&ctx);
195 + free(ctx.filename);
199 read_exclusion_file (file_name)
200 @@ -1330,6 +1519,7 @@
202 { "C++", scanner_cxx, },
203 { "PO", read_po_file, },
204 + { "DML", scanner_dml, },
205 /* Here will follow more languages and their scanners: awk, perl,
206 etc... Make sure new scanners honor the --exlude-file option. */