--- parser3/src/classes/table.C 2016/03/31 21:46:20 1.313 +++ parser3/src/classes/table.C 2016/09/21 15:14:39 1.331 @@ -22,7 +22,7 @@ #define USE_STRINGSTREAM #endif -volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.313 2016/03/31 21:46:20 moko Exp $"; +volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.331 2016/09/21 15:14:39 moko Exp $"; // class @@ -51,8 +51,7 @@ String table_reverse_name(TABLE_REVERSE_ // methods -static Table::Action_options get_action_options(Request& r, MethodParams& params, - size_t options_index, const Table& source) { +static Table::Action_options get_action_options(Request& r, MethodParams& params, size_t options_index, const Table& source) { Table::Action_options result; if(params.count() <= options_index) return result; @@ -73,9 +72,7 @@ static Table::Action_options get_action_ if(soffset == "cur") result.offset=source.current(); else - throw Exception(PARSER_RUNTIME, - &soffset, - "must be 'cur' string or expression"); + throw Exception(PARSER_RUNTIME, &soffset, "must be 'cur' string or expression"); } else result.offset=r.process_to_value(*voffset).as_int(); } @@ -96,23 +93,27 @@ static Table::Action_options get_action_ return result; } -struct TableSeparators { - char column; const String* scolumn; +struct TableControlChars { + char separator; const String* sseparator; char encloser; const String* sencloser; - TableSeparators(): - column('\t'), scolumn(new String("\t")), + char separators[3]; + + TableControlChars(): + separator('\t'), sseparator(new String("\t")), encloser(0), sencloser(0) - {} + { + strcpy(separators,"\t\n"); + } + int load( HashStringValue& options ) { int result=0; if(Value* vseparator=options.get(PA_COLUMN_SEPARATOR_NAME)) { - scolumn=&vseparator->as_string(); - if(scolumn->length()!=1) - throw Exception(PARSER_RUNTIME, - scolumn, - "separator must be one character long"); - column=scolumn->first_char(); + sseparator=&vseparator->as_string(); + if(sseparator->length()!=1) + throw Exception(PARSER_RUNTIME, sseparator, "separator must be one byte character"); + separator=sseparator->first_char(); + separators[0]=separator; result++; } if(Value* vencloser=options.get(PA_COLUMN_ENCLOSER_NAME)) { @@ -120,11 +121,9 @@ struct TableSeparators { if(sencloser->is_empty()){ encloser=0; } else { - if(sencloser->length()!=1) - throw Exception(PARSER_RUNTIME, - sencloser, - "encloser must be one character long"); - encloser=sencloser->first_char(); + if(sencloser->length()!=1) + throw Exception(PARSER_RUNTIME, sencloser, "encloser must be empty or one byte character"); + encloser=sencloser->first_char(); } result++; } @@ -132,6 +131,119 @@ struct TableSeparators { } }; + +struct lsplit_sresult { + String* piece; + char delim; + + lsplit_sresult() : piece(0), delim(0){} + + operator bool() { return piece!=0; } + + void append(String *str){ + if(piece) + *piece << *str; + else + piece = str; + } +}; + +class StringSplitHelper : public String { +public: + char* base; + + StringSplitHelper(String astring) : String(astring), base(cstrm()) {} + + bool check_lang(const char *pos){ + return langs.check_lang(L_AS_IS, pos-base, 1); + } + + String *extract(char *pos){ + String *result=new String; + if(size_t len=strlen(pos)){ + // first: their langs + result->langs.append(result->body, langs, pos-base, len); + // next: letters themselves + result->body=Body(pos); + } + return result; + } +}; + +inline lsplit_sresult lsplit(char* *string_ref, const char* delims, StringSplitHelper& helper) { + lsplit_sresult result; + if(char *pos=*string_ref) { + while(pos=strpbrk(pos, delims)) { + if(helper.check_lang(pos)){ + result.delim=*pos; + *pos=0; + result.piece=helper.extract(*string_ref); + *string_ref=pos+1; + return result; + } + pos++; + } + result.piece=helper.extract(*string_ref); + *string_ref=0; + } + return result; +} + +static lsplit_sresult lsplit(char** string_ref, const char* delims, char encloser, StringSplitHelper& helper) { + lsplit_sresult result; + + if(char *pos=*string_ref) { + if(encloser && *pos==encloser && helper.check_lang(pos)) { + *string_ref=++pos; + + // we are enclosed, searching for second encloser + while(1) { + if(pos=strchr(pos, encloser)){ + if(helper.check_lang(pos)){ + *(pos++)=0; + result.append(helper.extract(*string_ref)); + if(*pos==encloser && helper.check_lang(pos)){ // double-encloser stands for encloser + *string_ref=pos++; + } else { + *string_ref=pos; + break; + } + } + } else { + result.append(helper.extract(*string_ref)); + *string_ref=0; + return result; + } + } + + // we are no longer enclosed, searching for delimiter + while(pos=strpbrk(pos, delims)) { + if(helper.check_lang(pos)){ + result.delim=*pos; + if(pos>*string_ref){ + *pos=0; + result.append(helper.extract(*string_ref)); + } + *string_ref=pos+1; + return result; + } + pos++; + } + result.append(helper.extract(*string_ref)); + *string_ref=0; + } else + return lsplit(string_ref, delims, helper); + } + return result; +} + +static void skip_clean_empty_lines(char** data_ref, StringSplitHelper& helper) { + if(*data_ref) { + while(**data_ref == '\n' && helper.check_lang(*data_ref)) + (*data_ref)++; + } +} + static void _create(Request& r, MethodParams& params) { // clone/copy part? if(Table *source=params[0].get_table()) { @@ -149,75 +261,59 @@ static void _create(Request& r, MethodPa if(params[0].is_string()){ // can be nameless only const String& snameless=params.as_string(0, "called with more then 1 param, first param may be only string 'nameless' or junction"); if(snameless!="nameless") - throw Exception(PARSER_RUNTIME, - &snameless, - "table::create called with more then 1 param, first param may be only 'nameless'"); + throw Exception(PARSER_RUNTIME, &snameless, "table::create called with more then 1 param, first param may be only 'nameless'"); nameless=true; data_param_index++; } } HashStringValue *options=0; - TableSeparators separators; + TableControlChars control_chars; size_t options_param_index=data_param_index+1; - if( - options_param_indexcount()) + throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } // data Temp_lang temp_lang(r, String::L_PASS_APPENDED); - const String& data= - r.process_to_string(params.as_junction(data_param_index, "body must be table or code")); + StringSplitHelper sdata(r.process_to_string(params.as_junction(data_param_index, "body must be table or code"))); + char *data=sdata.base; // parse columns - size_t raw_pos_after=0; Table::columns_type columns; - - if(nameless){ - columns=Table::columns_type(0); // nameless + if(nameless) { + columns=0; // nameless } else { - columns=Table::columns_type(new ArrayString); - - ArrayString head; - data.split(head, raw_pos_after, "\n", String::L_AS_IS, 1); - if(head.count()) { - size_t col_pos_after=0; - if(head[0]->is_empty()) - *columns += new String(); - else - head[0]->split(*columns, col_pos_after, *separators.scolumn, String::L_AS_IS); + columns=new ArrayString; + while( lsplit_sresult sr=lsplit(&data, control_chars.separators, control_chars.encloser, sdata) ) { + *columns+=sr.piece; + if(sr.delim=='\n') + break; } } - + Table& table=*new Table(columns); - // parse cells - - ArrayString rows; - data.split(rows, raw_pos_after, "\n", String::L_AS_IS); - Array_iterator i(rows); - while(i.has_next()) { - Table::element_type row(new ArrayString); - const String& string=*i.next(); - // remove comment lines - if(string.is_empty()) - continue; + int columns_count=columns ? columns->count(): 0; - size_t col_pos_after=0; - string.split(*row, col_pos_after, *separators.scolumn, String::L_AS_IS); - table+=row; + // parse cells + Table::element_type row(new ArrayString(columns_count)); + skip_clean_empty_lines(&data, sdata); + while( lsplit_sresult sr=lsplit(&data, control_chars.separators, control_chars.encloser, sdata) ) { + if(sr.piece->is_empty() && !sr.delim && !row->count()) // append last empty column [if without \n] + break; + *row+=sr.piece; + if(sr.delim=='\n') { + table+=row; + row=new ArrayString(columns_count); + skip_clean_empty_lines(&data, sdata); + } } - + // last line [if without \n] + if(row->count()) + table+=row; + // replace any previous table value GET_SELF(r, VTable).set_table(table); } @@ -226,45 +322,36 @@ struct lsplit_result { char* piece; char delim; + lsplit_result(char *apiece=0) : piece(apiece), delim(0){} operator bool() { return piece!=0; } }; -inline lsplit_result lsplit(char* string, char delim1, char delim2) { - lsplit_result result; - if(string) { - char delims[]={delim1, delim2, 0}; - if(char* v=strpbrk(string, delims)) { +inline lsplit_result lsplit(char* *string_ref, const char* delims) { + lsplit_result result(*string_ref); + if(result.piece) { + if(char* v=strpbrk(result.piece, delims)) { result.delim=*v; *v=0; - result.piece=v+1; + *string_ref=v+1; return result; } + *string_ref=0; } - result.piece=0; - result.delim=0; return result; } -inline lsplit_result lsplit(char* *string_ref, char delim1, char delim2) { - lsplit_result result; - result.piece=*string_ref; - lsplit_result next=lsplit(*string_ref, delim1, delim2); - result.delim=next.delim; - *string_ref=next.piece; - return result; -} - -static lsplit_result lsplit(char** string_ref, char delim1, char delim2, char encloser) { - lsplit_result result; +static lsplit_result lsplit(char** string_ref, const char* delims, char encloser) { + lsplit_result result(*string_ref); - if(char* string=*string_ref) { - if(encloser && *string==encloser) { - string++; + if(result.piece) { + if(encloser && *result.piece==encloser) { + result.piece++; + char c; char *read; char *write; - write=read=string; - char c; + write=read=result.piece; + // we are enclosed, searching for second encloser while(c=*read++) { if(c==encloser) { @@ -275,50 +362,42 @@ static lsplit_result lsplit(char** strin } *write++=c; } - // we are no longer enclosed, searching for delimiter, skipping extra enclosers + + // we are no longer enclosed, searching for delimiter while(c=*read++) { - if(c==delim1 || c==delim2) { + if(c==delims[0] || c==delims[1]) { result.delim=c; break; - } else if(c!=encloser) + } else *write++=c; } + *write=0; // terminate - *string_ref=c? read: 0; - result.piece=string; + *string_ref=c ? read : 0; return result; } else - return lsplit(string_ref, delim1, delim2); + return lsplit(string_ref, delims); } - result.piece=0; return result; } static void skip_empty_and_comment_lines( char** data_ref ) { - if(char *data=*data_ref) { - while( char c=*data ) { - if( c== '\n' || c == '#' ) { - /*nowhere=*/getrow(&data); // remove empty&comment lines - if(!(*data_ref=data)) - break; - continue; - } - break; + while(*data_ref) { + if(**data_ref == '\n'){ + (*data_ref)++; + } else { + if(**data_ref == '#' ) + /*nowhere=*/getrow(data_ref); + else + break; } } } static void skip_empty_lines( char** data_ref ) { - if(char *data=*data_ref) { - while( char c=*data ) { - if( c== '\n' ) { - /*nowhere=*/getrow(&data); // remove empty lines - if(!(*data_ref=data)) - break; - continue; - } - break; - } + if(*data_ref) { + while(**data_ref == '\n') + (*data_ref)++; } } @@ -333,32 +412,28 @@ static void _load(Request& r, MethodPara size_t options_param_index=filename_param_index+1; HashStringValue *options=0; - TableSeparators separators; + TableControlChars control_chars; if(options_param_indexcount(): 0; + int columns_count=columns ? columns->count(): 0; // parse cells Table::element_type row(new ArrayString(columns_count)); skip_lines_action(&data); - while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { + while( lsplit_result sr=lsplit(&data, control_chars.separators, control_chars.encloser) ) { if(!*sr.piece && !sr.delim && !row->count()) // append last empty column [if without \n] break; *row+=new String(sr.piece, String::L_TAINTED); @@ -415,32 +490,32 @@ static void enclose( pa_stringstream& to } } -static void table_to_csv(pa_stringstream& result, Table& table, TableSeparators& separators, bool output_column_names) { +static void table_to_csv(pa_stringstream& result, Table& table, TableControlChars& control_chars, bool output_column_names) { if(output_column_names) { if(table.columns()) { // named table - if(separators.encloser){ + if(control_chars.encloser){ for(Array_iterator i(*table.columns()); i.has_next(); ) { - enclose( result, i.next(), separators.encloser ); + enclose( result, i.next(), control_chars.encloser ); if(i.has_next()) - result< i(*table.columns()); i.has_next(); ) { result<cstr(); if(i.has_next()) - result<count():0) for(int column=0; column i(table); - if(separators.encloser){ + if(control_chars.encloser){ while(i.has_next()) { for(Array_iterator c(*i.next()); c.has_next(); ) { - enclose( result, c.next(), separators.encloser ); + enclose( result, c.next(), control_chars.encloser ); if(c.has_next()) - result< c(*i.next()); c.has_next(); ) { result<cstr(); if(c.has_next()) - result< i(*table.columns()); i.has_next(); ) { - enclose( result, i.next(), separators.encloser, separators.sencloser ); + enclose( result, i.next(), control_chars.encloser, control_chars.sencloser ); if(i.has_next()) - result<<*separators.scolumn; + result<<*control_chars.sseparator; } } else { for(Array_iterator i(*table.columns()); i.has_next(); ) { result<<*i.next(); if(i.has_next()) - result<<*separators.scolumn; + result<<*control_chars.sseparator; } } } else { // nameless table [we were asked to output column names] if(int lsize=table.count()?table[0]->count():0) for(int column=0; column i(table); - if(separators.encloser){ + if(control_chars.encloser){ while(i.has_next()) { for(Array_iterator c(*i.next()); c.has_next(); ) { - enclose( result, c.next(), separators.encloser, separators.sencloser ); + enclose( result, c.next(), control_chars.encloser, control_chars.sencloser ); if(c.has_next()) - result<<*separators.scolumn; + result<<*control_chars.sseparator; } result.append_know_length("\n", 1, String::L_CLEAN); } @@ -544,7 +619,7 @@ static void table_to_csv(String& result, for(Array_iterator c(*i.next()); c.has_next(); ) { result<<*c.next(); if(c.has_next()) - result<<*separators.scolumn; + result<<*control_chars.sseparator; } result.append_know_length("\n", 1, String::L_CLEAN); } @@ -574,25 +649,23 @@ static void _save(Request& r, MethodPara if(do_append && file_exist(file_spec)) output_column_names=false; - TableSeparators separators; + TableControlChars control_chars; if(param_indexcount()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } if(param_indexcount()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } @@ -638,13 +709,13 @@ static void _csv_string(Request& r, Meth #ifdef USE_STRINGSTREAM pa_stringstream ost(std::stringstream::out); - table_to_csv(ost, table, separators, output_column_names); + table_to_csv(ost, table, control_chars, output_column_names); r.write_no_lang(*new VString(*new String(pa_strdup(ost.str().c_str()), String::L_CLEAN))); #else String sdata; - table_to_csv(sdata, table, separators, output_column_names); + table_to_csv(sdata, table, control_chars, output_column_names); r.write_no_lang(*new VString(*new String(sdata.cstr(), String::L_CLEAN))); #endif @@ -685,9 +756,7 @@ static void _offset(Request& r, MethodPa else if(whence=="set") absolute=true; else - throw Exception(PARSER_RUNTIME, - &whence, - "is invalid whence, valid are 'cur' or 'set'"); + throw Exception(PARSER_RUNTIME, &whence, "is invalid whence, valid are 'cur' or 'set'"); } int offset=params.as_int(params.count()-1, "offset must be expression", r); @@ -705,11 +774,10 @@ static void _menu(Request& r, MethodPara Table& table=GET_SELF(r, VTable).table(); size_t saved_current=table.current(); - size_t size=table.count(); if(delim_maybe_code) { // delimiter set bool need_delim=false; - for(size_t row=0; row* value_fields; + Value* value_code; HashStringValue* hash; Table2hash_distint distinct; size_t row; @@ -771,8 +840,12 @@ static void table_row_to_hash(Table::ele bool exist=false; switch(info->value_type) { case C_STRING: { - size_t index=info->value_fields->get(0); - exist=info->hash->put_dont_replace(*key, (index < row->count()) ? new VString(*row->get(index)) : new VString()); + if(info->value_fields->count()){ + size_t index=info->value_fields->get(0); + exist=info->hash->put_dont_replace(*key, (index < row->count()) ? new VString(*row->get(index)) : VString::empty()); + } else { + exist=info->hash->put_dont_replace(*key, VString::empty()); + } break; } case C_HASH: { @@ -781,9 +854,7 @@ static void table_row_to_hash(Table::ele for(Array_iterator i(*info->value_fields); i.has_next(); ) { size_t value_field=i.next(); if(value_fieldcount()) - hash.put( - *info->table->columns()->get(value_field), - new VString(*row->get(value_field))); + hash.put(*info->table->columns()->get(value_field), new VString(*row->get(value_field))); } exist=info->hash->put_dont_replace(*key, vhash); @@ -809,11 +880,15 @@ static void table_row_to_hash(Table::ele *table+=row_copy; break; } + case C_CODE: { + if(!info->key_code) + info->table->set_current(info->row++); // change context row + exist=info->hash->put_dont_replace(*key, &info->r->process(*info->value_code).as_value()); + break; + } } if(exist && info->distinct==D_ILLEGAL) - throw Exception(PARSER_RUNTIME, - key, - "duplicate key"); + throw Exception(PARSER_RUNTIME, key, "duplicate key"); } Table2hash_value_type get_value_type(Value& vvalue_type){ @@ -826,17 +901,24 @@ Table2hash_value_type get_value_type(Val } else if (svalue_type == "hash") { return C_HASH; } else { - throw Exception(PARSER_RUNTIME, - &svalue_type, - "must be 'hash', 'table' or 'string'"); + throw Exception(PARSER_RUNTIME, &svalue_type, "must be 'hash', 'table' or 'string'"); } } else { - throw Exception(PARSER_RUNTIME, - 0, - "'type' must be hash"); + throw Exception(PARSER_RUNTIME, 0, "'type' must be string"); } } +static Table2hash_distint get_distinct(Value& vdistinct, Table2hash_value_type& value_type){ + if(vdistinct.is_string()) { + const String& sdistinct=*vdistinct.get_string(); + if(sdistinct!="tables") + throw Exception(PARSER_RUNTIME, &sdistinct, "must be 'tables' or true/false"); + value_type=C_TABLE; + return D_FIRST; + } + return vdistinct.as_bool() ? D_FIRST : D_ILLEGAL; +} + static void _hash(Request& r, MethodParams& params) { Table& self_table=GET_SELF(r, VTable).table(); VHash& result=*new VHash; @@ -846,32 +928,22 @@ static void _hash(Request& r, MethodPara Table2hash_value_type value_type=C_HASH; int param_index=params.count()-1; if(param_index>0) { - if(HashStringValue* options=params.as_no_junction(param_index, PARAM_MUST_NOT_BE_CODE).get_hash()){ // can't use .as_has because the 2nd param could be table so .as_hash throws an error + + if(params[1].get_junction()) + value_type=C_CODE; + + if(HashStringValue* options=params[param_index].get_hash()){ // can't use .as_hash because the 2nd param could be table so .as_hash throws an error --param_index; int valid_options=0; if(Value* vdistinct_code=options->get(sql_distinct_name)) { // $.distinct ? valid_options++; - Value& vdistinct_value=r.process_to_value(*vdistinct_code); - if(vdistinct_value.is_string()) { - const String& sdistinct=*vdistinct_value.get_string(); - if(sdistinct=="tables") { - value_type=C_TABLE; - distinct=D_FIRST; - } else { - throw Exception(PARSER_RUNTIME, - &sdistinct, - "must be 'tables' or true/false"); - } - } else { - distinct=vdistinct_value.as_bool()?D_FIRST:D_ILLEGAL; - } + distinct=get_distinct(r.process_to_value(*vdistinct_code), value_type); } if(Value* vvalue_type_code=options->get(sql_value_type_name)) { // $.type ? if(value_type==C_TABLE) // $.distinct[tables] already was specified - throw Exception(PARSER_RUNTIME, - 0, - "you can't specify $.distinct[tables] and $.type[] together"); - + throw Exception(PARSER_RUNTIME, 0, "you can't specify $.distinct[tables] and $.type[] together"); + if(value_type==C_CODE) + throw Exception(PARSER_RUNTIME, 0, "you can't specify $.type[] if value is code"); valid_options++; value_type=get_value_type(r.process_to_value(*vvalue_type_code)); } @@ -881,59 +953,57 @@ static void _hash(Request& r, MethodPara } } - if(param_index==2) // options was specified but not as hash + if(param_index==2) // options were specified but not as hash throw Exception(PARSER_RUNTIME, 0, "options must be hash"); Array value_fields; + Value* value_code=0; + if(param_index==0){ // list of columns wasn't specified if(value_type==C_STRING) // $.type[string] - throw Exception(PARSER_RUNTIME, - 0, - "you must specify one value field with option $.type[string]"); + throw Exception(PARSER_RUNTIME, 0, "you must specify one value field with option $.type[string]"); for(size_t i=0; icount(); i++) // by all columns, including key value_fields+=i; - } else { // list of columns was specified + } else { // list of columns or code was specified if(value_type==C_TABLE) - throw Exception(PARSER_RUNTIME, - 0, - "you can't specify value field(s) with option $.distinct[tables] or $.type[tables]"); - - Value& value_fields_param=params.as_no_junction(param_index, "value field(s) must not be code"); - if(value_fields_param.is_string()) { // one column as string was specified - value_fields+=self_table.column_name2index(*value_fields_param.get_string(), true); + throw Exception(PARSER_RUNTIME, 0, "you can't specify value field(s) with option $.distinct[tables] or $.type[tables]"); + + Value& value_fields_param=params[1]; + if(value_fields_param.get_junction()){ // code specified + value_code=&value_fields_param; + } else if(value_fields_param.is_string()) { // one column as string was specified + const String &field_name=*value_fields_param.get_string(); + if(!field_name.is_empty()) + value_fields+=self_table.column_name2index(field_name, true); } else if(Table* value_fields_table=value_fields_param.get_table()) { // list of columns were specified in table for(Array_iterator i(*value_fields_table); i.has_next(); ) { const String& value_field_name =*i.next()->get(0); value_fields +=self_table.column_name2index(value_field_name, true); } } else - throw Exception(PARSER_RUNTIME, - 0, - "value field(s) must be string or table"); + throw Exception(PARSER_RUNTIME, 0, "value field(s) must be string or table or code"); } if(value_type==C_STRING && value_fields.count()!=1) - throw Exception(PARSER_RUNTIME, - 0, - "you can specify only one value field with option $.type[string]"); + throw Exception(PARSER_RUNTIME, 0, "you can specify only one value field with option $.type[string]"); { Value* key_param=¶ms[0]; Row_info info={ &r, &self_table, - /*key_code=*/key_param->get_junction()?key_param:0, + /*key_code=*/key_param->get_junction() ? key_param : 0, /*key_field=*/0/*filled below*/, &value_fields, + value_code, &result.hash(), distinct, /*row=*/0, value_type }; - info.key_field=(info.key_code?-1 - :self_table.column_name2index(key_param->as_string(), true)); + info.key_field=(info.key_code ? -1 : self_table.column_name2index(key_param->as_string(), true)); int saved_current=self_table.current(); self_table.for_each(table_row_to_hash, &info); @@ -1078,8 +1148,8 @@ static void _flip(Request& r, MethodPara static void _foreach(Request& r, MethodParams& params) { InCycle temp(r); - const String& rownum_name=params.as_string(0, "rownum-var name must be string"); - const String& value_name=params.as_string(1, "value-var name must be string"); + const String* rownum_var_name=¶ms.as_string(0, "rownum-var name must be string"); + const String* value_var_name=¶ms.as_string(1, "value-var name must be string"); Value& body_code=params.as_junction(2, "body must be code"); @@ -1087,16 +1157,15 @@ static void _foreach(Request& r, MethodP Table& table=GET_SELF(r, VTable).table(); size_t saved_current=table.current(); - size_t size=table.count(); - const String* rownum_var_name=rownum_name.is_empty()? 0 : &rownum_name; - const String* value_var_name=value_name.is_empty()? 0 : &value_name; + rownum_var_name=rownum_var_name->is_empty()? 0 : rownum_var_name; + value_var_name=value_var_name->is_empty()? 0 : value_var_name; Value* var_context=r.get_method_frame()->caller(); if(delim_maybe_code) { // delimiter set bool need_delim=false; - for(size_t row=0; row