1 /* Copyright (C) 1996-2004, 2005, 2006, 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; 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,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 #include <sys/param.h>
34 #include "../../crypt/md5.h"
35 #include "localedef.h"
36 #include "localeinfo.h"
38 #include "simple-hash.h"
40 #include "locfile-kw.h"
42 #define obstack_chunk_alloc xmalloc
43 #define obstack_chunk_free free
45 /* Temporary storage of the locale data before writing it to the archive. */
46 static locale_data_t to_archive;
50 locfile_read (struct localedef_t *result, const struct charmap_t *charmap)
52 const char *filename = result->name;
53 const char *repertoire_name = result->repertoire_name;
54 int locale_mask = result->needed & ~result->avail;
55 struct linereader *ldfile;
56 int not_here = ALL_LOCALES;
58 /* If no repertoire name was specified use the global one. */
59 if (repertoire_name == NULL)
60 repertoire_name = repertoire_global;
62 /* Open the locale definition file. */
63 ldfile = lr_open (filename, locfile_hash);
66 if (filename != NULL && filename[0] != '/')
68 char *i18npath = getenv ("I18NPATH");
69 if (i18npath != NULL && *i18npath != '\0')
71 const size_t pathlen = strlen (i18npath);
72 char i18npathbuf[pathlen + 1];
73 char path[strlen (filename) + 1 + pathlen
74 + sizeof ("/locales/") - 1];
76 i18npath = memcpy (i18npathbuf, i18npath, pathlen + 1);
79 && (next = strsep (&i18npath, ":")) != NULL)
81 stpcpy (stpcpy (stpcpy (path, next), "/locales/"), filename);
83 ldfile = lr_open (path, locfile_hash);
87 stpcpy (stpcpy (path, next), filename);
89 ldfile = lr_open (path, locfile_hash);
94 /* Test in the default directory. */
97 char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)];
99 stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename);
100 ldfile = lr_open (path, locfile_hash);
108 /* Parse locale definition file and store result in RESULT. */
111 struct token *now = lr_token (ldfile, charmap, NULL, NULL, verbose);
112 enum token_t nowtok = now->tok;
115 if (nowtok == tok_eof)
118 if (nowtok == tok_eol)
119 /* Ignore empty lines. */
124 case tok_escape_char:
125 case tok_comment_char:
126 /* We need an argument. */
127 arg = lr_token (ldfile, charmap, NULL, NULL, verbose);
129 if (arg->tok != tok_ident)
131 SYNTAX_ERROR (_("bad argument"));
135 if (arg->val.str.lenmb != 1)
137 lr_error (ldfile, _("\
138 argument to `%s' must be a single character"),
139 nowtok == tok_escape_char
140 ? "escape_char" : "comment_char");
142 lr_ignore_rest (ldfile, 0);
146 if (nowtok == tok_escape_char)
147 ldfile->escape_char = *arg->val.str.startmb;
149 ldfile->comment_char = *arg->val.str.startmb;
152 case tok_repertoiremap:
153 /* We need an argument. */
154 arg = lr_token (ldfile, charmap, NULL, NULL, verbose);
156 if (arg->tok != tok_ident)
158 SYNTAX_ERROR (_("bad argument"));
162 if (repertoire_name == NULL)
164 char *newp = alloca (arg->val.str.lenmb + 1);
166 *((char *) mempcpy (newp, arg->val.str.startmb,
167 arg->val.str.lenmb)) = '\0';
168 repertoire_name = newp;
173 ctype_read (ldfile, result, charmap, repertoire_name,
174 (locale_mask & CTYPE_LOCALE) == 0);
175 result->avail |= locale_mask & CTYPE_LOCALE;
176 not_here ^= CTYPE_LOCALE;
180 collate_read (ldfile, result, charmap, repertoire_name,
181 (locale_mask & COLLATE_LOCALE) == 0);
182 result->avail |= locale_mask & COLLATE_LOCALE;
183 not_here ^= COLLATE_LOCALE;
186 case tok_lc_monetary:
187 monetary_read (ldfile, result, charmap, repertoire_name,
188 (locale_mask & MONETARY_LOCALE) == 0);
189 result->avail |= locale_mask & MONETARY_LOCALE;
190 not_here ^= MONETARY_LOCALE;
194 numeric_read (ldfile, result, charmap, repertoire_name,
195 (locale_mask & NUMERIC_LOCALE) == 0);
196 result->avail |= locale_mask & NUMERIC_LOCALE;
197 not_here ^= NUMERIC_LOCALE;
201 time_read (ldfile, result, charmap, repertoire_name,
202 (locale_mask & TIME_LOCALE) == 0);
203 result->avail |= locale_mask & TIME_LOCALE;
204 not_here ^= TIME_LOCALE;
207 case tok_lc_messages:
208 messages_read (ldfile, result, charmap, repertoire_name,
209 (locale_mask & MESSAGES_LOCALE) == 0);
210 result->avail |= locale_mask & MESSAGES_LOCALE;
211 not_here ^= MESSAGES_LOCALE;
215 paper_read (ldfile, result, charmap, repertoire_name,
216 (locale_mask & PAPER_LOCALE) == 0);
217 result->avail |= locale_mask & PAPER_LOCALE;
218 not_here ^= PAPER_LOCALE;
222 name_read (ldfile, result, charmap, repertoire_name,
223 (locale_mask & NAME_LOCALE) == 0);
224 result->avail |= locale_mask & NAME_LOCALE;
225 not_here ^= NAME_LOCALE;
229 address_read (ldfile, result, charmap, repertoire_name,
230 (locale_mask & ADDRESS_LOCALE) == 0);
231 result->avail |= locale_mask & ADDRESS_LOCALE;
232 not_here ^= ADDRESS_LOCALE;
235 case tok_lc_telephone:
236 telephone_read (ldfile, result, charmap, repertoire_name,
237 (locale_mask & TELEPHONE_LOCALE) == 0);
238 result->avail |= locale_mask & TELEPHONE_LOCALE;
239 not_here ^= TELEPHONE_LOCALE;
242 case tok_lc_measurement:
243 measurement_read (ldfile, result, charmap, repertoire_name,
244 (locale_mask & MEASUREMENT_LOCALE) == 0);
245 result->avail |= locale_mask & MEASUREMENT_LOCALE;
246 not_here ^= MEASUREMENT_LOCALE;
249 case tok_lc_identification:
250 identification_read (ldfile, result, charmap, repertoire_name,
251 (locale_mask & IDENTIFICATION_LOCALE) == 0);
252 result->avail |= locale_mask & IDENTIFICATION_LOCALE;
253 not_here ^= IDENTIFICATION_LOCALE;
258 syntax error: not inside a locale definition section"));
262 /* The rest of the line must be empty. */
263 lr_ignore_rest (ldfile, 1);
266 /* We read all of the file. */
269 /* Mark the categories which are not contained in the file. We assume
270 them to be available and the default data will be used. */
271 result->avail |= not_here;
277 /* Semantic checking of locale specifications. */
279 static void (*const check_funcs[]) (struct localedef_t *,
280 const struct charmap_t *) =
282 [LC_CTYPE] = ctype_finish,
283 [LC_COLLATE] = collate_finish,
284 [LC_MESSAGES] = messages_finish,
285 [LC_MONETARY] = monetary_finish,
286 [LC_NUMERIC] = numeric_finish,
287 [LC_TIME] = time_finish,
288 [LC_PAPER] = paper_finish,
289 [LC_NAME] = name_finish,
290 [LC_ADDRESS] = address_finish,
291 [LC_TELEPHONE] = telephone_finish,
292 [LC_MEASUREMENT] = measurement_finish,
293 [LC_IDENTIFICATION] = identification_finish
297 check_all_categories (struct localedef_t *definitions,
298 const struct charmap_t *charmap)
302 for (cnt = 0; cnt < sizeof (check_funcs) / sizeof (check_funcs[0]); ++cnt)
303 if (check_funcs[cnt] != NULL)
304 check_funcs[cnt] (definitions, charmap);
308 /* Writing the locale data files. All files use the same output_path. */
310 static void (*const write_funcs[]) (struct localedef_t *,
311 const struct charmap_t *, const char *) =
313 [LC_CTYPE] = ctype_output,
314 [LC_COLLATE] = collate_output,
315 [LC_MESSAGES] = messages_output,
316 [LC_MONETARY] = monetary_output,
317 [LC_NUMERIC] = numeric_output,
318 [LC_TIME] = time_output,
319 [LC_PAPER] = paper_output,
320 [LC_NAME] = name_output,
321 [LC_ADDRESS] = address_output,
322 [LC_TELEPHONE] = telephone_output,
323 [LC_MEASUREMENT] = measurement_output,
324 [LC_IDENTIFICATION] = identification_output
329 write_all_categories (struct localedef_t *definitions,
330 const struct charmap_t *charmap, const char *locname,
331 const char *output_path)
335 for (cnt = 0; cnt < sizeof (write_funcs) / sizeof (write_funcs[0]); ++cnt)
336 if (write_funcs[cnt] != NULL)
337 write_funcs[cnt] (definitions, charmap, output_path);
341 /* The data has to be added to the archive. Do this now. */
342 struct locarhandle ah;
344 /* Open the archive. This call never returns if we cannot
345 successfully open the archive. */
346 open_archive (&ah, false);
348 if (add_locale_to_archive (&ah, locname, to_archive, true) != 0)
349 error (EXIT_FAILURE, errno, _("cannot add to locale archive"));
357 /* Return a NULL terminated list of the directories next to output_path
358 that have the same owner, group, permissions and device as output_path. */
360 siblings_uncached (const char *output_path)
364 struct stat output_stat;
369 /* Remove trailing slashes and trailing pathname component. */
370 len = strlen (output_path);
371 base = (char *) alloca (len);
372 memcpy (base, output_path, len);
374 while (p > base && p[-1] == '/')
380 while (p > base && p[-1] != '/');
386 /* Get the properties of output_path. */
387 if (lstat (output_path, &output_stat) < 0 || !S_ISDIR (output_stat.st_mode))
390 /* Iterate through the directories in base directory. */
391 dirp = opendir (base);
398 struct dirent64 *other_dentry;
399 const char *other_name;
401 struct stat other_stat;
403 other_dentry = readdir64 (dirp);
404 if (other_dentry == NULL)
407 other_name = other_dentry->d_name;
408 if (strcmp (other_name, ".") == 0 || strcmp (other_name, "..") == 0)
411 other_path = (char *) xmalloc (len + 1 + strlen (other_name) + 2);
412 memcpy (other_path, base, len);
413 other_path[len] = '/';
414 strcpy (other_path + len + 1, other_name);
416 if (lstat (other_path, &other_stat) >= 0
417 && S_ISDIR (other_stat.st_mode)
418 && other_stat.st_uid == output_stat.st_uid
419 && other_stat.st_gid == output_stat.st_gid
420 && other_stat.st_mode == output_stat.st_mode
421 && other_stat.st_dev == output_stat.st_dev)
423 /* Found a subdirectory. Add a trailing slash and store it. */
424 p = other_path + len + 1 + strlen (other_name);
427 elems = (const char **) xrealloc ((char *) elems,
428 (nelems + 2) * sizeof (char **));
429 elems[nelems++] = other_path;
437 elems[nelems] = NULL;
442 /* Return a NULL terminated list of the directories next to output_path
443 that have the same owner, group, permissions and device as output_path.
444 Cache the result for future calls. */
446 siblings (const char *output_path)
448 static const char *last_output_path;
449 static const char **last_result;
451 if (output_path != last_output_path)
453 if (last_result != NULL)
457 for (p = last_result; *p != NULL; p++)
462 last_output_path = output_path;
463 last_result = siblings_uncached (output_path);
469 /* Read as many bytes from a file descriptor as possible. */
471 full_read (int fd, void *bufarea, size_t nbyte)
473 char *buf = (char *) bufarea;
477 ssize_t retval = read (fd, buf, nbyte);
486 else if (errno != EINTR)
489 return buf - (char *) bufarea;
493 /* Compare the contents of two regular files of the same size. Return 0
494 if they are equal, 1 if they are different, or -1 if an error occurs. */
496 compare_files (const char *filename1, const char *filename2, size_t size,
502 fd1 = open (filename1, O_RDONLY);
505 fd2 = open (filename2, O_RDONLY);
508 char *buf1 = (char *) xmalloc (2 * blocksize);
509 char *buf2 = buf1 + blocksize;
514 size_t bytes = (size < blocksize ? size : blocksize);
516 if (full_read (fd1, buf1, bytes) < (ssize_t) bytes)
521 if (full_read (fd2, buf2, bytes) < (ssize_t) bytes)
526 if (memcmp (buf1, buf2, bytes) != 0)
542 /* True if the locale files use the opposite endianness to the
543 machine running localedef. */
544 int swap_endianness_p;
546 /* The target's value of __align__(uint32_t) - 1. */
547 unsigned int uint32_align_mask = 3;
549 /* When called outside a start_locale_structure()/end_locale_structure()
550 or start_locale_prelude()/end_locale_prelude() block, record that the
551 next byte in FILE's obstack will be the first byte of a new element.
552 Do likewise for the first call inside a start_locale_structure()/
553 end_locale_structure() block. */
555 record_offset (struct locale_file *file)
557 if (file->structure_stage < 2)
559 assert (file->next_element < file->n_elements);
560 file->offsets[file->next_element++]
561 = (obstack_object_size (&file->data)
562 + (file->n_elements + 2) * sizeof (uint32_t));
563 if (file->structure_stage == 1)
564 file->structure_stage = 2;
568 /* Initialize FILE for a new output file. N_ELEMENTS is the number
569 of elements in the file. */
571 init_locale_data (struct locale_file *file, size_t n_elements)
573 file->n_elements = n_elements;
574 file->next_element = 0;
575 file->offsets = xmalloc (sizeof (uint32_t) * n_elements);
576 obstack_init (&file->data);
577 file->structure_stage = 0;
580 /* Align the size of FILE's obstack object to BOUNDARY bytes. */
582 align_locale_data (struct locale_file *file, size_t boundary)
584 size_t size = -obstack_object_size (&file->data) & (boundary - 1);
585 obstack_blank (&file->data, size);
586 memset (obstack_next_free (&file->data) - size, 0, size);
589 /* Record that FILE's next element contains no data. */
591 add_locale_empty (struct locale_file *file)
593 record_offset (file);
596 /* Record that FILE's next element consists of SIZE bytes starting at DATA. */
598 add_locale_raw_data (struct locale_file *file, const void *data, size_t size)
600 record_offset (file);
601 obstack_grow (&file->data, data, size);
604 /* Finish the current object on OBSTACK and use it as the data for FILE's
607 add_locale_raw_obstack (struct locale_file *file, struct obstack *obstack)
609 size_t size = obstack_object_size (obstack);
610 record_offset (file);
611 obstack_grow (&file->data, obstack_finish (obstack), size);
614 /* Use STRING as FILE's next element. */
616 add_locale_string (struct locale_file *file, const char *string)
618 record_offset (file);
619 obstack_grow (&file->data, string, strlen (string) + 1);
622 /* Likewise for wide strings. */
624 add_locale_wstring (struct locale_file *file, const uint32_t *string)
626 add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1);
629 /* Record that FILE's next element is the 32-bit integer VALUE. */
631 add_locale_uint32 (struct locale_file *file, uint32_t value)
633 align_locale_data (file, sizeof (uint32_t));
634 record_offset (file);
635 value = maybe_swap_uint32 (value);
636 obstack_grow (&file->data, &value, sizeof (value));
639 /* Record that FILE's next element is an array of N_ELEMS integers
642 add_locale_uint32_array (struct locale_file *file,
643 const uint32_t *data, size_t n_elems)
645 align_locale_data (file, sizeof (uint32_t));
646 record_offset (file);
647 obstack_grow (&file->data, data, n_elems * sizeof (uint32_t));
648 maybe_swap_uint32_obstack (&file->data, n_elems);
651 /* Record that FILE's next element is the single byte given by VALUE. */
653 add_locale_char (struct locale_file *file, char value)
655 record_offset (file);
656 obstack_1grow (&file->data, value);
659 /* Start building an element that contains several different pieces of data.
660 Subsequent calls to add_locale_*() will add data to the same element up
661 till the next call to end_locale_structure(). The element's alignment
662 is dictated by the first piece of data added to it. */
664 start_locale_structure (struct locale_file *file)
666 assert (file->structure_stage == 0);
667 file->structure_stage = 1;
670 /* Finish a structure element that was started by start_locale_structure().
671 Empty structures are OK and behave like add_locale_empty(). */
673 end_locale_structure (struct locale_file *file)
675 record_offset (file);
676 assert (file->structure_stage == 2);
677 file->structure_stage = 0;
680 /* Start building data that goes before the next element's recorded offset.
681 Subsequent calls to add_locale_*() will add data to the file without
682 treating any of it as the start of a new element. Calling
683 end_locale_prelude() switches back to the usual behavior. */
685 start_locale_prelude (struct locale_file *file)
687 assert (file->structure_stage == 0);
688 file->structure_stage = 3;
691 /* End a block started by start_locale_prelude(). */
693 end_locale_prelude (struct locale_file *file)
695 assert (file->structure_stage == 3);
696 file->structure_stage = 0;
699 /* Write a locale file, with contents given by FILE. */
701 write_locale_data (const char *output_path, int catidx, const char *category,
702 struct locale_file *file)
704 size_t cnt, step, maxiov;
707 const char **other_paths;
712 assert (file->n_elements == file->next_element);
713 header[0] = LIMAGIC (catidx);
714 header[1] = file->n_elements;
715 vec[0].iov_len = sizeof (header);
716 vec[0].iov_base = header;
717 vec[1].iov_len = sizeof (uint32_t) * file->n_elements;
718 vec[1].iov_base = file->offsets;
719 vec[2].iov_len = obstack_object_size (&file->data);
720 vec[2].iov_base = obstack_finish (&file->data);
721 maybe_swap_uint32_array (vec[0].iov_base, 2);
722 maybe_swap_uint32_array (vec[1].iov_base, file->n_elements);
726 /* The data will be added to the archive. For now we simply
727 generate the image which will be written. First determine
732 to_archive[catidx].size = 0;
733 for (cnt = 0; cnt < n_elem; ++cnt)
734 to_archive[catidx].size += vec[cnt].iov_len;
736 /* Allocate the memory for it. */
737 to_archive[catidx].addr = xmalloc (to_archive[catidx].size);
740 for (cnt = 0, endp = to_archive[catidx].addr; cnt < n_elem; ++cnt)
741 endp = mempcpy (endp, vec[cnt].iov_base, vec[cnt].iov_len);
743 /* Compute the MD5 sum for the data. */
744 __md5_buffer (to_archive[catidx].addr, to_archive[catidx].size,
745 to_archive[catidx].sum);
750 fname = xmalloc (strlen (output_path) + 2 * strlen (category) + 7);
752 /* Normally we write to the directory pointed to by the OUTPUT_PATH.
753 But for LC_MESSAGES we have to take care for the translation
754 data. This means we need to have a directory LC_MESSAGES in
755 which we place the file under the name SYS_LC_MESSAGES. */
756 sprintf (fname, "%s%s", output_path, category);
758 if (strcmp (category, "LC_MESSAGES") == 0)
762 if (stat (fname, &st) < 0)
764 if (mkdir (fname, 0777) >= 0)
770 else if (!S_ISREG (st.st_mode))
777 /* Create the locale file with nlinks == 1; this avoids crashing processes
778 which currently use the locale and damaging files belonging to other
783 fd = creat (fname, 0666);
788 int save_err = errno;
792 sprintf (fname, "%1$s%2$s/SYS_%2$s", output_path, category);
794 fd = creat (fname, 0666);
802 WITH_CUR_LOCALE (error (0, save_err, _("\
803 cannot open output file `%s' for category `%s'"), fname, category));
812 maxiov = sysconf (_SC_UIO_MAXIOV);
815 /* Write the data using writev. But we must take care for the
816 limitation of the implementation. */
817 for (cnt = 0; cnt < n_elem; cnt += step)
821 step = MIN (maxiov, step);
823 if (writev (fd, &vec[cnt], step) < 0)
826 WITH_CUR_LOCALE (error (0, errno, _("\
827 failure while writing data for category `%s'"), category));
834 /* Compare the file with the locale data files for the same category in
835 other locales, and see if we can reuse it, to save disk space. */
836 other_paths = siblings (output_path);
837 if (other_paths != NULL)
839 struct stat fname_stat;
841 if (lstat (fname, &fname_stat) >= 0
842 && S_ISREG (fname_stat.st_mode))
844 const char *fname_tail = fname + strlen (output_path);
845 const char **other_p;
850 for (other_p = other_paths; *other_p; other_p++)
852 seen_inodes = (ino_t *) xmalloc (seen_count * sizeof (ino_t));
855 for (other_p = other_paths; *other_p; other_p++)
857 const char *other_path = *other_p;
858 size_t other_path_len = strlen (other_path);
860 struct stat other_fname_stat;
863 (char *) xmalloc (other_path_len + strlen (fname_tail) + 1);
864 memcpy (other_fname, other_path, other_path_len);
865 strcpy (other_fname + other_path_len, fname_tail);
867 if (lstat (other_fname, &other_fname_stat) >= 0
868 && S_ISREG (other_fname_stat.st_mode)
869 /* Consider only files on the same device.
870 Otherwise hard linking won't work anyway. */
871 && other_fname_stat.st_dev == fname_stat.st_dev
872 /* Consider only files with the same permissions.
873 Otherwise there are security risks. */
874 && other_fname_stat.st_uid == fname_stat.st_uid
875 && other_fname_stat.st_gid == fname_stat.st_gid
876 && other_fname_stat.st_mode == fname_stat.st_mode
877 /* Don't compare fname with itself. */
878 && other_fname_stat.st_ino != fname_stat.st_ino
879 /* Files must have the same size, otherwise they
880 cannot be the same. */
881 && other_fname_stat.st_size == fname_stat.st_size)
883 /* Skip this file if we have already read it (under a
887 for (i = seen_count - 1; i >= 0; i--)
888 if (seen_inodes[i] == other_fname_stat.st_ino)
892 /* Now compare fname and other_fname for real. */
895 #ifdef _STATBUF_ST_BLKSIZE
896 blocksize = MAX (fname_stat.st_blksize,
897 other_fname_stat.st_blksize);
898 if (blocksize > 8 * 1024)
899 blocksize = 8 * 1024;
901 blocksize = 8 * 1024;
904 if (compare_files (fname, other_fname,
905 fname_stat.st_size, blocksize) == 0)
907 /* Found! other_fname is identical to fname. */
908 /* Link other_fname to fname. But use a temporary
909 file, in case hard links don't work on the
910 particular filesystem. */
912 (char *) xmalloc (strlen (fname) + 4 + 1);
914 strcpy (stpcpy (tmp_fname, fname), ".tmp");
916 if (link (other_fname, tmp_fname) >= 0)
919 if (rename (tmp_fname, fname) < 0)
922 WITH_CUR_LOCALE (error (0, errno, _("\
923 cannot create output file `%s' for category `%s'"), fname, category));
932 /* Don't compare with this file a second time. */
933 seen_inodes[seen_count++] = other_fname_stat.st_ino;
946 /* General handling of `copy'. */
948 handle_copy (struct linereader *ldfile, const struct charmap_t *charmap,
949 const char *repertoire_name, struct localedef_t *result,
950 enum token_t token, int locale, const char *locale_name,
956 now = lr_token (ldfile, charmap, result, NULL, verbose);
957 if (now->tok != tok_string)
958 lr_error (ldfile, _("expecting string argument for `copy'"));
959 else if (!ignore_content)
961 if (now->val.str.startmb == NULL)
962 lr_error (ldfile, _("\
963 locale name should consist only of portable characters"));
966 (void) add_to_readlist (locale, now->val.str.startmb,
967 repertoire_name, 1, NULL);
968 result->copy_name[locale] = now->val.str.startmb;
972 lr_ignore_rest (ldfile, now->tok == tok_string);
974 /* The rest of the line must be empty and the next keyword must be
976 while ((now = lr_token (ldfile, charmap, result, NULL, verbose))->tok
977 != tok_end && now->tok != tok_eof)
981 lr_error (ldfile, _("\
982 no other keyword shall be specified when `copy' is used"));
986 lr_ignore_rest (ldfile, 0);
989 if (now->tok != tok_eof)
991 /* Handle `END xxx'. */
992 now = lr_token (ldfile, charmap, result, NULL, verbose);
994 if (now->tok != token)
995 lr_error (ldfile, _("\
996 `%1$s' definition does not end with `END %1$s'"), locale_name);
998 lr_ignore_rest (ldfile, now->tok == token);
1001 /* When we come here we reached the end of the file. */
1002 lr_error (ldfile, _("%s: premature end of file"), locale_name);