X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fstr.c;h=7cddccbf504ff34669897ab8dff4435fb8da25c8;hb=4a39fcdeb5ff8d29084cd5cfbaed223de8adf4c1;hp=05872052706f1abc070ecff8a1565041f05a6d57;hpb=b7953727b0415d171133ea7caa7aca5672129f99;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/str.c b/x2p/str.c index 0587205..7cddccb 100644 --- a/x2p/str.c +++ b/x2p/str.c @@ -1,6 +1,7 @@ /* $RCSfile: str.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:26 $ * - * Copyright (c) 1991-2001, Larry Wall + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, + * 2001, 2002, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -77,7 +78,7 @@ void str_nset(register STR *str, register char *ptr, register int len) { GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); - bcopy(ptr,str->str_ptr,len); + memcpy(str->str_ptr,ptr,len); str->str_cur = len; *(str->str_ptr+str->str_cur) = '\0'; str->str_nok = 0; /* invalidate number */ @@ -93,7 +94,7 @@ str_set(register STR *str, register char *ptr) ptr = ""; len = strlen(ptr); GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); - bcopy(ptr,str->str_ptr,len+1); + memcpy(str->str_ptr,ptr,len+1); str->str_cur = len; str->str_nok = 0; /* invalidate number */ str->str_pok = 1; /* validate pointer */ @@ -107,7 +108,7 @@ str_chop(register STR *str, register char *ptr) /* like set but assuming ptr is if (!(str->str_pok)) str_2ptr(str); str->str_cur -= (ptr - str->str_ptr); - bcopy(ptr,str->str_ptr, str->str_cur + 1); + memcpy(str->str_ptr, ptr, str->str_cur + 1); str->str_nok = 0; /* invalidate number */ str->str_pok = 1; /* validate pointer */ } @@ -118,7 +119,7 @@ str_ncat(register STR *str, register char *ptr, register int len) if (!(str->str_pok)) str_2ptr(str); GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); - bcopy(ptr,str->str_ptr+str->str_cur,len); + memcpy(str->str_ptr+str->str_cur, ptr, len); str->str_cur += len; *(str->str_ptr+str->str_cur) = '\0'; str->str_nok = 0; /* invalidate number */ @@ -145,7 +146,7 @@ str_cat(register STR *str, register char *ptr) str_2ptr(str); len = strlen(ptr); GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); - bcopy(ptr,str->str_ptr+str->str_cur,len+1); + memcpy(str->str_ptr+str->str_cur, ptr, len+1); str->str_cur += len; str->str_nok = 0; /* invalidate number */ str->str_pok = 1; /* validate pointer */ @@ -197,7 +198,7 @@ str_new(int len) } else { str = (STR *) safemalloc(sizeof(STR)); - bzero((char*)str,sizeof(STR)); + memset((char*)str,0,sizeof(STR)); } if (len) GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); @@ -282,23 +283,24 @@ str_gets(register STR *str, register FILE *fp) if (str->str_len <= cnt) /* make sure we have the room */ GROWSTR(&(str->str_ptr), &(str->str_len), cnt+1); bp = str->str_ptr; /* move these two too to registers */ - ptr = FILE_ptr(fp); + ptr = (STDCHAR*)FILE_ptr(fp); for (;;) { while (--cnt >= 0) { - if ((*bp++ = *ptr++) == newline) + if ((*bp++ = *ptr++) == newline) { if (bp <= str->str_ptr || bp[-2] != '\\') goto thats_all_folks; else { line++; bp -= 2; } + } } FILE_cnt(fp) = cnt; /* deregisterize cnt and ptr */ - FILE_ptr(fp) = ptr; + FILE_ptr(fp) = (void*)ptr; /* LHS STDCHAR* cast non-portable */ i = getc(fp); /* get more characters */ cnt = FILE_cnt(fp); - ptr = FILE_ptr(fp); /* reregisterize cnt and ptr */ + ptr = (STDCHAR*)FILE_ptr(fp); /* reregisterize cnt and ptr */ bpx = bp - str->str_ptr; /* prepare for possible relocation */ GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + cnt + 1); @@ -315,7 +317,7 @@ str_gets(register STR *str, register FILE *fp) thats_all_folks: FILE_cnt(fp) = cnt; /* put these back or we're in trouble */ - FILE_ptr(fp) = ptr; + FILE_ptr(fp) = (void*)ptr; /* LHS STDCHAR* cast non-portable */ *bp = '\0'; str->str_cur = bp - str->str_ptr; /* set length */ @@ -353,7 +355,7 @@ str_inc(register STR *str) } for (d = str->str_ptr; *d && *d != '.'; d++) ; d--; - if (!isdigit(*str->str_ptr) || !isdigit(*d) ) { + if (!isDIGIT(*str->str_ptr) || !isDIGIT(*d) ) { str_numset(str,atof(str->str_ptr) + 1.0); /* punt */ return; } @@ -389,7 +391,7 @@ str_dec(register STR *str) } for (d = str->str_ptr; *d && *d != '.'; d++) ; d--; - if (!isdigit(*str->str_ptr) || !isdigit(*d) || (*d == '0' && d == str->str_ptr)) { + if (!isDIGIT(*str->str_ptr) || !isDIGIT(*d) || (*d == '0' && d == str->str_ptr)) { str_numset(str,atof(str->str_ptr) - 1.0); /* punt */ return; }