--- parser3/src/main/pa_common.C 2001/10/31 16:19:58 1.83 +++ parser3/src/main/pa_common.C 2001/11/09 11:06:57 1.86 @@ -2,9 +2,9 @@ Parser: commonly functions. Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: pa_common.C,v 1.83 2001/10/31 16:19:58 paf Exp $ + $Id: pa_common.C,v 1.86 2001/11/09 11:06:57 paf Exp $ */ #include "pa_common.h" @@ -43,12 +43,22 @@ int __snprintf(char *b, size_t s, const #endif -void fix_line_breaks(char *cstr, size_t& size) { +static char *strnchr(char *buf, size_t size, char c) { + for(; size-->0; buf++) { + if(*buf==c) + return buf; + } + + return 0; +} + +void fix_line_breaks(char *buf, size_t& size) { + const char * const eob=buf+size; char *dest=cstr; // fix DOS: \r\n -> \n // fix Macintosh: \r -> \n char *bol=cstr; - while(char *eol=strchr(bol, '\r')) { + while(char *eol=strnchr(bol, eob -bol, '\r')) { size_t len=eol-bol; if(dest!=bol) memcpy(dest, bol, len); @@ -442,7 +452,7 @@ bool StrEqNc(const char *s1, const char } } -static int isLeap(int year) { +static bool isLeap(int year) { return !( (year % 4) || ((year % 400) && !(year % 100)) );