summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorerco77 <erco@seriss.com>2020-08-01 14:35:44 -0700
committerGitHub <noreply@github.com>2020-08-01 14:35:44 -0700
commit7abc09ad89b4c3d0c17ee8dc9d02ccd261cd13f2 (patch)
tree72e461bac5930f8a319d48a6ea99ba793dd35a8b /fluid
parent7514a73ba759f7fc9965eeef3b92ece899bd7a69 (diff)
parente9688822ec68f066f425953278a853e049b93dfb (diff)
Merge pull request #116 from erco77/fl_strdup
fl_strdup() implemented + deployed
Diffstat (limited to 'fluid')
-rw-r--r--fluid/ExternalCodeEditor_UNIX.cxx3
-rw-r--r--fluid/ExternalCodeEditor_WIN32.cxx3
-rw-r--r--fluid/Fl_Function_Type.cxx15
-rw-r--r--fluid/Fluid_Image.cxx3
-rw-r--r--fluid/code.cxx5
-rw-r--r--fluid/file.cxx13
-rw-r--r--fluid/fluid.cxx3
-rw-r--r--fluid/print_panel.cxx3
-rw-r--r--fluid/print_panel.fl5
-rw-r--r--fluid/template_panel.cxx3
-rw-r--r--fluid/template_panel.fl5
11 files changed, 38 insertions, 23 deletions
diff --git a/fluid/ExternalCodeEditor_UNIX.cxx b/fluid/ExternalCodeEditor_UNIX.cxx
index 189f29778..c0f753550 100644
--- a/fluid/ExternalCodeEditor_UNIX.cxx
+++ b/fluid/ExternalCodeEditor_UNIX.cxx
@@ -16,6 +16,7 @@
#include <FL/Fl.H> /* Fl_Timeout_Handler.. */
#include <FL/fl_ask.H> /* fl_alert() */
+#include <FL/fl_string.h> /* fl_strdup() */
#include "ExternalCodeEditor_UNIX.h"
@@ -61,7 +62,7 @@ ExternalCodeEditor::~ExternalCodeEditor() {
//
void ExternalCodeEditor::set_filename(const char *val) {
if ( filename_ ) free((void*)filename_);
- filename_ = val ? strdup(val) : 0;
+ filename_ = val ? fl_strdup(val) : 0;
}
// [Public] Is editor running?
diff --git a/fluid/ExternalCodeEditor_WIN32.cxx b/fluid/ExternalCodeEditor_WIN32.cxx
index 9be5a30aa..45ad61288 100644
--- a/fluid/ExternalCodeEditor_WIN32.cxx
+++ b/fluid/ExternalCodeEditor_WIN32.cxx
@@ -8,6 +8,7 @@
#include <FL/Fl.H> // Fl_Timeout_Handler..
#include <FL/fl_ask.H> // fl_alert()
#include <FL/fl_utf8.h> // fl_utf8fromwc()
+#include <FL/fl_string.h> // fl_strdup()
#include "ExternalCodeEditor_WIN32.h"
@@ -83,7 +84,7 @@ ExternalCodeEditor::~ExternalCodeEditor() {
//
void ExternalCodeEditor::set_filename(const char *val) {
if ( filename_ ) free((void*)filename_);
- filename_ = val ? strdup(val) : 0;
+ filename_ = val ? fl_strdup(val) : 0;
}
// [Public] Is editor running?
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx
index f6e8f5b29..54b4a7313 100644
--- a/fluid/Fl_Function_Type.cxx
+++ b/fluid/Fl_Function_Type.cxx
@@ -17,6 +17,7 @@
#include <FL/Fl_Window.H>
#include <FL/Fl_Preferences.H>
#include <FL/Fl_File_Chooser.H>
+#include <FL/fl_string.h>
#include "Fl_Type.h"
#include <FL/fl_show_input.H>
#include <FL/Fl_File_Chooser.H>
@@ -843,7 +844,7 @@ void Fl_Data_Type::open() {
}
// store the variable name:
const char*c = data_input->value();
- char *s = strdup(c), *p = s, *q, *n;
+ char *s = fl_strdup(c), *p = s, *q, *n;
for (;;++p) {
if (!isspace((unsigned char)(*p))) break;
}
@@ -890,7 +891,7 @@ void Fl_Data_Type::open() {
else if (!filename_ && *c)
set_modflag(1);
if (filename_) { free((void*)filename_); filename_ = 0L; }
- if (c && *c) filename_ = strdup(c);
+ if (c && *c) filename_ = fl_strdup(c);
// store the comment
c = data_comment_input->buffer()->text();
if (c && *c) {
@@ -1016,7 +1017,7 @@ Fl_Type *Fl_DeclBlock_Type::make() {
Fl_DeclBlock_Type *o = new Fl_DeclBlock_Type();
o->name("#if 1");
o->public_ = 0;
- o->after = strdup("#endif");
+ o->after = fl_strdup("#endif");
o->add(p);
o->factory = this;
return o;
@@ -1188,7 +1189,7 @@ void Fl_Comment_Type::open() {
"Use forward slashes '/' to create submenus.",
"My Comment");
if (xname) {
- char *name = strdup(xname);
+ char *name = fl_strdup(xname);
for (char*s=name;*s;s++) if (*s==':') *s = ';';
int n;
Fl_Preferences db(Fl_Preferences::USER, "fltk.org", "fluid_comments");
@@ -1305,7 +1306,7 @@ void Fl_Comment_Type::write_code1() {
return;
}
// copy the comment line by line, add the double slash if needed
- char *txt = strdup(c);
+ char *txt = fl_strdup(c);
char *b = txt, *e = txt;
for (;;) {
// find the end of the line and set it to NUL
@@ -1374,7 +1375,7 @@ int Fl_Class_Type::is_public() const {return public_;}
void Fl_Class_Type::prefix(const char*p) {
free((void*) class_prefix);
- class_prefix=strdup(p ? p : "" );
+ class_prefix=fl_strdup(p ? p : "" );
}
Fl_Type *Fl_Class_Type::make() {
@@ -1440,7 +1441,7 @@ void Fl_Class_Type::open() {
else if (!w) Fl::wait();
}
const char*c = c_name_input->value();
- char *s = strdup(c);
+ char *s = fl_strdup(c);
size_t len = strlen(s);
if (!*s) goto OOPS;
p = (char*) (s+len-1);
diff --git a/fluid/Fluid_Image.cxx b/fluid/Fluid_Image.cxx
index 19784e0e0..1f41a09fd 100644
--- a/fluid/Fluid_Image.cxx
+++ b/fluid/Fluid_Image.cxx
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <FL/filename.H>
+#include <FL/fl_string.h>
extern void goto_source_dir(); // in fluid.cxx
extern void leave_source_dir(); // in fluid.cxx
@@ -204,7 +205,7 @@ Fluid_Image* Fluid_Image::find(const char *iname) {
}
Fluid_Image::Fluid_Image(const char *iname) {
- name_ = strdup(iname);
+ name_ = fl_strdup(iname);
written = 0;
refcount = 0;
img = Fl_Shared_Image::get(iname);
diff --git a/fluid/code.cxx b/fluid/code.cxx
index 7b156f57e..4603e9582 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <FL/Fl.H>
+#include <FL/fl_string.h>
#include "Fl_Type.h"
#include "alignment_panel.h"
@@ -46,7 +47,7 @@ struct id {
char* text;
void* object;
id *left, *right;
- id (const char* t, void* o) : text(strdup(t)), object(o) {left = right = 0;}
+ id (const char* t, void* o) : text(fl_strdup(t)), object(o) {left = right = 0;}
~id();
};
@@ -109,7 +110,7 @@ struct included {
char *text;
included *left, *right;
included(const char *t) {
- text = strdup(t);
+ text = fl_strdup(t);
left = right = 0;
}
~included();
diff --git a/fluid/file.cxx b/fluid/file.cxx
index dd2ef345c..30335a232 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -25,6 +25,7 @@
#include <stdarg.h>
#include "alignment_panel.h"
#include <FL/Fl.H>
+#include <FL/fl_string.h>
#include "Fl_Widget_Type.h"
////////////////////////////////////////////////////////////////
@@ -405,19 +406,19 @@ static void read_children(Fl_Type *p, int paste) {
goto CONTINUE;
}
if (!strcmp(c,"i18n_function")) {
- i18n_function = strdup(read_word());
+ i18n_function = fl_strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_file")) {
- i18n_file = strdup(read_word());
+ i18n_file = fl_strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_set")) {
- i18n_set = strdup(read_word());
+ i18n_set = fl_strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_include")) {
- i18n_include = strdup(read_word());
+ i18n_include = fl_strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_type"))
@@ -431,13 +432,13 @@ static void read_children(Fl_Type *p, int paste) {
goto CONTINUE;
}
if (!strcmp(c,"header_name")) {
- if (!header_file_set) header_file_name = strdup(read_word());
+ if (!header_file_set) header_file_name = fl_strdup(read_word());
else read_word();
goto CONTINUE;
}
if (!strcmp(c,"code_name")) {
- if (!code_file_set) code_file_name = strdup(read_word());
+ if (!code_file_set) code_file_name = fl_strdup(read_word());
else read_word();
goto CONTINUE;
}
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 0cd678827..e9025a4e3 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -36,6 +36,7 @@
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_Printer.H>
#include <FL/fl_utf8.h>
+#include <FL/fl_string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -1544,7 +1545,7 @@ show_shell_window() {
void set_filename(const char *c) {
if (filename) free((void *)filename);
- filename = c ? strdup(c) : NULL;
+ filename = c ? fl_strdup(c) : NULL;
if (filename && !batch_mode)
update_history(filename);
diff --git a/fluid/print_panel.cxx b/fluid/print_panel.cxx
index f41cae23d..c5e520fbb 100644
--- a/fluid/print_panel.cxx
+++ b/fluid/print_panel.cxx
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include "../src/flstring.h"
#include <FL/Fl_Preferences.H>
+#include <FL/fl_string.h>
extern Fl_Preferences fluid_prefs;
Fl_Double_Window *print_panel=(Fl_Double_Window *)0;
@@ -531,7 +532,7 @@ void print_load() {
}
*qptr = '\0';
- print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
+ print_choice->add(qname, 0, 0, (void *)fl_strdup(name), 0);
} else if (!strncmp(line, "system default destination: ", 28)) {
if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\0';
}
diff --git a/fluid/print_panel.fl b/fluid/print_panel.fl
index 1dd08615f..e2042f531 100644
--- a/fluid/print_panel.fl
+++ b/fluid/print_panel.fl
@@ -29,6 +29,9 @@ decl {\#include <stdlib.h>} {private local
decl {\#include "../src/flstring.h"} {private local
}
+decl {\#include <FL/fl_string.h>} {private local
+}
+
decl {\#include <FL/Fl_Preferences.H>} {private local
}
@@ -307,7 +310,7 @@ if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) {
}
*qptr = '\\0';
- print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
+ print_choice->add(qname, 0, 0, (void *)fl_strdup(name), 0);
} else if (!strncmp(line, "system default destination: ", 28)) {
if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\\0';
}
diff --git a/fluid/template_panel.cxx b/fluid/template_panel.cxx
index f46b85d18..fc04495df 100644
--- a/fluid/template_panel.cxx
+++ b/fluid/template_panel.cxx
@@ -25,6 +25,7 @@
#include <FL/fl_ask.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Preferences.H>
+#include <FL/fl_string.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <io.h>
#else
@@ -257,7 +258,7 @@ void template_load() {
// Add the template to the browser...
snprintf(filename, sizeof(filename), "%s/%s", path, files[i]->d_name);
- template_browser->add(name, strdup(filename));
+ template_browser->add(name, fl_strdup(filename));
}
free(files[i]);
diff --git a/fluid/template_panel.fl b/fluid/template_panel.fl
index 5da887495..b0d5b9ff9 100644
--- a/fluid/template_panel.fl
+++ b/fluid/template_panel.fl
@@ -29,6 +29,9 @@ decl {\#include <stdlib.h>} {private local
decl {\#include "../src/flstring.h"} {private local
}
+decl {\#include <FL/fl_string.h>} {private local
+}
+
decl {\#include <errno.h>} {private local
}
@@ -253,7 +256,7 @@ for (i = 0; i < num_files; i ++) {
// Add the template to the browser...
snprintf(filename, sizeof(filename), "%s/%s", path, files[i]->d_name);
- template_browser->add(name, strdup(filename));
+ template_browser->add(name, fl_strdup(filename));
}
free(files[i]);