diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-03-02 23:14:07 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-03-02 23:14:07 +0100 |
| commit | 4ccadff4b9120cba114da964fd0e79c762a6fd3d (patch) | |
| tree | 9a2f7183abc2b91f690bfa2c8a660d0bb84552f4 /documentation | |
| parent | ec9430e744d33d6c88a00481057ecd5298c8e882 (diff) | |
Fix test/editor use of strncy to strlcpy
Diffstat (limited to 'documentation')
| -rw-r--r-- | documentation/src/editor.dox | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/documentation/src/editor.dox b/documentation/src/editor.dox index 823c7c34c..13b23b58d 100644 --- a/documentation/src/editor.dox +++ b/documentation/src/editor.dox @@ -52,6 +52,7 @@ marked in the source code as `TUTORIAL_CHAPTER = 1`. \code #include <FL/Fl_Double_Window.H> #include <FL/Fl.H> +#include <string.h> Fl_Double_Window *app_window = NULL; @@ -365,7 +366,7 @@ little chunk of code will separate the file name from the path before we call // insert before `if (file_chooser.show()...` if (app_filename[0]) { char temp_filename[FL_PATH_MAX]; - strncpy(temp_filename, app_filename, FL_PATH_MAX-1); + strlcpy(temp_filename, app_filename, FL_PATH_MAX); const char *name = fl_filename_name(temp_filename); if (name) { file_chooser.preset_file(name); @@ -478,7 +479,7 @@ name: ... if (app_filename[0]) { char temp_filename[FL_PATH_MAX]; - strncpy(temp_filename, app_filename, FL_PATH_MAX-1); + strlcpy(temp_filename, app_filename, FL_PATH_MAX); const char *name = fl_filename_name(temp_filename); if (name) { file_chooser.preset_file(name); @@ -647,7 +648,7 @@ char last_find_text[1024] = ""; void menu_find_callback(Fl_Widget*, void* v) { const char *find_text = fl_input("Find in text:", last_find_text); if (find_text) { - strncpy(last_find_text, find_text, sizeof(last_find_text)-1); + strlcpy(last_find_text, find_text, sizeof(last_find_text)); find_next(find_text); } } @@ -811,8 +812,8 @@ function: \code void Replace_Dialog::find_next_callback(Fl_Widget*, void* my_dialog) { Replace_Dialog *dlg = static_cast<Replace_Dialog*>(my_dialog); - strncpy(last_find_text, dlg->find_text_input->value(), sizeof(last_find_text)-1); - strncpy(last_replace_text, dlg->replace_text_input->value(), sizeof(last_replace_text)-1); + strlcpy(last_find_text, dlg->find_text_input->value(), sizeof(last_find_text)); + strlcpy(last_replace_text, dlg->replace_text_input->value(), sizeof(last_replace_text)); if (last_find_text[0]) find_next(last_find_text); } |
