fileptr->data = mallocstrcpy(NULL, buf);
#ifndef NANO_SMALL
- /* If it's a DOS file (CR LF), and file conversion isn't disabled,
- * strip the CR part from fileptr->data. */
+ /* If it's a DOS file ("\r\n"), and file conversion isn't disabled,
+ * strip the '\r' part from fileptr->data. */
if (!ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r')
fileptr->data[len - 1] = '\0';
#endif
if (*first_line_ins == TRUE || fileage == NULL) {
- /* Special case: we're inserting with the cursor on the first
+ /* Special case: We're inserting with the cursor on the first
* line. */
fileptr->prev = NULL;
fileptr->next = fileage;
while ((input_int = getc(f)) != EOF) {
input = (char)input_int;
- /* If it's a *nix file (LF) or a DOS file (CR LF), and file
+ /* If it's a *nix file ("\n") or a DOS file ("\r\n"), and file
* conversion isn't disabled, handle it! */
if (input == '\n') {
#ifndef NANO_SMALL
- /* If there's a CR before the LF, set format to DOS if we
- * currently think this is a *nix file, or to both if we
+ /* If there's a '\r' before the '\n', set format to DOS if
+ * we currently think this is a *nix file, or to both if we
* currently think it's a Mac file. */
if (!ISSET(NO_CONVERT) && i > 0 && buf[i - 1] == '\r' &&
(format == 0 || format == 2))
buf[0] = '\0';
i = 0;
#ifndef NANO_SMALL
- /* If it's a Mac file (CR without an LF), and file conversion
+ /* If it's a Mac file ('\r' without '\n'), and file conversion
* isn't disabled, handle it! */
} else if (!ISSET(NO_CONVERT) && i > 0 && buf[i - 1] == '\r') {
#ifndef NANO_SMALL
/* If file conversion isn't disabled and the last character in this
- * file is a CR, read it in properly as a Mac format line. */
+ * file is '\r', read it in properly as a Mac format line. */
if (len == 0 && !ISSET(NO_CONVERT) && input == '\r') {
len = 1;
if (len > 0) {
#ifndef NANO_SMALL
/* If file conversion isn't disabled and the last character in
- * this file is a CR, set format to Mac if we currently think
+ * this file is '\r', set format to Mac if we currently think
* the file is a *nix file, or to both DOS and Mac if we
* currently think the file is a DOS file. */
if (!ISSET(NO_CONVERT) && buf[len - 1] == '\r' &&
return !canceled;
}
-/* Integrated spell checking using 'spell' program. Return value: NULL
- * for normal termination, otherwise the error string. */
+/* Integrated spell checking using the spell program, filtered through
+ * the sort and uniq programs. Return NULL for normal termination,
+ * and the error string otherwise. */
const char *do_int_speller(const char *tempfile_name)
{
char *read_buff, *read_buff_ptr, *read_buff_word;
/* A new process to run spell in. */
if ((pid_spell = fork()) == 0) {
-
/* Child continues (i.e, future spell process). */
-
close(spell_fd[0]);
/* Replace the standard input with the temp file. */
close(spell_fd[1]);
- /* Start spell program; we are using PATH. */
+ /* Start the spell program; we are using PATH. */
execlp("spell", "spell", NULL);
- /* Should not be reached, if spell is found. */
+ /* This should not be reached if spell is found. */
exit(1);
}
/* A new process to run sort in. */
if ((pid_sort = fork()) == 0) {
-
/* Child continues (i.e, future spell process). Replace the
* standard input with the standard output of the old pipe. */
if (dup2(spell_fd[0], STDIN_FILENO) != STDIN_FILENO)
close(sort_fd[1]);
- /* Start sort program. Use -f to remove mixed case without
- * having to have ANOTHER pipe for tr. If this isn't portable,
- * let me know. */
+ /* Start the sort program. Use -f to remove mixed case. If
+ * this isn't portable, let me know. */
execlp("sort", "sort", "-f", NULL);
- /* Should not be reached, if sort is found. */
+ /* This should not be reached if sort is found. */
exit(1);
}
/* A new process to run uniq in. */
if ((pid_uniq = fork()) == 0) {
-
/* Child continues (i.e, future uniq process). Replace the
* standard input with the standard output of the old pipe. */
if (dup2(sort_fd[0], STDIN_FILENO) != STDIN_FILENO)
close(uniq_fd[1]);
- /* Start uniq program; we are using PATH. */
+ /* Start the uniq program; we are using PATH. */
execlp("uniq", "uniq", NULL);
- /* Should not be reached, if uniq is found. */
+ /* This should not be reached if uniq is found. */
exit(1);
}
close(sort_fd[0]);
close(uniq_fd[1]);
- /* Child process was not forked successfully. */
+ /* The child process was not forked successfully. */
if (pid_spell < 0 || pid_sort < 0 || pid_uniq < 0) {
close(uniq_fd[0]);
return _("Could not fork");
}
- /* Get system pipe buffer size. */
+ /* Get the system pipe buffer size. */
if ((pipe_buff_size = fpathconf(uniq_fd[0], _PC_PIPE_BUF)) < 1) {
close(uniq_fd[0]);
return _("Could not get size of pipe buffer");
read_buff_word = read_buff_ptr = read_buff;
while (*read_buff_ptr != '\0') {
-
- if ((*read_buff_ptr == '\n') || (*read_buff_ptr == '\r')) {
+ if ((*read_buff_ptr == '\r') || (*read_buff_ptr == '\n')) {
*read_buff_ptr = '\0';
if (read_buff_word != read_buff_ptr) {
if (!do_int_spell_fix(read_buff_word)) {
read_buff_ptr++;
}
- /* Special case where last word doesn't end with \n or \r. */
+ /* Special case: the last word doesn't end with '\r' or '\n'. */
if (read_buff_word != read_buff_ptr)
do_int_spell_fix(read_buff_word);
replace_abort();
edit_refresh();
- /* Process end of spell process. */
+ /* Process the end of the spell process. */
waitpid(pid_spell, &spell_status, 0);
waitpid(pid_sort, &sort_status, 0);
waitpid(pid_uniq, &uniq_status, 0);