From d8880f69ff2e5c0a88007c48a5142db388426868 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 3 Nov 2000 16:52:45 +0000 Subject: [PATCH 1/1] Don't use `atexit'. * src/files.c (obstack_save): New function. (done): Rename as... (output_files): this. Use `obstack_save'. * src/main.c (main): Don't use `atexit' to register `done', since it no longer has to remove tmp files, just call `output_files' when there are no errors. --- ChangeLog | 12 +++++++++ po/de.po | 45 +++++++++++++++++++++++++++++---- po/es.po | 45 +++++++++++++++++++++++++++++---- po/et.po | 45 +++++++++++++++++++++++++++++---- po/fr.po | 45 +++++++++++++++++++++++++++++---- po/ja.po | 45 +++++++++++++++++++++++++++++---- po/nl.po | 45 +++++++++++++++++++++++++++++---- po/ru.po | 45 +++++++++++++++++++++++++++++---- src/files.c | 71 +++++++++++++++++++++++++---------------------------- src/files.h | 2 +- src/main.c | 6 ++--- 11 files changed, 330 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index e48feda7..6f84dacb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2000-11-03 Akim Demaille + + Don't use `atexit'. + + * src/files.c (obstack_save): New function. + (done): Rename as... + (output_files): this. + Use `obstack_save'. + * src/main.c (main): Don't use `atexit' to register `done', since + it no longer has to remove tmp files, just call `output_files' + when there are no errors. + 2000-11-02 Akim Demaille * src/files.c [VMS]: No longer include `ssdef.h', no longer define diff --git a/po/de.po b/po/de.po index 20bbad85..c5dd45c9 100644 --- a/po/de.po +++ b/po/de.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.25\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 1996-10-10 17:54 MET DST\n" "Last-Translator: Ulrich Drepper \n" "Language-Team: German \n" @@ -249,7 +249,7 @@ msgstr "unerwarteter Typname" msgid "use \"...\" for multi-character literal tokens" msgstr "für Literal mit mehreren Zeichen bitte \"...\" verwenden" -#: src/main.c:104 +#: src/main.c:103 #, fuzzy, c-format msgid "%s: internal error: %s\n" msgstr "interner Fehler, %s\n" @@ -674,6 +674,10 @@ msgstr "" "Reduzierung von %s definiert %d Terminal, %d Nicht-Terminal und %d " "Produktionen.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -733,12 +737,43 @@ msgstr "%s: die Option msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: die Option »--%s« erlaubt kein Argument\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: Hauptspeicher erschöpft\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: Hauptspeicher erschöpft\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s ist unzulässig" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: Hauptspeicher erschöpft\n" - #~ msgid "unmatched close-brace (`}')" #~ msgstr "schließende geschweifte Klammer (»}«) hat kein Gegenstück" diff --git a/po/es.po b/po/es.po index 282936b1..7f700560 100644 --- a/po/es.po +++ b/po/es.po @@ -30,7 +30,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU bison 1.25\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 1998-09-21 10:19+0200\n" "Last-Translator: Nicolás García-Pedrajas \n" "Language-Team: Spanish \n" @@ -310,7 +310,7 @@ msgstr "nombre de tipo sin terminar" msgid "use \"...\" for multi-character literal tokens" msgstr "use \"...\" para terminales literales multicarácter" -#: src/main.c:104 +#: src/main.c:103 #, fuzzy, c-format msgid "%s: internal error: %s\n" msgstr "error interno, %s\n" @@ -778,6 +778,10 @@ msgstr "" "la reducción de %s define %d terminal%s, %d no terminal%s, y %d " "produccion%s.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -861,12 +865,43 @@ msgstr "%s: la opci msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: la opción `--%s' no admite ningún argumento\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: memoria agotada\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: memoria agotada\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s no es válida" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: memoria agotada\n" - #~ msgid "unmatched close-brace (`}')" #~ msgstr "llave de cierre (`}') desemparejada" diff --git a/po/et.po b/po/et.po index 31d70c95..3d520b40 100644 --- a/po/et.po +++ b/po/et.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.25\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 2000-04-11 22:19+02:00\n" "Last-Translator: Toomas Soome \n" "Language-Team: Estonian \n" @@ -272,7 +272,7 @@ msgstr "l msgid "use \"...\" for multi-character literal tokens" msgstr "kasuta mitmesümboliliste literaalidega \"...\" konstruktsiooni" -#: src/main.c:104 +#: src/main.c:103 #, c-format msgid "%s: internal error: %s\n" msgstr "%s: sisemine viga: %s\n" @@ -693,6 +693,10 @@ msgstr "" "redutseeritud %s defineerib %d terminali%s, %d mitteterminali%s ja %d " "reeglit%s.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -752,12 +756,43 @@ msgstr "%s: v msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: võti `-W %s' ei luba argumenti\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: mälu on otsas\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: mälu on otsas\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s on vigane" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: mälu on otsas\n" - #~ msgid "multiple %union declarations" #~ msgstr "korduvad %union deklaratsioonid" diff --git a/po/fr.po b/po/fr.po index 0d9bd6d1..b0d2555a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.25\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 1996-03-19 20:05 EST\n" "Last-Translator: Dominique Boucher \n" "Language-Team: French \n" @@ -255,7 +255,7 @@ msgstr "le nom de type ne se termine pas" msgid "use \"...\" for multi-character literal tokens" msgstr "utilisez \"...\" pour les terminaux litéraux de plusieurs caractères" -#: src/main.c:104 +#: src/main.c:103 #, fuzzy, c-format msgid "%s: internal error: %s\n" msgstr "erreur interne, %s\n" @@ -678,6 +678,10 @@ msgstr "" "la réduction de %s définit %d terminal%s, %d catégorie%s et %d " "production%s.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -737,12 +741,43 @@ msgstr "%s: l'option %s est ambig msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: l'option --%s n'admet pas de paramètre\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: mémoire épuisée\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: mémoire épuisée\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s n'est pas valide" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: mémoire épuisée\n" - #~ msgid "unmatched close-brace (`}')" #~ msgstr "accolade fermante `}' non appariée" diff --git a/po/ja.po b/po/ja.po index e0d637d1..0bb41cf4 100644 --- a/po/ja.po +++ b/po/ja.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU bison 1.28\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 1999-09-28 21:10+0900\n" "Last-Translator: Daisuke Yamashita \n" "Language-Team: Japanese \n" @@ -254,7 +254,7 @@ msgstr " msgid "use \"...\" for multi-character literal tokens" msgstr "Ê£¿ôʸ»ú¤Î¥ê¥Æ¥é¥ë¥È¡¼¥¯¥ó¤Ë¤Ï \"...\" ¤ò»È¤¤¤Þ¤·¤ç¤¦" -#: src/main.c:104 +#: src/main.c:103 #, c-format msgid "%s: internal error: %s\n" msgstr "%s: ÆâÉô¥¨¥é¡¼: %s\n" @@ -676,6 +676,10 @@ msgstr "" "´Ô¸µ¥Õ¥¡¥¤¥ë %s ¤Ç %d ¸Ä¤Î½ªÃ¼»Ò%.0s, %d ¸Ä¤ÎÈó½ªÃ¼»Ò%.0s, %d " "¸Ä¤Îµ¬Â§%.0s¤¬ÄêµÁ¤µ¤ì¤Þ¤·¤¿\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -735,12 +739,43 @@ msgstr "%s: msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: ¥ª¥×¥·¥ç¥ó `-W %s' ¤Ï°ú¿ô¤òµö¤·¤Þ¤»¤ó\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: ¥á¥â¥ê¤ò»È¤¤²Ì¤¿¤·¤Þ¤·¤¿\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: ¥á¥â¥ê¤ò»È¤¤²Ì¤¿¤·¤Þ¤·¤¿\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s ¤Ï̵¸ú¤Ç¤¹" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: ¥á¥â¥ê¤ò»È¤¤²Ì¤¿¤·¤Þ¤·¤¿\n" - #~ msgid "" #~ "\n" #~ "\n" diff --git a/po/nl.po b/po/nl.po index 83377139..68eb4bd5 100644 --- a/po/nl.po +++ b/po/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.25\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 1996-08-27 15:34 MET DST\n" "Last-Translator: Erick Branderhorst \n" "Language-Team: Dutch \n" @@ -254,7 +254,7 @@ msgstr "niet getermineerd type naam" msgid "use \"...\" for multi-character literal tokens" msgstr "gebruik \"...\" voor meerdere karakters literal tekens" -#: src/main.c:104 +#: src/main.c:103 #, fuzzy, c-format msgid "%s: internal error: %s\n" msgstr "interne fout, %s\n" @@ -677,6 +677,10 @@ msgstr "" "gereduceerd %s gedefinieerd %d terminal%s, %d nietterminal%s, en %d " "productie%s.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -736,12 +740,43 @@ msgstr "%s: optie `%s' is niet eenduidig\n" msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: optie `--%s' staat geen argument toe\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: geen geheugen meer beschikbaar\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: geen geheugen meer beschikbaar\n" + #~ msgid "$%s is invalid" #~ msgstr "$%s is onjuist" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: geen geheugen meer beschikbaar\n" - #~ msgid "unmatched close-brace (`}')" #~ msgstr "niet overeenkomstige afsluit-haakje (`}')" diff --git a/po/ru.po b/po/ru.po index a678efe2..bc5b1c9e 100644 --- a/po/ru.po +++ b/po/ru.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.28a\n" -"POT-Creation-Date: 2000-11-02 12:45+0100\n" +"POT-Creation-Date: 2000-11-03 17:35+0100\n" "PO-Revision-Date: 2000-04-12 13:16+04:00\n" "Last-Translator: Dmitry S. Sivachenko \n" "Language-Team: Russian \n" @@ -274,7 +274,7 @@ msgstr " msgid "use \"...\" for multi-character literal tokens" msgstr "ÉÓÐÏÌØÚÕÊÔÅ \"...\" ÄÌÑ ÍÎÏÇÏÓÉÍ×ÏÌØÎÙÈ ÌÉÔÅÒÁÌØÎÙÈ ÌÅËÓÅÍ" -#: src/main.c:104 +#: src/main.c:103 #, c-format msgid "%s: internal error: %s\n" msgstr "%s: ×ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ: %s\n" @@ -694,6 +694,10 @@ msgstr "" "×Ù×ÅÄÅÎÎÙÊ %s ÏÐÒÅÄÅÌÑÅÔ %d ÔÅÒÍÉÎÁÌÏ×%s, %d ÎÅÔÅÒÍÉÎÁÌÏ×%s, É %d ÐÒÁ×ÉÌ " "×Ù×ÏÄÁ%s.\n" +#: lib/error.c:102 +msgid "Unknown system error" +msgstr "" + #: lib/getopt.c:675 #, c-format msgid "%s: option `%s' is ambiguous\n" @@ -753,12 +757,43 @@ msgstr "%s: msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: ËÌÀÞ `-W %s' ÄÏÌÖÅÎ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ ÂÅÚ ÁÒÇÕÍÅÎÔÁ\n" +#: lib/obstack.c:477 +#, fuzzy +msgid "memory exhausted" +msgstr "%s: ÐÁÍÑÔØ ÉÓÞÅÒÐÁÎÁ\n" + +#. Get translations for open and closing quotation marks. +#. +#. The message catalog should translate "`" to a left +#. quotation mark suitable for the locale, and similarly for +#. "'". If the catalog has no translation, +#. locale_quoting_style quotes `like this', and +#. clocale_quoting_style quotes "like this". +#. +#. For example, an American English Unicode locale should +#. translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and +#. should translate "'" to U+201D (RIGHT DOUBLE QUOTATION +#. MARK). A British English Unicode locale should instead +#. translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and +#. U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. +#: lib/quotearg.c:262 +msgid "`" +msgstr "" + +#: lib/quotearg.c:263 +msgid "'" +msgstr "" + +#. If XALLOC_FAIL_FUNC is NULL, or does return, display this message +#. before exiting when memory is exhausted. Goes through gettext. +#: lib/xmalloc.c:66 +#, fuzzy +msgid "Memory exhausted" +msgstr "%s: ÐÁÍÑÔØ ÉÓÞÅÒÐÁÎÁ\n" + #~ msgid "$%s is invalid" #~ msgstr "ÎÅ×ÅÒÎÙÊ ÚÎÁË $%s" -#~ msgid "%s: memory exhausted\n" -#~ msgstr "%s: ÐÁÍÑÔØ ÉÓÞÅÒÐÁÎÁ\n" - #~ msgid "multiple %union declarations" #~ msgstr "ÍÎÏÖÅÓÔ×ÅÎÎÏÅ ÏÐÉÓÁÎÉÅ %union" diff --git a/src/files.c b/src/files.c index 7e0b24a4..3e52ff66 100644 --- a/src/files.c +++ b/src/files.c @@ -136,9 +136,26 @@ xfclose (FILE *ptr) return result; } + +/*--------------------------------------------------. +| Save the content of the obstack OBS in FILENAME. | +`--------------------------------------------------*/ + +void +obstack_save (struct obstack *obs, const char *filename) +{ + FILE *out = xfopen (filename, "w"); + size_t size = obstack_object_size (obs); + fwrite (obstack_finish (obs), 1, size, out); + xfclose (out); +} + -/* JF this has been hacked to death. Nowaday it sets up the file names for - the output files, and opens the tmp files and the parser */ +/*-----------------------------------------------------------------. +| Open the input file. Look for the skeletons. Find the names of | +| the output files. Prepare the obstacks. | +`-----------------------------------------------------------------*/ + void open_files (void) { @@ -358,53 +375,33 @@ open_extra_files (void) fguard = xfopen (guardfile, "w"); } + +/*-----------------------------------------------------. +| Close the open files, produce all the output files. | +`-----------------------------------------------------*/ + void -done (void) +output_files (void) { xfclose (fguard); xfclose (finput); xfclose (fparser); xfclose (foutput); - /* JF write out the output file */ - if (!complain_message_count) - { - /* Output the main file. */ - FILE *ftab = xfopen (tabfile, "w"); - size_t size = obstack_object_size (&table_obstack); - fwrite (obstack_finish (&table_obstack), 1, size, ftab); - xfclose (ftab); - - /* Output the header file is wanted. */ - if (defines_flag) - { - FILE *fdefs = xfopen (defsfile, "w"); - size_t size = obstack_object_size (&defines_obstack); - fwrite (obstack_finish (&defines_obstack), 1, size, fdefs); - xfclose (fdefs); - } - } + /* Output the main file. */ + obstack_save (&table_obstack, tabfile); + + /* Output the header file if wanted. */ + if (defines_flag) + obstack_save (&defines_obstack, defsfile); - /* If we output only the table, dump the actions in ACTION_OBSTACK. + /* If we output only the table, dump the actions in ACTFILE. */ if (no_parser_flag) - { - FILE *faction = xfopen (actfile, "w"); - size_t size = obstack_object_size (&action_obstack); - fwrite (obstack_finish (&action_obstack), 1, size, faction); - xfclose (faction); - } + obstack_save (&action_obstack, actfile); /* If we produced a semantic parser ATTRS_OBSTACK must be dumped into its own file, ATTTRSFILE. */ if (semantic_parser) - { - FILE *fattrs = xfopen (attrsfile, "w"); - size_t size = obstack_object_size (&attrs_obstack); - fwrite (obstack_finish (&attrs_obstack), 1, size, fattrs); - xfclose (fattrs); - } - -/* Don't call exit again, we're in atexit (). - exit (complain_message_count ? 1 : 0); */ + obstack_save (&attrs_obstack, attrsfile); } diff --git a/src/files.h b/src/files.h index c0d4a362..961b3d4b 100644 --- a/src/files.h +++ b/src/files.h @@ -76,5 +76,5 @@ extern char *actfile; void open_files PARAMS((void)); void open_extra_files PARAMS((void)); -void done PARAMS((void)); +void output_files PARAMS((void)); #endif /* !FILES_H_ */ diff --git a/src/main.c b/src/main.c index d14657a1..1b3a45a1 100644 --- a/src/main.c +++ b/src/main.c @@ -50,9 +50,6 @@ main (int argc, char *argv[]) lineno = 0; getargs (argc, argv); - /* Be ready to clean up if we exit. */ - atexit (done); - open_files (); /* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE @@ -93,6 +90,9 @@ main (int argc, char *argv[]) free_nullable (); free_derives (); + if (!complain_message_count) + output_files (); + exit (complain_message_count ? 1 : 0); } -- 2.45.2