summaryrefslogtreecommitdiff
path: root/textscreen/examples/calculator.c
diff options
context:
space:
mode:
authorSimon Howard2014-04-01 21:49:16 -0400
committerSimon Howard2014-04-01 21:49:16 -0400
commita9d9335b20a0b708fae1b978f70348aec998356a (patch)
tree9d775843fddbffaa9babdf54221b0ac98105dc91 /textscreen/examples/calculator.c
parent17c14e1fad6dc277a6e58e4f421d5c65e210d1fe (diff)
downloadchocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.tar.gz
chocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.tar.bz2
chocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.zip
textscreen: Use safe string functions.
Define TXT_{StringCopy,StringConcat,snprintf,vsnprintf} as analogs of the m_misc.c versions so that the textscreen library does not need a dependency on the Doom code, and change all textscreen code to use these instead of unsafe functions. This fixes #372.
Diffstat (limited to 'textscreen/examples/calculator.c')
-rw-r--r--textscreen/examples/calculator.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/textscreen/examples/calculator.c b/textscreen/examples/calculator.c
index 7c77e838..3db60ef7 100644
--- a/textscreen/examples/calculator.c
+++ b/textscreen/examples/calculator.c
@@ -49,7 +49,7 @@ void UpdateInputBox(void)
{
char buf[20];
- sprintf(buf, " %i", input_value);
+ TXT_snprintf(buf, sizeof(buf), " %i", input_value);
TXT_SetLabel(input_box, buf);
}
@@ -76,7 +76,7 @@ void AddNumberButton(txt_table_t *table, int value)
val_copy = malloc(sizeof(int));
*val_copy = value;
- sprintf(buf, " %i ", value);
+ TXT_snprintf(buf, sizeof(buf), " %i ", value);
TXT_AddWidget(table, TXT_NewButton2(buf, InsertNumber, val_copy));
}
@@ -98,7 +98,7 @@ void AddOperatorButton(txt_table_t *table, char *label, operator_t op)
op_copy = malloc(sizeof(operator_t));
*op_copy = op;
- sprintf(buf, " %s ", label);
+ TXT_snprintf(buf, sizeof(buf), " %s ", label);
TXT_AddWidget(table, TXT_NewButton2(buf, Operator, op_copy));
}