version 1.18, 2002/05/29 12:41:42 |
version 1.19, 2002/06/19 22:02:08 |
|
|
* Read the file "fname" into the current buffer. Make all of the text |
* Read the file "fname" into the current buffer. Make all of the text |
* in the buffer go away, after checking for unsaved changes. This is |
* in the buffer go away, after checking for unsaved changes. This is |
* called by the "read" command, the "visit" command, and the mainline |
* called by the "read" command, the "visit" command, and the mainline |
* (for "uemacs file"). |
* (for "mg file"). |
*/ |
*/ |
int |
int |
readin(fname) |
readin(char *fname) |
char *fname; |
|
{ |
{ |
MGWIN *wp; |
MGWIN *wp; |
int status, i; |
int status, i; |
|
|
else |
else |
curbp->b_flag &=~ BFREADONLY; |
curbp->b_flag &=~ BFREADONLY; |
|
|
|
|
return status; |
return status; |
} |
} |
|
|
|
|
LINE *lp1, *lp2; |
LINE *lp1, *lp2; |
LINE *olp; /* line we started at */ |
LINE *olp; /* line we started at */ |
MGWIN *wp; |
MGWIN *wp; |
int nbytes, s, nline; |
int nbytes, s, nline, siz; |
int opos; /* and offset into it */ |
int opos; /* offset we started at */ |
|
|
lp1 = NULL; |
lp1 = NULL; |
|
|
if (line == NULL) { |
if (line == NULL) { |
line = malloc(NLINE); |
line = malloc(NLINE); |
linesize = NLINE; |
linesize = NLINE; |
|
|
opos = curwp->w_doto; |
opos = curwp->w_doto; |
|
|
/* open a new line, at point, and start inserting after it */ |
/* open a new line, at point, and start inserting after it */ |
(void)lnewline(); |
lnewline(); |
olp = lback(curwp->w_dotp); |
olp = lback(curwp->w_dotp); |
if (olp == curbp->b_linep) { |
if (olp == curbp->b_linep) { |
/* if at end of buffer, create a line to insert before */ |
/* if at end of buffer, create a line to insert before */ |
|
|
|
|
/* don't count fake lines at the end */ |
/* don't count fake lines at the end */ |
nline = 0; |
nline = 0; |
|
siz = 0; |
while ((s = ffgetline(line, linesize, &nbytes)) != FIOERR) { |
while ((s = ffgetline(line, linesize, &nbytes)) != FIOERR) { |
doneread: |
doneread: |
|
siz += nbytes + 1; |
switch (s) { |
switch (s) { |
case FIOSUC: |
case FIOSUC: |
++nline; |
++nline; |
|
|
if (s == FIOEOF) |
if (s == FIOEOF) |
goto endoffile; |
goto endoffile; |
break; |
break; |
case FIOLONG:{ |
case FIOLONG: { |
/* a line too long to fit in our buffer */ |
/* a line too long to fit in our buffer */ |
char *cp; |
char *cp; |
int newsize; |
int newsize; |
|
|
} |
} |
} |
} |
endoffile: |
endoffile: |
|
undo_add_insert(olp, opos, siz); |
|
|
/* ignore errors */ |
/* ignore errors */ |
ffclose(NULL); |
ffclose(NULL); |
/* don't zap an error */ |
/* don't zap an error */ |