rem: var expr="State==State"; 
add: if(!gnats.reset_expr()) error(); 
context: function set_prlist(s){	var i;	var j;	var f;	var done=false;	fields=new Array();	for (field in query) {		fields.push(field);	}	while(!done) {		var text='';		var expr='';		console.uselect(0,"Field","Run Query","");		for(i=0;i<fields.length;i++) {			console.uselect(i+1,"Field",query[fields[i]].desc+": "+query[fields[i]].text,"");		}		f=console.uselect();		if(f==-1)			return(true);		if(f==0)			break;		f--;		if(f>=0 && f < fields.length) {			// Field selected to change...			console.uselect(0,query[fields[f]].desc,"Equals","");			console.uselect(1,query[fields[f]].desc,"Does not equal","");			console.uselect(2,query[fields[f]].desc,"Contains","");			console.uselect(3,query[fields[f]].desc,"Is greater than","");			console.uselect(4,query[fields[f]].desc,"Is less than","");			console.uselect(5,query[fields[f]].desc,"Any","");			var op=console.uselect();			switch(op) {				case 0:					text += "Equals";					expr += query[fields[f]].field+"==";					break;				case 1:					text += "Doesn't equal";					expr += query[fields[f]].field+"!=";					break;				case 2:					text += "Contains";					expr += query[fields[f]].field+"~";					break;				case 3:					text += "Is greater than";					expr += query[fields[f]].field+">";					break;				case 4:					text += "Is less than";					expr += query[fields[f]].field+"<";					break;				case 5:					text = "Any";					expr=undefined;					query[fields[f]].text=text;					query[fields[f]].expr=expr;					continue;					break;			}			if(op>=0 && op <= 4) {				if(query[fields[f]].list != undefined) {					s.send("LIST "+query[fields[f]].list+"\r\n");					r=get_response(s);					if(r.code!=301) {						writeln("LIST Expected 301, got "+r.code);						writeln(r.message);						console.pause();						clean_exit(s);					}					vals=r.text.split(/\r\n/);					vals.pop();	// Remove blank at end					for(i=0; i<vals.length; i++) {						cols=vals[i].split(/:/);						console.uselect(i, query[fields[f]].desc, cols[0]+" ("+cols[query[fields[f]].listdesc]+")", "");					}					var val=console.uselect();					if(val>0 && val < vals.length) {						cols=vals[val].split(/:/);						text += ' "'+cols[0]+'"';						expr += ' "'+cols[0].replace(/"/,'\\"')+'"';						query[fields[f]].text=text;						query[fields[f]].expr=expr;					}				}				else {					write(query[fields[f]].desc+" "+text+": ");					var val=console.getstr();					text += ' "'+val+'"';					val.replace(/"/,'\\"');					expr += ' "'+val.replace(/"/,'\\"')+'"';					query[fields[f]].text=text;					query[fields[f]].expr=expr;				}			}		}	}	var expr="State==State";	// Must have SOME query...	for(field in fields) {		if(query[fields[field]].expr != undefined) {			expr += " & ";			expr += query[fields[field]].expr;		}	}	s.send('RSET\r\n');	r=get_response(s);	if(r.type!=SUCCESS) {		writeln("RSET got unexpected "+r.code);		writeln(r.message);		console.pause();		clean_exit(s);	}	s.send('EXPR '+expr+'\r\n');	r=get_response(s);	if(r.code!=210) {		writeln("EXPR Expected 210, got "+r.code);		writeln(r.message);		console.pause();		clean_exit(s);	}	s.send('QFMT "%-72.72s %-10.10s %-6.6s %-10.10s %-10.10s" Synopsis Category Number Responsible State\r\n');	r=get_response(s);	if(r.code!=210) {		writeln("QFMT Expected 210, got "+r.code);		writeln(r.message);		console.pause();		clean_exit(s);	}}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/0172a9c9d8c678201b82af125f33ca856459917d/query_pr.js/buggy/query_pr.js