"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fs.c" between
bas-2.5.tar.gz and bas-2.6.tar.gz

About: bas is an interpreter for the programming language BASIC.

fs.c  (bas-2.5):fs.c  (bas-2.6)
skipping to change at line 148 skipping to change at line 148
FS_errmsg=(len==-1?strerror(errno):(const char*)0); FS_errmsg=(len==-1?strerror(errno):(const char*)0);
return -1; return -1;
} }
else else
{ {
f->inCapacity=len; f->inCapacity=len;
return 0; return 0;
} }
} }
/*}}}*/ /*}}}*/
static int edit(int chn, int onl) /*{{{*/ static int edit(int chn, int output_nl) /*{{{*/
{ {
struct FileStream *f=file[chn]; struct FileStream *f=file[chn];
char *buf=f->inBuf; char *buf=f->inBuf;
char ch; char ch;
int r; int r;
for (buf=f->inBuf; buf<(f->inBuf+f->inCapacity); ++buf) for (buf=f->inBuf; buf<(f->inBuf+f->inCapacity); ++buf)
{ {
if (*buf>='\0' && *buf<' ') if (*buf>='\0' && *buf<' ')
{ {
skipping to change at line 198 skipping to change at line 198
{ {
if (ch!='\n') if (ch!='\n')
{ {
if (ch>='\0' && ch<' ') if (ch>='\0' && ch<' ')
{ {
FS_putChar(chn,'^'); FS_putChar(chn,'^');
FS_putChar(chn,ch?(ch+'a'-1):'@'); FS_putChar(chn,ch?(ch+'a'-1):'@');
} }
else FS_putChar(chn,ch); else FS_putChar(chn,ch);
} }
else if (onl) FS_putChar(chn,'\n'); else if (output_nl) FS_putChar(chn,'\n');
f->inBuf[f->inCapacity++]=ch; f->inBuf[f->inCapacity++]=ch;
} }
} while (ch!='\n'); } while (ch!='\n');
return 0; return 0;
} }
/*}}}*/ /*}}}*/
static int outc(int ch) /*{{{*/ static int outc(int ch) /*{{{*/
{ {
struct FileStream *f; struct FileStream *f;
skipping to change at line 340 skipping to change at line 340
return 0; return 0;
} }
/*}}}*/ /*}}}*/
static int resetcolour(int chn) /*{{{*/ static int resetcolour(int chn) /*{{{*/
{ {
if (me) mytputs(me,0,outc); if (me) mytputs(me,0,outc);
if (ce) mytputs(ce,0,outc); if (ce) mytputs(ce,0,outc);
return 0; return 0;
} }
/*}}}*/ /*}}}*/
static void carriage_return(int chn) /*{{{*/ static void crlf(int chn) /*{{{*/
{ {
if (cr) mytputs(cr,0,outc); if (cr) mytputs(cr,0,outc);
else outc('\r'); else outc('\r');
outc('\n'); outc('\n');
} }
/*}}}*/ /*}}}*/
#else #else
static int initTerminal(int chn) /*{{{*/ static int initTerminal(int chn) /*{{{*/
{ {
termchannel=chn; termchannel=chn;
skipping to change at line 377 skipping to change at line 377
{ {
FS_errmsg=_("This installation does not support terminal handling"); FS_errmsg=_("This installation does not support terminal handling");
return -1; return -1;
} }
/*}}}*/ /*}}}*/
static int resetcolour(int chn) /*{{{*/ static int resetcolour(int chn) /*{{{*/
{ {
return 0; return 0;
} }
/*}}}*/ /*}}}*/
static void carriage_return(int chn) /*{{{*/ static void crlf(int chn) /*{{{*/
{ {
outc('\r'); outc('\r');
outc('\n'); outc('\n');
} }
/*}}}*/ /*}}}*/
#endif #endif
static void sigintr(int sig) /*{{{*/ static void sigintr(int sig) /*{{{*/
{ {
FS_intr=1; FS_intr=1;
FS_allowIntr(0); FS_allowIntr(0);
skipping to change at line 843 skipping to change at line 843
{ {
struct FileStream *f; struct FileStream *f;
if (opened(dev,0)==-1) return -1; if (opened(dev,0)==-1) return -1;
f=file[dev]; f=file[dev];
if (ch=='\n') f->outPos=0; if (ch=='\n') f->outPos=0;
if (ch=='\b' && f->outPos) --f->outPos; if (ch=='\b' && f->outPos) --f->outPos;
if (f->outSize+2>=f->outCapacity && FS_flush(dev)==-1) return -1; if (f->outSize+2>=f->outCapacity && FS_flush(dev)==-1) return -1;
if (f->outLineWidth && f->outPos==f->outLineWidth) if (f->outLineWidth && f->outPos==f->outLineWidth)
{ {
if (FS_istty(dev)) carriage_return(dev); if (FS_istty(dev)) crlf(dev);
else f->outBuf[f->outSize++]='\n'; else f->outBuf[f->outSize++]='\n';
f->outPos=0; f->outPos=0;
} }
if (FS_istty(dev) && ch=='\n') carriage_return(dev); if (FS_istty(dev) && ch=='\n') crlf(dev);
else f->outBuf[f->outSize++]=ch; else f->outBuf[f->outSize++]=ch;
if (ch!='\n' && ch!='\b') ++f->outPos; if (ch!='\n' && ch!='\b') ++f->outPos;
FS_errmsg=(const char*)0; FS_errmsg=(const char*)0;
return 0; return 0;
} }
/*}}}*/ /*}}}*/
int FS_putChars(int dev, const char *chars) /*{{{*/ int FS_putChars(int dev, const char *chars) /*{{{*/
{ {
while (*chars) if (FS_putChar(dev,*chars++)==-1) return -1; while (*chars) if (FS_putChar(dev,*chars++)==-1) return -1;
return 0; return 0;
skipping to change at line 875 skipping to change at line 875
while (len) if (FS_putChar(dev,*c++)==-1) return -1; else --len; while (len) if (FS_putChar(dev,*c++)==-1) return -1; else --len;
return 0; return 0;
} }
/*}}}*/ /*}}}*/
int FS_putItem(int dev, const struct String *s) /*{{{*/ int FS_putItem(int dev, const struct String *s) /*{{{*/
{ {
struct FileStream *f; struct FileStream *f;
if (opened(dev,0)==-1) return -1; if (opened(dev,0)==-1) return -1;
f=file[dev]; f=file[dev];
if (f->outPos && f->outPos+s->length>f->outLineWidth) FS_nextline(dev); if (f->outPos && f->outLineWidth && f->outPos+s->length>f->outLineWidth) FS_ne xtline(dev);
return FS_putString(dev, s); return FS_putString(dev, s);
} }
/*}}}*/ /*}}}*/
int FS_putbinaryString(int chn, const struct String *s) /*{{{*/ int FS_putbinaryString(int chn, const struct String *s) /*{{{*/
{ {
if (opened(chn,3)==-1) return -1; if (opened(chn,3)==-1) return -1;
if (s->length && write(file[chn]->binaryfd,s->character,s->length)!=s->length) if (s->length && write(file[chn]->binaryfd,s->character,s->length)!=s->length)
{ {
FS_errmsg=strerror(errno); FS_errmsg=strerror(errno);
return -1; return -1;
skipping to change at line 1270 skipping to change at line 1270
FS_errmsg=strerror(errno); FS_errmsg=strerror(errno);
} }
else if (opened(chn,4)!=-1) else if (opened(chn,4)!=-1)
{ {
if (lseek(file[chn]->binaryfd,(off_t)record,SEEK_SET)!=-1) return 0; if (lseek(file[chn]->binaryfd,(off_t)record,SEEK_SET)!=-1) return 0;
FS_errmsg=strerror(errno); FS_errmsg=strerror(errno);
} }
return -1; return -1;
} }
/*}}}*/ /*}}}*/
int FS_appendToString(int chn, struct String *s, int onl) /*{{{*/ int FS_appendToString(int chn, struct String *s, int output_nl) /*{{{*/
{ {
size_t new; size_t new;
char *n; char *n;
struct FileStream *f=file[chn]; struct FileStream *f=file[chn];
int c; int c;
if (f->tty && f->inSize==f->inCapacity) if (f->tty && f->inSize==f->inCapacity)
{ {
if (edit(chn,onl)==-1) return (FS_errmsg ? -1 : 0); if (edit(chn,output_nl)==-1) return (FS_errmsg ? -1 : 0);
} }
do do
{ {
n=f->inBuf+f->inSize; n=f->inBuf+f->inSize;
while (1) while (1)
{ {
if (n==f->inBuf+f->inCapacity) break; if (n==f->inBuf+f->inCapacity) break;
c=*n++; c=*n++;
if (c=='\n') break; if (c=='\n') break;
} }
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)