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>
35 error_table|et { yylval.sval = g_strdup(yytext);
36 return ERROR_TABLE_START; };
37 end { return ERROR_TABLE_END; };
38 error_code|ec { yylval.sval = g_strdup(yytext);
39 return ERROR_CODE_START; };
43 <INITIAL>[A-Za-z0-9_-]+ { yylval.sval = g_strdup(yytext);
46 <INITIAL>\" { BEGIN(QUOTED);
47 yylval.sval = g_strdup("");
49 <QUOTED>\" { BEGIN(INITIAL);
51 <QUOTED>[^\"]+ { yylval.sval = g_strdup(yytext);
53 <QUOTED>\n { yylval.sval = g_strdup(yytext);
58 /* Complete list of filenames, an iterator for that list, and the contents of
59 * the current item. */
60 static GList *filenames = NULL, *filename = NULL;
61 const char *currentfile = NULL;
66 g_print("Syntax error (%s).\n", currentfile);
70 /* Callback for ftw(). Adds the filename being examined to the global list of
73 fn(const char *file, const struct stat *st, int flag)
79 (strncmp(file + strlen(file) - 3, ".et", 3) == 0)) {
80 filenames = g_list_append(filenames, g_strdup(file));
86 /* Open the next filename in the list of files, if we have a list and we
87 * haven't reached its end. */
91 if ((filename != NULL) && (g_list_next(filename) != NULL)) {
93 filename = g_list_next(filename);
94 currentfile = filename->data;
95 yyin = fopen(currentfile, "r");
101 /* Spew forth a gettext .pot header. */
105 const char *boilerplate = "const char *dummy = {\n";
112 const char *boilerplate = "};\n";
117 main(int argc, char **argv)
120 /* Call getopt. We don't provide any options just now, but this lets
121 * us handle "--help" and "-h" queries simply. */
122 while ((i = getopt(argc, argv, "")) != -1) {
125 printf("Usage: etpo [directory ...]\n");
130 /* Assume that each non-option argument is a directory. */
131 for (i = optind; i < argc; i++) {
132 if (ftw(argv[i], fn, 10) != 0) {
137 /* Spew out a header. */
139 if (g_list_length(filenames) > 0) {
140 /* Open the first file and start parsing it. */
141 filename = filenames;
142 currentfile = filename->data;
143 yyin = fopen(currentfile, "r");
147 /* Start parsing stdin. */
148 currentfile = "<stdin>";