diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
| commit | 2ffd4e4f1af16b17a286ff354603a717f5d828a5 (patch) | |
| tree | 99e2d4a7e2fde8e3abb027eb687901440750ee00 /test/keyboard.cxx | |
| parent | 53d9614adbb728fc4db983c9bb817c6eea870994 (diff) | |
Replace all calls to sprintf() by calls to snprintf().
Diffstat (limited to 'test/keyboard.cxx')
| -rw-r--r-- | test/keyboard.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/keyboard.cxx b/test/keyboard.cxx index feb896c3f..a3603cabf 100644 --- a/test/keyboard.cxx +++ b/test/keyboard.cxx @@ -119,20 +119,20 @@ int main(int argc, char** argv) { if (!k) keyname = "0"; else if (k < 128) { // ASCII - sprintf(buffer, "'%c'", k); + snprintf(buffer, sizeof(buffer), "'%c'", k); } else if (k >= 0xa0 && k <= 0xff) { // ISO-8859-1 (international keyboards) char key[8]; int kl = fl_utf8encode((unsigned)k, key); key[kl] = '\0'; - sprintf(buffer, "'%s'", key); + snprintf(buffer, sizeof(buffer), "'%s'", key); } else if (k > FL_F && k <= FL_F_Last) { - sprintf(buffer, "FL_F+%d", k - FL_F); + snprintf(buffer, sizeof(buffer), "FL_F+%d", k - FL_F); } else if (k >= FL_KP && k <= FL_KP_Last) { - sprintf(buffer, "FL_KP+'%c'", k-FL_KP); + snprintf(buffer, sizeof(buffer), "FL_KP+'%c'", k-FL_KP); } else if (k >= FL_Button && k <= FL_Button+7) { - sprintf(buffer, "FL_Button+%d", k-FL_Button); + snprintf(buffer, sizeof(buffer), "FL_Button+%d", k-FL_Button); } else { - sprintf(buffer, "0x%04x", k); + snprintf(buffer, sizeof(buffer), "0x%04x", k); for (int i = 0; i < int(sizeof(table)/sizeof(*table)); i++) if (table[i].n == k) {keyname = table[i].text; break;} } |
