* find.c (get_line_at): Strip trailing newline to fix $

matching.
This commit is contained in:
Pavel Roskin 2003-04-16 15:26:29 +00:00
parent 6b36ea2689
commit 0900e8faee
2 changed files with 20 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2003-04-16 Andrew V. Samoilov <sav@bcs.zp.ua>
* find.c (get_line_at): Strip trailing newline to fix $
matching.
2003-03-26 Andrew V. Samoilov <sav@bcs.zp.ua>
* file.c (copy_file_file): Fix data corruption if mc_write()

View File

@ -394,21 +394,22 @@ find_add_match (Dlg_head *h, char *dir, char *file)
* has_newline - is there newline ?
*/
static char *
get_line_at (int file_fd, char *buf, int *pos, int *n_read, int buf_size, int *has_newline)
get_line_at (int file_fd, char *buf, int *pos, int *n_read, int buf_size,
int *has_newline)
{
char *buffer = 0;
int buffer_size = 0;
int buffer_size = 0;
char ch = 0;
int i = 0;
int i = 0;
do {
if (*pos >= *n_read){
for (;;) {
if (*pos >= *n_read) {
*pos = 0;
if ((*n_read = mc_read (file_fd, buf, buf_size)) <= 0)
break;
}
ch = buf [(*pos)++];
ch = buf[(*pos)++];
if (ch == 0) {
/* skip possible leading zero(s) */
if (i == 0)
@ -417,18 +418,20 @@ get_line_at (int file_fd, char *buf, int *pos, int *n_read, int buf_size, int *h
break;
}
if (i >= buffer_size - 1){
if (i >= buffer_size - 1) {
buffer = g_realloc (buffer, buffer_size += 80);
}
/* Strip newline */
if (ch == '\n')
break;
buffer [i++] = ch;
} while (ch != '\n');
buffer[i++] = ch;
}
*has_newline = ch ? 1 : 0;
if (buffer){
buffer [i] = 0;
if (buffer) {
buffer[i] = 0;
}
return buffer;