#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;
#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
#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;
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"));
{"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;
msgid ""
msgstr ""
"Project-Id-Version: nano 0.9.17\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-09-09 11:55+0200\n"
"Last-Translator: Florian König <floki@bigfoot.com>\n"
"Language-Team: German <floki@bigfoot.com>\n"
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 <jordi@sindominio.net>\n"
"Language-Team: Spanish <es@li.org>\n"
msgid ""
msgstr ""
"Project-Id-Version: nano 0.9.11\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-21 23:08+03:00\n"
"Last-Translator: Pauli Virtanen <pauli.virtanen@saunalahti.fi>\n"
"Language-Team: Finnish <fi@li.org>\n"
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 <sheep.killer@free.fr>\n"
"Language-Team: French <LL@li.org>\n"
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 <tedi-h@usa.net>\n"
"Language-Team: Indonesian <id@li.org>\n"
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 <madrid@linux.it>\n"
"MIME-Version: 1.0\n"
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
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 ""
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 ""