dc: execute shouldn't pop if stack head is not a string
This matches the behaviour of both GNU dc (as specified in its man page), and BSD dc (where stack_popstring() pops only if the head is a string.) Add a couple of tests to verify this behavior. function old new delta zxc_vm_process 6882 6884 +2 Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		
				
					committed by
					
						 Denys Vlasenko
						Denys Vlasenko
					
				
			
			
				
	
			
			
			
						parent
						
							22a6339627
						
					
				
				
					commit
					7454879a1d
				
			| @@ -6521,7 +6521,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | ||||
| 			if (s || !BC_PROG_STR(n)) goto exit; | ||||
| 			sidx = n->rdx; | ||||
| 		} else | ||||
| 			goto exit; | ||||
| 			goto exit_nopop; | ||||
| 	} | ||||
|  | ||||
| 	fidx = sidx + BC_PROG_REQ_FUNCS; | ||||
| @@ -6561,6 +6561,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | ||||
| 	RETURN_STATUS(BC_STATUS_SUCCESS); | ||||
|  exit: | ||||
| 	bc_vec_pop(&G.prog.results); | ||||
|  exit_nopop: | ||||
| 	RETURN_STATUS(s); | ||||
| } | ||||
| #define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user