3 * Copyright (C) 2004 Red Hat, Inc.
5 * This is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <sys/types.h>
34 error_table|et { yylval.sval = g_strdup(yytext);
35 return ERROR_TABLE_START; };
36 end { return ERROR_TABLE_END; };
37 error_code|ec { yylval.sval = g_strdup(yytext);
38 return ERROR_CODE_START; };
42 <INITIAL>[A-Za-z0-9_-]+ { yylval.sval = g_strdup(yytext);
45 <INITIAL>\" { BEGIN(QUOTED);
46 yylval.sval = g_strdup("");
48 <QUOTED>\" { BEGIN(INITIAL);
50 <QUOTED>[^\"]+ { yylval.sval = g_strdup(yytext);
52 <QUOTED>\n { yylval.sval = g_strdup(yytext);
57 /* Complete list of filenames, an iterator for that list, and the contents of
58 * the current item. */
59 static GList *filenames = NULL, *filename = NULL;
60 const char *currentfile = NULL;
65 g_print("Syntax error (%s).\n", currentfile);
69 /* Callback for ftw(). Adds the filename being examined to the global list of
72 fn(const char *file, const struct stat *st, int flag)
78 (strncmp(file + strlen(file) - 3, ".et", 3) == 0)) {
79 filenames = g_list_append(filenames, g_strdup(file));
85 /* Open the next filename in the list of files, if we have a list and we
86 * haven't reached its end. */
90 if ((filename != NULL) && (g_list_next(filename) != NULL)) {
92 filename = g_list_next(filename);
93 currentfile = filename->data;
94 yyin = fopen(currentfile, "r");
100 /* Spew forth a gettext .pot header. */
104 const char *boilerplate = "const char *dummy = {\n";
111 const char *boilerplate = "};\n";
116 main(int argc, char **argv)
119 /* Call getopt. We don't provide any options just now, but this lets
120 * us handle "--help" and "-h" queries simply. */
121 while ((i = getopt(argc, argv, "")) != -1) {
124 printf("Usage: etpo [directory ...]\n");
129 /* Assume that each non-option argument is a directory. */
130 for (i = optind; i < argc; i++) {
131 if (ftw(argv[i], fn, 10) != 0) {
136 /* Spew out a header. */
138 if (g_list_length(filenames) > 0) {
139 /* Open the first file and start parsing it. */
140 filename = filenames;
141 currentfile = filename->data;
142 yyin = fopen(currentfile, "r");
146 /* Start parsing stdin. */
147 currentfile = "<stdin>";