From: Bruno Haible Date: Wed, 29 May 2002 12:59:09 +0000 (+0000) Subject: Make xgettext -D and -j options work together. X-Git-Tag: v0.11.3~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3608e1634c7f344183d7bc507e023f17252955f;p=thirdparty%2Fgettext.git Make xgettext -D and -j options work together. --- diff --git a/src/ChangeLog b/src/ChangeLog index fc498fd7d..3f9355d5e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-05-29 Bruno Haible + + * dir-list.h (dir_list_save_reset, dir_list_restore): New declarations. + * dir-list.c (dir_list_save_reset, dir_list_restore): New functions. + * xgettext.c (main): Temporarily reset the dir_list while opening + reading the contents of the output file. + Reported by Mark Eichin . + 2002-05-22 Bruno Haible * msgl-iconv.h (iconv_message_list): Add from_filename argument. diff --git a/src/dir-list.c b/src/dir-list.c index 851b8524b..e802e1af9 100644 --- a/src/dir-list.c +++ b/src/dir-list.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1996, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000-2002 Free Software Foundation, Inc. This file was written by Peter Miller @@ -56,3 +56,33 @@ dir_list_nth (n) return NULL; return directory->item[n]; } + + +/* Return the current list of directories, for later use with dir_list_restore. + Reset the list to empty. */ +void * +dir_list_save_reset () +{ + void *saved_value = directory; + + directory = NULL; + return saved_value; +} + + +/* Restore a previously saved list of directories. */ +void +dir_list_restore (saved_value) + void *saved_value; +{ + /* Don't free the contained strings, because they may have been returned + by dir_list_nth and may still be in use. */ + if (directory != NULL) + { + if (directory->item != NULL) + free (directory->item); + free (directory); + } + + directory = saved_value; +} diff --git a/src/dir-list.h b/src/dir-list.h index ffa68f0de..38d0e1b06 100644 --- a/src/dir-list.h +++ b/src/dir-list.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1996, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000-2002 Free Software Foundation, Inc. This file was written by Peter Miller @@ -30,4 +30,11 @@ extern void dir_list_append PARAMS ((const char *directory)); /* Return the nth directory, or NULL of n is out of range. */ extern const char *dir_list_nth PARAMS ((int n)); +/* Return the current list of directories, for later use with dir_list_restore. + Reset the list to empty. */ +extern void *dir_list_save_reset PARAMS ((void)); + +/* Restore a previously saved list of directories. */ +extern void dir_list_restore PARAMS ((void *saved_value)); + #endif /* _DIR_LIST_H */ diff --git a/src/xgettext.c b/src/xgettext.c index eed8f628f..33982848b 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -459,7 +459,15 @@ xgettext cannot work without keywords to look for")); /* Read in the old messages, so that we can add to them. */ if (join_existing) - extract_from_file (file_name, extract_po, mdlp); + { + /* Temporarily reset the directory list to empty, because file_name + is an output file and therefore should not be searched for. */ + void *saved_directory_list = dir_list_save_reset (); + + extract_from_file (file_name, extract_po, mdlp); + + dir_list_restore (saved_directory_list); + } /* Process all input files. */ for (cnt = 0; cnt < file_list->nitems; ++cnt)