--- parser3/src/classes/table.C 2008/05/27 19:01:46 1.243 +++ parser3/src/classes/table.C 2009/05/13 07:36:05 1.253 @@ -1,11 +1,11 @@ /** @file Parser: @b table parser class. - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_TABLE_C="$Date: 2008/05/27 19:01:46 $"; +static const char * const IDENT_TABLE_C="$Date: 2009/05/13 07:36:05 $"; #ifndef NO_STRINGSTREAM #include @@ -230,9 +230,9 @@ static void _create(Request& r, MethodPa Array_iterator i(rows); while(i.has_next()) { Table::element_type row(new ArrayString); - const String& string=*i.next(); + const String& string=*i.next(); // remove comment lines - if(!string.length()) + if(string.is_empty()) continue; size_t col_pos_after=0; @@ -344,7 +344,7 @@ static void _load(Request& r, MethodPara } // loading text - char *data=file_read_text(r.charsets, + char *data=file_load_text(r, r.absolute(params.as_string(filename_param_index, FILE_NAME_MUST_BE_STRING)), true, options @@ -359,7 +359,7 @@ static void _load(Request& r, MethodPara skip_empty_and_comment_lines(&data); while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { - *columns+=new String(sr.piece, 0, true); + *columns+=new String(sr.piece, true); if(sr.delim=='\n') break; } @@ -374,7 +374,7 @@ static void _load(Request& r, MethodPara while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { if(!*sr.piece && !sr.delim && !row->count()) // append last empty column [if without \n] break; - *row+=new String(sr.piece, 0, true); + *row+=new String(sr.piece, true); if(sr.delim=='\n') { table+=row; row=new ArrayString(columns_count); @@ -451,6 +451,10 @@ static void _save(Request& r, MethodPara --param_index; const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE); + String file_spec=r.absolute(file_name); + + if(do_append && file_exist(file_spec)) + output_column_names=false; TableSeparators separators; if(param_index1?¶ms[1]:0; Table& table=GET_SELF(r, VTable).table(); - bool need_delim=false; int saved_current=table.current(); int size=table.count(); - for(int row=0; rowlength()) { // delimiter set and we have body - if(need_delim) // need delim & iteration produced string? - r.write_pass_lang(r.process(*delim_maybe_code)); - else - need_delim=true; - } + if(delim_maybe_code) { // delimiter set + bool need_delim=false; + for(int row=0; rowis_empty()) { // we have body + if(need_delim) // need delim & iteration produced string? + r.write_pass_lang(r.process(*delim_maybe_code)); + else + need_delim=true; + } - r.write_pass_lang(sv_processed); + r.write_pass_lang(sv_processed); - if(lskip==Request::SKIP_BREAK) - break; + if(lskip==Request::SKIP_BREAK) + break; + } + } else { + for(int row=0; rowwere_updated) { Value* value; if(ph->is_null) - value=new VVoid(); + value=VVoid::get(); else if(ph->value) - value=new VString(*new String(ph->value, 0, true/*tainted*/)); + value=new VString(*new String(ph->value, true/*tainted*/)); else value=new VString(*new String()); hash.put(ph->name, value); @@ -1117,7 +1134,7 @@ static void _sql(Request& r, MethodParam Value& statement=params.as_junction(0, "statement must be code"); HashStringValue* bind=0; - ulong limit=0; + ulong limit=SQL_NO_LIMIT; ulong offset=0; if(params.count()>1) { Value& voptions=params.as_no_junction(1, "options must be hash, not code");