cut down on redundant inclusions of <sys/types.h>, include it in proto.h
per DB's patch, and make a few more minor cosmetic cleanups git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1857 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
fb8bf40efb
commit
fd3039a8e7
|
@ -40,6 +40,8 @@ CVS code -
|
||||||
tabsize value is handled.
|
tabsize value is handled.
|
||||||
- Remove several unnecessary reset_cursor() calls. (David
|
- Remove several unnecessary reset_cursor() calls. (David
|
||||||
Benbennick)
|
Benbennick)
|
||||||
|
- Include <sys/types.h> in proto.h. (David Benbennick) DLR:
|
||||||
|
Remove some redundant inclusions of <sys/types.h> elsewhere.
|
||||||
- files.c:
|
- files.c:
|
||||||
close_open_file()
|
close_open_file()
|
||||||
- Tweak to no longer rely on the return values of
|
- Tweak to no longer rely on the return values of
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
@ -2080,7 +2079,7 @@ char **username_tab_completion(char *buf, int *num_matches)
|
||||||
matchline = charalloc(strlen(userdata->pw_name) + 2);
|
matchline = charalloc(strlen(userdata->pw_name) + 2);
|
||||||
sprintf(matchline, "~%s", userdata->pw_name);
|
sprintf(matchline, "~%s", userdata->pw_name);
|
||||||
matches[*num_matches] = matchline;
|
matches[*num_matches] = matchline;
|
||||||
++*num_matches;
|
++(*num_matches);
|
||||||
|
|
||||||
/* If there's no more room, bail out */
|
/* If there's no more room, bail out */
|
||||||
if (*num_matches == BUFSIZ)
|
if (*num_matches == BUFSIZ)
|
||||||
|
|
13
src/nano.c
13
src/nano.c
|
@ -31,7 +31,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1268,7 +1267,7 @@ int do_wrap(filestruct *inptr)
|
||||||
size_t after_break_len; /* strlen(after_break) */
|
size_t after_break_len; /* strlen(after_break) */
|
||||||
int wrapping = FALSE; /* Do we prepend to the next line? */
|
int wrapping = FALSE; /* Do we prepend to the next line? */
|
||||||
const char *wrap_line = NULL;
|
const char *wrap_line = NULL;
|
||||||
/* The next line, minus indentation */
|
/* The next line, minus indentation. */
|
||||||
size_t wrap_line_len = 0; /* strlen(wrap_line) */
|
size_t wrap_line_len = 0; /* strlen(wrap_line) */
|
||||||
char *newline = NULL; /* The line we create. */
|
char *newline = NULL; /* The line we create. */
|
||||||
size_t new_line_len = 0; /* Eventual length of newline. */
|
size_t new_line_len = 0; /* Eventual length of newline. */
|
||||||
|
@ -1276,7 +1275,7 @@ int do_wrap(filestruct *inptr)
|
||||||
/* There are three steps. First, we decide where to wrap. Then, we
|
/* There are three steps. First, we decide where to wrap. Then, we
|
||||||
* create the new wrap line. Finally, we clean up. */
|
* create the new wrap line. Finally, we clean up. */
|
||||||
|
|
||||||
/* Step 1, finding where to wrap. We are going to add a new-line
|
/* Step 1, finding where to wrap. We are going to add a new line
|
||||||
* after a whitespace character. In this step, we set wrap_loc as the
|
* after a whitespace character. In this step, we set wrap_loc as the
|
||||||
* location of this replacement.
|
* location of this replacement.
|
||||||
*
|
*
|
||||||
|
@ -1412,7 +1411,7 @@ int do_wrap(filestruct *inptr)
|
||||||
/* Step 3, clean up. Here we reposition the cursor and mark, and do
|
/* Step 3, clean up. Here we reposition the cursor and mark, and do
|
||||||
* some other sundry things. */
|
* some other sundry things. */
|
||||||
|
|
||||||
/* later wraps of this line will be prepended to the next line. */
|
/* Later wraps of this line will be prepended to the next line. */
|
||||||
same_line_wrap = TRUE;
|
same_line_wrap = TRUE;
|
||||||
|
|
||||||
/* Each line knows its line number. We recalculate these if we
|
/* Each line knows its line number. We recalculate these if we
|
||||||
|
@ -1433,8 +1432,8 @@ int do_wrap(filestruct *inptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* If the mark was on this line after the wrap point, we move it down.
|
/* If the mark was on this line after the wrap point, we move it
|
||||||
* If it was on the next line and we wrapped, we must move it
|
* down. If it was on the next line and we wrapped, we move it
|
||||||
* right. */
|
* right. */
|
||||||
if (mark_beginbuf == inptr && mark_beginx > wrap_loc) {
|
if (mark_beginbuf == inptr && mark_beginx > wrap_loc) {
|
||||||
mark_beginbuf = inptr->next;
|
mark_beginbuf = inptr->next;
|
||||||
|
@ -1981,7 +1980,7 @@ size_t quote_length(const char *line)
|
||||||
size_t qdepth = 0;
|
size_t qdepth = 0;
|
||||||
size_t qlen = strlen(quotestr);
|
size_t qlen = strlen(quotestr);
|
||||||
|
|
||||||
/* Compute quote depth level */
|
/* Compute quote depth level. */
|
||||||
while (!strcmp(line + qdepth, quotestr))
|
while (!strcmp(line + qdepth, quotestr))
|
||||||
qdepth += qlen;
|
qdepth += qlen;
|
||||||
return qdepth;
|
return qdepth;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
/* Externs. */
|
/* Externs. */
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
24
src/search.c
24
src/search.c
|
@ -406,8 +406,10 @@ void do_search(void)
|
||||||
* that we find one only once per line. We should only end up
|
* that we find one only once per line. We should only end up
|
||||||
* back at the same position if the string isn't found again, in
|
* back at the same position if the string isn't found again, in
|
||||||
* which case it's the only occurrence. */
|
* which case it's the only occurrence. */
|
||||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp, last_search)) {
|
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||||
didfind = findnextstr(TRUE, FALSE, current, current_x, answer, TRUE);
|
last_search)) {
|
||||||
|
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||||
|
answer, TRUE);
|
||||||
if (fileptr == current && fileptr_x == current_x && !didfind)
|
if (fileptr == current && fileptr_x == current_x && !didfind)
|
||||||
statusbar(_("This is the only occurrence"));
|
statusbar(_("This is the only occurrence"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -445,7 +447,8 @@ void do_research(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
didfind = findnextstr(TRUE, FALSE, current, current_x, last_search, FALSE);
|
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||||
|
last_search, FALSE);
|
||||||
|
|
||||||
/* Check to see if there's only one occurrence of the string and
|
/* Check to see if there's only one occurrence of the string and
|
||||||
* we're on it now. */
|
* we're on it now. */
|
||||||
|
@ -456,8 +459,10 @@ void do_research(void)
|
||||||
* "^$"), so that we find one only once per line. We should
|
* "^$"), so that we find one only once per line. We should
|
||||||
* only end up back at the same position if the string isn't
|
* only end up back at the same position if the string isn't
|
||||||
* found again, in which case it's the only occurrence. */
|
* found again, in which case it's the only occurrence. */
|
||||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp, last_search)) {
|
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||||
didfind = findnextstr(TRUE, FALSE, current, current_x, answer, TRUE);
|
last_search)) {
|
||||||
|
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||||
|
answer, TRUE);
|
||||||
if (fileptr == current && fileptr_x == current_x && !didfind)
|
if (fileptr == current && fileptr_x == current_x && !didfind)
|
||||||
statusbar(_("This is the only occurrence"));
|
statusbar(_("This is the only occurrence"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -922,11 +927,13 @@ void do_find_bracket(void)
|
||||||
/* Apparent near redundancy with regexp_pat[] here is needed.
|
/* Apparent near redundancy with regexp_pat[] here is needed.
|
||||||
* "[][]" works, "[[]]" doesn't. */
|
* "[][]" works, "[[]]" doesn't. */
|
||||||
|
|
||||||
if (pos < brackets + (strlen(brackets) / 2)) { /* On a left bracket. */
|
if (pos < brackets + (strlen(brackets) / 2)) {
|
||||||
|
/* On a left bracket. */
|
||||||
regexp_pat[1] = wanted_ch;
|
regexp_pat[1] = wanted_ch;
|
||||||
regexp_pat[2] = ch_under_cursor;
|
regexp_pat[2] = ch_under_cursor;
|
||||||
UNSET(REVERSE_SEARCH);
|
UNSET(REVERSE_SEARCH);
|
||||||
} else { /* On a right bracket. */
|
} else {
|
||||||
|
/* On a right bracket. */
|
||||||
regexp_pat[1] = ch_under_cursor;
|
regexp_pat[1] = ch_under_cursor;
|
||||||
regexp_pat[2] = wanted_ch;
|
regexp_pat[2] = wanted_ch;
|
||||||
SET(REVERSE_SEARCH);
|
SET(REVERSE_SEARCH);
|
||||||
|
@ -938,7 +945,8 @@ void do_find_bracket(void)
|
||||||
|
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat, FALSE) != 0) {
|
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat,
|
||||||
|
FALSE) != 0) {
|
||||||
/* Found identical bracket. */
|
/* Found identical bracket. */
|
||||||
if (current->data[current_x] == ch_under_cursor)
|
if (current->data[current_x] == ch_under_cursor)
|
||||||
count++;
|
count++;
|
||||||
|
|
|
@ -2183,7 +2183,6 @@ void reset_cursor(void)
|
||||||
current_y = current->lineno - edittop->lineno;
|
current_y = current->lineno - edittop->lineno;
|
||||||
if (current_y < editwinrows) {
|
if (current_y < editwinrows) {
|
||||||
size_t x = xplustabs();
|
size_t x = xplustabs();
|
||||||
|
|
||||||
wmove(edit, current_y, x - get_page_start(x));
|
wmove(edit, current_y, x - get_page_start(x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3212,7 +3211,7 @@ void dump_buffer_reverse(void)
|
||||||
const filestruct *fileptr = filebot;
|
const filestruct *fileptr = filebot;
|
||||||
|
|
||||||
while (fileptr != NULL) {
|
while (fileptr != NULL) {
|
||||||
fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
|
fprintf(stderr, "(%lu) %s\n", (unsigned long)fileptr->lineno, fileptr->data);
|
||||||
fileptr = fileptr->prev;
|
fileptr = fileptr->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue