"Fossies" - the Fresh Open Source Software Archive  

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

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

str.c  (bas-2.5):str.c  (bas-2.6)
skipping to change at line 172 skipping to change at line 172
if (String_size(this,j+l)==-1) return -1; if (String_size(this,j+l)==-1) return -1;
memcpy(this->character+j,buf,l); memcpy(this->character+j,buf,l);
return 0; return 0;
} }
/*}}}*/ /*}}}*/
int String_insertChar(struct String *this, size_t where, char ch) /*{{{*/ int String_insertChar(struct String *this, size_t where, char ch) /*{{{*/
{ {
size_t oldlength=this->length; size_t oldlength=this->length;
if (this->field) String_leaveField(this); if (this->field) String_leaveField(this);
assert(where<oldlength); assert(where<=oldlength);
if (String_size(this,this->length+1)==-1) return -1; if (String_size(this,this->length+1)==-1) return -1;
memmove(this->character+where+1,this->character+where,oldlength-where); memmove(this->character+where+1,this->character+where,oldlength-where);
this->character[where]=ch; this->character[where]=ch;
return 0; return 0;
} }
/*}}}*/ /*}}}*/
int String_delete(struct String *this, size_t where, size_t len) /*{{{*/ int String_delete(struct String *this, size_t where, size_t len) /*{{{*/
{ {
size_t oldlength=this->length; size_t oldlength=this->length;
skipping to change at line 218 skipping to change at line 218
int res; int res;
const char *thisch,*sch; const char *thisch,*sch;
for (pos=0,thisch=this->character,sch=s->character; pos<this->length && pos<s- >length; ++pos,++thisch,++sch) for (pos=0,thisch=this->character,sch=s->character; pos<this->length && pos<s- >length; ++pos,++thisch,++sch)
{ {
if ((res=(*thisch-*sch))) return res; if ((res=(*thisch-*sch))) return res;
} }
return (this->length-s->length); return (this->length-s->length);
} }
/*}}}*/ /*}}}*/
int String_quote(struct String *this) /*{{{*/
{
size_t i;
for (i=0; i<this->length; ++i)
{
int ch;
ch=this->character[i];
if (!isalpha(ch) && !isdigit(ch) && ch!='*' && ch!='?' && ch!='[' && ch!=']'
)
{
if (String_insertChar(this, i, '\\')==-1) return -1;
++i;
}
}
return 0;
}
/*}}}*/
void String_lset(struct String *this, const struct String *s) /*{{{*/ void String_lset(struct String *this, const struct String *s) /*{{{*/
{ {
size_t copy; size_t copy;
copy=(this->length<s->length ? this->length : s->length); copy=(this->length<s->length ? this->length : s->length);
if (copy) memcpy(this->character,s->character,copy); if (copy) memcpy(this->character,s->character,copy);
if (copy<this->length) memset(this->character+copy,' ',this->length-copy); if (copy<this->length) memset(this->character+copy,' ',this->length-copy);
} }
/*}}}*/ /*}}}*/
void String_rset(struct String *this, const struct String *s) /*{{{*/ void String_rset(struct String *this, const struct String *s) /*{{{*/
 End of changes. 2 change blocks. 
1 lines changed or deleted 20 lines changed or added

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