--- parser3/src/main/pa_common.C 2002/03/27 15:30:36 1.106 +++ parser3/src/main/pa_common.C 2002/06/10 09:24:36 1.109 @@ -4,7 +4,7 @@ Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_common.C,v 1.106 2002/03/27 15:30:36 paf Exp $ + $Id: pa_common.C,v 1.109 2002/06/10 09:24:36 paf Exp $ */ #include "pa_common.h" @@ -151,7 +151,7 @@ bool file_read(Pool& pool, const String& } #ifdef NO_FOREIGN_GROUP_FILES if(finfo.st_gid/*foreign?*/!=getegid()) { - Exception e("parser.runtime", 0, + Exception e("parser.runtime", &file_spec, "parser reading files of foreign group disabled [recompile parser without --disable-foreign-group-files configure option], actual filename '%s'", fname); @@ -323,7 +323,7 @@ static bool entry_readable(const String& const char *fname=file_spec.cstr(String::UL_FILE_SPEC); struct stat finfo; if(access(fname, R_OK)==0 && stat(fname, &finfo)==0) { - bool is_dir=finfo.st_mode&S_IFDIR != 0; + bool is_dir=(finfo.st_mode&S_IFDIR) != 0; return is_dir==need_dir; } return false; @@ -411,19 +411,23 @@ char *rsplit(char *string, char delim) { /// @todo less stupid type detection char *format(Pool& pool, double value, char *fmt) { - char *result=(char *)pool.malloc(MAX_NUMBER, 4); + char local_buf[MAX_NUMBER]; + size_t size; + if(fmt) if(strpbrk(fmt, "diouxX")) if(strpbrk(fmt, "ouxX")) - snprintf(result, MAX_NUMBER, fmt, (uint)value ); + size=snprintf(local_buf, sizeof(local_buf), fmt, (uint)value); else - snprintf(result, MAX_NUMBER, fmt, (int)value ); + size=snprintf(local_buf, sizeof(local_buf), fmt, (int)value); else - snprintf(result, MAX_NUMBER, fmt, value); + size=snprintf(local_buf, sizeof(local_buf), fmt, value); else - snprintf(result, MAX_NUMBER, "%d", (int)value); + size=snprintf(local_buf, sizeof(local_buf), "%d", (int)value); - return result; + char *pool_buf=(char *)pool.malloc(size+1, 4); + memcpy(pool_buf, local_buf, size+1); + return pool_buf; } size_t stdout_write(const void *buf, size_t size) {