in read_line(), rename variable len to buf_len, for consistency

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2733 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-06-19 19:57:13 +00:00
parent 90d505cc4a
commit 483f3ac1b5
3 changed files with 8 additions and 7 deletions

View File

@ -131,6 +131,7 @@ CVS code -
- files.c: - files.c:
read_line() read_line()
- Rename variable prev to prevnode to avoid confusion. (DLR) - Rename variable prev to prevnode to avoid confusion. (DLR)
- Rename variable len to buf_len, for consistency. (DLR)
load_open_file() load_open_file()
- Remove an unneeded clearok(FALSE). (DLR) - Remove an unneeded clearok(FALSE). (DLR)
get_next_filename() get_next_filename()

View File

@ -59,28 +59,28 @@ void new_file(void)
#endif #endif
} }
/* We make a new line of text from buf. buf is length len. If /* We make a new line of text from buf. buf is length buf_len. If
* first_line_ins is TRUE, then we put the new line at the top of the * first_line_ins is TRUE, then we put the new line at the top of the
* file. Otherwise, we assume prevnode is the last line of the file, * file. Otherwise, we assume prevnode is the last line of the file,
* and put our line after prevnode. */ * and put our line after prevnode. */
filestruct *read_line(char *buf, filestruct *prevnode, bool filestruct *read_line(char *buf, filestruct *prevnode, bool
*first_line_ins, size_t len) *first_line_ins, size_t buf_len)
{ {
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct)); filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
/* Convert nulls to newlines. len is the string's real length /* Convert nulls to newlines. len is the string's real length
* here. */ * here. */
unsunder(buf, len); unsunder(buf, buf_len);
assert(strlen(buf) == len); assert(strlen(buf) == buf_len);
fileptr->data = mallocstrcpy(NULL, buf); fileptr->data = mallocstrcpy(NULL, buf);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* If it's a DOS file ("\r\n"), and file conversion isn't disabled, /* If it's a DOS file ("\r\n"), and file conversion isn't disabled,
* strip the '\r' part from fileptr->data. */ * strip the '\r' part from fileptr->data. */
if (!ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r') if (!ISSET(NO_CONVERT) && buf_len > 0 && buf[buf_len - 1] == '\r')
fileptr->data[len - 1] = '\0'; fileptr->data[buf_len - 1] = '\0';
#endif #endif
if (*first_line_ins == TRUE || fileage == NULL) { if (*first_line_ins == TRUE || fileage == NULL) {

View File

@ -251,7 +251,7 @@ void do_uncut_text(void);
/* Public functions in files.c. */ /* Public functions in files.c. */
void new_file(void); void new_file(void);
filestruct *read_line(char *buf, filestruct *prevnode, bool filestruct *read_line(char *buf, filestruct *prevnode, bool
*first_line_ins, size_t len); *first_line_ins, size_t buf_len);
void load_file(void); void load_file(void);
void read_file(FILE *f, const char *filename); void read_file(FILE *f, const char *filename);
int open_file(const char *filename, bool newfie, FILE **f); int open_file(const char *filename, bool newfie, FILE **f);