"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/core_globals.cc" between
free42-3.0.3.tar.gz and free42-3.0.4.tar.gz

About: Free42 is a re-implementation of the HP-42S scientific calculator and the HP-82240 printer.

core_globals.cc  (free42-3.0.3):core_globals.cc  (free42-3.0.4)
skipping to change at line 2889 skipping to change at line 2889
return ERR_INSUFFICIENT_MEMORY; return ERR_INSUFFICIENT_MEMORY;
vartype_complex *c = (vartype_complex *) stack[sp]; vartype_complex *c = (vartype_complex *) stack[sp];
arg_struct arg; arg_struct arg;
arg.type = ARGTYPE_DOUBLE; arg.type = ARGTYPE_DOUBLE;
arg.val_d = c->re; arg.val_d = c->re;
store_command_after(&pc, CMD_NUMBER, &arg, NULL); store_command_after(&pc, CMD_NUMBER, &arg, NULL);
arg.type = ARGTYPE_DOUBLE; arg.type = ARGTYPE_DOUBLE;
arg.val_d = c->im; arg.val_d = c->im;
store_command_after(&pc, CMD_NUMBER, &arg, NULL); store_command_after(&pc, CMD_NUMBER, &arg, NULL);
arg.type = ARGTYPE_NONE; arg.type = ARGTYPE_NONE;
store_command_after(&pc, CMD_COMPLEX, &arg, NULL); store_command_after(&pc, CMD_RCOMPLX, &arg, NULL);
return ERR_NONE; return ERR_NONE;
} }
case TYPE_STRING: { case TYPE_STRING: {
vartype_string *s = (vartype_string *) stack[sp]; vartype_string *s = (vartype_string *) stack[sp];
int len = s->length; int len = s->length;
if (len > 65535) if (len > 65535)
len = 65535; len = 65535;
if (!ensure_prgm_space(4 + len)) if (!ensure_prgm_space(4 + len))
return ERR_INSUFFICIENT_MEMORY; return ERR_INSUFFICIENT_MEMORY;
arg_struct arg; arg_struct arg;
skipping to change at line 3166 skipping to change at line 3166
return ERR_INVALID_CONTEXT; return ERR_INVALID_CONTEXT;
if (!ensure_var_space(1)) if (!ensure_var_space(1))
return ERR_INSUFFICIENT_MEMORY; return ERR_INSUFFICIENT_MEMORY;
int inputs = flags.f.big_stack ? n / 10 : 4; int inputs = flags.f.big_stack ? n / 10 : 4;
if (sp + 1 < inputs) if (sp + 1 < inputs)
return ERR_TOO_FEW_ARGUMENTS; return ERR_TOO_FEW_ARGUMENTS;
int size = inputs + 4; int size = inputs + 4;
// FD list layout: // FD list layout:
// 0: n, the 2-digit parameter to FUNC // 0: n, the 2-digit parameter to FUNC
// 1: original stack depth, or -1 for 4-level stack // 1: original stack depth, or -1 for 4-level stack
// 2: flag 25, encoded as a string "0" or "1" // 2: flag 25, ERRNO, and ERRMSG
// 3: lastx // 3: lastx
// 4: X / level 1 // 4: X / level 1
// 5: Y / level 2 // 5: Y / level 2
// etc. // etc.
// For 4-level stack, all 4 registers are saved; // For 4-level stack, all 4 registers are saved;
// for big stack, the input parameters are saved. // for big stack, the input parameters are saved.
fd = new_list(size); fd = new_list(size);
if (fd == NULL) if (fd == NULL)
return ERR_INSUFFICIENT_MEMORY; return ERR_INSUFFICIENT_MEMORY;
vartype **fd_data = ((vartype_list *) fd)->array->data; vartype **fd_data = ((vartype_list *) fd)->array->data;
fd_data[0] = new_real(n); fd_data[0] = new_real(n);
fd_data[1] = new_real(flags.f.big_stack ? sp + 1 : -1); fd_data[1] = new_real(flags.f.big_stack ? sp + 1 : -1);
fd_data[2] = new_string(flags.f.error_ignore ? "1" : "0", 1); fd_data[2] = new_string(NULL, lasterr == -1 ? 2 + lasterr_length : 2);
fd_data[3] = dup_vartype(lastx); fd_data[3] = dup_vartype(lastx);
for (int i = 0; i < inputs; i++) for (int i = 0; i < inputs; i++)
fd_data[i + 4] = dup_vartype(stack[sp - i]); fd_data[i + 4] = dup_vartype(stack[sp - i]);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
if (fd_data[i] == NULL) { if (fd_data[i] == NULL) {
free_vartype(fd); free_vartype(fd);
return ERR_INSUFFICIENT_MEMORY; return ERR_INSUFFICIENT_MEMORY;
} }
vartype_string *s = (vartype_string *) fd_data[2];
s->txt()[0] = flags.f.error_ignore ? '1' : '0';
s->txt()[1] = (char) lasterr;
if (lasterr == -1)
memcpy(s->txt() + 2, lasterr_text, lasterr_length);
store_private_var("FD", 2, fd); store_private_var("FD", 2, fd);
flags.f.error_ignore = 0; flags.f.error_ignore = 0;
lasterr = ERR_NONE;
if (rtn_level == 0) if (rtn_level == 0)
rtn_level_0_has_func_state = true; rtn_level_0_has_func_state = true;
else else
rtn_stack[rtn_sp - 1].set_has_func(true); rtn_stack[rtn_sp - 1].set_has_func(true);
return ERR_NONE; return ERR_NONE;
} }
int push_stack_state(bool big) { int push_stack_state(bool big) {
vartype *st = recall_private_var("ST", 2); vartype *st = recall_private_var("ST", 2);
skipping to change at line 3392 skipping to change at line 3398
memmove(stack + depth - out - excess, stack + depth - out, out * sizeof(vartype *)); memmove(stack + depth - out - excess, stack + depth - out, out * sizeof(vartype *));
sp -= excess; sp -= excess;
} }
} }
free_vartype(lastx); free_vartype(lastx);
int li = in == 0 ? 3 : 4; // L : X int li = in == 0 ? 3 : 4; // L : X
lastx = fd_data[li]; lastx = fd_data[li];
fd_data[li] = NULL; fd_data[li] = NULL;
char f25 = ((vartype_string *) fd_data[2])->txt()[0] == '1'; vartype_string *s = (vartype_string *) fd_data[2];
flags.f.error_ignore = f25; flags.f.error_ignore = s->txt()[0] == '1';
if (s->length > 1) {
lasterr = (signed char) s->txt()[1];
if (lasterr == -1) {
lasterr_length = s->length - 2;
memcpy(lasterr_text, s->txt() + 2, lasterr_length);
}
}
goto done; goto done;
} }
if (st != NULL && fd != NULL) { if (st != NULL && fd != NULL) {
vartype **st_data = st->array->data; vartype **st_data = st->array->data;
char st_big = ((vartype_string *) st_data[0])->txt()[0] == '1'; char st_big = ((vartype_string *) st_data[0])->txt()[0] == '1';
vartype **fd_data = fd->array->data; vartype **fd_data = fd->array->data;
int old_depth = to_int(((vartype_real *) fd_data[1])->x); int old_depth = to_int(((vartype_real *) fd_data[1])->x);
char fd_big = old_depth >= 0; char fd_big = old_depth >= 0;
skipping to change at line 3493 skipping to change at line 3506
memcpy(stack, st->array->data + 1, st_levels * sizeof(vartype *)); memcpy(stack, st->array->data + 1, st_levels * sizeof(vartype *));
sp = st_levels + out - 1; sp = st_levels + out - 1;
memset(st->array->data + 1, 0, st_levels * sizeof(vartype *)); memset(st->array->data + 1, 0, st_levels * sizeof(vartype *));
} }
free_vartype(lastx); free_vartype(lastx);
int li = in == 0 ? 3 : 4; // L : X int li = in == 0 ? 3 : 4; // L : X
lastx = fd_data[li]; lastx = fd_data[li];
fd_data[li] = NULL; fd_data[li] = NULL;
char f25 = ((vartype_string *) fd_data[2])->txt()[0] == '1'; vartype_string *s = (vartype_string *) fd_data[2];
flags.f.error_ignore = f25; flags.f.error_ignore = s->txt()[0] == '1';
if (s->length > 1) {
lasterr = (signed char) s->txt()[1];
if (lasterr == -1) {
lasterr_length = s->length - 2;
memcpy(lasterr_text, s->txt() + 2, lasterr_length);
}
}
flags.f.big_stack = fd_big; flags.f.big_stack = fd_big;
} }
done: done:
if (rtn_level == 0) if (rtn_level == 0)
rtn_level_0_has_func_state = false; rtn_level_0_has_func_state = false;
else else
rtn_stack[rtn_sp - 1].set_has_func(false); rtn_stack[rtn_sp - 1].set_has_func(false);
skipping to change at line 3761 skipping to change at line 3781
pop_rtn_addr(&dummy1, &dummy2, &dummy3); pop_rtn_addr(&dummy1, &dummy2, &dummy3);
} }
get_saved_stack_mode(&st_mode); get_saved_stack_mode(&st_mode);
pop_rtn_addr(&dummy1, &dummy2, &dummy3); pop_rtn_addr(&dummy1, &dummy2, &dummy3);
if (st_mode == 0) { if (st_mode == 0) {
arg_struct dummy_arg; arg_struct dummy_arg;
docmd_4stk(&dummy_arg); docmd_4stk(&dummy_arg);
} else if (st_mode == 1) { } else if (st_mode == 1) {
docmd_nstk(NULL); docmd_nstk(NULL);
} }
if (mode_plainmenu == MENU_PROGRAMMABLE)
set_menu(MENULEVEL_PLAIN, MENU_NONE);
if (varmenu_role == 3)
varmenu_role = 0;
} }
int get_rtn_level() { int get_rtn_level() {
return rtn_level; return rtn_level;
} }
bool solve_active() { bool solve_active() {
return rtn_solve_active; return rtn_solve_active;
} }
 End of changes. 8 change blocks. 
7 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)