--- parser3/src/main/pa_common.C 2001/04/10 11:24:00 1.45 +++ parser3/src/main/pa_common.C 2001/04/17 19:00:41 1.47 @@ -6,18 +6,10 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_common.C,v 1.45 2001/04/10 11:24:00 paf Exp $ + $Id: pa_common.C,v 1.47 2001/04/17 19:00:41 paf Exp $ */ #include "pa_config_includes.h" - -#include -#include -#include -#include -#include -#include - #include "pa_common.h" #include "pa_types.h" #include "pa_exception.h" @@ -27,6 +19,15 @@ #include "pa_hash.h" #include "pa_string.h" +#ifndef WIN32 +# ifndef _O_TEXT +# define _O_TEXT 0 +# endif +# ifndef _O_BINARY +# define _O_BINARY 0 +# endif +#endif + #if _MSC_VER int __vsnprintf(char *b, size_t s, const char *f, va_list l) { @@ -73,6 +74,11 @@ bool file_read(Pool& pool, const String& /*if(exclusive) flock(f, LOCK_EX);*/ size_t max_size=limit?min(offset+limit, finfo.st_size)-offset:finfo.st_size; + if(!max_size) { // eof + data=0; + read_size=0; + return true; + } data=pool.malloc(max_size+(as_text?1:0)); if(offset) lseek(f, offset, SEEK_SET); @@ -83,7 +89,7 @@ bool file_read(Pool& pool, const String& if(read_size>=0 && read_size<=max_size) { if(as_text) - ((char *)data)[read_size]=0; + ((char*&)data)[read_size]=0; } else PTHROW(0, 0, &file_spec, @@ -285,8 +291,7 @@ static void append_attribute_subattribut Attributed_meaning_info& ami=*static_cast(info); // ...; charset=windows1251 - if(ami.header->size()) - ami.header->APPEND_CONST("; "); + ami.header->APPEND_CONST("; "); ami.header->append(akey, ami.lang, true); ami.header->APPEND_CONST("="); ami.header->append(static_cast(avalue)->as_string(),