File positions are off_t nowdays, not long, so:
fseek -> fseeko ftell -> ftello fseek(x, 0L, 0) -> rewind(x) NOTE: that fseek/ftell not works for >long offsets per POSIX: [EOVERFLOW] For fseek( ), the resulting file offset would be a value which cannot be represented correctly in an object of type long. [EOVERFLOW] For ftell ( ), the current file offset cannot be represented correctly in an object of type long.
This commit is contained in:
parent
bdaeb9cc90
commit
005ee369ed
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=82846
@ -438,7 +438,7 @@ int argc; char *argv[];
|
|||||||
}
|
}
|
||||||
if (newrc) {
|
if (newrc) {
|
||||||
nextmsg = firstmsg;
|
nextmsg = firstmsg;
|
||||||
fseek(msgsrc, 0L, 0);
|
rewind(msgsrc);
|
||||||
fprintf(msgsrc, "%d\n", nextmsg);
|
fprintf(msgsrc, "%d\n", nextmsg);
|
||||||
fflush(msgsrc);
|
fflush(msgsrc);
|
||||||
}
|
}
|
||||||
@ -582,7 +582,7 @@ int argc; char *argv[];
|
|||||||
sep = "-";
|
sep = "-";
|
||||||
if (msg >= nextmsg) {
|
if (msg >= nextmsg) {
|
||||||
nextmsg = msg + 1;
|
nextmsg = msg + 1;
|
||||||
fseek(msgsrc, 0L, 0);
|
rewind(msgsrc);
|
||||||
fprintf(msgsrc, "%d\n", nextmsg);
|
fprintf(msgsrc, "%d\n", nextmsg);
|
||||||
fflush(msgsrc);
|
fflush(msgsrc);
|
||||||
}
|
}
|
||||||
@ -597,7 +597,7 @@ int argc; char *argv[];
|
|||||||
*/
|
*/
|
||||||
if (--msg >= nextmsg) {
|
if (--msg >= nextmsg) {
|
||||||
nextmsg = msg + 1;
|
nextmsg = msg + 1;
|
||||||
fseek(msgsrc, 0L, 0);
|
rewind(msgsrc);
|
||||||
fprintf(msgsrc, "%d\n", nextmsg);
|
fprintf(msgsrc, "%d\n", nextmsg);
|
||||||
fflush(msgsrc);
|
fflush(msgsrc);
|
||||||
}
|
}
|
||||||
@ -688,7 +688,7 @@ onintr(unused)
|
|||||||
exit(0);
|
exit(0);
|
||||||
sep = "Interrupt";
|
sep = "Interrupt";
|
||||||
if (newmsg)
|
if (newmsg)
|
||||||
fseek(newmsg, 0L, 2);
|
fseeko(newmsg, (off_t)0, SEEK_END);
|
||||||
intrpflg = YES;
|
intrpflg = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -712,14 +712,14 @@ int
|
|||||||
linecnt(f)
|
linecnt(f)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
{
|
{
|
||||||
off_t oldpos = ftell(f);
|
off_t oldpos = ftello(f);
|
||||||
int l = 0;
|
int l = 0;
|
||||||
char lbuf[BUFSIZ];
|
char lbuf[BUFSIZ];
|
||||||
|
|
||||||
while (fgets(lbuf, sizeof lbuf, f))
|
while (fgets(lbuf, sizeof lbuf, f))
|
||||||
l++;
|
l++;
|
||||||
clearerr(f);
|
clearerr(f);
|
||||||
fseek(f, oldpos, 0);
|
fseeko(f, oldpos, SEEK_SET);
|
||||||
return (l);
|
return (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +763,7 @@ const char *prompt;
|
|||||||
cmsg = msg;
|
cmsg = msg;
|
||||||
snprintf(fname, sizeof(fname), "%s/%d", _PATH_MSGS, cmsg);
|
snprintf(fname, sizeof(fname), "%s/%d", _PATH_MSGS, cmsg);
|
||||||
|
|
||||||
oldpos = ftell(newmsg);
|
oldpos = ftello(newmsg);
|
||||||
|
|
||||||
cpfrom = fopen(fname, "r");
|
cpfrom = fopen(fname, "r");
|
||||||
if (!cpfrom) {
|
if (!cpfrom) {
|
||||||
@ -798,7 +798,7 @@ const char *prompt;
|
|||||||
close(fd);
|
close(fd);
|
||||||
warn("%s", fname);
|
warn("%s", fname);
|
||||||
mailing = NO;
|
mailing = NO;
|
||||||
fseek(newmsg, oldpos, 0);
|
fseeko(newmsg, oldpos, SEEK_SET);
|
||||||
ask(prompt);
|
ask(prompt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ const char *prompt;
|
|||||||
|
|
||||||
fclose(cpfrom);
|
fclose(cpfrom);
|
||||||
fclose(cpto);
|
fclose(cpto);
|
||||||
fseek(newmsg, oldpos, 0); /* reposition current message */
|
fseeko(newmsg, oldpos, SEEK_SET);/* reposition current message */
|
||||||
if (inch == 's')
|
if (inch == 's')
|
||||||
printf("Message %d saved in \"%s\"\n", cmsg, fname);
|
printf("Message %d saved in \"%s\"\n", cmsg, fname);
|
||||||
else {
|
else {
|
||||||
@ -840,7 +840,7 @@ FILE *infile;
|
|||||||
* expected form starts with From
|
* expected form starts with From
|
||||||
*/
|
*/
|
||||||
seenfrom = YES;
|
seenfrom = YES;
|
||||||
frompos = ftell(infile);
|
frompos = ftello(infile);
|
||||||
ptr = from;
|
ptr = from;
|
||||||
in = nxtfld(inbuf);
|
in = nxtfld(inbuf);
|
||||||
if (*in) {
|
if (*in) {
|
||||||
@ -864,7 +864,7 @@ FILE *infile;
|
|||||||
/*
|
/*
|
||||||
* not the expected form
|
* not the expected form
|
||||||
*/
|
*/
|
||||||
fseek(infile, 0L, 0);
|
rewind(infile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ FILE *infile;
|
|||||||
*/
|
*/
|
||||||
if (!seensubj && strncmp(inbuf, "Subj", 4)==0) {
|
if (!seensubj && strncmp(inbuf, "Subj", 4)==0) {
|
||||||
seensubj = YES;
|
seensubj = YES;
|
||||||
frompos = ftell(infile);
|
frompos = ftello(infile);
|
||||||
strncpy(subj, nxtfld(inbuf), sizeof subj);
|
strncpy(subj, nxtfld(inbuf), sizeof subj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ FILE *infile;
|
|||||||
/*
|
/*
|
||||||
* ran into EOF
|
* ran into EOF
|
||||||
*/
|
*/
|
||||||
fseek(infile, frompos, 0);
|
fseeko(infile, frompos, SEEK_SET);
|
||||||
|
|
||||||
if (!seensubj)
|
if (!seensubj)
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user