--- parser3/src/classes/image.C 2012/06/15 11:54:18 1.142 +++ parser3/src/classes/image.C 2015/09/18 00:08:12 1.147 @@ -25,7 +25,7 @@ #include "pa_vdate.h" #include "pa_table.h" -volatile const char * IDENT_IMAGE_C="$Id: image.C,v 1.142 2012/06/15 11:54:18 moko Exp $"; +volatile const char * IDENT_IMAGE_C="$Id: image.C,v 1.147 2015/09/18 00:08:12 moko Exp $"; // defines @@ -243,13 +243,9 @@ public: return 0; char* lbuf=new(PointerFreeGC) char[limit]; - size_t read_size=(size_t)::read(f, lbuf, limit); abuf=lbuf; - if(ssize_t(read_size)<0 || read_size>limit) - throw Exception(0, - &file_name, - "measure failed: actually read %u bytes count not in [0..%u] valid range", - read_size, limit); - + ssize_t read_size=::read(f, lbuf, limit); abuf=lbuf; + if(read_size<0) + throw Exception(0, &file_name, "measure read failed: %s (%d)", strerror(errno), errno); return read_size; } @@ -463,7 +459,7 @@ static Value* parse_IFD_entry_formatted_ } // date.C -tm cstr_to_time_t(char *cstr); +tm cstr_to_time_t(char *, const char **); static Value* parse_IFD_entry_formatted_value(bool is_big, ushort format, size_t component_size, uint components_count, @@ -479,7 +475,8 @@ static Value* parse_IFD_entry_formatted_ strcpy(cstr_writable, cstr); try { - return new VDate(cstr_to_time_t(cstr_writable)); + tm tmIn=cstr_to_time_t(cstr_writable, 0); + return new VDate(tmIn); } catch(...) { /*ignore bad date times*/ } } @@ -827,7 +824,7 @@ static void _html(Request& r, MethodPara if(params.count()) { // for backward compatibility: someday was ^html{} Value& vattribs=r.process_to_value(params[0], false/*don't intercept string*/); - if(!vattribs.is_string()) // allow empty + if(!vattribs.is_string()) { // allow empty if((attribs=vattribs.get_hash())) { Attrib_info info={&tag, 0}; attribs->for_each(append_attrib_pair, &info); @@ -835,6 +832,7 @@ static void _html(Request& r, MethodPara throw Exception(PARSER_RUNTIME, 0, "attributes must be hash"); + } } { @@ -1141,12 +1139,10 @@ static void _font(Request& r, MethodPara int monospace_width=0; // proportional int letter_spacing=1; if(params.count()>2){ - if(HashStringValue* options=params.as_no_junction(2, "param must be int or hash").get_hash()){ + if(HashStringValue* options=params[2].get_hash()){ // third option is hash if(params.count()>3) - throw Exception(PARSER_RUNTIME, - 0, - "too many options were specified"); + throw Exception(PARSER_RUNTIME, 0, "too many params were specified"); int valid_options=0; if(Value* vspacebar_width=options->get(spacebar_width_name)){ valid_options++; @@ -1166,7 +1162,7 @@ static void _font(Request& r, MethodPara throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } else { // backward - spacebar_width=params.as_int(2, "spacebar_width must be int", r); + spacebar_width=params.as_int(2, "param must be int or hash", r); if(params.count()>3) { monospace_width=params.as_int(3, "monospace_width must be int", r); if(!monospace_width)