tweaks: rename a symbol, to better suit its purpose, and reduce its scope
parent
b47d111a3d
commit
ef4b0edd4e
11
src/files.c
11
src/files.c
|
@ -609,6 +609,9 @@ char *encode_data(char *text, size_t length)
|
||||||
return copy_of(text);
|
return copy_of(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The number of bytes by which we expand the line buffer while reading. */
|
||||||
|
#define LUMPSIZE 120
|
||||||
|
|
||||||
/* Read the given open file f into the current buffer. filename should be
|
/* Read the given open file f into the current buffer. filename should be
|
||||||
* set to the name of the file. undoable means that undo records should be
|
* set to the name of the file. undoable means that undo records should be
|
||||||
* created and that the file does not need to be checked for writability. */
|
* created and that the file does not need to be checked for writability. */
|
||||||
|
@ -626,7 +629,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||||
/* The current input character. */
|
/* The current input character. */
|
||||||
char *buf;
|
char *buf;
|
||||||
/* The buffer in which we assemble each line of the file. */
|
/* The buffer in which we assemble each line of the file. */
|
||||||
size_t bufx = MAX_BUF_SIZE;
|
size_t bufx = LUMPSIZE;
|
||||||
/* The allocated size of the line buffer; increased as needed. */
|
/* The allocated size of the line buffer; increased as needed. */
|
||||||
linestruct *topline;
|
linestruct *topline;
|
||||||
/* The top of the new buffer where we store the read file. */
|
/* The top of the new buffer where we store the read file. */
|
||||||
|
@ -698,10 +701,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||||
* NUL bytes in it, so we can't just use strlen() later. */
|
* NUL bytes in it, so we can't just use strlen() later. */
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
/* If needed, increase the buffer size, MAX_BUF_SIZE characters at
|
/* When needed, increase the line-buffer size. Don't bother
|
||||||
* a time. Don't bother decreasing it; it is freed at the end. */
|
* decreasing it -- it gets freed when reading is finished. */
|
||||||
if (len == bufx) {
|
if (len == bufx) {
|
||||||
bufx += MAX_BUF_SIZE;
|
bufx += LUMPSIZE;
|
||||||
buf = charealloc(buf, bufx);
|
buf = charealloc(buf, bufx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -649,8 +649,5 @@ enum
|
||||||
* counting the blank lines at their ends. */
|
* counting the blank lines at their ends. */
|
||||||
#define MAX_SEARCH_HISTORY 100
|
#define MAX_SEARCH_HISTORY 100
|
||||||
|
|
||||||
/* The maximum number of bytes buffered at one time. */
|
|
||||||
#define MAX_BUF_SIZE 128
|
|
||||||
|
|
||||||
/* The largest size_t number that doesn't have the high bit set. */
|
/* The largest size_t number that doesn't have the high bit set. */
|
||||||
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
||||||
|
|
Loading…
Reference in New Issue