Patch some bits of calc.c for new stringObj()

This commit is contained in:
Sage Vaillancourt 2022-03-29 14:02:02 -04:00 committed by Sage Vaillancourt
parent a444bc11bb
commit bedf525dcb
1 changed files with 6 additions and 4 deletions

View File

@ -213,14 +213,13 @@ static void add_token()
// Calculate result, display it and reset
static void calculate()
{
char temp[RESULT_LENGTH + 2] = "";
trim(excess_chars);
excess_chars = 0;
Object obj = parseEval(displayed_code, &env);
updateText();
stringNObj(temp, &obj, RESULT_LENGTH);
size_t length;
char* temp = stringObj(&obj, &length);
if (obj.type == TYPE_ERROR) {
text_layer_set_font(s_result_text_layer,
fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
@ -229,6 +228,7 @@ static void calculate()
fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
}
snprintf(result_text, RESULT_LENGTH, RESULT_PREFIX "%s", temp);
free(temp);
text_layer_set_text(s_result_text_layer, result_text);
}
@ -470,7 +470,9 @@ static void custom_load(Window* window)
Object add_window(Object obj1, Object _, struct Environment* env)
{
printf("ADD_WINDOW\n");
stringObj(header, &obj1);
size_t length;
char* temp = stringObj(&obj1, &length);
sprintf(header, "%s", temp);
if (!s_custom_window) {
s_custom_window = window_create();