--- parser3/src/main/pa_common.C 2001/03/28 09:38:08 1.34 +++ parser3/src/main/pa_common.C 2001/04/03 07:54:25 1.38 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_common.C,v 1.34 2001/03/28 09:38:08 paf Exp $ + $Id: pa_common.C,v 1.38 2001/04/03 07:54:25 paf Exp $ */ #include "pa_config_includes.h" @@ -47,8 +47,8 @@ int __snprintf(char *b, size_t s, const char *file_read_text(Pool& pool, const String& file_spec, bool fail_on_read_problem) { void *result; size_t size; - return - file_read(pool, file_spec, result, size, fail_on_read_problem)?(char *)result:0; + return file_read(pool, file_spec, result, size, true, + fail_on_read_problem)?(char *)result:0; } bool file_read(Pool& pool, const String& file_spec, void*& data, size_t& size, bool as_text, @@ -63,7 +63,8 @@ bool file_read(Pool& pool, const String& // a.html:^test[] and b.html hardlink to a.html // user inserts ! before ^test in a.html // directory entry of b.html in NTFS not updated at once, - // they delay update till open, so we must not do stat before that + // they delay update till open, so we would receive "!^test[" string + // if would do stat, next open. if( (f=open(fname, O_RDONLY|(as_text?_O_TEXT:_O_BINARY)))>=0 && stat(fname, &finfo)==0) { @@ -82,7 +83,7 @@ bool file_read(Pool& pool, const String& PTHROW(0, 0, &file_spec, "read failed: actually read %d bytes count not in [0..%ul] valid range", - size, (unsigned long)finfo.st_size); + size, (unsigned long)finfo.st_size); //never return true;//prepare_config(result, remove_empty_lines); } @@ -93,6 +94,7 @@ bool file_read(Pool& pool, const String& return false; } +/// @test mkdirs void file_write(Pool& pool, const String& file_spec, const void *data, size_t size, @@ -181,6 +183,7 @@ char *rsplit(char *string, char delim) { return NULL; } +/// @todo less stupid type detection char *format(Pool& pool, double value, char *fmt) { char *result=(char *)pool.malloc(MAX_NUMBER); if(fmt) @@ -197,14 +200,14 @@ char *format(Pool& pool, double value, c return result; } -size_t stdout_write(const char *buf, size_t size) { +size_t stdout_write(const void *buf, size_t size) { #ifdef WIN32 do{ int chunk_written=fwrite(buf, 1, min(8*0x400, size), stdout); if(chunk_written<=0) break; size-=chunk_written; - buf+=chunk_written; + buf=((const char*)buf)+chunk_written; } while(size>0); return size; @@ -258,7 +261,8 @@ static void append_attribute_subattribut // ...; charset=windows1251 String *string=static_cast(info); - string->APPEND_CONST("; "); + if(string->size()) + string->APPEND_CONST("; "); string->append(akey, String::UL_HEADER, true); string->APPEND_CONST("="); string->append(static_cast(avalue)->as_string(),