From 271e972ff00f6c155fb4f5072916c163fb1ff809 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Fri, 10 Nov 2000 18:15:43 +0000 Subject: [PATCH] Rocco's changes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@279 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- nano.c | 224 +++++++++++++++++++++++++----------------------- po/cat-id-tbl.c | 119 +++++++++++++------------ po/de.gmo | Bin 17217 -> 17217 bytes po/de.po | 2 +- po/es.gmo | Bin 17270 -> 17270 bytes po/es.po | 2 +- po/fi.gmo | Bin 13445 -> 13445 bytes po/fi.po | 2 +- po/fr.po | 2 +- po/id.gmo | Bin 13114 -> 13114 bytes po/id.po | 2 +- po/it.gmo | Bin 12888 -> 12888 bytes po/it.po | 2 +- po/nano.pot | 54 ++++++------ 14 files changed, 206 insertions(+), 203 deletions(-) diff --git a/nano.c b/nano.c index 9a88f081..e673e33a 100644 --- a/nano.c +++ b/nano.c @@ -1053,19 +1053,6 @@ void wrap_reset(void) #ifndef NANO_SMALL -/* Stuff we want to do when we exit the spell program one of its many ways */ -void exit_spell(char *tmpfilename, char *foo) -{ - free(foo); - - if (remove(tmpfilename) == -1) - statusbar(_("Error deleting tempfile, ack!")); - display_main_list(); -} -#endif - -#ifndef NANO_SMALL - int do_int_spell_fix(char *word) { char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL; @@ -1128,126 +1115,128 @@ int do_int_spell_fix(char *word) #ifndef NANO_SMALL /* Integrated spell checking using 'spell' program */ -int do_int_speller(void) +int do_int_speller(char *tempfile_name) { - - filestruct *fileptr; - char read_buff[2], *read_buff_ptr; - char curr_word[132], *curr_word_ptr; - int in_fd[2], out_fd[2]; + char *read_buff, *read_buff_ptr, *read_buff_word; + long pipe_buff_size; + int in_fd[2], tempfile_fd; int spell_status; pid_t pid_spell; ssize_t bytesread; - /* Input from spell pipe */ + /* Create a pipe to spell program */ + if (pipe(in_fd) == -1) return FALSE; - /* Output to spell pipe */ - if (pipe(out_fd) == -1) { + /* A new process to run spell in */ + + if ( (pid_spell = fork()) == 0) { + + /* Child continues, (i.e. future spell process) */ close(in_fd[0]); - close(in_fd[1]); - return FALSE; - } + /* replace the standard in with the tempfile */ - if ( (pid_spell = fork()) == 0) { + if ( (tempfile_fd = open(tempfile_name, O_RDONLY)) == -1) { - /* Child continues, (i.e. future spell process) */ + close(in_fd[1]); + exit(1); + } - close(in_fd[1]); - close(out_fd[0]); + if (dup2(tempfile_fd, STDIN_FILENO) != STDIN_FILENO) { - /* setup spell standard in */ - if (dup2(in_fd[0], STDIN_FILENO) != STDIN_FILENO) - { - close(in_fd[0]); - close(out_fd[1]); - return FALSE; + close(tempfile_fd); + close(in_fd[1]); + exit(1); } - close(in_fd[0]); + close(tempfile_fd); - /* setup spell standard out */ - if (dup2(out_fd[1], STDOUT_FILENO) != STDOUT_FILENO) - { - close(out_fd[1]); - return FALSE; + /* send spell's standard out to the pipe */ + + if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) { + + close(in_fd[1]); + exit(1); } - close(out_fd[1]); + close(in_fd[1]); - /* Start spell program */ + /* Start spell program, we are using the PATH here!?!? */ execlp("spell", "spell", NULL); - /* Should not be reached, if spell is available!!! */ + /* Should not be reached, if spell is found!!! */ - exit(-1); + exit(1); } /* Parent continues here */ - close(in_fd[0]); /* close child's input pipe */ - close(out_fd[1]); /* close child's output pipe */ - - if (pid_spell < 0) { + close(in_fd[1]); - /* Child process was not forked successfully */ + /* Child process was not forked successfully */ - close(in_fd[1]); /* close parent's output pipe */ - close(out_fd[0]); /* close parent's input pipe */ + if (pid_spell < 0) { + close(in_fd[0]); return FALSE; } - /* Send out the file content to spell program */ + /* Get system pipe buffer size */ - fileptr = fileage; + if ( (pipe_buff_size = fpathconf(in_fd[0], _PC_PIPE_BUF)) < 1) { - while ( fileptr != NULL ) - { - write(in_fd[1], fileptr->data, strlen(fileptr->data)); - write(in_fd[1], "\n", 1); - fileptr = fileptr->next; + close(in_fd[0]); + return FALSE; } - close(in_fd[1]); - /* Let spell process the file */ + read_buff = nmalloc( pipe_buff_size + 1 ); - wait(&spell_status); - if (spell_status != 0) - return FALSE; + /* Process the returned spelling errors */ - /* Read spelling errors from spell */ + while ( (bytesread = read(in_fd[0], read_buff, pipe_buff_size)) > 0) { - curr_word_ptr = curr_word; + read_buff[bytesread] = (char) NULL; + read_buff_word = read_buff_ptr = read_buff; - while ( (bytesread = read(out_fd[0], read_buff, sizeof(read_buff) - 1)) > 0) - { - read_buff[bytesread]=(char) NULL; - read_buff_ptr = read_buff; + while (*read_buff_ptr != (char) NULL) { + + /* Windows version may need to process additional char '\r' */ + + /* Possible problem here if last word not followed by '\n' */ - while (*read_buff_ptr != (char) NULL) - { if (*read_buff_ptr == '\n') { - *curr_word_ptr = (char) NULL; - if (do_int_spell_fix(curr_word) == FALSE) - { - close(out_fd[0]); - return TRUE; - } - curr_word_ptr = curr_word; - } - else { - *curr_word_ptr = *read_buff_ptr; - curr_word_ptr++; + *read_buff_ptr = (char) NULL; + if (!do_int_spell_fix(read_buff_word)) { + + close(in_fd[0]); + free(read_buff); + replace_abort(); + + return TRUE; + } + read_buff_word = read_buff_ptr; + read_buff_word++; } read_buff_ptr++; } } - close(out_fd[0]); + + close(in_fd[0]); + free(read_buff); replace_abort(); + /* Process end of spell process */ + + wait(&spell_status); + if (WIFEXITED(spell_status)) { + if (WEXITSTATUS(spell_status) != 0) + return FALSE; + } + else + return FALSE; + return TRUE; } #endif @@ -1255,21 +1244,46 @@ int do_int_speller(void) #ifndef NANO_SMALL /* External spell checking */ -int do_alt_speller(char *command_line, char *file_name) +int do_alt_speller(char *file_name) { - int i; + int alt_spell_status; + pid_t pid_spell; endwin(); - if ( (i = system(command_line) == -1) || (i == 32512)) + /* Start a new process for the alternate speller */ + + if ( (pid_spell = fork()) == 0) { + + /* Start alternate spell program, we are using the PATH here!?!? */ + execlp(alt_speller, alt_speller, file_name, NULL); + + /* Should not be reached, if alternate speller is found!!! */ + + exit(1); + } + + /* Could not fork?? */ + + if (pid_spell < 0) return FALSE; - refresh(); + /* Wait for alternate speller to complete */ + wait(&alt_spell_status); + if (WIFEXITED(alt_spell_status)) { + if (WEXITSTATUS(alt_spell_status) != 0) + return FALSE; + } + else + return FALSE; + + refresh(); free_filestruct(fileage); global_init(); open_file(file_name, 0, 1); edit_update(fileage, CENTER); + display_main_list(); set_modified(); return TRUE; @@ -1283,30 +1297,24 @@ int do_spell(void) nano_small_msg(); return (TRUE); #else - char *temp, *foo; - int size, spell_res; - - if (alt_speller) { + char *temp; + int spell_res; - if ((temp = tempnam(0, "nano.")) == NULL) { - statusbar(_("Could not create a temporary filename: %s"), - strerror(errno)); - return 0; - } - - if (write_file(temp, 1) == -1) - return 0; - - size = strlen(temp) + strlen(alt_speller) + 2; - foo = nmalloc(size); - snprintf(foo, size, "%s %s", alt_speller, temp); + if ((temp = tempnam(0, "nano.")) == NULL) { + statusbar(_("Could not create a temporary filename: %s"), + strerror(errno)); + return 0; + } - spell_res = do_alt_speller(foo, temp); + if (write_file(temp, 1) == -1) + return 0; - exit_spell(temp, foo); + if (alt_speller) + spell_res = do_alt_speller(temp); + else + spell_res = do_int_speller(temp); - } else - spell_res = do_int_speller(); + remove(temp); if (spell_res) statusbar(_("Finished checking spelling")); diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index 6a379f03..8f0d9a29 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -175,65 +175,64 @@ Usage: nano [option] +LINE \n\ {"check_wrap called with inptr->data=\"%s\"\n", 142}, {"current->data now = \"%s\"\n", 143}, {"After, data = \"%s\"\n", 144}, - {"Error deleting tempfile, ack!", 145}, - {"Edit a replacement", 146}, - {"Could not create a temporary filename: %s", 147}, - {"Finished checking spelling", 148}, - {"Spell checking failed", 149}, - {"Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ", 150}, - {"Cannot resize top win", 151}, - {"Cannot move top win", 152}, - {"Cannot resize edit win", 153}, - {"Cannot move edit win", 154}, - {"Cannot resize bottom win", 155}, - {"Cannot move bottom win", 156}, - {"Justify Complete", 157}, - {"%s enable/disable", 158}, - {"enabled", 159}, - {"disabled", 160}, - {"Main: set up windows\n", 161}, - {"Main: bottom win\n", 162}, - {"Main: open file\n", 163}, - {"I got Alt-O-%c! (%d)\n", 164}, - {"I got Alt-[-1-%c! (%d)\n", 165}, - {"I got Alt-[-2-%c! (%d)\n", 166}, - {"I got Alt-[-%c! (%d)\n", 167}, - {"I got Alt-%c! (%d)\n", 168}, - {"Case Sensitive Regexp Search%s%s", 169}, - {"Regexp Search%s%s", 170}, - {"Case Sensitive Search%s%s", 171}, - {"Search%s%s", 172}, - {" (to replace)", 173}, - {"Search Cancelled", 174}, - {"\"%s...\" not found", 175}, - {"Search Wrapped", 176}, - {"Replaced %d occurences", 177}, - {"Replaced 1 occurence", 178}, - {"Replace Cancelled", 179}, - {"Replace this instance?", 180}, - {"Replace failed: unknown subexpression!", 181}, - {"Replace with [%s]", 182}, - {"Replace with", 183}, - {"Enter line number", 184}, - {"Aborted", 185}, - {"Come on, be reasonable", 186}, - {"Only %d lines available, skipping to last line", 187}, - {"actual_x_from_start for xplus=%d returned %d\n", 188}, - {"input '%c' (%d)\n", 189}, - {"New Buffer", 190}, - {" File: ...", 191}, - {"Modified", 192}, - {"Moved to (%d, %d) in edit buffer\n", 193}, - {"current->data = \"%s\"\n", 194}, - {"I got \"%s\"\n", 195}, - {"Yes", 196}, - {"All", 197}, - {"No", 198}, - {"do_cursorpos: linepct = %f, bytepct = %f\n", 199}, - {"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 200}, - {"Dumping file buffer to stderr...\n", 201}, - {"Dumping cutbuffer to stderr...\n", 202}, - {"Dumping a buffer to stderr...\n", 203}, + {"Edit a replacement", 145}, + {"Could not create a temporary filename: %s", 146}, + {"Finished checking spelling", 147}, + {"Spell checking failed", 148}, + {"Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ", 149}, + {"Cannot resize top win", 150}, + {"Cannot move top win", 151}, + {"Cannot resize edit win", 152}, + {"Cannot move edit win", 153}, + {"Cannot resize bottom win", 154}, + {"Cannot move bottom win", 155}, + {"Justify Complete", 156}, + {"%s enable/disable", 157}, + {"enabled", 158}, + {"disabled", 159}, + {"Main: set up windows\n", 160}, + {"Main: bottom win\n", 161}, + {"Main: open file\n", 162}, + {"I got Alt-O-%c! (%d)\n", 163}, + {"I got Alt-[-1-%c! (%d)\n", 164}, + {"I got Alt-[-2-%c! (%d)\n", 165}, + {"I got Alt-[-%c! (%d)\n", 166}, + {"I got Alt-%c! (%d)\n", 167}, + {"Case Sensitive Regexp Search%s%s", 168}, + {"Regexp Search%s%s", 169}, + {"Case Sensitive Search%s%s", 170}, + {"Search%s%s", 171}, + {" (to replace)", 172}, + {"Search Cancelled", 173}, + {"\"%s...\" not found", 174}, + {"Search Wrapped", 175}, + {"Replaced %d occurences", 176}, + {"Replaced 1 occurence", 177}, + {"Replace Cancelled", 178}, + {"Replace this instance?", 179}, + {"Replace failed: unknown subexpression!", 180}, + {"Replace with [%s]", 181}, + {"Replace with", 182}, + {"Enter line number", 183}, + {"Aborted", 184}, + {"Come on, be reasonable", 185}, + {"Only %d lines available, skipping to last line", 186}, + {"actual_x_from_start for xplus=%d returned %d\n", 187}, + {"input '%c' (%d)\n", 188}, + {"New Buffer", 189}, + {" File: ...", 190}, + {"Modified", 191}, + {"Moved to (%d, %d) in edit buffer\n", 192}, + {"current->data = \"%s\"\n", 193}, + {"I got \"%s\"\n", 194}, + {"Yes", 195}, + {"All", 196}, + {"No", 197}, + {"do_cursorpos: linepct = %f, bytepct = %f\n", 198}, + {"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 199}, + {"Dumping file buffer to stderr...\n", 200}, + {"Dumping cutbuffer to stderr...\n", 201}, + {"Dumping a buffer to stderr...\n", 202}, }; -int _msg_tbl_length = 203; +int _msg_tbl_length = 202; diff --git a/po/de.gmo b/po/de.gmo index 4698db0504bffce73bcf59807ec5c7905601895f..1067e110da2db05645be428dd591d81255d7d719 100644 GIT binary patch delta 19 acmX@u#(1!ealIZND delta 19 acmX@u#(1!eal\n" "Language-Team: German \n" diff --git a/po/es.gmo b/po/es.gmo index 5dfdbcd8cee1942f8ce0eca5ddeca1f2f6bfafd4..be47f69a64f78e4a05022db4b9931c6be0542e23 100644 GIT binary patch delta 19 bcmey?#`vv`al-|577Hsw%gtBR7fAyER<{T3 delta 19 bcmey?#`vv`al-|576U6&gUwge7fAyER#gY! diff --git a/po/es.po b/po/es.po index 26ff2e7b..922cfda5 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.9.19+CVS\n" -"POT-Creation-Date: 2000-11-06 00:50-0500\n" +"POT-Creation-Date: 2000-11-06 08:19-0500\n" "PO-Revision-Date: 2000-11-01 17:55+0100\n" "Last-Translator: Jordi Mallach \n" "Language-Team: Spanish \n" diff --git a/po/fi.gmo b/po/fi.gmo index 8b5de76457d606f4afc713fb8dcc34a726b0a934..6470cb9f292c8544d85691dfa60b604f93f2e7d2 100644 GIT binary patch delta 17 YcmZq8Y|Y%@roduhWoWtCOTk(M05-)1KL7v# delta 17 YcmZq8Y|Y%@rodugWooe5OTk(M05)R\n" "Language-Team: Finnish \n" diff --git a/po/fr.po b/po/fr.po index 9220d9ae..62412663 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.8.9\n" -"POT-Creation-Date: 2000-11-06 00:50-0500\n" +"POT-Creation-Date: 2000-11-06 08:19-0500\n" "PO-Revision-Date: 2000-07-09 01:32+0100\n" "Last-Translator: Clement Laforet \n" "Language-Team: French \n" diff --git a/po/id.gmo b/po/id.gmo index d43c3533bf4111e77fc7fab986345bb24c21e57f..60ce6c6598290045511b2c44108eea2c20a423cd 100644 GIT binary patch delta 17 Ycmdm$wkvJJN_iFwD?`i8Yvp@|0YlIRxBvhE delta 17 Ycmdm$wkvJJN_iFoD^r8bYvp@|0Yh#Es{jB1 diff --git a/po/id.po b/po/id.po index f9562cf5..3130c22d 100644 --- a/po/id.po +++ b/po/id.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: nano-0.9.10\n" -"POT-Creation-Date: 2000-11-06 00:50-0500\n" +"POT-Creation-Date: 2000-11-06 08:19-0500\n" "PO-Revision-Date: 2000-06-08 20:56+07:00\n" "Last-Translator: Tedi Heriyanto \n" "Language-Team: Indonesian \n" diff --git a/po/it.gmo b/po/it.gmo index d83d70223ed0258d15789dda1147ded63c91055d..84a5ac3ac1741cc0f5d1f366c34d8bb571dec886 100644 GIT binary patch delta 17 ZcmcbSawBEKd^r{iD?`i8i{-Wo0{}+$2Lb>9 delta 17 ZcmcbSawBEKd^r{aD^r8bi{-Wo0{}*p2K4{{ diff --git a/po/it.po b/po/it.po index 1a8e0b1e..5cac3bc3 100644 --- a/po/it.po +++ b/po/it.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.8.7\n" -"POT-Creation-Date: 2000-11-06 00:50-0500\n" +"POT-Creation-Date: 2000-11-06 08:19-0500\n" "PO-Revision-Date: 2000-03-03 04:57+0100\n" "Last-Translator: Daniele Medri \n" "MIME-Version: 1.0\n" diff --git a/po/nano.pot b/po/nano.pot index 5b7a09a2..b07f124a 100644 --- a/po/nano.pot +++ b/po/nano.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-11-06 08:18-0500\n" +"POT-Creation-Date: 2000-11-09 23:23-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -55,7 +55,7 @@ msgstr "" msgid "File to insert [from ./] " msgstr "" -#: files.c:276 files.c:300 files.c:488 nano.c:1347 +#: files.c:276 files.c:300 files.c:488 nano.c:1355 msgid "Cancelled" msgstr "" @@ -628,105 +628,101 @@ msgstr "" msgid "After, data = \"%s\"\n" msgstr "" -#: nano.c:1062 -msgid "Error deleting tempfile, ack!" -msgstr "" - -#: nano.c:1106 +#: nano.c:1093 msgid "Edit a replacement" msgstr "" -#: nano.c:1292 +#: nano.c:1304 #, c-format msgid "Could not create a temporary filename: %s" msgstr "" -#: nano.c:1312 +#: nano.c:1320 msgid "Finished checking spelling" msgstr "" -#: nano.c:1314 +#: nano.c:1322 msgid "Spell checking failed" msgstr "" -#: nano.c:1334 +#: nano.c:1342 msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? " msgstr "" -#: nano.c:1497 +#: nano.c:1505 msgid "Cannot resize top win" msgstr "" -#: nano.c:1499 +#: nano.c:1507 msgid "Cannot move top win" msgstr "" -#: nano.c:1501 +#: nano.c:1509 msgid "Cannot resize edit win" msgstr "" -#: nano.c:1503 +#: nano.c:1511 msgid "Cannot move edit win" msgstr "" -#: nano.c:1505 +#: nano.c:1513 msgid "Cannot resize bottom win" msgstr "" -#: nano.c:1507 +#: nano.c:1515 msgid "Cannot move bottom win" msgstr "" -#: nano.c:1778 +#: nano.c:1786 msgid "Justify Complete" msgstr "" -#: nano.c:1846 +#: nano.c:1854 #, c-format msgid "%s enable/disable" msgstr "" -#: nano.c:1858 +#: nano.c:1866 msgid "enabled" msgstr "" -#: nano.c:1859 +#: nano.c:1867 msgid "disabled" msgstr "" -#: nano.c:2089 +#: nano.c:2097 msgid "Main: set up windows\n" msgstr "" -#: nano.c:2102 +#: nano.c:2110 msgid "Main: bottom win\n" msgstr "" -#: nano.c:2108 +#: nano.c:2116 msgid "Main: open file\n" msgstr "" -#: nano.c:2142 +#: nano.c:2150 #, c-format msgid "I got Alt-O-%c! (%d)\n" msgstr "" -#: nano.c:2164 +#: nano.c:2172 #, c-format msgid "I got Alt-[-1-%c! (%d)\n" msgstr "" -#: nano.c:2197 +#: nano.c:2205 #, c-format msgid "I got Alt-[-2-%c! (%d)\n" msgstr "" -#: nano.c:2245 +#: nano.c:2253 #, c-format msgid "I got Alt-[-%c! (%d)\n" msgstr "" -#: nano.c:2271 +#: nano.c:2279 #, c-format msgid "I got Alt-%c! (%d)\n" msgstr "" -- 2.39.5