--- parser3/src/main/pa_common.C 2001/10/16 07:51:07 1.72 +++ parser3/src/main/pa_common.C 2001/10/24 14:39:44 1.76 @@ -4,7 +4,7 @@ Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_common.C,v 1.72 2001/10/16 07:51:07 parser Exp $ + $Id: pa_common.C,v 1.76 2001/10/24 14:39:44 parser Exp $ */ #include "pa_common.h" @@ -42,8 +42,7 @@ int __snprintf(char *b, size_t s, const #endif -// under WIN32 "t" mode fixes DOS chars OK, can't say that about other systems/ line break styles -static void fix_line_breaks(char *src, size_t& size) { +void fix_line_breaks(char *src, size_t& size) { char *dest=src; // fix DOS: \r\n -> \n // fix Macintosh: \r -> \n @@ -112,7 +111,7 @@ bool file_read(Pool& pool, const String& if(as_text) ((char*&)data)[read_size]=0; } else - PTHROW(0, 0, + throw Exception(0, 0, &file_spec, "read failed: actually read %d bytes count not in [0..%lu] valid range", read_size, (unsigned long)max_size); //never @@ -122,7 +121,7 @@ bool file_read(Pool& pool, const String& return true; } if(fail_on_read_problem) - PTHROW(0, 0, + throw Exception(0, 0, &file_spec, "read failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); @@ -171,7 +170,7 @@ void file_write(Pool& pool, return; } } - PTHROW(0, 0, + throw Exception(0, 0, &file_spec, "write failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); @@ -188,7 +187,7 @@ static void rmdir(const String& file_spe void file_delete(Pool& pool, const String& file_spec) { const char *fname=file_spec.cstr(String::UL_FILE_SPEC); if(unlink(fname)!=0) - PTHROW(0, 0, + throw Exception(0, 0, &file_spec, "unlink failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); @@ -202,7 +201,7 @@ void file_move(Pool& pool, const String& create_dir_for_file(new_spec); if(rename(old_spec_cstr, new_spec_cstr)!=0) - PTHROW(0, 0, + throw Exception(0, 0, &old_spec, "rename failed: %s (%d), actual filename '%s' to '%s'", strerror(errno), errno, old_spec_cstr, new_spec_cstr); @@ -215,7 +214,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=(bool)(finfo.st_mode&S_IFDIR); + bool is_dir=finfo.st_mode&S_IFDIR != 0; return is_dir==need_dir; } return false; @@ -247,7 +246,7 @@ bool file_stat(const String& file_spec, struct stat finfo; if(stat(fname, &finfo)!=0) if(fail_on_read_problem) - PTHROW(0, 0, + throw Exception(0, 0, &file_spec, "getting file size failed: %s (%d), real filename '%s'", strerror(errno), errno, fname); @@ -393,7 +392,7 @@ static void append_attribute_subattribut const String& attributed_meaning_to_string(Value& meaning, String::Untaint_lang lang) { String &result=*new(meaning.pool()) String(meaning.pool()); - if(Hash *hash=meaning.get_hash()) { + if(Hash *hash=meaning.get_hash(0)) { // $value(value) $subattribute(subattribute value) if(Value *value=static_cast(hash->get(*value_name))) result.append(value->as_string(), lang, true); @@ -475,4 +474,4 @@ void remove_crlf(char *start, char *end) case '\n': *p='|'; break; case '\r': *p=' '; break; } -} \ No newline at end of file +}