diff options
| -rwxr-xr-x | bin/fluid | bin | 2623064 -> 2623592 bytes | |||
| -rw-r--r-- | fluid/app/Image_Asset.cxx | 23 | ||||
| -rw-r--r-- | fluid/app/Image_Asset.h | 12 | ||||
| -rw-r--r-- | fluid/app/Snap_Action.cxx | 22 | ||||
| -rw-r--r-- | fluid/app/Snap_Action.h | 8 | ||||
| -rw-r--r-- | fluid/io/Code_Writer.cxx | 28 | ||||
| -rw-r--r-- | fluid/io/String_Writer.cxx | 2 | ||||
| -rw-r--r-- | fluid/nodes/Menu_Node.cxx | 14 | ||||
| -rw-r--r-- | fluid/nodes/Widget_Node.cxx | 12 | ||||
| -rw-r--r-- | fluid/panels/settings_panel.cxx | 38 | ||||
| -rw-r--r-- | fluid/panels/settings_panel.fl | 32 | ||||
| -rw-r--r-- | fluid/proj/i18n.cxx | 124 | ||||
| -rw-r--r-- | fluid/proj/i18n.h | 36 | ||||
| -rw-r--r-- | fluid/tools/ExternalCodeEditor_UNIX.cxx | 7 | ||||
| -rw-r--r-- | fluid/tools/ExternalCodeEditor_UNIX.h | 2 | ||||
| -rw-r--r-- | lib/libfltk.a | bin | 2237456 -> 2237456 bytes | |||
| -rw-r--r-- | lib/libfltk_forms.a | bin | 32888 -> 32888 bytes | |||
| -rw-r--r-- | lib/libfltk_gl.a | bin | 212448 -> 212448 bytes | |||
| -rw-r--r-- | lib/libfltk_images.a | bin | 268016 -> 268016 bytes | |||
| -rw-r--r-- | lib/libfltk_jpeg.a | bin | 305416 -> 305416 bytes | |||
| -rw-r--r-- | lib/libfltk_png.a | bin | 287384 -> 287384 bytes | |||
| -rw-r--r-- | lib/libfltk_z.a | bin | 103976 -> 103976 bytes |
22 files changed, 217 insertions, 143 deletions
| Binary files differ diff --git a/fluid/app/Image_Asset.cxx b/fluid/app/Image_Asset.cxx index cea3cc058..36fa4d443 100644 --- a/fluid/app/Image_Asset.cxx +++ b/fluid/app/Image_Asset.cxx @@ -39,7 +39,6 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <string> /** Simple string-to-Image_Asset map entry */ struct Image_Asset_Entry { @@ -210,7 +209,8 @@ void Image_Asset::write_static_rgb(fld::io::Code_Writer& f, const char* idata_na void Image_Asset::write_static(fld::io::Code_Writer& f, int compressed) { if (!image_) return; const char *idata_name = f.unique_id(this, "idata", fl_filename_name(filename()), 0); - initializer_function_ = f.unique_id(this, "image", fl_filename_name(filename()), 0); + if (initializer_function_) free(initializer_function_); + initializer_function_ = fl_strdup(f.unique_id(this, "image", fl_filename_name(filename()), 0)); if (is_animated_gif_) { // Write animated gif image data... @@ -370,7 +370,7 @@ void Image_Asset::write_file_error(fld::io::Code_Writer& f, const char *fmt) { void Image_Asset::write_initializer(fld::io::Code_Writer& f, const char *image_class, const char *format, ...) { va_list ap; va_start(ap, format); - f.write_c("static Fl_Image *%s() {\n", initializer_function_.c_str()); + f.write_c("static Fl_Image *%s() {\n", initializer_function_); if (is_animated_gif_) f.write_c("%sFl_GIF_Image::animate = true;\n", f.indent(1)); f.write_c("%sstatic Fl_Image *image = 0L;\n", f.indent(1)); @@ -402,11 +402,11 @@ void Image_Asset::write_code(fld::io::Code_Writer& f, int bind, const char *var, var, bind ? "bind_" : "", inactive ? "deimage" : "image", - initializer_function_.c_str()); + initializer_function_); if (is_animated_gif_) f.write_c("%s((Fl_Anim_GIF_Image*)(%s()))->canvas(%s, Fl_Anim_GIF_Image::DONT_RESIZE_CANVAS);\n", f.indent(), - initializer_function_.c_str(), + initializer_function_, var); } } @@ -424,7 +424,7 @@ void Image_Asset::write_code(fld::io::Code_Writer& f, int bind, const char *var, void Image_Asset::write_inline(fld::io::Code_Writer& f, int inactive) { (void)inactive; if (image_) { - f.write_c("%s()", initializer_function_.c_str()); + f.write_c("%s()", initializer_function_); } } @@ -492,13 +492,16 @@ Image_Asset* Image_Asset::find(const char *iname) { */ Image_Asset::Image_Asset(const char *iname) { - filename_ = iname; + is_animated_gif_ = 0; + filename_ = iname ? fl_strdup(iname) : 0; + refcount_ = 0; + initializer_function_ = 0; image_ = Fl_Shared_Image::get(iname); if (image_ && iname) { const char *ext = fl_filename_ext(iname); if (fl_ascii_strcasecmp(ext, ".gif")==0) { int fc = Fl_Anim_GIF_Image::frame_count(iname); - if (fc > 0) is_animated_gif_ = true; + if (fc > 0) is_animated_gif_ = 1; } } } @@ -538,8 +541,10 @@ void Image_Asset::dec_ref() { when the object is destroyed. */ Image_Asset::~Image_Asset() { - image_asset_map.erase(filename_.c_str()); + image_asset_map.erase(filename_); if (image_) image_->release(); + if (filename_) free(filename_); + if (initializer_function_) free(initializer_function_); } //////////////////////////////////////////////////////////////// diff --git a/fluid/app/Image_Asset.h b/fluid/app/Image_Asset.h index fcc8fb31c..1d6909a70 100644 --- a/fluid/app/Image_Asset.h +++ b/fluid/app/Image_Asset.h @@ -29,11 +29,11 @@ class Image_Asset { private: // member variables - bool is_animated_gif_ = false; ///< It's an animated gif. - std::string filename_ { }; ///< Relative path to the image file - int refcount_ = 0; ///< Reference count - Fl_Shared_Image *image_ = 0; ///< The actual image as managed by FLTK - std::string initializer_function_ { }; ///< The name of the initializer function + int is_animated_gif_; ///< It's an animated gif. + char *filename_; ///< Relative path to the image file + int refcount_; ///< Reference count + Fl_Shared_Image *image_; ///< The actual image as managed by FLTK + char *initializer_function_; ///< The name of the initializer function private: // methods Image_Asset(const char *name); // no public constructor @@ -52,7 +52,7 @@ public: // methods void write_code(fld::io::Code_Writer& f, int bind, const char *var, int inactive = 0); void write_inline(fld::io::Code_Writer& f, int inactive = 0); void write_file_error(fld::io::Code_Writer& f, const char *fmt); - const char *filename() const { return filename_.c_str(); } + const char *filename() const { return filename_ ? filename_ : ""; } }; // pop up file chooser and return a legal image selected by user, diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index 51cdb9817..2e30853d4 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -38,6 +38,7 @@ #define MAX(a,b) ((a)>=(b) ? (a) : (b)) #endif + using namespace fld; using namespace fld::app; @@ -663,9 +664,9 @@ void Layout_List::update_menu_labels() { /** Load all user layouts from the FLUID user preferences. */ -int Layout_List::load(const std::string &filename) { +int Layout_List::load(const char *filename) { remove_all(FLD_TOOL_STORE_FILE); - Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", 0, Fl_Preferences::C_LOCALE); + Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, Fl_Preferences::C_LOCALE); read(prefs, FLD_TOOL_STORE_FILE); return 0; } @@ -673,9 +674,9 @@ int Layout_List::load(const std::string &filename) { /** Save all user layouts to the FLUID user preferences. */ -int Layout_List::save(const std::string &filename) { +int Layout_List::save(const char *filename) { assert(this); - Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", 0, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR)); + Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR)); prefs.clear(); write(prefs, FLD_TOOL_STORE_FILE); return 0; @@ -721,7 +722,7 @@ void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { } } if (cs_ptr) { - current_suite(std::string(cs_ptr)); + current_suite(cs_ptr); ::free(cs_ptr); } current_preset(cp); @@ -758,7 +759,7 @@ void Layout_List::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { - std::string cs; + const char *cs = 0; int cp = 0; for (;;) { key = in->read_word(); @@ -803,11 +804,12 @@ void Layout_List::current_suite(int ix) { \param[in] arg_name name of the selected suite \return if no name is given or the name is not found, keep the current suite selected */ -void Layout_List::current_suite(std::string arg_name) { - if (arg_name.empty()) return; - for (int i = 0; i < list_size_; ++i) { +void Layout_List::current_suite(const char *arg_name) { + if (!arg_name || !arg_name[0]) return; + int i; + for (i = 0; i < list_size_; ++i) { Layout_Suite &suite = list_[i]; - if (suite.name_ && (strcmp(suite.name_, arg_name.c_str()) == 0)) { + if (suite.name_ && (strcmp(suite.name_, arg_name) == 0)) { current_suite(i); break; } diff --git a/fluid/app/Snap_Action.h b/fluid/app/Snap_Action.h index 6bbe07bb8..7c1e3fabc 100644 --- a/fluid/app/Snap_Action.h +++ b/fluid/app/Snap_Action.h @@ -18,7 +18,6 @@ #define _FLUID_FD_SNAP_ACTION_H #include "../fld_tool_store.h" -#include <string> class Window_Node; class Widget_Node; @@ -131,7 +130,6 @@ public: bool list_is_static_; int current_suite_; int current_preset_; - std::string filename_; public: Layout_List(); ~Layout_List(); @@ -139,7 +137,7 @@ public: void update_menu_labels(); int current_suite() const { return current_suite_; } void current_suite(int ix); - void current_suite(std::string); + void current_suite(const char *); int current_preset() const { return current_preset_; } void current_preset(int ix); Layout_Suite &operator[](int ix) { return list_[ix]; } @@ -147,8 +145,8 @@ public: void rename(const char *name); void capacity(int); - int load(const std::string &filename); - int save(const std::string &filename); + int load(const char *filename); + int save(const char *filename); void write(Fl_Preferences &prefs, fld::Tool_Store storage); void read(Fl_Preferences &prefs, fld::Tool_Store storage); void write(fld::io::Project_Writer*); diff --git a/fluid/io/Code_Writer.cxx b/fluid/io/Code_Writer.cxx index 357db80dd..9460a6ac0 100644 --- a/fluid/io/Code_Writer.cxx +++ b/fluid/io/Code_Writer.cxx @@ -782,7 +782,7 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { } } } - std::string loc_include, loc_conditional; + const char *loc_include, *loc_conditional; if (proj_.i18n.type==FLD_I18N_TYPE_GNU) { loc_include = proj_.i18n.gnu_include; loc_conditional = proj_.i18n.gnu_conditional; @@ -790,19 +790,19 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { loc_include = proj_.i18n.posix_include; loc_conditional = proj_.i18n.posix_conditional; } - if ((proj_.i18n.type != FLD_I18N_TYPE_NONE) && !loc_include.empty()) { - int conditional = !loc_conditional.empty(); + if ((proj_.i18n.type != FLD_I18N_TYPE_NONE) && loc_include && loc_include[0]) { + int conditional = (loc_conditional && loc_conditional[0]); if (conditional) { - write_c("#ifdef %s\n", loc_conditional.c_str()); + write_c("#ifdef %s\n", loc_conditional); indentation++; } if (loc_include[0] != '<' && loc_include[0] != '\"') - write_c("#%sinclude \"%s\"\n", indent(), loc_include.c_str()); + write_c("#%sinclude \"%s\"\n", indent(), loc_include); else - write_c("#%sinclude %s\n", indent(), loc_include.c_str()); + write_c("#%sinclude %s\n", indent(), loc_include); if (proj_.i18n.type == FLD_I18N_TYPE_POSIX) { - if (!proj_.i18n.posix_file.empty()) { - write_c("extern nl_catd %s;\n", proj_.i18n.posix_file.c_str()); + if (proj_.i18n.posix_file && proj_.i18n.posix_file[0]) { + write_c("extern nl_catd %s;\n", proj_.i18n.posix_file); } else { write_c("// Initialize I18N stuff now for menus...\n"); write_c("#%sinclude <locale.h>\n", indent()); @@ -817,9 +817,9 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { if (conditional) { write_c("#else\n"); if (proj_.i18n.type == FLD_I18N_TYPE_GNU) { - if (!proj_.i18n.gnu_function.empty()) { - write_c("#%sifndef %s\n", indent(), proj_.i18n.gnu_function.c_str()); - write_c("#%sdefine %s(text) text\n", indent_plus(1), proj_.i18n.gnu_function.c_str()); + if (proj_.i18n.gnu_function && proj_.i18n.gnu_function[0]) { + write_c("#%sifndef %s\n", indent(), proj_.i18n.gnu_function); + write_c("#%sdefine %s(text) text\n", indent_plus(1), proj_.i18n.gnu_function); write_c("#%sendif\n", indent()); } } @@ -831,9 +831,9 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { indentation--; write_c("#endif\n"); } - if (proj_.i18n.type == FLD_I18N_TYPE_GNU && proj_.i18n.gnu_static_function[0]) { - write_c("#ifndef %s\n", proj_.i18n.gnu_static_function.c_str()); - write_c("#%sdefine %s(text) text\n", indent_plus(1), proj_.i18n.gnu_static_function.c_str()); + if (proj_.i18n.type == FLD_I18N_TYPE_GNU && proj_.i18n.gnu_static_function && proj_.i18n.gnu_static_function[0]) { + write_c("#ifndef %s\n", proj_.i18n.gnu_static_function); + write_c("#%sdefine %s(text) text\n", indent_plus(1), proj_.i18n.gnu_static_function); write_c("#endif\n"); } } diff --git a/fluid/io/String_Writer.cxx b/fluid/io/String_Writer.cxx index cf59935aa..3066aa97b 100644 --- a/fluid/io/String_Writer.cxx +++ b/fluid/io/String_Writer.cxx @@ -115,7 +115,7 @@ int fld::io::write_strings(Project &proj, const std::string &filename) { case FLD_I18N_TYPE_POSIX : /* POSIX catgets, put a .msg file out */ fprintf(fp, "$ generated by Fast Light User Interface Designer (fluid) version %.4f\n", FL_VERSION); - fprintf(fp, "$set %s\n", proj.i18n.posix_set.c_str()); + fprintf(fp, "$set %s\n", proj.i18n.posix_set); fputs("$quote \"\n", fp); for (i = 1, p = proj.tree.first; p; p = p->next) { diff --git a/fluid/nodes/Menu_Node.cxx b/fluid/nodes/Menu_Node.cxx index b669c18e0..8075c9c60 100644 --- a/fluid/nodes/Menu_Node.cxx +++ b/fluid/nodes/Menu_Node.cxx @@ -489,7 +489,7 @@ void Menu_Item_Node::write_item(fld::io::Code_Writer& f) { switch (Fluid.proj.i18n.type) { case FLD_I18N_TYPE_GNU: // we will call i18n when the menu is instantiated for the first time - f.write_c("%s(", Fluid.proj.i18n.gnu_static_function.c_str()); + f.write_c("%s(", Fluid.proj.i18n.gnu_static_function); f.write_cstring(label()); f.write_c(")"); break; @@ -605,12 +605,12 @@ void Menu_Item_Node::write_code1(fld::io::Code_Writer& f) { f.write_c("%sml->labelb = o->label();\n", f.indent()); } else if (Fluid.proj.i18n.type==FLD_I18N_TYPE_GNU) { f.write_c("%sml->labelb = %s(o->label());\n", - f.indent(), Fluid.proj.i18n.gnu_function.c_str()); + f.indent(), Fluid.proj.i18n.gnu_function); } else if (Fluid.proj.i18n.type==FLD_I18N_TYPE_POSIX) { f.write_c("%sml->labelb = catgets(%s,%s,i+%d,o->label());\n", f.indent(), - Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(), - Fluid.proj.i18n.posix_set.c_str(), msgnum()); + (Fluid.proj.i18n.posix_file && Fluid.proj.i18n.posix_file[0]) ? Fluid.proj.i18n.posix_file : "_catalog", + Fluid.proj.i18n.posix_set, msgnum()); } f.write_c("%sml->typea = FL_IMAGE_LABEL;\n", f.indent()); f.write_c("%sml->typeb = FL_NORMAL_LABEL;\n", f.indent()); @@ -628,12 +628,12 @@ void Menu_Item_Node::write_code1(fld::io::Code_Writer& f) { start_menu_initialiser(f, menuItemInitialized, mname, i); if (Fluid.proj.i18n.type==FLD_I18N_TYPE_GNU) { f.write_c("%so->label(%s(o->label()));\n", - f.indent(), Fluid.proj.i18n.gnu_function.c_str()); + f.indent(), Fluid.proj.i18n.gnu_function); } else if (Fluid.proj.i18n.type==FLD_I18N_TYPE_POSIX) { f.write_c("%so->label(catgets(%s,%s,i+%d,o->label()));\n", f.indent(), - Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(), - Fluid.proj.i18n.posix_set.c_str(), msgnum()); + (Fluid.proj.i18n.posix_file && Fluid.proj.i18n.posix_file[0]) ? Fluid.proj.i18n.posix_file : "_catalog", + Fluid.proj.i18n.posix_set, msgnum()); } } } diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx index 6f5a6a0fb..d5d256dbe 100644 --- a/fluid/nodes/Widget_Node.cxx +++ b/fluid/nodes/Widget_Node.cxx @@ -1747,14 +1747,14 @@ void Widget_Node::write_code1(fld::io::Code_Writer& f) { f.write_cstring(label()); break; case FLD_I18N_TYPE_GNU : /* GNU gettext */ - f.write_c("%s(", Fluid.proj.i18n.gnu_function.c_str()); + f.write_c("%s(", Fluid.proj.i18n.gnu_function); f.write_cstring(label()); f.write_c(")"); break; case FLD_I18N_TYPE_POSIX : /* POSIX catgets */ f.write_c("catgets(%s,%s,%d,", - Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(), - Fluid.proj.i18n.posix_set.c_str(), msgnum()); + (Fluid.proj.i18n.posix_file == 0 || Fluid.proj.i18n.posix_file[0] == 0) ? "_catalog" : Fluid.proj.i18n.posix_file, + Fluid.proj.i18n.posix_set, msgnum()); f.write_cstring(label()); f.write_c(")"); break; @@ -1821,14 +1821,14 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { f.write_cstring(tooltip()); break; case FLD_I18N_TYPE_GNU : /* GNU gettext */ - f.write_c("%s(", Fluid.proj.i18n.gnu_function.c_str()); + f.write_c("%s(", Fluid.proj.i18n.gnu_function); f.write_cstring(tooltip()); f.write_c(")"); break; case FLD_I18N_TYPE_POSIX : /* POSIX catgets */ f.write_c("catgets(%s,%s,%d,", - Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(), - Fluid.proj.i18n.posix_set.c_str(), + (Fluid.proj.i18n.posix_file == 0 || Fluid.proj.i18n.posix_file[0] == 0) ? "_catalog" : Fluid.proj.i18n.posix_file, + Fluid.proj.i18n.posix_set, msgnum() + 1); f.write_cstring(tooltip()); f.write_c(")"); diff --git a/fluid/panels/settings_panel.cxx b/fluid/panels/settings_panel.cxx index 3b32fc665..04aa8e900 100644 --- a/fluid/panels/settings_panel.cxx +++ b/fluid/panels/settings_panel.cxx @@ -611,20 +611,14 @@ static void cb_w_layout_menu_load(Fl_Menu_*, void*) { static void cb_w_layout_menu_save(Fl_Menu_*, void*) { // Give the user a file chooser with a suggested name - char path[FL_PATH_MAX]; Fl_Native_File_Chooser fnfc; fnfc.title("Save Layout Settings:"); fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT); fnfc.filter("FLUID Layouts\t*.fll\n"); - const char *filename = Fluid.layout_list->filename_.c_str(); - fl_filename_path(path, FL_PATH_MAX, filename); - fnfc.directory(path); - fnfc.preset_file(fl_filename_name(filename)); if (fnfc.show() != 0) return; const char *new_filename = fnfc.filename(); if (!new_filename) return; - Fluid.layout_list->filename_ = new_filename; Fluid.layout_list->save(new_filename); } @@ -2153,10 +2147,10 @@ Fl_Input *i18n_gnu_include_input=(Fl_Input *)0; static void cb_i18n_gnu_include_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_include.c_str()); + o->value(Fluid.proj.i18n.gnu_include); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_include = o->value(); + Fluid.proj.i18n.set_gnu_include(o->value()); Fluid.proj.set_modflag(1); } } @@ -2165,10 +2159,10 @@ Fl_Input *i18n_gnu_conditional_input=(Fl_Input *)0; static void cb_i18n_gnu_conditional_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_conditional.c_str()); + o->value(Fluid.proj.i18n.gnu_conditional); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_conditional = o->value(); + Fluid.proj.i18n.set_gnu_conditional(o->value()); Fluid.proj.set_modflag(1); } } @@ -2177,10 +2171,10 @@ Fl_Input *i18n_gnu_function_input=(Fl_Input *)0; static void cb_i18n_gnu_function_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_function.c_str()); + o->value(Fluid.proj.i18n.gnu_function); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_function = o->value(); + Fluid.proj.i18n.set_gnu_function(o->value()); Fluid.proj.set_modflag(1); } } @@ -2189,10 +2183,10 @@ Fl_Input *i18n_gnu_static_function_input=(Fl_Input *)0; static void cb_i18n_gnu_static_function_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_static_function.c_str()); + o->value(Fluid.proj.i18n.gnu_static_function); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_static_function = o->value(); + Fluid.proj.i18n.set_gnu_static_function(o->value()); Fluid.proj.set_modflag(1); } } @@ -2207,10 +2201,10 @@ Fl_Input *i18n_pos_include_input=(Fl_Input *)0; static void cb_i18n_pos_include_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_include.c_str()); + o->value(Fluid.proj.i18n.posix_include); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_include = o->value(); + Fluid.proj.i18n.set_posix_include(o->value()); Fluid.proj.set_modflag(1); } } @@ -2219,10 +2213,10 @@ Fl_Input *i18n_pos_conditional_input=(Fl_Input *)0; static void cb_i18n_pos_conditional_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_conditional.c_str()); + o->value(Fluid.proj.i18n.posix_conditional); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_conditional = o->value(); + Fluid.proj.i18n.set_posix_conditional(o->value()); Fluid.proj.set_modflag(1); } } @@ -2231,10 +2225,10 @@ Fl_Input *i18n_pos_file_input=(Fl_Input *)0; static void cb_i18n_pos_file_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_file.c_str()); + o->value(Fluid.proj.i18n.posix_file); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_file = o->value(); + Fluid.proj.i18n.set_posix_file(o->value()); Fluid.proj.set_modflag(1); } } @@ -2247,10 +2241,10 @@ Fl_Int_Input *i18n_pos_set_input=(Fl_Int_Input *)0; static void cb_i18n_pos_set_input(Fl_Int_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_set.c_str()); + o->value(Fluid.proj.i18n.posix_set); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_set = o->value(); + Fluid.proj.i18n.set_posix_set(o->value()); Fluid.proj.set_modflag(1); } } diff --git a/fluid/panels/settings_panel.fl b/fluid/panels/settings_panel.fl index abc0ade2f..86513bafd 100644 --- a/fluid/panels/settings_panel.fl +++ b/fluid/panels/settings_panel.fl @@ -1586,10 +1586,10 @@ if (v == LOAD) { Fl_Input i18n_gnu_include_input { label {\#include:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_include.c_str()); + o->value(Fluid.proj.i18n.gnu_include); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_include = o->value(); + Fluid.proj.i18n.set_gnu_include(o->value()); Fluid.proj.set_modflag(1); }} tooltip {The include file for internationalization.} xywh {110 103 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1597,10 +1597,10 @@ if (v == LOAD) { Fl_Input i18n_gnu_conditional_input { label {Conditional:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_conditional.c_str()); + o->value(Fluid.proj.i18n.gnu_conditional); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_conditional = o->value(); + Fluid.proj.i18n.set_gnu_conditional(o->value()); Fluid.proj.set_modflag(1); }} tooltip {only include the header file if this preprocessor macro is defined, for example FLTK_GETTEXT_FOUND} xywh {110 128 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1608,10 +1608,10 @@ if (v == LOAD) { Fl_Input i18n_gnu_function_input { label {Function:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_function.c_str()); + o->value(Fluid.proj.i18n.gnu_function); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_function = o->value(); + Fluid.proj.i18n.set_gnu_function(o->value()); Fluid.proj.set_modflag(1); }} tooltip {The function to call to translate labels and tooltips, usually "gettext" or "_"} xywh {110 153 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1619,10 +1619,10 @@ if (v == LOAD) { Fl_Input i18n_gnu_static_function_input { label {Static Function:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.gnu_static_function.c_str()); + o->value(Fluid.proj.i18n.gnu_static_function); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.gnu_static_function = o->value(); + Fluid.proj.i18n.set_gnu_static_function(o->value()); Fluid.proj.set_modflag(1); }} tooltip {function to call to translate static text, The function to call to internationalize labels and tooltips, usually "gettext_noop" or "N_"} xywh {110 178 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1635,10 +1635,10 @@ if (v == LOAD) { Fl_Input i18n_pos_include_input { label {\#include:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_include.c_str()); + o->value(Fluid.proj.i18n.posix_include); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_include = o->value(); + Fluid.proj.i18n.set_posix_include(o->value()); Fluid.proj.set_modflag(1); }} tooltip {The include file for internationalization.} xywh {110 103 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1646,10 +1646,10 @@ if (v == LOAD) { Fl_Input i18n_pos_conditional_input { label {Conditional:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_conditional.c_str()); + o->value(Fluid.proj.i18n.posix_conditional); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_conditional = o->value(); + Fluid.proj.i18n.set_posix_conditional(o->value()); Fluid.proj.set_modflag(1); }} tooltip {only include the header file if this preprocessor macro is defined, for example FLTK_GETTEXT_FOUND} xywh {110 128 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1657,10 +1657,10 @@ if (v == LOAD) { Fl_Input i18n_pos_file_input { label {Catalog:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_file.c_str()); + o->value(Fluid.proj.i18n.posix_file); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_file = o->value(); + Fluid.proj.i18n.set_posix_file(o->value()); Fluid.proj.set_modflag(1); }} tooltip {The name of the message catalog.} xywh {110 153 230 20} box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 @@ -1672,10 +1672,10 @@ if (v == LOAD) { Fl_Input i18n_pos_set_input { label {Set:} callback {if (v == LOAD) { - o->value(Fluid.proj.i18n.posix_set.c_str()); + o->value(Fluid.proj.i18n.posix_set); } else { Fluid.proj.undo.checkpoint(); - Fluid.proj.i18n.posix_set = o->value(); + Fluid.proj.i18n.set_posix_set(o->value()); Fluid.proj.set_modflag(1); }} tooltip {The message set number.} xywh {110 178 80 20} type Int box THIN_DOWN_BOX labelsize 12 textfont 4 textsize 12 diff --git a/fluid/proj/i18n.cxx b/fluid/proj/i18n.cxx index dc4380bd4..71ba892a1 100644 --- a/fluid/proj/i18n.cxx +++ b/fluid/proj/i18n.cxx @@ -19,74 +19,136 @@ #include "io/Project_Reader.h" #include "io/Project_Writer.h" -using namespace fld; +static char *dup_str(const char *s) { + return s ? fl_strdup(s) : 0; +} + +fld::proj::I18n::I18n(Project &p) : project_(p) { + type = FLD_I18N_TYPE_NONE; + gnu_include = fl_strdup("<libintl.h>"); + gnu_conditional = 0; + gnu_function = fl_strdup("gettext"); + gnu_static_function = fl_strdup("gettext_noop"); + posix_include = fl_strdup("<nl_types.h>"); + posix_conditional = 0; + posix_file = 0; + posix_set = fl_strdup("1"); +} + +fld::proj::I18n::~I18n() { + if (gnu_include) free(gnu_include); + if (gnu_conditional) free(gnu_conditional); + if (gnu_function) free(gnu_function); + if (gnu_static_function) free(gnu_static_function); + if (posix_include) free(posix_include); + if (posix_conditional) free(posix_conditional); + if (posix_file) free(posix_file); + if (posix_set) free(posix_set); +} + +void fld::proj::I18n::set_gnu_include(const char *s) { + if (gnu_include) free(gnu_include); + gnu_include = dup_str(s); +} + +void fld::proj::I18n::set_gnu_conditional(const char *s) { + if (gnu_conditional) free(gnu_conditional); + gnu_conditional = dup_str(s); +} -using namespace fld::proj; +void fld::proj::I18n::set_gnu_function(const char *s) { + if (gnu_function) free(gnu_function); + gnu_function = dup_str(s); +} + +void fld::proj::I18n::set_gnu_static_function(const char *s) { + if (gnu_static_function) free(gnu_static_function); + gnu_static_function = dup_str(s); +} + +void fld::proj::I18n::set_posix_include(const char *s) { + if (posix_include) free(posix_include); + posix_include = dup_str(s); +} +void fld::proj::I18n::set_posix_conditional(const char *s) { + if (posix_conditional) free(posix_conditional); + posix_conditional = dup_str(s); +} + +void fld::proj::I18n::set_posix_file(const char *s) { + if (posix_file) free(posix_file); + posix_file = dup_str(s); +} + +void fld::proj::I18n::set_posix_set(const char *s) { + if (posix_set) free(posix_set); + posix_set = dup_str(s); +} /** Reset all project setting to create a new empty project. */ -void I18n::reset() { +void fld::proj::I18n::reset() { type = FLD_I18N_TYPE_NONE; - gnu_include = "<libintl.h>"; - gnu_conditional = ""; - gnu_function = "gettext"; - gnu_static_function = "gettext_noop"; + set_gnu_include("<libintl.h>"); + set_gnu_conditional(0); + set_gnu_function("gettext"); + set_gnu_static_function("gettext_noop"); - posix_include = "<nl_types.h>"; - posix_conditional = ""; - posix_file = ""; - posix_set = "1"; + set_posix_include("<nl_types.h>"); + set_posix_conditional(0); + set_posix_file(0); + set_posix_set("1"); } -void I18n::read(io::Project_Reader &f, const char *key) { +void fld::proj::I18n::read(io::Project_Reader &f, const char *key) { if (!strcmp(key, "i18n_type")) { - type = static_cast<fld::I18n_Type>(atoi(f.read_word())); + type = (fld::I18n_Type)(atoi(f.read_word())); } else if (!strcmp(key, "i18n_gnu_function")) { - gnu_function = f.read_word(); + set_gnu_function(f.read_word()); } else if (!strcmp(key, "i18n_gnu_static_function")) { - gnu_static_function = f.read_word(); + set_gnu_static_function(f.read_word()); } else if (!strcmp(key, "i18n_pos_file")) { - posix_file = f.read_word(); + set_posix_file(f.read_word()); } else if (!strcmp(key, "i18n_pos_set")) { - posix_set = f.read_word(); + set_posix_set(f.read_word()); } else if (!strcmp(key, "i18n_include")) { if (type == FLD_I18N_TYPE_GNU) { - gnu_include = f.read_word(); + set_gnu_include(f.read_word()); } else if (type == FLD_I18N_TYPE_POSIX) { - posix_include = f.read_word(); + set_posix_include(f.read_word()); } } else if (!strcmp(key, "i18n_conditional")) { if (type == FLD_I18N_TYPE_GNU) { - gnu_conditional = f.read_word(); + set_gnu_conditional(f.read_word()); } else if (type == FLD_I18N_TYPE_POSIX) { - posix_conditional = f.read_word(); + set_posix_conditional(f.read_word()); } } } -void I18n::write(io::Project_Writer &f) const { +void fld::proj::I18n::write(io::Project_Writer &f) const { if ((type != FLD_I18N_TYPE_NONE)) { - f.write_string("\ni18n_type %d", static_cast<int>(type)); + f.write_string("\ni18n_type %d", (int)(type)); switch (type) { case FLD_I18N_TYPE_NONE: break; case FLD_I18N_TYPE_GNU : /* GNU gettext */ - f.write_string("\ni18n_include"); f.write_word(gnu_include); - f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional); - f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function); - f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function); + f.write_string("\ni18n_include"); f.write_word(gnu_include ? gnu_include : ""); + f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional ? gnu_conditional : ""); + f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function ? gnu_function : ""); + f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function ? gnu_static_function : ""); break; case FLD_I18N_TYPE_POSIX : /* POSIX catgets */ - f.write_string("\ni18n_include"); f.write_word(posix_include); - f.write_string("\ni18n_conditional"); f.write_word(posix_conditional); - if (!posix_file.empty()) { + f.write_string("\ni18n_include"); f.write_word(posix_include ? posix_include : ""); + f.write_string("\ni18n_conditional"); f.write_word(posix_conditional ? posix_conditional : ""); + if (posix_file && posix_file[0]) { f.write_string("\ni18n_pos_file"); f.write_word(posix_file); } - f.write_string("\ni18n_pos_set"); f.write_word(posix_set); + f.write_string("\ni18n_pos_set"); f.write_word(posix_set ? posix_set : ""); break; } } diff --git a/fluid/proj/i18n.h b/fluid/proj/i18n.h index 0d9119ca2..65ef72bf6 100644 --- a/fluid/proj/i18n.h +++ b/fluid/proj/i18n.h @@ -17,7 +17,9 @@ #ifndef FLUID_PROJ_I18N_H #define FLUID_PROJ_I18N_H -#include <string> +#include <FL/fl_string_functions.h> +#include <stdlib.h> +#include <string.h> namespace fld { @@ -54,35 +56,44 @@ public: Project &project_; /// One of the available internationalization types. - fld::I18n_Type type = FLD_I18N_TYPE_NONE; + fld::I18n_Type type; /// Include file for GNU i18n, writes an #include statement into the source /// file. This is usually `<libintl.h>` or `"gettext.h"` for GNU gettext. - std::string gnu_include = "<libintl.h>"; + char *gnu_include; // Optional name of a macro for conditional i18n compilation. - std::string gnu_conditional = ""; + char *gnu_conditional; /// For the gettext/intl.h options, this is the function that translates text /// at runtime. This is usually "gettext" or "_". - std::string gnu_function = "gettext"; + char *gnu_function; /// For the gettext/intl.h options, this is the function that marks the translation /// of text at initialisation time. This is usually "gettext_noop" or "N_". - std::string gnu_static_function = "gettext_noop"; + char *gnu_static_function; /// Include file for Posix i18n, write a #include statement into the source /// file. This is usually `<nl_types.h>` for Posix catgets. - std::string posix_include = "<nl_types.h>"; + char *posix_include; // Optional name of a macro for conditional i18n compilation. - std::string posix_conditional = ""; + char *posix_conditional; /// Name of the nl_catd database - std::string posix_file = ""; + char *posix_file; /// Message set ID for the catalog. - std::string posix_set = "1"; + char *posix_set; public: // Methods - I18n(Project &p) : project_(p) {}; - ~I18n() = default; + I18n(Project &p); + ~I18n(); void reset(); void read(io::Project_Reader &f, const char *key); void write(io::Project_Writer &f) const; + + void set_gnu_include(const char *s); + void set_gnu_conditional(const char *s); + void set_gnu_function(const char *s); + void set_gnu_static_function(const char *s); + void set_posix_include(const char *s); + void set_posix_conditional(const char *s); + void set_posix_file(const char *s); + void set_posix_set(const char *s); }; } // namespace proj @@ -91,4 +102,3 @@ public: // Methods #endif // FLUID_PROJ_I18N_H - diff --git a/fluid/tools/ExternalCodeEditor_UNIX.cxx b/fluid/tools/ExternalCodeEditor_UNIX.cxx index 60ed16814..1d1efc462 100644 --- a/fluid/tools/ExternalCodeEditor_UNIX.cxx +++ b/fluid/tools/ExternalCodeEditor_UNIX.cxx @@ -62,6 +62,7 @@ ExternalCodeEditor::ExternalCodeEditor() { filename_ = 0; file_mtime_ = 0; file_size_ = 0; + command_line_ = 0; alert_pipe_[0] = alert_pipe_[1] = -1; alert_pipe_open_ = false; } @@ -76,6 +77,7 @@ ExternalCodeEditor::~ExternalCodeEditor() { (void*)this, (long)pid_); close_editor(); // close editor, delete tmp file set_filename(0); // free()s filename + if (command_line_) free(command_line_); if (alert_pipe_open_) { Fl::remove_fd(alert_pipe_[0]); @@ -389,7 +391,8 @@ int ExternalCodeEditor::start_editor(const char *editor_cmd, editor_cmd, filename); char cmd[1024]; snprintf(cmd, sizeof(cmd), "%s %s", editor_cmd, filename); - command_line_ = editor_cmd; + if (command_line_) free(command_line_); + command_line_ = fl_strdup(editor_cmd); open_alert_pipe(); // Fork editor to background.. switch ( pid_ = fork() ) { @@ -564,7 +567,7 @@ void ExternalCodeEditor::alert_pipe_cb(FL_SOCKET s, void* d) { self->last_error_ = 0; if (::read(s, &self->last_error_, sizeof(int)) != sizeof(int)) return; - const char* cmd = self->command_line_.c_str(); + const char* cmd = self->command_line_; if (cmd && *cmd) { if (cmd[0] == '/') { // is this an absolute filename? fl_alert("Can't launch external editor '%s':\n%s\n\ncmd: \"%s\"", diff --git a/fluid/tools/ExternalCodeEditor_UNIX.h b/fluid/tools/ExternalCodeEditor_UNIX.h index dfcc1e785..0542a5e94 100644 --- a/fluid/tools/ExternalCodeEditor_UNIX.h +++ b/fluid/tools/ExternalCodeEditor_UNIX.h @@ -24,7 +24,7 @@ class ExternalCodeEditor { time_t file_mtime_; // last modify time of the file (used to determine if file changed) size_t file_size_; // last file size (used to determine if changed) const char *filename_; - std::string command_line_; + char *command_line_; int last_error_; int alert_pipe_[2]; bool alert_pipe_open_; diff --git a/lib/libfltk.a b/lib/libfltk.a Binary files differindex d8dd7cddb..0a20a7bf3 100644 --- a/lib/libfltk.a +++ b/lib/libfltk.a diff --git a/lib/libfltk_forms.a b/lib/libfltk_forms.a Binary files differindex 9862d482a..1aecb11d4 100644 --- a/lib/libfltk_forms.a +++ b/lib/libfltk_forms.a diff --git a/lib/libfltk_gl.a b/lib/libfltk_gl.a Binary files differindex c1982e5a8..b48c982c7 100644 --- a/lib/libfltk_gl.a +++ b/lib/libfltk_gl.a diff --git a/lib/libfltk_images.a b/lib/libfltk_images.a Binary files differindex 7292e1174..ff9396527 100644 --- a/lib/libfltk_images.a +++ b/lib/libfltk_images.a diff --git a/lib/libfltk_jpeg.a b/lib/libfltk_jpeg.a Binary files differindex a826800cd..f92ed5d7f 100644 --- a/lib/libfltk_jpeg.a +++ b/lib/libfltk_jpeg.a diff --git a/lib/libfltk_png.a b/lib/libfltk_png.a Binary files differindex 924b33d25..62407c30b 100644 --- a/lib/libfltk_png.a +++ b/lib/libfltk_png.a diff --git a/lib/libfltk_z.a b/lib/libfltk_z.a Binary files differindex c47a475a7..3612fbbe4 100644 --- a/lib/libfltk_z.a +++ b/lib/libfltk_z.a |
