annotate lib-src/make-msgfile.c @ 2903:e376896b9f5c

[xemacs-hg @ 2005-08-20 21:51:17 by viteno] Update xemacs_extra_name.
author viteno
date Sat, 20 Aug 2005 21:51:17 +0000
parents ecf1ebac70d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 613
diff changeset
1 /* #### Old code! Replaced with make-msgfile.lex. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 /* Scan specified C and Lisp files, extracting the following messages:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 C files:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 GETTEXT (...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 DEFER_GETTEXT (...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 DEFUN interactive prompts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Lisp files:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 (gettext ...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 (dgettext "domain-name" ...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 (defer-gettext ...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 (interactive ...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 The arguments given to this program are all the C and Lisp source files
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 442
diff changeset
17 of XEmacs. .el and .c files are allowed. There is no support for .elc
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 files at this time, but they may be specified; the corresponding .el file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 will be used. Similarly, .o files can also be specified, and the corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 .c file will be used. This helps the makefile pass the correct list of files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 The results, which go to standard output or to a file specified with -a or -o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 (-a to append, -o to start from nothing), are quoted strings wrapped in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 gettext(...). The results can be passed to xgettext to produce a .po message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #define LINESIZE 256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #define GET_LINE fgets (line, LINESIZE, infile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #define CHECK_EOL(p) if (*(p) == '\0') (p) = GET_LINE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #define SKIP_BLANKS(p) while ((*p) == ' ' || (*p) == '\t') (p)++
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 enum filetype { C_FILE, LISP_FILE, INVALID_FILE };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 /* some brain-dead headers define this ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #undef FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #undef TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 enum boolean { FALSE, TRUE };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 FILE *infile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 FILE *outfile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 char line[LINESIZE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 void scan_file (char *filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 void process_C_file (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 void process_Lisp_file (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 char *copy_up_to_paren (register char *p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 char *copy_quoted_string (register char *p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 enum boolean no_interactive_prompt (register char *q);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 char *skip_blanks (register char *p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 main (int argc, char *argv[])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 outfile = stdout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /* If first two args are -o FILE, output to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 i = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 if (argc > i + 1 && strcmp (argv[i], "-o") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 outfile = fopen (argv[++i], "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ++i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 /* ...Or if args are -a FILE, append to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 if (argc > i + 1 && strcmp (argv[i], "-a") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 outfile = fopen (argv[++i], "a");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 ++i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 if (!outfile) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 fprintf (stderr, "Unable to open output file %s\n", argv[--i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 for (; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 scan_file (argv[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 void scan_file (char *filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 enum filetype type = INVALID_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 register char *p = filename + strlen (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 if (strcmp (p - 4, ".elc") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 *--p = '\0'; /* Use .el file instead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 type = LISP_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 } else if (strcmp (p - 3, ".el") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 type = LISP_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 else if (strcmp (p - 2, ".o") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 *--p = 'c'; /* Use .c file instead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 type = C_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 } else if (strcmp (p - 2, ".c") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 type = C_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 if (type == INVALID_FILE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 fprintf (stderr, "File %s being ignored\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 infile = fopen (filename, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 if (!infile) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 fprintf (stderr, "Unable to open input file %s\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 fprintf (outfile, "/* %s */\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 if (type == C_FILE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 process_C_file ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 process_Lisp_file ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 fputc ('\n', outfile);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
117
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 fclose (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 void process_C_file (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 char *gettext, *defun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 while (p = GET_LINE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 gettext = strstr (p, "GETTEXT");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 defun = strstr (p, "DEFUN");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 if (gettext || defun) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 if (gettext) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 p = gettext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 p += 7; /* Skip over "GETTEXT" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 else if (defun) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 p = defun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 p += 5; /* Skip over "DEFUN" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 p = skip_blanks (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 if (*p++ != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 if (defun) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 for (i = 0; i < 5; i++) /* Skip over commas to doc string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 while (*p++ != ',')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 CHECK_EOL (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 if (*p == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 p = GET_LINE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 p = skip_blanks (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 if (*p != '\"') /* Make sure there is a quoted string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 if (defun && no_interactive_prompt (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 fprintf (outfile, "gettext(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (gettext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 p = copy_up_to_paren (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 p = copy_quoted_string (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 fprintf (outfile, ")\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 void process_Lisp_file (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 char *gettext, *interactive;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 enum boolean dgettext = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 while (p = GET_LINE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 gettext = strstr (p, "gettext");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 interactive = strstr (p, "(interactive");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 if (gettext || interactive) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (!interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 p = gettext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 else if (!gettext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 p = interactive;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 else if (gettext < interactive) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 p = gettext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 interactive = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 p = interactive;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 gettext = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 if (gettext) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 if (p > line && *(p-1) == 'd')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 dgettext = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 p += 7; /* Skip over "gettext" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 } else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 p += 12; /* Skip over "(interactive" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 p = skip_blanks (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 if (*p != '\"') /* Make sure there is a quoted string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (dgettext) { /* Skip first quoted string (domain name) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 while (*++p != '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ; /* null statement */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 ++p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 p = skip_blanks (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (*p != '\"') /* Check for second quoted string (message) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 if (interactive && no_interactive_prompt (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 fprintf (outfile, "gettext(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 p = copy_up_to_paren (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 fprintf (outfile, ")\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 /* Assuming p points to some character beyond an opening parenthesis, copy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 everything to outfile up to but not including the closing parenthesis.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 char *copy_up_to_paren (register char *p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 for (;;) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 SKIP_BLANKS (p); /* We don't call skip_blanks() in order to */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 CHECK_EOL (p); /* preserve blanks at the beginning of the line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 if (*p == ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 if (*p == '\"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 p = copy_quoted_string (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 fputc (*p++, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 return p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* Assuming p points to a quote character, copy the quoted string to outfile.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 char *copy_quoted_string (register char *p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 do {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 if (*p == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 fputc (*p++, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 fputc (*p++, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 CHECK_EOL (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 } while (*p != '\"');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 fputc (*p++, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 return p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 /* Return TRUE if the interactive specification consists only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 of code letters and no prompt.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 enum boolean no_interactive_prompt (register char *q)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 while (++q, *q == '*' || *q == '@')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ; /* null statement */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 if (*q == '\"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 skip_code_letter:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 if (*++q == '\"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 if (*q == '\\' && *++q == 'n') {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 ++q;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 goto skip_code_letter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 char *skip_blanks (register char *p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 while (*p == ' ' || *p == '\t' || *p == '\n') {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 CHECK_EOL (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 return p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 }