1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-23 09:36:31 -05:00

Use memcpy to fill in line structure when reading and inserting files.

This commit is contained in:
Renaud 2013-06-10 15:54:28 +08:00
parent b6c7a2cc80
commit a3b5257bfe

16
file.c
View File

@ -227,7 +227,6 @@ int readin(char *fname, int lockfl)
{ {
struct line *lp1; struct line *lp1;
struct line *lp2; struct line *lp2;
int i;
struct window *wp; struct window *wp;
struct buffer *bp; struct buffer *bp;
int s; int s;
@ -276,23 +275,22 @@ int readin(char *fname, int lockfl)
nline = 0; nline = 0;
while ((s = ffgetline()) == FIOSUC) { while ((s = ffgetline()) == FIOSUC) {
nbytes = fpayload ; nbytes = fpayload ;
if ((lp1 = lalloc(nbytes)) == NULL) {
s = FIOMEM; /* Keep message on the */
break; /* display. */
}
#if PKCODE #if PKCODE
if (nline > MAXNLINE) { if (nline > MAXNLINE) {
s = FIOMEM; s = FIOMEM;
break; break;
} }
#endif #endif
if ((lp1 = lalloc(nbytes)) == NULL) {
s = FIOMEM; /* Keep message on the */
break; /* display. */
}
lp2 = lback(curbp->b_linep); lp2 = lback(curbp->b_linep);
lp2->l_fp = lp1; lp2->l_fp = lp1;
lp1->l_fp = curbp->b_linep; lp1->l_fp = curbp->b_linep;
lp1->l_bp = lp2; lp1->l_bp = lp2;
curbp->b_linep->l_bp = lp1; curbp->b_linep->l_bp = lp1;
for (i = 0; i < nbytes; ++i) memcpy( lp1->l_text, fline, nbytes) ;
lputc(lp1, i, fline[i]);
++nline; ++nline;
} }
eoltype = ftype ; eoltype = ftype ;
@ -579,7 +577,6 @@ int ifile(char *fname)
struct line *lp0; struct line *lp0;
struct line *lp1; struct line *lp1;
struct line *lp2; struct line *lp2;
int i;
struct buffer *bp; struct buffer *bp;
int s; int s;
int nbytes; int nbytes;
@ -626,8 +623,7 @@ int ifile(char *fname)
/* and advance and write out the current line */ /* and advance and write out the current line */
curwp->w_dotp = lp1; curwp->w_dotp = lp1;
for (i = 0; i < nbytes; ++i) memcpy( lp1->l_text, fline, nbytes) ;
lputc(lp1, i, fline[i]);
++nline; ++nline;
} }
ffclose(); /* Ignore errors. */ ffclose(); /* Ignore errors. */