diff --git a/Common/Colors.h b/Common/Colors.h index a98eac6b5d42e55cae25b7545dad4c6c968aadec..5400fa938e9c3496d5b4f5c7e6da86ac23c1ca3a 100644 --- a/Common/Colors.h +++ b/Common/Colors.h @@ -666,7 +666,7 @@ StringX4Int ColorString[] = { { "DarkMagenta" , 139, 0, 139, 255 } , { "DarkRed" , 139, 0, 0, 255 } , { "LightGreen" , 144, 238, 144, 255 } , - { NULL , 0 , 0, 0, 255 } + { 0 , 0 , 0, 0, 255 } } ; int Get_ColorForString(StringX4Int SX4I[], int alpha, const char *string, diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 8cece1f843f8f1042d6df1cf2e4f7aff4547b0b7..8d5fc9834da46fde6d257d9df80f24ba6eaae5f1 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -182,7 +182,7 @@ void Get_Options(int argc, char *argv[]) if(!strcmp(argv[i] + 1, "socket")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.solver.socket_name = argv[i++]; else Msg::Fatal("Missing string"); @@ -218,7 +218,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "part")) { i++; - if(argv[i] != NULL){ + if(argv[i]){ CTX.batch_after_mesh = 1; opt_mesh_partition_num(0, GMSH_SET, atoi(argv[i++])); } @@ -272,42 +272,42 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "string")) { i++; - if(argv[i] != NULL) + if(argv[i]) ParseString(argv[i++]); else Msg::Fatal("Missing string"); } else if(!strcmp(argv[i] + 1, "option")) { i++; - if(argv[i] != NULL) + if(argv[i]) ParseFile(argv[i++], true); else Msg::Fatal("Missing file name"); } else if(!strcmp(argv[i] + 1, "o")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.output_filename = argv[i++]; else Msg::Fatal("Missing file name"); } else if(!strcmp(argv[i] + 1, "bgm")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.bgm_filename = argv[i++]; else Msg::Fatal("Missing file name"); } else if(!strcmp(argv[i] + 1, "nw")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.num_windows = atoi(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "nt")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.num_tiles = atoi(argv[i++]); else Msg::Fatal("Missing number"); @@ -338,35 +338,35 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "tol")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.geom.tolerance = atof(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "scale")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.geom.scaling_factor = atof(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "meshscale")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.mesh.scaling_factor = atof(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "rand")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.mesh.rand_factor = atof(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "clscale")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.lc_factor = atof(argv[i++]); if(CTX.mesh.lc_factor <= 0.0) Msg::Fatal("Characteristic length factor must be > 0"); @@ -376,7 +376,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "clmin")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.lc_min = atof(argv[i++]); if(CTX.mesh.lc_min <= 0.0) Msg::Fatal("Minimum length size must be > 0"); @@ -386,7 +386,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "clmax")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.lc_max = atof(argv[i++]); if(CTX.mesh.lc_max <= 0.0) Msg::Fatal("Maximum length size must be > 0"); @@ -396,7 +396,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "edgelmin")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.tolerance_edge_length = atof(argv[i++]); if( CTX.mesh.tolerance_edge_length <= 0.0) Msg::Fatal("Tolerance for model edge length must be > 0 (here %g)", @@ -407,7 +407,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "epslc1d")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.lc_integration_precision = atof(argv[i++]); if(CTX.mesh.lc_integration_precision <= 0.0) Msg::Fatal("Integration accuracy must be > 0"); @@ -417,7 +417,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "swapangle")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { CTX.mesh.allow_swap_edge_angle = atof(argv[i++]); if(CTX.mesh.allow_swap_edge_angle <= 0.0) Msg::Fatal("Treshold angle for edge swap must be > 0"); @@ -431,21 +431,21 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "smooth")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.mesh.nb_smoothing = atoi(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "order") || !strcmp(argv[i] + 1, "degree")) { i++; - if(argv[i] != NULL) + if(argv[i]) opt_mesh_order(0, GMSH_SET, atof(argv[i++])); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "numsubedges")) { i++; - if(argv[i] != NULL) + if(argv[i]) opt_mesh_num_sub_edges(0, GMSH_SET, atof(argv[i++])); else Msg::Fatal("Missing number"); @@ -457,16 +457,16 @@ void Get_Options(int argc, char *argv[]) else if(!strcmp(argv[i] + 1, "statreport")) { i++; CTX.create_append_statreport = 1; - if(argv[i] != NULL) - strcpy(CTX.statreport, argv[i++]); + if(argv[i]) + CTX.statreport = argv[i++]; else Msg::Fatal("Missing argument"); } else if(!strcmp(argv[i] + 1, "append_statreport")) { i++; CTX.create_append_statreport = 2; - if(argv[i] != NULL) - strcpy(CTX.statreport, argv[i++]); + if(argv[i]) + CTX.statreport = argv[i++]; else Msg::Fatal("Missing argument"); } @@ -476,7 +476,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { if(!strcmp(argv[i], "msh1")){ CTX.mesh.format = FORMAT_MSH; CTX.mesh.msh_file_version = 1.0; @@ -522,7 +522,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "algo")) { i++; - if(argv[i] != NULL) { + if(argv[i]) { if(!strncmp(argv[i], "del3d", 5) || !strncmp(argv[i], "tetgen", 6)) CTX.mesh.algo2d = ALGO_3D_TETGEN_DELAUNAY; else if(!strncmp(argv[i], "netgen", 6)) @@ -576,7 +576,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "v")) { i++; - if(argv[i] != NULL) + if(argv[i]) Msg::SetVerbosity(atoi(argv[i++])); else Msg::Fatal("Missing number"); @@ -600,7 +600,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "link")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.post.link = atoi(argv[i++]); else Msg::Fatal("Missing number"); @@ -619,28 +619,28 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "fontsize")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.fontsize = atoi(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "deltafontsize")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.deltafontsize = atoi(argv[i++]); else Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "theme") || !strcmp(argv[i] + 1, "scheme")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.gui_theme = argv[i++]; else Msg::Fatal("Missing argument"); } else if(!strcmp(argv[i] + 1, "display")) { i++; - if(argv[i] != NULL) + if(argv[i]) CTX.display = argv[i++]; else Msg::Fatal("Missing argument"); diff --git a/Common/Context.h b/Common/Context.h index 9ab1a0ae9629970885590777db95763d10b3f0bc..add84c671ddacaaba2b82182b241a691c8cbcaa4 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -19,22 +19,22 @@ class Context_T { std::vector<std::string> files; // all the files on the command line std::string bgm_filename; // background mesh std::string output_filename; // output file specified with command line option '-o' - const char *default_filename; - const char *tmp_filename; - const char *session_filename; - const char *options_filename; - const char *error_filename; - char statreport[256]; // mesh stat output file + std::string default_filename; + std::string tmp_filename; + std::string session_filename; + std::string options_filename; + std::string error_filename; + std::string statreport; // mesh stat output file int create_append_statreport; // do nothing 0 create 1 append 2 int session_save, options_save; // save session/option file on exit int confirm_overwrite; // confirm overwrite when file->save as - const char *display; // forced display host:0.0 under X11 + std::string display; // forced display host:0.0 under X11 int terminal; // show we print to the terminal console? int num_windows, num_tiles; // number of graphical windows/tiles to create - const char *editor; // text editor command (with included '%s') - const char *web_browser; // web browser command (with included '%s') + std::string editor; // text editor command (with included '%s') + std::string web_browser; // web browser command (with included '%s') std::string home_dir; // the home directory - const char *gui_theme; // FLTK GUI theme + std::string gui_theme; // FLTK GUI theme int tooltips; // show tootips in GUI? int position[2]; // position of the menu window on the screen int gl_position[2]; // position of the graphic window on the screen @@ -76,13 +76,13 @@ class Context_T { int small_axes, small_axes_size, small_axes_pos[2]; // small axes int axes, axes_auto_position, axes_tics[3],axes_mikado; // large axes double axes_position[6]; - char axes_label[3][256], axes_format[3][256]; + std::string axes_label[3], axes_format[3]; int threads, threads_lock; // threads?, lock (should be a mutex...) int alpha; // enable alpha blending double zoom_factor; // mouse2 zoom coefficient int bg_gradient; // draw background gradient? int fontsize, deltafontsize; // fltk font size (and delta for palettes) - const char *gl_font; // font for opengl graphics + std::string gl_font; // font for opengl graphics int gl_font_enum; // font for opengl graphics (fltk enum value) int gl_fontsize; // font size for opengl graphics double point_size, line_width; // point/line widths @@ -182,7 +182,7 @@ class Context_T { // solver options struct{ int max_delay, plugins, listen ; - const char *socket_name ; + std::string socket_name ; }solver; // print options diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 983c1a746d55032cfdf9c3a772f577c362928719..0bb295aba5a9e7a27c57e424ae45b1699f2e5c46 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -82,15 +82,15 @@ StringXString GeneralOptions_String[] = { #endif "System command to launch a web browser" }, - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString GeometryOptions_String[] = { - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString MeshOptions_String[] = { - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString SolverOptions_String[] = { @@ -355,11 +355,11 @@ StringXString SolverOptions_String[] = { { F|O, "FifthButtonCommand4" , opt_solver_fifth_button_command4 , "" , "Command associated with the fifth button for solver 4" }, - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString PostProcessingOptions_String[] = { - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString ViewOptions_String[] = { @@ -412,11 +412,11 @@ StringXString ViewOptions_String[] = { { F|O, "Stipple9" , opt_view_stipple9 , "1*0xFFFF" , "Tenth stippling pattern" }, - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; StringXString PrintOptions_String[] = { - { 0, NULL , NULL , NULL , NULL } + { 0, 0 , 0 , "" , 0 } } ; // NUMBERS @@ -785,7 +785,7 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "ZoomFactor" , opt_general_zoom_factor , 4.0 , "Middle mouse button zoom acceleration factor" }, - { 0, NULL , NULL , 0. , NULL } + { 0, 0 , 0 , 0. , 0 } } ; StringXNumber GeometryOptions_Number[] = { @@ -896,7 +896,7 @@ StringXNumber GeometryOptions_Number[] = { { F|O, "VolumeNumbers" , opt_geometry_volumes_num , 0. , "Display volume numbers? (not implemented yet)" }, - { 0, NULL , NULL , 0. , NULL } + { 0, 0 , 0 , 0. , 0 } } ; StringXNumber MeshOptions_Number[] = { @@ -1133,7 +1133,7 @@ StringXNumber MeshOptions_Number[] = { { F|O, "ZoneDefinition" , opt_mesh_zone_definition , 0. , "Method for defining a zone (0=single zone, 1=by partition, 2=by physical)" }, - { 0, NULL , NULL , 0. , NULL } + { 0, 0 , 0 , 0. , 0 } } ; StringXNumber SolverOptions_Number[] = { @@ -1182,7 +1182,7 @@ StringXNumber SolverOptions_Number[] = { { F|O, "PopupMessages4" , opt_solver_popup_messages4 , 1. , "Automatically display messages produced by solver 4" }, - { 0, NULL , NULL , 0. , NULL } + { 0, 0 , 0 , 0. , 0 } } ; StringXNumber PostProcessingOptions_Number[] = { @@ -1212,7 +1212,7 @@ StringXNumber PostProcessingOptions_Number[] = { { F|O, "Smoothing" , opt_post_smooth , 0. , "Apply (non-reversible) smoothing to post-processing view when merged" }, - { 0, NULL , NULL , 0. } + { 0, 0 , 0 , 0. } } ; StringXNumber ViewOptions_Number[] = { @@ -1450,7 +1450,7 @@ StringXNumber ViewOptions_Number[] = { { F|O, "Width" , opt_view_size0 , 300. , "Width (in pixels) of the scale or 2D plot" }, - { 0, NULL , NULL , 0. , NULL } + { 0, 0 , 0 , 0. , 0 } } ; StringXNumber PrintOptions_Number[] = { @@ -1508,7 +1508,7 @@ StringXNumber PrintOptions_Number[] = { { F|O, "Text" , opt_print_text , 1. , "Print text strings?" }, - { 0, NULL , NULL , 0. } + { 0, 0 , 0 , 0. } } ; // COLORS @@ -1546,7 +1546,7 @@ StringXColor GeneralOptions_Color[] = { { F|O, "SpecularLight" , opt_general_color_specular_light, {255, 255, 255, 255}, {255, 255, 255, 255}, {255, 255, 255, 255}, "Specular light color" }, - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; StringXColor GeometryOptions_Color[] = { @@ -1583,7 +1583,7 @@ StringXColor GeometryOptions_Color[] = { { F|O, "Projection" , opt_geometry_color_projection , {0, 255, 0, 255}, {0, 255, 0, 255}, {0, 0, 0, 255}, "Projection surface color" }, - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; #define COLW {210, 210, 210, 255} @@ -1667,15 +1667,15 @@ StringXColor MeshOptions_Color[] = { { F|O, "Seventeen", opt_mesh_color_17, COL17, COL17, COLW, "Color 17 in color carousel" }, { F|O, "Eighteen" , opt_mesh_color_18, COL18, COL18, COLW, "Color 18 in color carousel" }, { F|O, "Nineteen" , opt_mesh_color_19, COL19, COL19, COLW, "Color 19 in color carousel" }, - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; StringXColor SolverOptions_Color[] = { - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; StringXColor PostProcessingOptions_Color[] = { - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; #define ELECOL {255, 255, 255, 255}, {0, 0, 0, 255}, {0, 0, 0, 255} @@ -1698,11 +1698,11 @@ StringXColor ViewOptions_Color[] = { { F|O, "Text2D" , opt_view_color_text2d , ELECOL, "2D text color" }, { F|O, "Text3D" , opt_view_color_text3d , ELECOL, "3D text color" }, { F|O, "Axes" , opt_view_color_axes , ELECOL, "Axes color" }, - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; StringXColor PrintOptions_Color[] = { - { 0, NULL , NULL , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , NULL } + { 0, 0 , 0 , {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} , 0 } } ; #undef S diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index eecd0c5b404e74b0566240e449560280b0a3056a..c1cd311d384c2eca2f0192e17fecd7ec5e04b76e 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -65,8 +65,7 @@ int GmshSetMessageHandler(GmshMessage *callback) int GmshSetOption(std::string category, std::string name, std::string value, int index) { - std::string dummy; - if(StringOption(GMSH_SET, category.c_str(), index, name.c_str(), value.c_str(), dummy)) + if(StringOption(GMSH_SET, category.c_str(), index, name.c_str(), value)) return 1; return 0; } diff --git a/Common/Options.cpp b/Common/Options.cpp index facb1518ef50547ca7f9d3059f771920e2aa163e..055b10685e45ea9b73a8a61e22e989aff59260e0 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -51,7 +51,7 @@ Context_T CTX; // General routines for string options bool StringOption(int action, const char *category, int num, - const char *name, const char *val, std::string &out) + const char *name, std::string &val) { StringXString *s = 0; if(!strcmp(category, "General")) @@ -80,7 +80,7 @@ bool StringOption(int action, const char *category, int num, return false; } - out = s[i].function(num, action, val); + val = s[i].function(num, action, val); return true; } @@ -97,7 +97,7 @@ static void Set_StringOptions_GUI(int num, StringXString s[]) { int i = 0; while(s[i].str) { - s[i].function(num, GMSH_GUI, 0); + s[i].function(num, GMSH_GUI, ""); i++; } } @@ -108,10 +108,10 @@ static void Print_StringOptions(int num, int level, int diff, int help, int i = 0; while(s[i].str) { if(s[i].level & level) { - if(!diff || strcmp(s[i].function(num, GMSH_GET, NULL), s[i].def)){ + if(!diff || s[i].function(num, GMSH_GET, "") != s[i].def){ char tmp[1024]; sprintf(tmp, "%s%s = \"%s\";%s%s", prefix, - s[i].str, s[i].function(num, GMSH_GET, NULL), + s[i].str, s[i].function(num, GMSH_GET, "").c_str(), help ? " // " : "", help ? s[i].help : ""); if(file) fprintf(file, "%s\n", tmp); @@ -152,19 +152,12 @@ static void Print_StringOptionsDoc(StringXString s[], const char *prefix, FILE * fprintf(file, "%s@*\n", s[i].help); // sanitize the string for texinfo - const char *ptr = s[i].function(0, GMSH_GET, NULL); - int len = strlen(ptr); - j = 0; - while(j < len){ - tmp[j] = *(ptr++); - if(j && tmp[j] == '\n' && tmp[j-1] == '\n') - tmp[j-1] = '.'; - j++; - if(j == 1023) break; + std::string val = s[i].function(0, GMSH_GET, ""); + for(unsigned int j = 1; j < val.size(); j++){ + if(val[j] == '\n' && val[j - 1] == '\n') + val[j - 1] = '.'; } - tmp[j] = '\0'; - - fprintf(file, "Default value: @code{\"%s\"}@*\n", tmp); + fprintf(file, "Default value: @code{\"%s\"}@*\n", val.c_str()); fprintf(file, "Saved in: @code{%s}\n\n", Get_OptionSaveLevel(s[i].level)); i++; } @@ -196,7 +189,7 @@ bool NumberOption(int action, const char *category, int num, } int i = 0; - while((s[i].str != NULL) && (strcmp(s[i].str, name))) i++; + while(s[i].str && strcmp(s[i].str, name)) i++; if(!s[i].str){ Msg::Error("Unknown number option '%s.%s'", category, name); return false; @@ -282,7 +275,7 @@ bool ColorOption(int action, const char *category, int num, } int i = 0; - while((s[i].str != NULL) && (strcmp(s[i].str, name))) i++; + while(s[i].str && strcmp(s[i].str, name)) i++; if(!s[i].str){ Msg::Error("Unknown color option '%s.%s'", category, name); return false; @@ -295,9 +288,9 @@ int Get_ColorForString(StringX4Int SX4I[], int alpha, const char *str, int *FlagError) { int i = 0; - while((SX4I[i].str != NULL) && (strcmp(SX4I[i].str, str))) + while(SX4I[i].str && strcmp(SX4I[i].str, str)) i++; - *FlagError = (SX4I[i].str == NULL) ? 1 : 0; + *FlagError = !SX4I[i].str ? 1 : 0; if(alpha > 0) return CTX.PACK_COLOR(SX4I[i].int1, SX4I[i].int2, SX4I[i].int3, alpha); else @@ -437,7 +430,7 @@ static const char *gmsh_getenv(const char *var) // Don't accept top dir or anything partially expanded like // c:\Documents and Settings\%USERPROFILE%, etc. if(!tmp || !strcmp(tmp, "/") || strstr(tmp, "%") || strstr(tmp, "$")) - return NULL; + return 0; else return tmp; #endif @@ -492,7 +485,7 @@ void Init_Options(int num) CTX.threads_lock = 0; // very primitive locking CTX.mesh.changed = 0; CTX.post.combine_time = 0; // try to combine_time views at startup - CTX.post.plugin_draw_function = NULL; + CTX.post.plugin_draw_function = 0; #if defined(HAVE_FLTK) CTX.gl_font_enum = FL_HELVETICA; #else @@ -642,7 +635,7 @@ void Print_Options(int num, int level, int diff, int help, const char *filename) } } else - file = NULL; + file = 0; if((level & GMSH_SESSIONRC) && file) { fprintf(file, "// Gmsh Session File\n"); @@ -860,7 +853,7 @@ void Print_OptionsDoc() for(int i = 0; i < m; i++) { StringXString *sxs = p->getOptionStr(i); fprintf(file, "@item %s\n", sxs->str); - fprintf(file, "Default value: @code{\"%s\"}\n", sxs->def); + fprintf(file, "Default value: @code{\"%s\"}\n", sxs->def.c_str()); } fprintf(file, "@end table\n"); } @@ -935,158 +928,158 @@ void Print_OptionsDoc() // String option routines -const char *opt_general_axes_label0(OPT_ARGS_STR) +std::string opt_general_axes_label0(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_label[0], val); + CTX.axes_label[0] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[6]->value(CTX.axes_label[0]); + GUI::instance()->options->general.input[6]->value(CTX.axes_label[0].c_str()); #endif return CTX.axes_label[0]; } -const char *opt_general_axes_label1(OPT_ARGS_STR) +std::string opt_general_axes_label1(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_label[1], val); + CTX.axes_label[1] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[7]->value(CTX.axes_label[1]); + GUI::instance()->options->general.input[7]->value(CTX.axes_label[1].c_str()); #endif return CTX.axes_label[1]; } -const char *opt_general_axes_label2(OPT_ARGS_STR) +std::string opt_general_axes_label2(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_label[2], val); + CTX.axes_label[2] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[8]->value(CTX.axes_label[2]); + GUI::instance()->options->general.input[8]->value(CTX.axes_label[2].c_str()); #endif return CTX.axes_label[2]; } -const char *opt_general_axes_format0(OPT_ARGS_STR) +std::string opt_general_axes_format0(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_format[0], val); + CTX.axes_format[0] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[3]->value(CTX.axes_format[0]); + GUI::instance()->options->general.input[3]->value(CTX.axes_format[0].c_str()); #endif return CTX.axes_format[0]; } -const char *opt_general_axes_format1(OPT_ARGS_STR) +std::string opt_general_axes_format1(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_format[1], val); + CTX.axes_format[1] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[4]->value(CTX.axes_format[1]); + GUI::instance()->options->general.input[4]->value(CTX.axes_format[1].c_str()); #endif return CTX.axes_format[1]; } -const char *opt_general_axes_format2(OPT_ARGS_STR) +std::string opt_general_axes_format2(OPT_ARGS_STR) { if(action & GMSH_SET) - strcpy(CTX.axes_format[2], val); + CTX.axes_format[2] = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[5]->value(CTX.axes_format[2]); + GUI::instance()->options->general.input[5]->value(CTX.axes_format[2].c_str()); #endif return CTX.axes_format[2]; } -const char *opt_general_display(OPT_ARGS_STR) +std::string opt_general_display(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.display = val; return CTX.display; } -const char *opt_general_filename(OPT_ARGS_STR) +std::string opt_general_filename(OPT_ARGS_STR) { - return GModel::current()->getFileName().c_str(); + return GModel::current()->getFileName(); } -const char *opt_general_default_filename(OPT_ARGS_STR) +std::string opt_general_default_filename(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.default_filename = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[0]->value(CTX.default_filename); + GUI::instance()->options->general.input[0]->value(CTX.default_filename.c_str()); #endif return CTX.default_filename; } -const char *opt_general_tmp_filename(OPT_ARGS_STR) +std::string opt_general_tmp_filename(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.tmp_filename = val; return CTX.tmp_filename; } -const char *opt_general_error_filename(OPT_ARGS_STR) +std::string opt_general_error_filename(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.error_filename = val; return CTX.error_filename; } -const char *opt_general_session_filename(OPT_ARGS_STR) +std::string opt_general_session_filename(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.session_filename = val; return CTX.session_filename; } -const char *opt_general_options_filename(OPT_ARGS_STR) +std::string opt_general_options_filename(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.options_filename = val; return CTX.options_filename; } -const char *opt_general_editor(OPT_ARGS_STR) +std::string opt_general_editor(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.editor = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[1]->value(CTX.editor); + GUI::instance()->options->general.input[1]->value(CTX.editor.c_str()); #endif return CTX.editor; } -const char *opt_general_web_browser(OPT_ARGS_STR) +std::string opt_general_web_browser(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.web_browser = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.input[2]->value(CTX.web_browser); + GUI::instance()->options->general.input[2]->value(CTX.web_browser.c_str()); #endif return CTX.web_browser; } -const char *opt_general_gui_theme(OPT_ARGS_STR) +std::string opt_general_gui_theme(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.gui_theme = val; return CTX.gui_theme; } -const char *opt_general_graphics_font(OPT_ARGS_STR) +std::string opt_general_graphics_font(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.gl_font = val; #if defined(HAVE_FLTK) - int index = GetFontIndex(CTX.gl_font); + int index = GetFontIndex(CTX.gl_font.c_str()); if(action & GMSH_SET){ CTX.gl_font = GetFontName(index); CTX.gl_font_enum = GetFontEnum(index); @@ -1098,94 +1091,94 @@ const char *opt_general_graphics_font(OPT_ARGS_STR) return CTX.gl_font; } -const char *opt_solver_socket_name(OPT_ARGS_STR) +std::string opt_solver_socket_name(OPT_ARGS_STR) { if(action & GMSH_SET) CTX.solver.socket_name = val; #if defined(HAVE_FLTK) if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->solver.input[0]->value(CTX.solver.socket_name); + GUI::instance()->options->solver.input[0]->value(CTX.solver.socket_name.c_str()); #endif return CTX.solver.socket_name; } -const char *opt_solver_name(OPT_ARGS_STR) +std::string opt_solver_name(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].name, val); + SINFO[num].name = val; if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->solver[num]->win->label(SINFO[num].name); + GUI::instance()->solver[num]->win->label(SINFO[num].name.c_str()); return SINFO[num].name; #else return "undefined"; #endif } -const char *opt_solver_name0(OPT_ARGS_STR) +std::string opt_solver_name0(OPT_ARGS_STR) { return opt_solver_name(0, action, val); } -const char *opt_solver_name1(OPT_ARGS_STR) +std::string opt_solver_name1(OPT_ARGS_STR) { return opt_solver_name(1, action, val); } -const char *opt_solver_name2(OPT_ARGS_STR) +std::string opt_solver_name2(OPT_ARGS_STR) { return opt_solver_name(2, action, val); } -const char *opt_solver_name3(OPT_ARGS_STR) +std::string opt_solver_name3(OPT_ARGS_STR) { return opt_solver_name(3, action, val); } -const char *opt_solver_name4(OPT_ARGS_STR) +std::string opt_solver_name4(OPT_ARGS_STR) { return opt_solver_name(4, action, val); } -const char *opt_solver_executable(OPT_ARGS_STR) +std::string opt_solver_executable(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].executable_name, val); + SINFO[num].executable_name = val; if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->solver[num]->input[2]->value(SINFO[num].executable_name); + GUI::instance()->solver[num]->input[2]->value(SINFO[num].executable_name.c_str()); return SINFO[num].executable_name; #else return "undefined"; #endif } -const char *opt_solver_executable0(OPT_ARGS_STR) +std::string opt_solver_executable0(OPT_ARGS_STR) { return opt_solver_executable(0, action, val); } -const char *opt_solver_executable1(OPT_ARGS_STR) +std::string opt_solver_executable1(OPT_ARGS_STR) { return opt_solver_executable(1, action, val); } -const char *opt_solver_executable2(OPT_ARGS_STR) +std::string opt_solver_executable2(OPT_ARGS_STR) { return opt_solver_executable(2, action, val); } -const char *opt_solver_executable3(OPT_ARGS_STR) +std::string opt_solver_executable3(OPT_ARGS_STR) { return opt_solver_executable(3, action, val); } -const char *opt_solver_executable4(OPT_ARGS_STR) +std::string opt_solver_executable4(OPT_ARGS_STR) { return opt_solver_executable(4, action, val); } -const char *opt_solver_help(OPT_ARGS_STR) +std::string opt_solver_help(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) @@ -1196,785 +1189,785 @@ const char *opt_solver_help(OPT_ARGS_STR) #endif } -const char *opt_solver_help0(OPT_ARGS_STR) +std::string opt_solver_help0(OPT_ARGS_STR) { return opt_solver_help(0, action, val); } -const char *opt_solver_help1(OPT_ARGS_STR) +std::string opt_solver_help1(OPT_ARGS_STR) { return opt_solver_help(1, action, val); } -const char *opt_solver_help2(OPT_ARGS_STR) +std::string opt_solver_help2(OPT_ARGS_STR) { return opt_solver_help(2, action, val); } -const char *opt_solver_help3(OPT_ARGS_STR) +std::string opt_solver_help3(OPT_ARGS_STR) { return opt_solver_help(3, action, val); } -const char *opt_solver_help4(OPT_ARGS_STR) +std::string opt_solver_help4(OPT_ARGS_STR) { return opt_solver_help(4, action, val); } -const char *opt_solver_extension(OPT_ARGS_STR) +std::string opt_solver_extension(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].extension, val); + SINFO[num].extension = val; return SINFO[num].extension; #else return "undefined"; #endif } -const char *opt_solver_extension0(OPT_ARGS_STR) +std::string opt_solver_extension0(OPT_ARGS_STR) { return opt_solver_extension(0, action, val); } -const char *opt_solver_extension1(OPT_ARGS_STR) +std::string opt_solver_extension1(OPT_ARGS_STR) { return opt_solver_extension(1, action, val); } -const char *opt_solver_extension2(OPT_ARGS_STR) +std::string opt_solver_extension2(OPT_ARGS_STR) { return opt_solver_extension(2, action, val); } -const char *opt_solver_extension3(OPT_ARGS_STR) +std::string opt_solver_extension3(OPT_ARGS_STR) { return opt_solver_extension(3, action, val); } -const char *opt_solver_extension4(OPT_ARGS_STR) +std::string opt_solver_extension4(OPT_ARGS_STR) { return opt_solver_extension(4, action, val); } -const char *opt_solver_mesh_name(OPT_ARGS_STR) +std::string opt_solver_mesh_name(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].mesh_name, val); + SINFO[num].mesh_name = val; return SINFO[num].mesh_name; #else return "undefined"; #endif } -const char *opt_solver_mesh_name0(OPT_ARGS_STR) +std::string opt_solver_mesh_name0(OPT_ARGS_STR) { return opt_solver_mesh_name(0, action, val); } -const char *opt_solver_mesh_name1(OPT_ARGS_STR) +std::string opt_solver_mesh_name1(OPT_ARGS_STR) { return opt_solver_mesh_name(1, action, val); } -const char *opt_solver_mesh_name2(OPT_ARGS_STR) +std::string opt_solver_mesh_name2(OPT_ARGS_STR) { return opt_solver_mesh_name(2, action, val); } -const char *opt_solver_mesh_name3(OPT_ARGS_STR) +std::string opt_solver_mesh_name3(OPT_ARGS_STR) { return opt_solver_mesh_name(3, action, val); } -const char *opt_solver_mesh_name4(OPT_ARGS_STR) +std::string opt_solver_mesh_name4(OPT_ARGS_STR) { return opt_solver_mesh_name(4, action, val); } -const char *opt_solver_mesh_command(OPT_ARGS_STR) +std::string opt_solver_mesh_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].mesh_command, val); + SINFO[num].mesh_command = val; if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->solver[num]->input[1]->value(SINFO[num].mesh_name); + GUI::instance()->solver[num]->input[1]->value(SINFO[num].mesh_name.c_str()); return SINFO[num].mesh_command; #else return "undefined"; #endif } -const char *opt_solver_mesh_command0(OPT_ARGS_STR) +std::string opt_solver_mesh_command0(OPT_ARGS_STR) { return opt_solver_mesh_command(0, action, val); } -const char *opt_solver_mesh_command1(OPT_ARGS_STR) +std::string opt_solver_mesh_command1(OPT_ARGS_STR) { return opt_solver_mesh_command(1, action, val); } -const char *opt_solver_mesh_command2(OPT_ARGS_STR) +std::string opt_solver_mesh_command2(OPT_ARGS_STR) { return opt_solver_mesh_command(2, action, val); } -const char *opt_solver_mesh_command3(OPT_ARGS_STR) +std::string opt_solver_mesh_command3(OPT_ARGS_STR) { return opt_solver_mesh_command(3, action, val); } -const char *opt_solver_mesh_command4(OPT_ARGS_STR) +std::string opt_solver_mesh_command4(OPT_ARGS_STR) { return opt_solver_mesh_command(4, action, val); } -const char *opt_solver_socket_command(OPT_ARGS_STR) +std::string opt_solver_socket_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].socket_command, val); + SINFO[num].socket_command = val; return SINFO[num].socket_command; #else return "undefined"; #endif } -const char *opt_solver_socket_command0(OPT_ARGS_STR) +std::string opt_solver_socket_command0(OPT_ARGS_STR) { return opt_solver_socket_command(0, action, val); } -const char *opt_solver_socket_command1(OPT_ARGS_STR) +std::string opt_solver_socket_command1(OPT_ARGS_STR) { return opt_solver_socket_command(1, action, val); } -const char *opt_solver_socket_command2(OPT_ARGS_STR) +std::string opt_solver_socket_command2(OPT_ARGS_STR) { return opt_solver_socket_command(2, action, val); } -const char *opt_solver_socket_command3(OPT_ARGS_STR) +std::string opt_solver_socket_command3(OPT_ARGS_STR) { return opt_solver_socket_command(3, action, val); } -const char *opt_solver_socket_command4(OPT_ARGS_STR) +std::string opt_solver_socket_command4(OPT_ARGS_STR) { return opt_solver_socket_command(4, action, val); } -const char *opt_solver_name_command(OPT_ARGS_STR) +std::string opt_solver_name_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].name_command, val); + SINFO[num].name_command = val; return SINFO[num].name_command; #else return "undefined"; #endif } -const char *opt_solver_name_command0(OPT_ARGS_STR) +std::string opt_solver_name_command0(OPT_ARGS_STR) { return opt_solver_name_command(0, action, val); } -const char *opt_solver_name_command1(OPT_ARGS_STR) +std::string opt_solver_name_command1(OPT_ARGS_STR) { return opt_solver_name_command(1, action, val); } -const char *opt_solver_name_command2(OPT_ARGS_STR) +std::string opt_solver_name_command2(OPT_ARGS_STR) { return opt_solver_name_command(2, action, val); } -const char *opt_solver_name_command3(OPT_ARGS_STR) +std::string opt_solver_name_command3(OPT_ARGS_STR) { return opt_solver_name_command(3, action, val); } -const char *opt_solver_name_command4(OPT_ARGS_STR) +std::string opt_solver_name_command4(OPT_ARGS_STR) { return opt_solver_name_command(4, action, val); } -const char *opt_solver_option_command(OPT_ARGS_STR) +std::string opt_solver_option_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_command, val); + SINFO[num].option_command = val; return SINFO[num].option_command; #else return "undefined"; #endif } -const char *opt_solver_option_command0(OPT_ARGS_STR) +std::string opt_solver_option_command0(OPT_ARGS_STR) { return opt_solver_option_command(0, action, val); } -const char *opt_solver_option_command1(OPT_ARGS_STR) +std::string opt_solver_option_command1(OPT_ARGS_STR) { return opt_solver_option_command(1, action, val); } -const char *opt_solver_option_command2(OPT_ARGS_STR) +std::string opt_solver_option_command2(OPT_ARGS_STR) { return opt_solver_option_command(2, action, val); } -const char *opt_solver_option_command3(OPT_ARGS_STR) +std::string opt_solver_option_command3(OPT_ARGS_STR) { return opt_solver_option_command(3, action, val); } -const char *opt_solver_option_command4(OPT_ARGS_STR) +std::string opt_solver_option_command4(OPT_ARGS_STR) { return opt_solver_option_command(4, action, val); } -const char *opt_solver_first_option(OPT_ARGS_STR) +std::string opt_solver_first_option(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_name[0], val); + SINFO[num].option_name[0] = val; return SINFO[num].option_name[0]; #else return "undefined"; #endif } -const char *opt_solver_first_option0(OPT_ARGS_STR) +std::string opt_solver_first_option0(OPT_ARGS_STR) { return opt_solver_first_option(0, action, val); } -const char *opt_solver_first_option1(OPT_ARGS_STR) +std::string opt_solver_first_option1(OPT_ARGS_STR) { return opt_solver_first_option(1, action, val); } -const char *opt_solver_first_option2(OPT_ARGS_STR) +std::string opt_solver_first_option2(OPT_ARGS_STR) { return opt_solver_first_option(2, action, val); } -const char *opt_solver_first_option3(OPT_ARGS_STR) +std::string opt_solver_first_option3(OPT_ARGS_STR) { return opt_solver_first_option(3, action, val); } -const char *opt_solver_first_option4(OPT_ARGS_STR) +std::string opt_solver_first_option4(OPT_ARGS_STR) { return opt_solver_first_option(4, action, val); } -const char *opt_solver_second_option(OPT_ARGS_STR) +std::string opt_solver_second_option(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_name[1], val); + SINFO[num].option_name[1] = val; return SINFO[num].option_name[1]; #else return "undefined"; #endif } -const char *opt_solver_second_option0(OPT_ARGS_STR) +std::string opt_solver_second_option0(OPT_ARGS_STR) { return opt_solver_second_option(0, action, val); } -const char *opt_solver_second_option1(OPT_ARGS_STR) +std::string opt_solver_second_option1(OPT_ARGS_STR) { return opt_solver_second_option(1, action, val); } -const char *opt_solver_second_option2(OPT_ARGS_STR) +std::string opt_solver_second_option2(OPT_ARGS_STR) { return opt_solver_second_option(2, action, val); } -const char *opt_solver_second_option3(OPT_ARGS_STR) +std::string opt_solver_second_option3(OPT_ARGS_STR) { return opt_solver_second_option(3, action, val); } -const char *opt_solver_second_option4(OPT_ARGS_STR) +std::string opt_solver_second_option4(OPT_ARGS_STR) { return opt_solver_second_option(4, action, val); } -const char *opt_solver_third_option(OPT_ARGS_STR) +std::string opt_solver_third_option(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_name[2], val); + SINFO[num].option_name[2] = val; return SINFO[num].option_name[2]; #else return "undefined"; #endif } -const char *opt_solver_third_option0(OPT_ARGS_STR) +std::string opt_solver_third_option0(OPT_ARGS_STR) { return opt_solver_third_option(0, action, val); } -const char *opt_solver_third_option1(OPT_ARGS_STR) +std::string opt_solver_third_option1(OPT_ARGS_STR) { return opt_solver_third_option(1, action, val); } -const char *opt_solver_third_option2(OPT_ARGS_STR) +std::string opt_solver_third_option2(OPT_ARGS_STR) { return opt_solver_third_option(2, action, val); } -const char *opt_solver_third_option3(OPT_ARGS_STR) +std::string opt_solver_third_option3(OPT_ARGS_STR) { return opt_solver_third_option(3, action, val); } -const char *opt_solver_third_option4(OPT_ARGS_STR) +std::string opt_solver_third_option4(OPT_ARGS_STR) { return opt_solver_third_option(4, action, val); } -const char *opt_solver_fourth_option(OPT_ARGS_STR) +std::string opt_solver_fourth_option(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_name[3], val); + SINFO[num].option_name[3] = val; return SINFO[num].option_name[3]; #else return "undefined"; #endif } -const char *opt_solver_fourth_option0(OPT_ARGS_STR) +std::string opt_solver_fourth_option0(OPT_ARGS_STR) { return opt_solver_fourth_option(0, action, val); } -const char *opt_solver_fourth_option1(OPT_ARGS_STR) +std::string opt_solver_fourth_option1(OPT_ARGS_STR) { return opt_solver_fourth_option(1, action, val); } -const char *opt_solver_fourth_option2(OPT_ARGS_STR) +std::string opt_solver_fourth_option2(OPT_ARGS_STR) { return opt_solver_fourth_option(2, action, val); } -const char *opt_solver_fourth_option3(OPT_ARGS_STR) +std::string opt_solver_fourth_option3(OPT_ARGS_STR) { return opt_solver_fourth_option(3, action, val); } -const char *opt_solver_fourth_option4(OPT_ARGS_STR) +std::string opt_solver_fourth_option4(OPT_ARGS_STR) { return opt_solver_fourth_option(4, action, val); } -const char *opt_solver_fifth_option(OPT_ARGS_STR) +std::string opt_solver_fifth_option(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].option_name[4], val); + SINFO[num].option_name[4] = val; return SINFO[num].option_name[4]; #else return "undefined"; #endif } -const char *opt_solver_fifth_option0(OPT_ARGS_STR) +std::string opt_solver_fifth_option0(OPT_ARGS_STR) { return opt_solver_fifth_option(0, action, val); } -const char *opt_solver_fifth_option1(OPT_ARGS_STR) +std::string opt_solver_fifth_option1(OPT_ARGS_STR) { return opt_solver_fifth_option(1, action, val); } -const char *opt_solver_fifth_option2(OPT_ARGS_STR) +std::string opt_solver_fifth_option2(OPT_ARGS_STR) { return opt_solver_fifth_option(2, action, val); } -const char *opt_solver_fifth_option3(OPT_ARGS_STR) +std::string opt_solver_fifth_option3(OPT_ARGS_STR) { return opt_solver_fifth_option(3, action, val); } -const char *opt_solver_fifth_option4(OPT_ARGS_STR) +std::string opt_solver_fifth_option4(OPT_ARGS_STR) { return opt_solver_fifth_option(4, action, val); } -const char *opt_solver_first_button(OPT_ARGS_STR) +std::string opt_solver_first_button(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_name[0], val); + SINFO[num].button_name[0] = val; return SINFO[num].button_name[0]; #else return "undefined"; #endif } -const char *opt_solver_first_button0(OPT_ARGS_STR) +std::string opt_solver_first_button0(OPT_ARGS_STR) { return opt_solver_first_button(0, action, val); } -const char *opt_solver_first_button1(OPT_ARGS_STR) +std::string opt_solver_first_button1(OPT_ARGS_STR) { return opt_solver_first_button(1, action, val); } -const char *opt_solver_first_button2(OPT_ARGS_STR) +std::string opt_solver_first_button2(OPT_ARGS_STR) { return opt_solver_first_button(2, action, val); } -const char *opt_solver_first_button3(OPT_ARGS_STR) +std::string opt_solver_first_button3(OPT_ARGS_STR) { return opt_solver_first_button(3, action, val); } -const char *opt_solver_first_button4(OPT_ARGS_STR) +std::string opt_solver_first_button4(OPT_ARGS_STR) { return opt_solver_first_button(4, action, val); } -const char *opt_solver_first_button_command(OPT_ARGS_STR) +std::string opt_solver_first_button_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_command[0], val); + SINFO[num].button_command[0] = val; return SINFO[num].button_command[0]; #else return "undefined"; #endif } -const char *opt_solver_first_button_command0(OPT_ARGS_STR) +std::string opt_solver_first_button_command0(OPT_ARGS_STR) { return opt_solver_first_button_command(0, action, val); } -const char *opt_solver_first_button_command1(OPT_ARGS_STR) +std::string opt_solver_first_button_command1(OPT_ARGS_STR) { return opt_solver_first_button_command(1, action, val); } -const char *opt_solver_first_button_command2(OPT_ARGS_STR) +std::string opt_solver_first_button_command2(OPT_ARGS_STR) { return opt_solver_first_button_command(2, action, val); } -const char *opt_solver_first_button_command3(OPT_ARGS_STR) +std::string opt_solver_first_button_command3(OPT_ARGS_STR) { return opt_solver_first_button_command(3, action, val); } -const char *opt_solver_first_button_command4(OPT_ARGS_STR) +std::string opt_solver_first_button_command4(OPT_ARGS_STR) { return opt_solver_first_button_command(4, action, val); } -const char *opt_solver_second_button(OPT_ARGS_STR) +std::string opt_solver_second_button(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_name[1], val); + SINFO[num].button_name[1] = val; return SINFO[num].button_name[1]; #else return "undefined"; #endif } -const char *opt_solver_second_button0(OPT_ARGS_STR) +std::string opt_solver_second_button0(OPT_ARGS_STR) { return opt_solver_second_button(0, action, val); } -const char *opt_solver_second_button1(OPT_ARGS_STR) +std::string opt_solver_second_button1(OPT_ARGS_STR) { return opt_solver_second_button(1, action, val); } -const char *opt_solver_second_button2(OPT_ARGS_STR) +std::string opt_solver_second_button2(OPT_ARGS_STR) { return opt_solver_second_button(2, action, val); } -const char *opt_solver_second_button3(OPT_ARGS_STR) +std::string opt_solver_second_button3(OPT_ARGS_STR) { return opt_solver_second_button(3, action, val); } -const char *opt_solver_second_button4(OPT_ARGS_STR) +std::string opt_solver_second_button4(OPT_ARGS_STR) { return opt_solver_second_button(4, action, val); } -const char *opt_solver_second_button_command(OPT_ARGS_STR) +std::string opt_solver_second_button_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_command[1], val); + SINFO[num].button_command[1] = val; return SINFO[num].button_command[1]; #else return "undefined"; #endif } -const char *opt_solver_second_button_command0(OPT_ARGS_STR) +std::string opt_solver_second_button_command0(OPT_ARGS_STR) { return opt_solver_second_button_command(0, action, val); } -const char *opt_solver_second_button_command1(OPT_ARGS_STR) +std::string opt_solver_second_button_command1(OPT_ARGS_STR) { return opt_solver_second_button_command(1, action, val); } -const char *opt_solver_second_button_command2(OPT_ARGS_STR) +std::string opt_solver_second_button_command2(OPT_ARGS_STR) { return opt_solver_second_button_command(2, action, val); } -const char *opt_solver_second_button_command3(OPT_ARGS_STR) +std::string opt_solver_second_button_command3(OPT_ARGS_STR) { return opt_solver_second_button_command(3, action, val); } -const char *opt_solver_second_button_command4(OPT_ARGS_STR) +std::string opt_solver_second_button_command4(OPT_ARGS_STR) { return opt_solver_second_button_command(4, action, val); } -const char *opt_solver_third_button(OPT_ARGS_STR) +std::string opt_solver_third_button(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_name[2], val); + SINFO[num].button_name[2] = val; return SINFO[num].button_name[2]; #else return "undefined"; #endif } -const char *opt_solver_third_button0(OPT_ARGS_STR) +std::string opt_solver_third_button0(OPT_ARGS_STR) { return opt_solver_third_button(0, action, val); } -const char *opt_solver_third_button1(OPT_ARGS_STR) +std::string opt_solver_third_button1(OPT_ARGS_STR) { return opt_solver_third_button(1, action, val); } -const char *opt_solver_third_button2(OPT_ARGS_STR) +std::string opt_solver_third_button2(OPT_ARGS_STR) { return opt_solver_third_button(2, action, val); } -const char *opt_solver_third_button3(OPT_ARGS_STR) +std::string opt_solver_third_button3(OPT_ARGS_STR) { return opt_solver_third_button(3, action, val); } -const char *opt_solver_third_button4(OPT_ARGS_STR) +std::string opt_solver_third_button4(OPT_ARGS_STR) { return opt_solver_third_button(4, action, val); } -const char *opt_solver_third_button_command(OPT_ARGS_STR) +std::string opt_solver_third_button_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_command[2], val); + SINFO[num].button_command[2] = val; return SINFO[num].button_command[2]; #else return "undefined"; #endif } -const char *opt_solver_third_button_command0(OPT_ARGS_STR) +std::string opt_solver_third_button_command0(OPT_ARGS_STR) { return opt_solver_third_button_command(0, action, val); } -const char *opt_solver_third_button_command1(OPT_ARGS_STR) +std::string opt_solver_third_button_command1(OPT_ARGS_STR) { return opt_solver_third_button_command(1, action, val); } -const char *opt_solver_third_button_command2(OPT_ARGS_STR) +std::string opt_solver_third_button_command2(OPT_ARGS_STR) { return opt_solver_third_button_command(2, action, val); } -const char *opt_solver_third_button_command3(OPT_ARGS_STR) +std::string opt_solver_third_button_command3(OPT_ARGS_STR) { return opt_solver_third_button_command(3, action, val); } -const char *opt_solver_third_button_command4(OPT_ARGS_STR) +std::string opt_solver_third_button_command4(OPT_ARGS_STR) { return opt_solver_third_button_command(4, action, val); } -const char *opt_solver_fourth_button(OPT_ARGS_STR) +std::string opt_solver_fourth_button(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_name[3], val); + SINFO[num].button_name[3] = val; return SINFO[num].button_name[3]; #else return "undefined"; #endif } -const char *opt_solver_fourth_button0(OPT_ARGS_STR) +std::string opt_solver_fourth_button0(OPT_ARGS_STR) { return opt_solver_fourth_button(0, action, val); } -const char *opt_solver_fourth_button1(OPT_ARGS_STR) +std::string opt_solver_fourth_button1(OPT_ARGS_STR) { return opt_solver_fourth_button(1, action, val); } -const char *opt_solver_fourth_button2(OPT_ARGS_STR) +std::string opt_solver_fourth_button2(OPT_ARGS_STR) { return opt_solver_fourth_button(2, action, val); } -const char *opt_solver_fourth_button3(OPT_ARGS_STR) +std::string opt_solver_fourth_button3(OPT_ARGS_STR) { return opt_solver_fourth_button(3, action, val); } -const char *opt_solver_fourth_button4(OPT_ARGS_STR) +std::string opt_solver_fourth_button4(OPT_ARGS_STR) { return opt_solver_fourth_button(4, action, val); } -const char *opt_solver_fourth_button_command(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_command[3], val); + SINFO[num].button_command[3] = val; return SINFO[num].button_command[3]; #else return "undefined"; #endif } -const char *opt_solver_fourth_button_command0(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command0(OPT_ARGS_STR) { return opt_solver_fourth_button_command(0, action, val); } -const char *opt_solver_fourth_button_command1(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command1(OPT_ARGS_STR) { return opt_solver_fourth_button_command(1, action, val); } -const char *opt_solver_fourth_button_command2(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command2(OPT_ARGS_STR) { return opt_solver_fourth_button_command(2, action, val); } -const char *opt_solver_fourth_button_command3(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command3(OPT_ARGS_STR) { return opt_solver_fourth_button_command(3, action, val); } -const char *opt_solver_fourth_button_command4(OPT_ARGS_STR) +std::string opt_solver_fourth_button_command4(OPT_ARGS_STR) { return opt_solver_fourth_button_command(4, action, val); } -const char *opt_solver_fifth_button(OPT_ARGS_STR) +std::string opt_solver_fifth_button(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_name[4], val); + SINFO[num].button_name[4] = val; return SINFO[num].button_name[4]; #else return "undefined"; #endif } -const char *opt_solver_fifth_button0(OPT_ARGS_STR) +std::string opt_solver_fifth_button0(OPT_ARGS_STR) { return opt_solver_fifth_button(0, action, val); } -const char *opt_solver_fifth_button1(OPT_ARGS_STR) +std::string opt_solver_fifth_button1(OPT_ARGS_STR) { return opt_solver_fifth_button(1, action, val); } -const char *opt_solver_fifth_button2(OPT_ARGS_STR) +std::string opt_solver_fifth_button2(OPT_ARGS_STR) { return opt_solver_fifth_button(2, action, val); } -const char *opt_solver_fifth_button3(OPT_ARGS_STR) +std::string opt_solver_fifth_button3(OPT_ARGS_STR) { return opt_solver_fifth_button(3, action, val); } -const char *opt_solver_fifth_button4(OPT_ARGS_STR) +std::string opt_solver_fifth_button4(OPT_ARGS_STR) { return opt_solver_fifth_button(4, action, val); } -const char *opt_solver_fifth_button_command(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command(OPT_ARGS_STR) { #if defined(HAVE_FLTK) if(action & GMSH_SET) - strcpy(SINFO[num].button_command[4], val); + SINFO[num].button_command[4] = val; return SINFO[num].button_command[4]; #else return "undefined"; #endif } -const char *opt_solver_fifth_button_command0(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command0(OPT_ARGS_STR) { return opt_solver_fifth_button_command(0, action, val); } -const char *opt_solver_fifth_button_command1(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command1(OPT_ARGS_STR) { return opt_solver_fifth_button_command(1, action, val); } -const char *opt_solver_fifth_button_command2(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command2(OPT_ARGS_STR) { return opt_solver_fifth_button_command(2, action, val); } -const char *opt_solver_fifth_button_command3(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command3(OPT_ARGS_STR) { return opt_solver_fifth_button_command(3, action, val); } -const char *opt_solver_fifth_button_command4(OPT_ARGS_STR) +std::string opt_solver_fifth_button_command4(OPT_ARGS_STR) { return opt_solver_fifth_button_command(4, action, val); } @@ -1987,7 +1980,7 @@ int _gui_action_valid(int action, int num) } #endif -const char *opt_view_name(OPT_ARGS_STR) +std::string opt_view_name(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); @@ -2013,16 +2006,16 @@ const char *opt_view_name(OPT_ARGS_STR) #endif } -const char *opt_view_format(OPT_ARGS_STR) +std::string opt_view_format(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->Format, val); + opt->Format = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[1]->value(opt->Format); + GUI::instance()->options->view.input[1]->value(opt->Format.c_str()); #endif return opt->Format; #else @@ -2030,27 +2023,27 @@ const char *opt_view_format(OPT_ARGS_STR) #endif } -const char *opt_view_filename(OPT_ARGS_STR) +std::string opt_view_filename(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(!data) return ""; - return data->getFileName().c_str(); + return data->getFileName(); #else return ""; #endif } -const char *opt_view_axes_label0(OPT_ARGS_STR) +std::string opt_view_axes_label0(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesLabel[0], val); + opt->AxesLabel[0] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[10]->value(opt->AxesLabel[0]); + GUI::instance()->options->view.input[10]->value(opt->AxesLabel[0].c_str()); #endif return opt->AxesLabel[0]; #else @@ -2058,16 +2051,16 @@ const char *opt_view_axes_label0(OPT_ARGS_STR) #endif } -const char *opt_view_axes_label1(OPT_ARGS_STR) +std::string opt_view_axes_label1(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesLabel[1], val); + opt->AxesLabel[1] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[11]->value(opt->AxesLabel[1]); + GUI::instance()->options->view.input[11]->value(opt->AxesLabel[1].c_str()); #endif return opt->AxesLabel[1]; #else @@ -2075,16 +2068,16 @@ const char *opt_view_axes_label1(OPT_ARGS_STR) #endif } -const char *opt_view_axes_label2(OPT_ARGS_STR) +std::string opt_view_axes_label2(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesLabel[2], val); + opt->AxesLabel[2] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[12]->value(opt->AxesLabel[2]); + GUI::instance()->options->view.input[12]->value(opt->AxesLabel[2].c_str()); #endif return opt->AxesLabel[2]; #else @@ -2092,16 +2085,16 @@ const char *opt_view_axes_label2(OPT_ARGS_STR) #endif } -const char *opt_view_axes_format0(OPT_ARGS_STR) +std::string opt_view_axes_format0(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesFormat[0], val); + opt->AxesFormat[0] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[7]->value(opt->AxesFormat[0]); + GUI::instance()->options->view.input[7]->value(opt->AxesFormat[0].c_str()); #endif return opt->AxesFormat[0]; #else @@ -2109,16 +2102,16 @@ const char *opt_view_axes_format0(OPT_ARGS_STR) #endif } -const char *opt_view_axes_format1(OPT_ARGS_STR) +std::string opt_view_axes_format1(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesFormat[1], val); + opt->AxesFormat[1] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[8]->value(opt->AxesFormat[1]); + GUI::instance()->options->view.input[8]->value(opt->AxesFormat[1].c_str()); #endif return opt->AxesFormat[1]; #else @@ -2126,16 +2119,16 @@ const char *opt_view_axes_format1(OPT_ARGS_STR) #endif } -const char *opt_view_axes_format2(OPT_ARGS_STR) +std::string opt_view_axes_format2(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->AxesFormat[2], val); + opt->AxesFormat[2] = val; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[9]->value(opt->AxesFormat[2]); + GUI::instance()->options->view.input[9]->value(opt->AxesFormat[2].c_str()); #endif return opt->AxesFormat[2]; #else @@ -2143,17 +2136,17 @@ const char *opt_view_axes_format2(OPT_ARGS_STR) #endif } -const char *opt_view_gen_raise0(OPT_ARGS_STR) +std::string opt_view_gen_raise0(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->GenRaiseX, val); + opt->GenRaiseX = val; if(view) view->setChanged(true); } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[4]->value(opt->GenRaiseX); + GUI::instance()->options->view.input[4]->value(opt->GenRaiseX.c_str()); #endif return opt->GenRaiseX; #else @@ -2161,17 +2154,17 @@ const char *opt_view_gen_raise0(OPT_ARGS_STR) #endif } -const char *opt_view_gen_raise1(OPT_ARGS_STR) +std::string opt_view_gen_raise1(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->GenRaiseY, val); + opt->GenRaiseY = val; if(view) view->setChanged(true); } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[5]->value(opt->GenRaiseY); + GUI::instance()->options->view.input[5]->value(opt->GenRaiseY.c_str()); #endif return opt->GenRaiseY; #else @@ -2179,17 +2172,17 @@ const char *opt_view_gen_raise1(OPT_ARGS_STR) #endif } -const char *opt_view_gen_raise2(OPT_ARGS_STR) +std::string opt_view_gen_raise2(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strcpy(opt->GenRaiseZ, val); + opt->GenRaiseZ = val; if(view) view->setChanged(true); } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) - GUI::instance()->options->view.input[6]->value(opt->GenRaiseZ); + GUI::instance()->options->view.input[6]->value(opt->GenRaiseZ.c_str()); #endif return opt->GenRaiseZ; #else @@ -2214,27 +2207,31 @@ int _h2d(char c) } } -void _string2stipple(char str[32], int &repeat, int &pattern) +void _string2stipple(std::string str, int &repeat, int &pattern) { // "n*0xabcd" - if(str[1] != '*' || str[2] != '0' || str[3] != 'x'){ + if(str.size() < 8){ + repeat = 1; + pattern = 0xFFFF; + } + else if(str[1] != '*' || str[2] != '0' || str[3] != 'x'){ // bad format repeat = 1; pattern = 0xFFFF; } else{ repeat = (int)str[0] - '0'; - pattern = 16*16*16*_h2d(str[4]) + 16*16*_h2d(str[5]) + 16*_h2d(str[6]) + _h2d(str[7]); + pattern = 16 * 16 * 16 * _h2d(str[4]) + 16 * 16 * _h2d(str[5]) + + 16 * _h2d(str[6]) + _h2d(str[7]); } } -const char *opt_view_stipple0(OPT_ARGS_STR) +std::string opt_view_stipple0(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[0], val, 31); - opt->StippleString[0][31] = '\0'; // just as a precaution + opt->StippleString[0] = val; _string2stipple(opt->StippleString[0], opt->Stipple[0][0], opt->Stipple[0][1]); } return opt->StippleString[0]; @@ -2243,13 +2240,12 @@ const char *opt_view_stipple0(OPT_ARGS_STR) #endif } -const char *opt_view_stipple1(OPT_ARGS_STR) +std::string opt_view_stipple1(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[1], val, 31); - opt->StippleString[1][31] = '\0'; // just as a precaution + opt->StippleString[1] = val; _string2stipple(opt->StippleString[1], opt->Stipple[1][0], opt->Stipple[1][1]); } return opt->StippleString[1]; @@ -2258,13 +2254,12 @@ const char *opt_view_stipple1(OPT_ARGS_STR) #endif } -const char *opt_view_stipple2(OPT_ARGS_STR) +std::string opt_view_stipple2(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[2], val, 31); - opt->StippleString[2][31] = '\0'; // just as a precaution + opt->StippleString[2] = val; _string2stipple(opt->StippleString[2], opt->Stipple[2][0], opt->Stipple[2][1]); } return opt->StippleString[2]; @@ -2273,13 +2268,12 @@ const char *opt_view_stipple2(OPT_ARGS_STR) #endif } -const char *opt_view_stipple3(OPT_ARGS_STR) +std::string opt_view_stipple3(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[3], val, 31); - opt->StippleString[3][31] = '\0'; // just as a precaution + opt->StippleString[3] = val; _string2stipple(opt->StippleString[3], opt->Stipple[3][0], opt->Stipple[3][1]); } return opt->StippleString[3]; @@ -2288,13 +2282,12 @@ const char *opt_view_stipple3(OPT_ARGS_STR) #endif } -const char *opt_view_stipple4(OPT_ARGS_STR) +std::string opt_view_stipple4(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[4], val, 31); - opt->StippleString[4][31] = '\0'; // just as a precaution + opt->StippleString[4] = val; _string2stipple(opt->StippleString[4], opt->Stipple[4][0], opt->Stipple[4][1]); } return opt->StippleString[4]; @@ -2303,13 +2296,12 @@ const char *opt_view_stipple4(OPT_ARGS_STR) #endif } -const char *opt_view_stipple5(OPT_ARGS_STR) +std::string opt_view_stipple5(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[5], val, 31); - opt->StippleString[5][31] = '\0'; // just as a precaution + opt->StippleString[5] = val; _string2stipple(opt->StippleString[5], opt->Stipple[5][0], opt->Stipple[5][1]); } return opt->StippleString[5]; @@ -2318,13 +2310,12 @@ const char *opt_view_stipple5(OPT_ARGS_STR) #endif } -const char *opt_view_stipple6(OPT_ARGS_STR) +std::string opt_view_stipple6(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[6], val, 31); - opt->StippleString[6][31] = '\0'; // just as a precaution + opt->StippleString[6] = val; _string2stipple(opt->StippleString[6], opt->Stipple[6][0], opt->Stipple[6][1]); } return opt->StippleString[6]; @@ -2333,13 +2324,12 @@ const char *opt_view_stipple6(OPT_ARGS_STR) #endif } -const char *opt_view_stipple7(OPT_ARGS_STR) +std::string opt_view_stipple7(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[7], val, 31); - opt->StippleString[7][31] = '\0'; // just as a precaution + opt->StippleString[7] = val; _string2stipple(opt->StippleString[7], opt->Stipple[7][0], opt->Stipple[7][1]); } return opt->StippleString[7]; @@ -2348,13 +2338,12 @@ const char *opt_view_stipple7(OPT_ARGS_STR) #endif } -const char *opt_view_stipple8(OPT_ARGS_STR) +std::string opt_view_stipple8(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[8], val, 31); - opt->StippleString[8][31] = '\0'; // just as a precaution + opt->StippleString[8] = val; _string2stipple(opt->StippleString[8], opt->Stipple[8][0], opt->Stipple[8][1]); } return opt->StippleString[8]; @@ -2363,13 +2352,12 @@ const char *opt_view_stipple8(OPT_ARGS_STR) #endif } -const char *opt_view_stipple9(OPT_ARGS_STR) +std::string opt_view_stipple9(OPT_ARGS_STR) { #if !defined(HAVE_NO_POST) GET_VIEW(""); if(action & GMSH_SET) { - strncpy(opt->StippleString[9], val, 31); - opt->StippleString[9][31] = '\0'; // just as a precaution + opt->StippleString[9] = val; _string2stipple(opt->StippleString[9], opt->Stipple[9][0], opt->Stipple[9][1]); } return opt->StippleString[9]; diff --git a/Common/Options.h b/Common/Options.h index 0659b552c56653c03a192d04b71546301e0cc20a..0dfcdceac468b8f45560b1b236145243313e34ab 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -19,196 +19,196 @@ // action is a combination of GMSH_SET, GMSH_GET, GMSH_GUI -#define OPT_ARGS_STR int num, int action, const char *val +#define OPT_ARGS_STR int num, int action, std::string val #define OPT_ARGS_NUM int num, int action, double val #define OPT_ARGS_COL int num, int action, unsigned int val // STRINGS -const char *opt_general_axes_label0(OPT_ARGS_STR); -const char *opt_general_axes_label1(OPT_ARGS_STR); -const char *opt_general_axes_label2(OPT_ARGS_STR); -const char *opt_general_axes_format0(OPT_ARGS_STR); -const char *opt_general_axes_format1(OPT_ARGS_STR); -const char *opt_general_axes_format2(OPT_ARGS_STR); -const char *opt_general_display(OPT_ARGS_STR); -const char *opt_general_filename(OPT_ARGS_STR); -const char *opt_general_default_filename(OPT_ARGS_STR); -const char *opt_general_tmp_filename(OPT_ARGS_STR); -const char *opt_general_error_filename(OPT_ARGS_STR); -const char *opt_general_session_filename(OPT_ARGS_STR); -const char *opt_general_options_filename(OPT_ARGS_STR); -const char *opt_general_editor(OPT_ARGS_STR); -const char *opt_general_web_browser(OPT_ARGS_STR); -const char *opt_general_gui_theme(OPT_ARGS_STR); -const char *opt_general_graphics_font(OPT_ARGS_STR); -const char *opt_solver_socket_name(OPT_ARGS_STR); -const char *opt_solver_name(OPT_ARGS_STR); -const char *opt_solver_name0(OPT_ARGS_STR); -const char *opt_solver_name1(OPT_ARGS_STR); -const char *opt_solver_name2(OPT_ARGS_STR); -const char *opt_solver_name3(OPT_ARGS_STR); -const char *opt_solver_name4(OPT_ARGS_STR); -const char *opt_solver_executable(OPT_ARGS_STR); -const char *opt_solver_executable0(OPT_ARGS_STR); -const char *opt_solver_executable1(OPT_ARGS_STR); -const char *opt_solver_executable2(OPT_ARGS_STR); -const char *opt_solver_executable3(OPT_ARGS_STR); -const char *opt_solver_executable4(OPT_ARGS_STR); -const char *opt_solver_help(OPT_ARGS_STR); -const char *opt_solver_help0(OPT_ARGS_STR); -const char *opt_solver_help1(OPT_ARGS_STR); -const char *opt_solver_help2(OPT_ARGS_STR); -const char *opt_solver_help3(OPT_ARGS_STR); -const char *opt_solver_help4(OPT_ARGS_STR); -const char *opt_solver_extension(OPT_ARGS_STR); -const char *opt_solver_extension0(OPT_ARGS_STR); -const char *opt_solver_extension1(OPT_ARGS_STR); -const char *opt_solver_extension2(OPT_ARGS_STR); -const char *opt_solver_extension3(OPT_ARGS_STR); -const char *opt_solver_extension4(OPT_ARGS_STR); -const char *opt_solver_mesh_name(OPT_ARGS_STR); -const char *opt_solver_mesh_name0(OPT_ARGS_STR); -const char *opt_solver_mesh_name1(OPT_ARGS_STR); -const char *opt_solver_mesh_name2(OPT_ARGS_STR); -const char *opt_solver_mesh_name3(OPT_ARGS_STR); -const char *opt_solver_mesh_name4(OPT_ARGS_STR); -const char *opt_solver_mesh_command(OPT_ARGS_STR); -const char *opt_solver_mesh_command0(OPT_ARGS_STR); -const char *opt_solver_mesh_command1(OPT_ARGS_STR); -const char *opt_solver_mesh_command2(OPT_ARGS_STR); -const char *opt_solver_mesh_command3(OPT_ARGS_STR); -const char *opt_solver_mesh_command4(OPT_ARGS_STR); -const char *opt_solver_socket_command(OPT_ARGS_STR); -const char *opt_solver_socket_command0(OPT_ARGS_STR); -const char *opt_solver_socket_command1(OPT_ARGS_STR); -const char *opt_solver_socket_command2(OPT_ARGS_STR); -const char *opt_solver_socket_command3(OPT_ARGS_STR); -const char *opt_solver_socket_command4(OPT_ARGS_STR); -const char *opt_solver_name_command(OPT_ARGS_STR); -const char *opt_solver_name_command0(OPT_ARGS_STR); -const char *opt_solver_name_command1(OPT_ARGS_STR); -const char *opt_solver_name_command2(OPT_ARGS_STR); -const char *opt_solver_name_command3(OPT_ARGS_STR); -const char *opt_solver_name_command4(OPT_ARGS_STR); -const char *opt_solver_option_command(OPT_ARGS_STR); -const char *opt_solver_option_command0(OPT_ARGS_STR); -const char *opt_solver_option_command1(OPT_ARGS_STR); -const char *opt_solver_option_command2(OPT_ARGS_STR); -const char *opt_solver_option_command3(OPT_ARGS_STR); -const char *opt_solver_option_command4(OPT_ARGS_STR); -const char *opt_solver_first_option(OPT_ARGS_STR); -const char *opt_solver_first_option0(OPT_ARGS_STR); -const char *opt_solver_first_option1(OPT_ARGS_STR); -const char *opt_solver_first_option2(OPT_ARGS_STR); -const char *opt_solver_first_option3(OPT_ARGS_STR); -const char *opt_solver_first_option4(OPT_ARGS_STR); -const char *opt_solver_second_option(OPT_ARGS_STR); -const char *opt_solver_second_option0(OPT_ARGS_STR); -const char *opt_solver_second_option1(OPT_ARGS_STR); -const char *opt_solver_second_option2(OPT_ARGS_STR); -const char *opt_solver_second_option3(OPT_ARGS_STR); -const char *opt_solver_second_option4(OPT_ARGS_STR); -const char *opt_solver_third_option(OPT_ARGS_STR); -const char *opt_solver_third_option0(OPT_ARGS_STR); -const char *opt_solver_third_option1(OPT_ARGS_STR); -const char *opt_solver_third_option2(OPT_ARGS_STR); -const char *opt_solver_third_option3(OPT_ARGS_STR); -const char *opt_solver_third_option4(OPT_ARGS_STR); -const char *opt_solver_fourth_option(OPT_ARGS_STR); -const char *opt_solver_fourth_option0(OPT_ARGS_STR); -const char *opt_solver_fourth_option1(OPT_ARGS_STR); -const char *opt_solver_fourth_option2(OPT_ARGS_STR); -const char *opt_solver_fourth_option3(OPT_ARGS_STR); -const char *opt_solver_fourth_option4(OPT_ARGS_STR); -const char *opt_solver_fifth_option(OPT_ARGS_STR); -const char *opt_solver_fifth_option0(OPT_ARGS_STR); -const char *opt_solver_fifth_option1(OPT_ARGS_STR); -const char *opt_solver_fifth_option2(OPT_ARGS_STR); -const char *opt_solver_fifth_option3(OPT_ARGS_STR); -const char *opt_solver_fifth_option4(OPT_ARGS_STR); -const char *opt_solver_first_button(OPT_ARGS_STR); -const char *opt_solver_first_button0(OPT_ARGS_STR); -const char *opt_solver_first_button1(OPT_ARGS_STR); -const char *opt_solver_first_button2(OPT_ARGS_STR); -const char *opt_solver_first_button3(OPT_ARGS_STR); -const char *opt_solver_first_button4(OPT_ARGS_STR); -const char *opt_solver_first_button_command(OPT_ARGS_STR); -const char *opt_solver_first_button_command0(OPT_ARGS_STR); -const char *opt_solver_first_button_command1(OPT_ARGS_STR); -const char *opt_solver_first_button_command2(OPT_ARGS_STR); -const char *opt_solver_first_button_command3(OPT_ARGS_STR); -const char *opt_solver_first_button_command4(OPT_ARGS_STR); -const char *opt_solver_second_button(OPT_ARGS_STR); -const char *opt_solver_second_button0(OPT_ARGS_STR); -const char *opt_solver_second_button1(OPT_ARGS_STR); -const char *opt_solver_second_button2(OPT_ARGS_STR); -const char *opt_solver_second_button3(OPT_ARGS_STR); -const char *opt_solver_second_button4(OPT_ARGS_STR); -const char *opt_solver_second_button_command(OPT_ARGS_STR); -const char *opt_solver_second_button_command0(OPT_ARGS_STR); -const char *opt_solver_second_button_command1(OPT_ARGS_STR); -const char *opt_solver_second_button_command2(OPT_ARGS_STR); -const char *opt_solver_second_button_command3(OPT_ARGS_STR); -const char *opt_solver_second_button_command4(OPT_ARGS_STR); -const char *opt_solver_third_button(OPT_ARGS_STR); -const char *opt_solver_third_button0(OPT_ARGS_STR); -const char *opt_solver_third_button1(OPT_ARGS_STR); -const char *opt_solver_third_button2(OPT_ARGS_STR); -const char *opt_solver_third_button3(OPT_ARGS_STR); -const char *opt_solver_third_button4(OPT_ARGS_STR); -const char *opt_solver_third_button_command(OPT_ARGS_STR); -const char *opt_solver_third_button_command0(OPT_ARGS_STR); -const char *opt_solver_third_button_command1(OPT_ARGS_STR); -const char *opt_solver_third_button_command2(OPT_ARGS_STR); -const char *opt_solver_third_button_command3(OPT_ARGS_STR); -const char *opt_solver_third_button_command4(OPT_ARGS_STR); -const char *opt_solver_fourth_button(OPT_ARGS_STR); -const char *opt_solver_fourth_button0(OPT_ARGS_STR); -const char *opt_solver_fourth_button1(OPT_ARGS_STR); -const char *opt_solver_fourth_button2(OPT_ARGS_STR); -const char *opt_solver_fourth_button3(OPT_ARGS_STR); -const char *opt_solver_fourth_button4(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command0(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command1(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command2(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command3(OPT_ARGS_STR); -const char *opt_solver_fourth_button_command4(OPT_ARGS_STR); -const char *opt_solver_fifth_button(OPT_ARGS_STR); -const char *opt_solver_fifth_button0(OPT_ARGS_STR); -const char *opt_solver_fifth_button1(OPT_ARGS_STR); -const char *opt_solver_fifth_button2(OPT_ARGS_STR); -const char *opt_solver_fifth_button3(OPT_ARGS_STR); -const char *opt_solver_fifth_button4(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command0(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command1(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command2(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command3(OPT_ARGS_STR); -const char *opt_solver_fifth_button_command4(OPT_ARGS_STR); -const char *opt_view_name(OPT_ARGS_STR); -const char *opt_view_format(OPT_ARGS_STR); -const char *opt_view_filename(OPT_ARGS_STR); -const char *opt_view_axes_label0(OPT_ARGS_STR); -const char *opt_view_axes_label1(OPT_ARGS_STR); -const char *opt_view_axes_label2(OPT_ARGS_STR); -const char *opt_view_axes_format0(OPT_ARGS_STR); -const char *opt_view_axes_format1(OPT_ARGS_STR); -const char *opt_view_axes_format2(OPT_ARGS_STR); -const char *opt_view_gen_raise0(OPT_ARGS_STR); -const char *opt_view_gen_raise1(OPT_ARGS_STR); -const char *opt_view_gen_raise2(OPT_ARGS_STR); -const char *opt_view_stipple0(OPT_ARGS_STR); -const char *opt_view_stipple1(OPT_ARGS_STR); -const char *opt_view_stipple2(OPT_ARGS_STR); -const char *opt_view_stipple3(OPT_ARGS_STR); -const char *opt_view_stipple4(OPT_ARGS_STR); -const char *opt_view_stipple5(OPT_ARGS_STR); -const char *opt_view_stipple6(OPT_ARGS_STR); -const char *opt_view_stipple7(OPT_ARGS_STR); -const char *opt_view_stipple8(OPT_ARGS_STR); -const char *opt_view_stipple9(OPT_ARGS_STR); +std::string opt_general_axes_label0(OPT_ARGS_STR); +std::string opt_general_axes_label1(OPT_ARGS_STR); +std::string opt_general_axes_label2(OPT_ARGS_STR); +std::string opt_general_axes_format0(OPT_ARGS_STR); +std::string opt_general_axes_format1(OPT_ARGS_STR); +std::string opt_general_axes_format2(OPT_ARGS_STR); +std::string opt_general_display(OPT_ARGS_STR); +std::string opt_general_filename(OPT_ARGS_STR); +std::string opt_general_default_filename(OPT_ARGS_STR); +std::string opt_general_tmp_filename(OPT_ARGS_STR); +std::string opt_general_error_filename(OPT_ARGS_STR); +std::string opt_general_session_filename(OPT_ARGS_STR); +std::string opt_general_options_filename(OPT_ARGS_STR); +std::string opt_general_editor(OPT_ARGS_STR); +std::string opt_general_web_browser(OPT_ARGS_STR); +std::string opt_general_gui_theme(OPT_ARGS_STR); +std::string opt_general_graphics_font(OPT_ARGS_STR); +std::string opt_solver_socket_name(OPT_ARGS_STR); +std::string opt_solver_name(OPT_ARGS_STR); +std::string opt_solver_name0(OPT_ARGS_STR); +std::string opt_solver_name1(OPT_ARGS_STR); +std::string opt_solver_name2(OPT_ARGS_STR); +std::string opt_solver_name3(OPT_ARGS_STR); +std::string opt_solver_name4(OPT_ARGS_STR); +std::string opt_solver_executable(OPT_ARGS_STR); +std::string opt_solver_executable0(OPT_ARGS_STR); +std::string opt_solver_executable1(OPT_ARGS_STR); +std::string opt_solver_executable2(OPT_ARGS_STR); +std::string opt_solver_executable3(OPT_ARGS_STR); +std::string opt_solver_executable4(OPT_ARGS_STR); +std::string opt_solver_help(OPT_ARGS_STR); +std::string opt_solver_help0(OPT_ARGS_STR); +std::string opt_solver_help1(OPT_ARGS_STR); +std::string opt_solver_help2(OPT_ARGS_STR); +std::string opt_solver_help3(OPT_ARGS_STR); +std::string opt_solver_help4(OPT_ARGS_STR); +std::string opt_solver_extension(OPT_ARGS_STR); +std::string opt_solver_extension0(OPT_ARGS_STR); +std::string opt_solver_extension1(OPT_ARGS_STR); +std::string opt_solver_extension2(OPT_ARGS_STR); +std::string opt_solver_extension3(OPT_ARGS_STR); +std::string opt_solver_extension4(OPT_ARGS_STR); +std::string opt_solver_mesh_name(OPT_ARGS_STR); +std::string opt_solver_mesh_name0(OPT_ARGS_STR); +std::string opt_solver_mesh_name1(OPT_ARGS_STR); +std::string opt_solver_mesh_name2(OPT_ARGS_STR); +std::string opt_solver_mesh_name3(OPT_ARGS_STR); +std::string opt_solver_mesh_name4(OPT_ARGS_STR); +std::string opt_solver_mesh_command(OPT_ARGS_STR); +std::string opt_solver_mesh_command0(OPT_ARGS_STR); +std::string opt_solver_mesh_command1(OPT_ARGS_STR); +std::string opt_solver_mesh_command2(OPT_ARGS_STR); +std::string opt_solver_mesh_command3(OPT_ARGS_STR); +std::string opt_solver_mesh_command4(OPT_ARGS_STR); +std::string opt_solver_socket_command(OPT_ARGS_STR); +std::string opt_solver_socket_command0(OPT_ARGS_STR); +std::string opt_solver_socket_command1(OPT_ARGS_STR); +std::string opt_solver_socket_command2(OPT_ARGS_STR); +std::string opt_solver_socket_command3(OPT_ARGS_STR); +std::string opt_solver_socket_command4(OPT_ARGS_STR); +std::string opt_solver_name_command(OPT_ARGS_STR); +std::string opt_solver_name_command0(OPT_ARGS_STR); +std::string opt_solver_name_command1(OPT_ARGS_STR); +std::string opt_solver_name_command2(OPT_ARGS_STR); +std::string opt_solver_name_command3(OPT_ARGS_STR); +std::string opt_solver_name_command4(OPT_ARGS_STR); +std::string opt_solver_option_command(OPT_ARGS_STR); +std::string opt_solver_option_command0(OPT_ARGS_STR); +std::string opt_solver_option_command1(OPT_ARGS_STR); +std::string opt_solver_option_command2(OPT_ARGS_STR); +std::string opt_solver_option_command3(OPT_ARGS_STR); +std::string opt_solver_option_command4(OPT_ARGS_STR); +std::string opt_solver_first_option(OPT_ARGS_STR); +std::string opt_solver_first_option0(OPT_ARGS_STR); +std::string opt_solver_first_option1(OPT_ARGS_STR); +std::string opt_solver_first_option2(OPT_ARGS_STR); +std::string opt_solver_first_option3(OPT_ARGS_STR); +std::string opt_solver_first_option4(OPT_ARGS_STR); +std::string opt_solver_second_option(OPT_ARGS_STR); +std::string opt_solver_second_option0(OPT_ARGS_STR); +std::string opt_solver_second_option1(OPT_ARGS_STR); +std::string opt_solver_second_option2(OPT_ARGS_STR); +std::string opt_solver_second_option3(OPT_ARGS_STR); +std::string opt_solver_second_option4(OPT_ARGS_STR); +std::string opt_solver_third_option(OPT_ARGS_STR); +std::string opt_solver_third_option0(OPT_ARGS_STR); +std::string opt_solver_third_option1(OPT_ARGS_STR); +std::string opt_solver_third_option2(OPT_ARGS_STR); +std::string opt_solver_third_option3(OPT_ARGS_STR); +std::string opt_solver_third_option4(OPT_ARGS_STR); +std::string opt_solver_fourth_option(OPT_ARGS_STR); +std::string opt_solver_fourth_option0(OPT_ARGS_STR); +std::string opt_solver_fourth_option1(OPT_ARGS_STR); +std::string opt_solver_fourth_option2(OPT_ARGS_STR); +std::string opt_solver_fourth_option3(OPT_ARGS_STR); +std::string opt_solver_fourth_option4(OPT_ARGS_STR); +std::string opt_solver_fifth_option(OPT_ARGS_STR); +std::string opt_solver_fifth_option0(OPT_ARGS_STR); +std::string opt_solver_fifth_option1(OPT_ARGS_STR); +std::string opt_solver_fifth_option2(OPT_ARGS_STR); +std::string opt_solver_fifth_option3(OPT_ARGS_STR); +std::string opt_solver_fifth_option4(OPT_ARGS_STR); +std::string opt_solver_first_button(OPT_ARGS_STR); +std::string opt_solver_first_button0(OPT_ARGS_STR); +std::string opt_solver_first_button1(OPT_ARGS_STR); +std::string opt_solver_first_button2(OPT_ARGS_STR); +std::string opt_solver_first_button3(OPT_ARGS_STR); +std::string opt_solver_first_button4(OPT_ARGS_STR); +std::string opt_solver_first_button_command(OPT_ARGS_STR); +std::string opt_solver_first_button_command0(OPT_ARGS_STR); +std::string opt_solver_first_button_command1(OPT_ARGS_STR); +std::string opt_solver_first_button_command2(OPT_ARGS_STR); +std::string opt_solver_first_button_command3(OPT_ARGS_STR); +std::string opt_solver_first_button_command4(OPT_ARGS_STR); +std::string opt_solver_second_button(OPT_ARGS_STR); +std::string opt_solver_second_button0(OPT_ARGS_STR); +std::string opt_solver_second_button1(OPT_ARGS_STR); +std::string opt_solver_second_button2(OPT_ARGS_STR); +std::string opt_solver_second_button3(OPT_ARGS_STR); +std::string opt_solver_second_button4(OPT_ARGS_STR); +std::string opt_solver_second_button_command(OPT_ARGS_STR); +std::string opt_solver_second_button_command0(OPT_ARGS_STR); +std::string opt_solver_second_button_command1(OPT_ARGS_STR); +std::string opt_solver_second_button_command2(OPT_ARGS_STR); +std::string opt_solver_second_button_command3(OPT_ARGS_STR); +std::string opt_solver_second_button_command4(OPT_ARGS_STR); +std::string opt_solver_third_button(OPT_ARGS_STR); +std::string opt_solver_third_button0(OPT_ARGS_STR); +std::string opt_solver_third_button1(OPT_ARGS_STR); +std::string opt_solver_third_button2(OPT_ARGS_STR); +std::string opt_solver_third_button3(OPT_ARGS_STR); +std::string opt_solver_third_button4(OPT_ARGS_STR); +std::string opt_solver_third_button_command(OPT_ARGS_STR); +std::string opt_solver_third_button_command0(OPT_ARGS_STR); +std::string opt_solver_third_button_command1(OPT_ARGS_STR); +std::string opt_solver_third_button_command2(OPT_ARGS_STR); +std::string opt_solver_third_button_command3(OPT_ARGS_STR); +std::string opt_solver_third_button_command4(OPT_ARGS_STR); +std::string opt_solver_fourth_button(OPT_ARGS_STR); +std::string opt_solver_fourth_button0(OPT_ARGS_STR); +std::string opt_solver_fourth_button1(OPT_ARGS_STR); +std::string opt_solver_fourth_button2(OPT_ARGS_STR); +std::string opt_solver_fourth_button3(OPT_ARGS_STR); +std::string opt_solver_fourth_button4(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command0(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command1(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command2(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command3(OPT_ARGS_STR); +std::string opt_solver_fourth_button_command4(OPT_ARGS_STR); +std::string opt_solver_fifth_button(OPT_ARGS_STR); +std::string opt_solver_fifth_button0(OPT_ARGS_STR); +std::string opt_solver_fifth_button1(OPT_ARGS_STR); +std::string opt_solver_fifth_button2(OPT_ARGS_STR); +std::string opt_solver_fifth_button3(OPT_ARGS_STR); +std::string opt_solver_fifth_button4(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command0(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command1(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command2(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command3(OPT_ARGS_STR); +std::string opt_solver_fifth_button_command4(OPT_ARGS_STR); +std::string opt_view_name(OPT_ARGS_STR); +std::string opt_view_format(OPT_ARGS_STR); +std::string opt_view_filename(OPT_ARGS_STR); +std::string opt_view_axes_label0(OPT_ARGS_STR); +std::string opt_view_axes_label1(OPT_ARGS_STR); +std::string opt_view_axes_label2(OPT_ARGS_STR); +std::string opt_view_axes_format0(OPT_ARGS_STR); +std::string opt_view_axes_format1(OPT_ARGS_STR); +std::string opt_view_axes_format2(OPT_ARGS_STR); +std::string opt_view_gen_raise0(OPT_ARGS_STR); +std::string opt_view_gen_raise1(OPT_ARGS_STR); +std::string opt_view_gen_raise2(OPT_ARGS_STR); +std::string opt_view_stipple0(OPT_ARGS_STR); +std::string opt_view_stipple1(OPT_ARGS_STR); +std::string opt_view_stipple2(OPT_ARGS_STR); +std::string opt_view_stipple3(OPT_ARGS_STR); +std::string opt_view_stipple4(OPT_ARGS_STR); +std::string opt_view_stipple5(OPT_ARGS_STR); +std::string opt_view_stipple6(OPT_ARGS_STR); +std::string opt_view_stipple7(OPT_ARGS_STR); +std::string opt_view_stipple8(OPT_ARGS_STR); +std::string opt_view_stipple9(OPT_ARGS_STR); // NUMBERS @@ -773,8 +773,8 @@ typedef struct { typedef struct { int level; const char *str; - const char * (*function)(int num, int action, const char *val); - const char *def; + std::string (*function)(int num, int action, std::string val); + std::string def; const char *help; } StringXString; @@ -804,7 +804,7 @@ void Print_Options(int num, int level, int diff, int help, const char *filename) void Print_OptionsDoc(); bool StringOption(int action, const char *category, int num, - const char *name, const char *val, std::string &out); + const char *name, std::string &val); bool NumberOption(int action, const char *category, int num, const char *name, double &val); bool ColorOption(int action, const char *category, int num, diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index a0530707bd557b85dfca2c17f982d3ca985975a8..8032441cf4af5daf0f0f60fbe1d2c96d5109ac6b 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -51,8 +51,8 @@ static int globalShortcut(int event) GUI::GUI(int argc, char **argv) { // set X display - if(strlen(CTX.display)) - Fl::display(CTX.display); + if(CTX.display.size()) + Fl::display(CTX.display.c_str()); // add global shortcuts Fl::add_handler(globalShortcut); @@ -61,8 +61,8 @@ GUI::GUI(int argc, char **argv) FL_NORMAL_SIZE = GetFontSize(); // handle themes and tooltip font size - if(strlen(CTX.gui_theme)) - Fl::scheme(CTX.gui_theme); + if(CTX.gui_theme.size()) + Fl::scheme(CTX.gui_theme.c_str()); Fl_Tooltip::size(FL_NORMAL_SIZE); // register image formats not in core fltk library (jpeg/png) diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp index ef892f13b82c693846fb506c967cba8283345d5c..2845d4d579d1dfc377d99cd5667bc34765733650 100644 --- a/Fltk/Solvers.cpp +++ b/Fltk/Solvers.cpp @@ -78,7 +78,7 @@ int Solver(int num, const char *args) GmshServer *server = new myGmshServer; if(num >= 0){ - prog = FixWindowsPath(SINFO[num].executable_name); + prog = FixWindowsPath(SINFO[num].executable_name.c_str()); if(!SINFO[num].client_server) { command = prog + " " + args; #if !defined(WIN32) @@ -97,13 +97,14 @@ int Solver(int num, const char *args) prog = command = ""; } - if(!strstr(CTX.solver.socket_name, ":")){ + if(!strstr(CTX.solver.socket_name.c_str(), ":")){ // Unix socket char tmp[1024]; if(num >= 0) - sprintf(tmp, "%s%s-%d", CTX.home_dir.c_str(), CTX.solver.socket_name, num); + sprintf(tmp, "%s%s-%d", CTX.home_dir.c_str(), CTX.solver.socket_name.c_str(), + num); else - sprintf(tmp, "%s%s", CTX.home_dir.c_str(), CTX.solver.socket_name); + sprintf(tmp, "%s%s", CTX.home_dir.c_str(), CTX.solver.socket_name.c_str()); sockname = FixWindowsPath(tmp); } else{ @@ -117,7 +118,7 @@ int Solver(int num, const char *args) if(num >= 0){ std::string tmp2 = "\"" + sockname + "\""; char tmp[1024]; - sprintf(tmp, SINFO[num].socket_command, tmp2.c_str()); + sprintf(tmp, SINFO[num].socket_command.c_str(), tmp2.c_str()); command = prog + " " + args + " " + tmp; #if !defined(WIN32) command += " &"; @@ -206,29 +207,29 @@ int Solver(int num, const char *args) break; case GmshServer::CLIENT_PROGRESS: if(num >= 0) - Msg::StatusBar(2, false, "%s %s", SINFO[num].name, message); + Msg::StatusBar(2, false, "%s %s", SINFO[num].name.c_str(), message); else Msg::StatusBar(2, false, "%s", message); break; case GmshServer::CLIENT_OPTION_1: if(num >= 0) - strcpy(SINFO[num].option[0][SINFO[num].nbval[0]++], message); + SINFO[num].option[0][SINFO[num].nbval[0]++] = message; break; case GmshServer::CLIENT_OPTION_2: if(num >= 0) - strcpy(SINFO[num].option[1][SINFO[num].nbval[1]++], message); + SINFO[num].option[1][SINFO[num].nbval[1]++] = message; break; case GmshServer::CLIENT_OPTION_3: if(num >= 0) - strcpy(SINFO[num].option[2][SINFO[num].nbval[2]++], message); + SINFO[num].option[2][SINFO[num].nbval[2]++] = message; break; case GmshServer::CLIENT_OPTION_4: if(num >= 0) - strcpy(SINFO[num].option[3][SINFO[num].nbval[3]++], message); + SINFO[num].option[3][SINFO[num].nbval[3]++] = message; break; case GmshServer::CLIENT_OPTION_5: if(num >= 0) - strcpy(SINFO[num].option[4][SINFO[num].nbval[4]++], message); + SINFO[num].option[4][SINFO[num].nbval[4]++] = message; break; case GmshServer::CLIENT_MERGE_FILE: if(num < 0 || (num >= 0 && SINFO[num].merge_views)) { @@ -244,15 +245,15 @@ int Solver(int num, const char *args) Draw(); break; case GmshServer::CLIENT_INFO: - Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", + Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name.c_str() : "Client", message); break; case GmshServer::CLIENT_WARNING: - Msg::Direct(2, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", + Msg::Direct(2, "%-8.8s: %s", num >= 0 ? SINFO[num].name.c_str() : "Client", message); break; case GmshServer::CLIENT_ERROR: - Msg::Direct(1, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", + Msg::Direct(1, "%-8.8s: %s", num >= 0 ? SINFO[num].name.c_str() : "Client", message); break; case GmshServer::CLIENT_SPEED_TEST: @@ -261,8 +262,8 @@ int Solver(int num, const char *args) break; default: Msg::Warning("Unknown type of message received from %s", - num >= 0 ? SINFO[num].name : "client"); - Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", + num >= 0 ? SINFO[num].name.c_str() : "client"); + Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name.c_str() : "Client", message); break; } @@ -285,7 +286,7 @@ int Solver(int num, const char *args) if(SINFO[num].nbval[i]) { GUI::instance()->solver[num]->choice[i]->clear(); for(int j = 0; j < SINFO[num].nbval[i]; j++) - GUI::instance()->solver[num]->choice[i]->add(SINFO[num].option[i][j]); + GUI::instance()->solver[num]->choice[i]->add(SINFO[num].option[i][j].c_str()); GUI::instance()->solver[num]->choice[i]->value(0); } } diff --git a/Fltk/Solvers.h b/Fltk/Solvers.h index 00c9f3b359694a01701bb41136e8659163676c10..fe5cfc6c7b3edc2b6467541911bd9f028ed9f26f 100644 --- a/Fltk/Solvers.h +++ b/Fltk/Solvers.h @@ -6,22 +6,24 @@ #ifndef _SOLVERS_H_ #define _SOLVERS_H_ +#include <string> + #define MAX_NUM_SOLVERS 5 #define MAX_NUM_SOLVER_OPTIONS 5 class GmshServer; typedef struct{ - char name[256], extension[32], executable_name[256]; - char mesh_name[256], mesh_command[256]; - char socket_command[256]; - char name_command[256]; - char button_name[MAX_NUM_SOLVER_OPTIONS][32]; - char button_command[MAX_NUM_SOLVER_OPTIONS][256]; - char option_name[MAX_NUM_SOLVER_OPTIONS][256], option_command[256]; - char option[MAX_NUM_SOLVER_OPTIONS][100][256]; + std::string name, extension, executable_name; + std::string mesh_name, mesh_command; + std::string socket_command; + std::string name_command; + std::string button_name[MAX_NUM_SOLVER_OPTIONS]; + std::string button_command[MAX_NUM_SOLVER_OPTIONS]; + std::string option_name[MAX_NUM_SOLVER_OPTIONS], option_command; + std::string option[MAX_NUM_SOLVER_OPTIONS][100]; int nboptions, nbval[MAX_NUM_SOLVER_OPTIONS]; - const char *help; + std::string help; int client_server, popup_messages, merge_views; int pid; GmshServer *server; diff --git a/Fltk/aboutWindow.cpp b/Fltk/aboutWindow.cpp index d43889ea3cb777080bb884d7abc7e294ab3f5632..7f94a6761a4262019127f7502a6399dd395a46bd 100644 --- a/Fltk/aboutWindow.cpp +++ b/Fltk/aboutWindow.cpp @@ -18,7 +18,7 @@ extern Context_T CTX; static void help_license_cb(Fl_Widget *w, void *data) { - std::string prog = FixWindowsPath(CTX.web_browser); + std::string prog = FixWindowsPath(CTX.web_browser.c_str()); char cmd[1024]; ReplaceMultiFormat(prog.c_str(), "http://geuz.org/gmsh/doc/LICENSE.txt", cmd); SystemCall(cmd); @@ -26,7 +26,7 @@ static void help_license_cb(Fl_Widget *w, void *data) static void help_credits_cb(Fl_Widget *w, void *data) { - std::string prog = FixWindowsPath(CTX.web_browser); + std::string prog = FixWindowsPath(CTX.web_browser.c_str()); char cmd[1024]; ReplaceMultiFormat(prog.c_str(), "http://geuz.org/gmsh/doc/CREDITS.txt", cmd); SystemCall(cmd); diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 8df516bb7f8e9a9dcbec07162ea5d94bcbc93acd..02efb408c87be8086fd69b385f5e3690b5fe4420 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -58,7 +58,7 @@ static void file_new_cb(Fl_Widget *w, void *data) std::string name = file_chooser_get_name(1); if(!StatFile(name)){ if(fl_choice("File '%s' already exists.\n\nDo you want to erase it?", - "Cancel", "Erase", NULL, name.c_str())) + "Cancel", "Erase", 0, name.c_str())) UnlinkFile(name); else goto test; @@ -302,7 +302,7 @@ static void file_save_as_cb(Fl_Widget *w, void *data) if(CTX.confirm_overwrite) { if(!StatFile(name)) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", 0, name.c_str())) goto test; } int i = file_chooser_get_filter(); @@ -334,7 +334,7 @@ static void file_rename_cb(Fl_Widget *w, void *data) if(CTX.confirm_overwrite) { if(!StatFile(name)) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", 0, name.c_str())) goto test; } rename(GModel::current()->getFileName().c_str(), name.c_str()); @@ -483,7 +483,7 @@ static void help_command_line_cb(Fl_Widget *w, void *data) static void help_online_cb(Fl_Widget *w, void *data) { - std::string prog = FixWindowsPath(CTX.web_browser); + std::string prog = FixWindowsPath(CTX.web_browser.c_str()); char cmd[1024]; ReplaceMultiFormat(prog.c_str(), "http://geuz.org/gmsh/doc/texinfo/", cmd); SystemCall(cmd); @@ -516,12 +516,12 @@ void mod_post_cb(Fl_Widget *w, void *data) void mod_back_cb(Fl_Widget *w, void *data) { - GUI::instance()->menu->setContext(NULL, -1); + GUI::instance()->menu->setContext(0, -1); } void mod_forward_cb(Fl_Widget *w, void *data) { - GUI::instance()->menu->setContext(NULL, 1); + GUI::instance()->menu->setContext(0, 1); } static void geometry_elementary_cb(Fl_Widget *w, void *data) @@ -536,7 +536,7 @@ static void geometry_physical_cb(Fl_Widget *w, void *data) static void geometry_edit_cb(Fl_Widget *w, void *data) { - std::string prog = FixWindowsPath(CTX.editor); + std::string prog = FixWindowsPath(CTX.editor.c_str()); std::string file = FixWindowsPath(GModel::current()->getFileName().c_str()); char cmd[1024]; ReplaceMultiFormat(prog.c_str(), file.c_str(), cmd); @@ -1452,7 +1452,7 @@ static void mesh_save_cb(Fl_Widget *w, void *data) if(CTX.confirm_overwrite) { if(!StatFile(name)) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", 0, name.c_str())) return; } CreateOutputFile(name, CTX.mesh.format); @@ -2021,7 +2021,7 @@ static void view_save_as(int index, const char *title, int format) if(CTX.confirm_overwrite) { if(!StatFile(name)) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", 0, name.c_str())) goto test; } view->write(name, format); @@ -2237,15 +2237,15 @@ static Fl_Menu_Item module_table[] = { // Dynamic menus contexts contextItem menu_geometry[] = { - {"0Geometry", NULL} , + {"0Geometry"} , {"Elementary entities", (Fl_Callback *)geometry_elementary_cb} , {"Physical groups", (Fl_Callback *)geometry_physical_cb} , {"Edit", (Fl_Callback *)geometry_edit_cb} , {"Reload", (Fl_Callback *)geometry_reload_cb} , - {0} + {""} }; contextItem menu_geometry_elementary[] = { - {"0Geometry>Elementary", NULL} , + {"0Geometry>Elementary"} , {"Add", (Fl_Callback *)geometry_elementary_add_cb} , {"Delete", (Fl_Callback *)geometry_elementary_delete_cb, (void*)0} , {"Translate", (Fl_Callback *)geometry_elementary_translate_cb, (void*)0} , @@ -2255,19 +2255,19 @@ contextItem menu_geometry[] = { {"Symmetry", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)0} , {"Extrude", (Fl_Callback *)geometry_elementary_extrude_cb, (void*)0} , {"Coherence", (Fl_Callback *)geometry_elementary_coherence_cb} , - {0} + {""} }; contextItem menu_geometry_elementary_add[] = { - {"0Geometry>Elementary>Add", NULL} , + {"0Geometry>Elementary>Add"} , {"New", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)0} , {"Translate", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)0} , {"Rotate", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)0} , {"Scale", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)0} , {"Symmetry", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)0} , - {0} + {""} }; contextItem menu_geometry_elementary_add_new[] = { - {"0Geometry>Elementary>Add>New", NULL} , + {"0Geometry>Elementary>Add>New"} , {"Parameter", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Parameter"} , {"Point", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Point"} , {"Straight line", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Line"} , @@ -2278,121 +2278,121 @@ contextItem menu_geometry[] = { {"Plane surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Plane Surface"} , {"Ruled surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Ruled Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_add_translate[] = { - {"0Geometry>Elementary>Add>Translate", NULL} , + {"0Geometry>Elementary>Add>Translate"} , {"Point", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_add_rotate[] = { - {"0Geometry>Elementary>Add>Rotate", NULL} , + {"0Geometry>Elementary>Add>Rotate"} , {"Point", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_add_scale[] = { - {"0Geometry>Elementary>Add>Scale", NULL} , + {"0Geometry>Elementary>Add>Scale"} , {"Point", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_add_symmetry[] = { - {"0Geometry>Elementary>Add>Symmetry", NULL} , + {"0Geometry>Elementary>Add>Symmetry"} , {"Point", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_delete[] = { - {"0Geometry>Elementary>Delete", NULL} , + {"0Geometry>Elementary>Delete"} , {"Point", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_split[] = { - {"0Geometry>Elementary>Split",NULL}, + {"0Geometry>Elementary>Split"}, {"Line",(Fl_Callback *)geometry_elementary_split_cb,(void*)"Line"}, - {0} + {""} }; contextItem menu_geometry_elementary_translate[] = { - {"0Geometry>Elementary>Translate", NULL} , + {"0Geometry>Elementary>Translate"} , {"Point", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_rotate[] = { - {"0Geometry>Elementary>Rotate", NULL} , + {"0Geometry>Elementary>Rotate"} , {"Point", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_scale[] = { - {"0Geometry>Elementary>Scale", NULL} , + {"0Geometry>Elementary>Scale"} , {"Point", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_symmetry[] = { - {"0Geometry>Elementary>Symmetry", NULL} , + {"0Geometry>Elementary>Symmetry"} , {"Point", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Surface"} , {"Volume", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Volume"} , - {0} + {""} }; contextItem menu_geometry_elementary_extrude[] = { - {"0Geometry>Elementary>Extrude", NULL} , + {"0Geometry>Elementary>Extrude"} , {"Translate", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)0} , {"Rotate", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)0} , - {0} + {""} }; contextItem menu_geometry_elementary_extrude_translate[] = { - {"0Geometry>Elementary>Extrude>Translate", NULL} , + {"0Geometry>Elementary>Extrude>Translate"} , {"Point", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Surface"} , - {0} + {""} }; contextItem menu_geometry_elementary_extrude_rotate[] = { - {"0Geometry>Elementary>Extrude>Rotate", NULL} , + {"0Geometry>Elementary>Extrude>Rotate"} , {"Point", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Point"} , {"Line", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Line"} , {"Surface", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Surface"} , - {0} + {""} }; contextItem menu_geometry_physical[] = { - {"0Geometry>Physical", NULL} , + {"0Geometry>Physical"} , {"Add", (Fl_Callback *)geometry_physical_add_cb, (void*)0} , - {0} + {""} }; contextItem menu_geometry_physical_add[] = { - {"0Geometry>Physical>Add", NULL} , + {"0Geometry>Physical>Add"} , {"Point", (Fl_Callback *)geometry_physical_add_cb, (void*)"Point" } , {"Line", (Fl_Callback *)geometry_physical_add_cb, (void*)"Line" } , {"Surface", (Fl_Callback *)geometry_physical_add_cb, (void*)"Surface" } , {"Volume", (Fl_Callback *)geometry_physical_add_cb, (void*)"Volume" } , - {0} + {""} }; contextItem menu_mesh[] = { - {"1Mesh", NULL} , + {"1Mesh"} , {"Define", (Fl_Callback *)mesh_define_cb} , {"Inspect", (Fl_Callback *)mesh_inspect_cb} , {"Delete", (Fl_Callback *)mesh_delete_cb} , @@ -2414,45 +2414,45 @@ contextItem menu_mesh[] = { #endif // {"Reclassify", (Fl_Callback *)mesh_classify_cb} , {"Save", (Fl_Callback *)mesh_save_cb} , - {0} + {""} }; contextItem menu_mesh_define[] = { - {"1Mesh>Define", NULL} , + {"1Mesh>Define"} , {"Fields", (Fl_Callback *)field_cb}, {"Characteristic length", (Fl_Callback *)mesh_define_length_cb } , {"Recombine", (Fl_Callback *)mesh_define_recombine_cb } , {"Transfinite", (Fl_Callback *)mesh_define_transfinite_cb } , - {0} + {""} }; contextItem menu_mesh_define_transfinite[] = { - {"1Mesh>Define>Transfinite", NULL} , + {"1Mesh>Define>Transfinite"} , {"Line", (Fl_Callback *)mesh_define_transfinite_line_cb} , {"Surface", (Fl_Callback *)mesh_define_transfinite_surface_cb} , {"Volume", (Fl_Callback *)mesh_define_transfinite_volume_cb} , - {0} + {""} }; contextItem menu_mesh_delete[] = { - {"1Mesh>Edit>Delete", NULL} , + {"1Mesh>Edit>Delete"} , {"Elements", (Fl_Callback *)mesh_delete_parts_cb, (void*)"elements"} , {"Lines", (Fl_Callback *)mesh_delete_parts_cb, (void*)"lines"} , {"Surfaces", (Fl_Callback *)mesh_delete_parts_cb, (void*)"surfaces"} , {"Volumes", (Fl_Callback *)mesh_delete_parts_cb, (void*)"volumes"} , - {0} + {""} }; contextItem menu_solver[] = { - {"2Solver", NULL} , + {"2Solver"} , {"Solver 0", (Fl_Callback *)solver_cb , (void*)0} , {"Solver 1", (Fl_Callback *)solver_cb , (void*)1} , {"Solver 2", (Fl_Callback *)solver_cb , (void*)2} , {"Solver 3", (Fl_Callback *)solver_cb , (void*)3} , {"Solver 4", (Fl_Callback *)solver_cb , (void*)4} , - {0} + {""} }; contextItem menu_post[] = { - {"3Post-processing", NULL} , - {0} + {"3Post-processing"} , + {""} }; menuWindow::menuWindow() @@ -2547,7 +2547,7 @@ void menuWindow::setContext(contextItem *menu_asked, int flag) if(!init_context) { init_context = 1; for(int i = 0; i < NB_HISTORY_MAX; i++) { - menu_history[i] = NULL; + menu_history[i] = 0; } } @@ -2572,13 +2572,17 @@ void menuWindow::setContext(contextItem *menu_asked, int flag) else return; } - else { + else if(menu_asked){ menu = menu_asked; if(!nb_back || menu_history[nb_back - 1] != menu) { menu_history[nb_back++] = menu; } nb_forward = 0; } + else{ + Msg::Warning("No menu asked..."); + return; + } if(menu[0].label[0] == '0'){ module->value(0); @@ -2588,25 +2592,21 @@ void menuWindow::setContext(contextItem *menu_asked, int flag) } else if(menu[0].label[0] == '2'){ module->value(2); - menu[1].label = opt_solver_name0(0, GMSH_GET, 0); - menu[2].label = opt_solver_name1(0, GMSH_GET, 0); - menu[3].label = opt_solver_name2(0, GMSH_GET, 0); - menu[4].label = opt_solver_name3(0, GMSH_GET, 0); - menu[5].label = opt_solver_name4(0, GMSH_GET, 0); - for(int i = 0; i < MAX_NUM_SOLVERS; i++) { - if(!strlen(menu[i + 1].label)) - menu[i + 1].label = NULL; - } + menu[1].label = opt_solver_name0(0, GMSH_GET, ""); + menu[2].label = opt_solver_name1(0, GMSH_GET, ""); + menu[3].label = opt_solver_name2(0, GMSH_GET, ""); + menu[4].label = opt_solver_name3(0, GMSH_GET, ""); + menu[5].label = opt_solver_name4(0, GMSH_GET, ""); } else if(menu[0].label[0] == '3'){ module->value(3); } else { - Msg::Warning("Something is wrong in your dynamic context definition"); + Msg::Warning("Something is wrong in dynamic menu definition"); return; } - Msg::StatusBar(1, false, menu[0].label + 1); + Msg::StatusBar(1, false, menu[0].label.c_str() + 1); // cannot use scroll->clear() in fltk 1.1 (should be fixed in 1.3) for(unsigned int i = 0; i < push.size(); i++){ @@ -2746,9 +2746,9 @@ void menuWindow::setContext(contextItem *menu_asked, int flag) } } else{ // geometry, mesh and solver contexts - while(menu[nb + 1].label) { + while(menu[nb + 1].label.size()) { Fl_Button *b = new Fl_Button(0, _MH + nb * BH, width, BH); - b->copy_label(menu[nb + 1].label); + b->copy_label(menu[nb + 1].label.c_str()); b->callback(menu[nb + 1].callback, menu[nb + 1].arg); push.push_back(b); scroll->add(b); diff --git a/Fltk/menuWindow.h b/Fltk/menuWindow.h index 4ca0722af9a8376e199e09cb59a8c5d2451084d1..cac6b15d6c7f54f1627aac773cada0810482118a 100644 --- a/Fltk/menuWindow.h +++ b/Fltk/menuWindow.h @@ -6,6 +6,7 @@ #ifndef _MENU_WINDOW_H_ #define _MENU_WINDOW_H_ +#include <string> #include <vector> #include <FL/Fl_Window.H> #if defined(__APPLE__) @@ -20,7 +21,7 @@ // The dynamic menu contexts typedef struct{ - const char *label; + std::string label; Fl_Callback *callback; void *arg; } contextItem; diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 7155f44285d9d3eac0c99200d053a7633e0c166c..485d152a04f9e15e970df96cbf205d5bf528ae39 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -470,7 +470,7 @@ static void solver_options_ok_cb(Fl_Widget *w, void *data) int old_listen = (int)opt_solver_listen(0, GMSH_GET, o->solver.butt[0]->value()); opt_solver_listen(0, GMSH_SET, o->solver.butt[0]->value()); if(!old_listen && o->solver.butt[0]->value()) - Solver(-1, NULL); + Solver(-1, 0); opt_solver_max_delay(0, GMSH_SET, o->solver.value[0]->value()); @@ -644,28 +644,17 @@ static void view_options_ok_cb(Fl_Widget *w, void *data) double axes_zmax = opt_view_axes_zmax(current, GMSH_GET, 0); double gen_raise_factor = opt_view_gen_raise_factor(current, GMSH_GET, 0); - char name[256]; - strcpy(name, opt_view_name(current, GMSH_GET, NULL)); - char format[256]; - strcpy(format, opt_view_format(current, GMSH_GET, NULL)); - char axes_label0[256]; - strcpy(axes_label0, opt_view_axes_label0(current, GMSH_GET, NULL)); - char axes_label1[256]; - strcpy(axes_label1, opt_view_axes_label1(current, GMSH_GET, NULL)); - char axes_label2[256]; - strcpy(axes_label2, opt_view_axes_label2(current, GMSH_GET, NULL)); - char axes_format0[256]; - strcpy(axes_format0, opt_view_axes_format0(current, GMSH_GET, NULL)); - char axes_format1[256]; - strcpy(axes_format1, opt_view_axes_format1(current, GMSH_GET, NULL)); - char axes_format2[256]; - strcpy(axes_format2, opt_view_axes_format2(current, GMSH_GET, NULL)); - char gen_raise0[256]; - strcpy(gen_raise0, opt_view_gen_raise0(current, GMSH_GET, NULL)); - char gen_raise1[256]; - strcpy(gen_raise1, opt_view_gen_raise1(current, GMSH_GET, NULL)); - char gen_raise2[256]; - strcpy(gen_raise2, opt_view_gen_raise2(current, GMSH_GET, NULL)); + std::string name = opt_view_name(current, GMSH_GET, ""); + std::string format = opt_view_format(current, GMSH_GET, ""); + std::string axes_label0 = opt_view_axes_label0(current, GMSH_GET, ""); + std::string axes_label1 = opt_view_axes_label1(current, GMSH_GET, ""); + std::string axes_label2 = opt_view_axes_label2(current, GMSH_GET, ""); + std::string axes_format0 = opt_view_axes_format0(current, GMSH_GET, ""); + std::string axes_format1 = opt_view_axes_format1(current, GMSH_GET, ""); + std::string axes_format2 = opt_view_axes_format2(current, GMSH_GET, ""); + std::string gen_raise0 = opt_view_gen_raise0(current, GMSH_GET, ""); + std::string gen_raise1 = opt_view_gen_raise1(current, GMSH_GET, ""); + std::string gen_raise2 = opt_view_gen_raise2(current, GMSH_GET, ""); // modify only the views that need to be updated for(int i = 0; i < (int)PView::list.size(); i++) { @@ -1037,47 +1026,47 @@ static void view_options_ok_cb(Fl_Widget *w, void *data) const char *str; str = o->view.input[0]->value(); - if(force || strcmp(str, name)) + if(force || (str != name)) opt_view_name(i, GMSH_SET, str); str = o->view.input[1]->value(); - if(force || strcmp(str, format)) + if(force || (str != format)) opt_view_format(i, GMSH_SET, str); str = o->view.input[10]->value(); - if(force || strcmp(str, axes_label0)) + if(force || (str != axes_label0)) opt_view_axes_label0(i, GMSH_SET, str); str = o->view.input[11]->value(); - if(force || strcmp(str, axes_label1)) + if(force || (str != axes_label1)) opt_view_axes_label1(i, GMSH_SET, str); str = o->view.input[12]->value(); - if(force || strcmp(str, axes_label2)) + if(force || (str != axes_label2)) opt_view_axes_label2(i, GMSH_SET, str); str = o->view.input[7]->value(); - if(force || strcmp(str, axes_format0)) + if(force || (str != axes_format0)) opt_view_axes_format0(i, GMSH_SET, str); str = o->view.input[8]->value(); - if(force || strcmp(str, axes_format1)) + if(force || (str != axes_format1)) opt_view_axes_format1(i, GMSH_SET, str); str = o->view.input[9]->value(); - if(force || strcmp(str, axes_format2)) + if(force || (str != axes_format2)) opt_view_axes_format2(i, GMSH_SET, str); str = o->view.input[4]->value(); - if(force || strcmp(str, gen_raise0)) + if(force || (str != gen_raise0)) opt_view_gen_raise0(i, GMSH_SET, str); str = o->view.input[5]->value(); - if(force || strcmp(str, gen_raise1)) + if(force || (str != gen_raise1)) opt_view_gen_raise1(i, GMSH_SET, str); str = o->view.input[6]->value(); - if(force || strcmp(str, gen_raise2)) + if(force || (str != gen_raise2)) opt_view_gen_raise2(i, GMSH_SET, str); // colors (since the color buttons modify the values directly @@ -3134,8 +3123,8 @@ void optionWindow::updateViewGroup(int index) double val1 = 10. * CTX.lc; double val2 = 2. * CTX.lc / maxval; - opt_view_name(index, GMSH_GUI, NULL); - opt_view_format(index, GMSH_GUI, NULL); + opt_view_name(index, GMSH_GUI, ""); + opt_view_format(index, GMSH_GUI, ""); opt_view_type(index, GMSH_GUI, 0); opt_view_show_scale(index, GMSH_GUI, 0); opt_view_draw_strings(index, GMSH_GUI, 0); @@ -3161,15 +3150,15 @@ void optionWindow::updateViewGroup(int index) opt_view_axes(index, GMSH_GUI, 0); opt_view_axes_mikado(index, GMSH_GUI, 0); - opt_view_axes_format0(index, GMSH_GUI, NULL); - opt_view_axes_format1(index, GMSH_GUI, NULL); - opt_view_axes_format2(index, GMSH_GUI, NULL); + opt_view_axes_format0(index, GMSH_GUI, ""); + opt_view_axes_format1(index, GMSH_GUI, ""); + opt_view_axes_format2(index, GMSH_GUI, ""); opt_view_axes_tics0(index, GMSH_GUI, 0); opt_view_axes_tics1(index, GMSH_GUI, 0); opt_view_axes_tics2(index, GMSH_GUI, 0); - opt_view_axes_label0(index, GMSH_GUI, NULL); - opt_view_axes_label1(index, GMSH_GUI, NULL); - opt_view_axes_label2(index, GMSH_GUI, NULL); + opt_view_axes_label0(index, GMSH_GUI, ""); + opt_view_axes_label1(index, GMSH_GUI, ""); + opt_view_axes_label2(index, GMSH_GUI, ""); opt_view_axes_auto_position(index, GMSH_GUI, 0); opt_view_axes_xmin(index, GMSH_GUI, 0); opt_view_axes_xmax(index, GMSH_GUI, 0); @@ -3251,9 +3240,9 @@ void optionWindow::updateViewGroup(int index) opt_view_use_gen_raise(index, GMSH_GUI, 0); opt_view_gen_raise_view(index, GMSH_GUI, 0); opt_view_gen_raise_factor(index, GMSH_GUI, 0); - opt_view_gen_raise0(index, GMSH_GUI, 0); - opt_view_gen_raise1(index, GMSH_GUI, 0); - opt_view_gen_raise2(index, GMSH_GUI, 0); + opt_view_gen_raise0(index, GMSH_GUI, ""); + opt_view_gen_raise1(index, GMSH_GUI, ""); + opt_view_gen_raise2(index, GMSH_GUI, ""); view.value[2]->step(val2 / 100.); view.value[2]->minimum(-val2); view.value[2]->maximum(val2); diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp index 5d1d6f3c8ddbafac7efad611a48a9c51fbd1c578..7d853309c883acec2116529d489272bbccee9e00 100644 --- a/Fltk/pluginWindow.cpp +++ b/Fltk/pluginWindow.cpp @@ -43,7 +43,7 @@ static void plugin_input_value_cb(Fl_Widget *w, void *data) static void plugin_input_cb(Fl_Widget *w, void *data) { - const char* (*f)(int, int, const char*) = (const char* (*)(int, int, const char*)) data; + std::string (*f)(int, int, std::string) = (std::string (*)(int, int, std::string)) data; Fl_Input *input = (Fl_Input*) w; f(-1, 0, input->value()); } @@ -178,7 +178,7 @@ void pluginWindow::_createDialogBox(GMSH_Plugin *p, int x, int y, p->dialogBox->input[i] = new Fl_Input (x + WB, y + WB + (k + 1) * BH, IW, BH, sxs->str); p->dialogBox->input[i]->align(FL_ALIGN_RIGHT); - p->dialogBox->input[i]->value(sxs->def); + p->dialogBox->input[i]->value(sxs->def.c_str()); k++; } for(int i = 0; i < n; i++) { diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp index d888e0652a0340ace60adfc865c76c4bce1ae71f..46c1d77802927f8575c3f5dca6b44c4211681c76 100644 --- a/Fltk/solverWindow.cpp +++ b/Fltk/solverWindow.cpp @@ -40,7 +40,7 @@ void solver_cb(Fl_Widget *w, void *data) char file[256], no_ext[256], ext[256], base[256]; SplitFileName(GModel::current()->getFileName().c_str(), no_ext, ext, base); strcpy(file, no_ext); - strcat(file, SINFO[num].extension); + strcat(file, SINFO[num].extension.c_str()); GUI::instance()->solver[num]->input[0]->value(file); } if(SINFO[num].nboptions) { @@ -48,8 +48,8 @@ void solver_cb(Fl_Widget *w, void *data) (GUI::instance()->solver[num]->input[0]->value()); char tmp[256], tmp2[256]; sprintf(tmp, "\"%s\"", file.c_str()); - sprintf(tmp2, SINFO[num].name_command, tmp); - sprintf(tmp, "%s %s", SINFO[num].option_command, tmp2); + sprintf(tmp2, SINFO[num].name_command.c_str(), tmp); + sprintf(tmp, "%s %s", SINFO[num].option_command.c_str(), tmp2); Solver(num, tmp); } GUI::instance()->solver[num]->win->show(); @@ -59,7 +59,7 @@ static void solver_file_open_cb(Fl_Widget *w, void *data) { char tmp[256], tmp2[256]; int num = (int)(long)data; - sprintf(tmp, "*%s", SINFO[num].extension); + sprintf(tmp, "*%s", SINFO[num].extension.c_str()); // We allow to create the .pro file... Or should we add a "New file" // button? @@ -68,8 +68,8 @@ static void solver_file_open_cb(Fl_Widget *w, void *data) if(SINFO[num].nboptions) { std::string file = FixWindowsPath(file_chooser_get_name(1).c_str()); sprintf(tmp, "\"%s\"", file.c_str()); - sprintf(tmp2, SINFO[num].name_command, tmp); - sprintf(tmp, "%s %s", SINFO[num].option_command, tmp2); + sprintf(tmp2, SINFO[num].name_command.c_str(), tmp); + sprintf(tmp, "%s %s", SINFO[num].option_command.c_str(), tmp2); Solver(num, tmp); } } @@ -78,7 +78,7 @@ static void solver_file_open_cb(Fl_Widget *w, void *data) static void solver_file_edit_cb(Fl_Widget *w, void *data) { int num = (int)(long)data; - std::string prog = FixWindowsPath(CTX.editor); + std::string prog = FixWindowsPath(CTX.editor.c_str()); std::string file = FixWindowsPath(GUI::instance()->solver[num]->input[0]->value()); char cmd[1024]; ReplaceMultiFormat(prog.c_str(), file.c_str(), cmd); @@ -92,7 +92,7 @@ static void solver_choose_mesh_cb(Fl_Widget *w, void *data) GUI::instance()->solver[num]->input[1]->value(file_chooser_get_name(1).c_str()); } -static int nbs(char *str) +static int nbs(const char *str) { int i, nb = 0; for(i = 0; i < (int)strlen(str) - 1; i++) { @@ -117,29 +117,29 @@ static void solver_command_cb(Fl_Widget *w, void *data) if(strlen(GUI::instance()->solver[num]->input[1]->value())) { std::string m = FixWindowsPath(GUI::instance()->solver[num]->input[1]->value()); sprintf(tmp, "\"%s\"", m.c_str()); - sprintf(mesh, SINFO[num].mesh_command, tmp); + sprintf(mesh, SINFO[num].mesh_command.c_str(), tmp); } else { strcpy(mesh, ""); } - if(nbs(SINFO[num].button_command[idx])) { + if(nbs(SINFO[num].button_command[idx].c_str())) { for(i = 0; i < idx; i++) - usedopts += nbs(SINFO[num].button_command[i]); + usedopts += nbs(SINFO[num].button_command[i].c_str()); if(usedopts > SINFO[num].nboptions) { Msg::Error("Missing options to execute command"); return; } - sprintf(command, SINFO[num].button_command[idx], SINFO[num].option - [usedopts][GUI::instance()->solver[num]->choice[usedopts]->value()]); + sprintf(command, SINFO[num].button_command[idx].c_str(), SINFO[num].option + [usedopts][GUI::instance()->solver[num]->choice[usedopts]->value()].c_str()); } else { - strcpy(command, SINFO[num].button_command[idx]); + strcpy(command, SINFO[num].button_command[idx].c_str()); } std::string c = FixWindowsPath(GUI::instance()->solver[num]->input[0]->value()); sprintf(arg, "\"%s\"", c.c_str()); - sprintf(tmp, SINFO[num].name_command, arg); + sprintf(tmp, SINFO[num].name_command.c_str(), arg); sprintf(arg, "%s %s %s", tmp, mesh, command); Solver(num, arg); } @@ -149,7 +149,7 @@ static void solver_kill_cb(Fl_Widget *w, void *data) int num = (int)(long)data; if(SINFO[num].pid > 0) { if(KillProcess(SINFO[num].pid)) - Msg::Info("Killed %s pid %d", SINFO[num].name, SINFO[num].pid); + Msg::Info("Killed %s pid %d", SINFO[num].name.c_str(), SINFO[num].pid); } SINFO[num].pid = -1; } @@ -163,13 +163,13 @@ static void solver_ok_cb(Fl_Widget *w, void *data) (num, GMSH_SET, GUI::instance()->solver[num]->butt[1]->value()); opt_solver_client_server (num, GMSH_SET, GUI::instance()->solver[num]->butt[2]->value()); - if(strcmp(opt_solver_executable(num, GMSH_GET, NULL), + if(strcmp(opt_solver_executable(num, GMSH_GET, "").c_str(), GUI::instance()->solver[num]->input[2]->value())) retry = 1; opt_solver_executable (num, GMSH_SET, GUI::instance()->solver[num]->input[2]->value()); if(retry) - solver_cb(NULL, data); + solver_cb(0, data); } static void solver_choose_executable_cb(Fl_Widget *w, void *data) @@ -192,7 +192,7 @@ solverWindow::solverWindow(int solverIndex, int deltaFontSize) FL_NORMAL_SIZE -= deltaFontSize; for(int i = 0; i < MAX_NUM_SOLVER_OPTIONS; i++) - if(strlen(SINFO[solverIndex].option_name[i])) + if(SINFO[solverIndex].option_name[i].size()) SINFO[solverIndex].nboptions = i + 1; int LL = 2 * IW; @@ -255,18 +255,18 @@ solverWindow::solverWindow(int solverIndex, int deltaFontSize) for(int i = 0; i < SINFO[solverIndex].nboptions; i++) { choice[i] = new Fl_Choice - (2 * WB, 2 * WB + (6 + i) * BH, LL, BH, SINFO[solverIndex].option_name[i]); + (2 * WB, 2 * WB + (6 + i) * BH, LL, BH, SINFO[solverIndex].option_name[i].c_str()); choice[i]->align(FL_ALIGN_RIGHT); } static int arg[MAX_NUM_SOLVERS][5][2]; for(int i = 0; i < 4; i++) { - if(strlen(SINFO[solverIndex].button_name[i])) { + if(SINFO[solverIndex].button_name[i].size()) { arg[solverIndex][i][0] = solverIndex; arg[solverIndex][i][1] = i; command[i] = new Fl_Button ((2 + i) * WB + i * BBS, 3 * WB + (6 + SINFO[solverIndex].nboptions) * BH, - BBS, BH, SINFO[solverIndex].button_name[i]); + BBS, BH, SINFO[solverIndex].button_name[i].c_str()); command[i]->callback (solver_command_cb, (void *)arg[solverIndex][i]); } @@ -288,9 +288,9 @@ solverWindow::solverWindow(int solverIndex, int deltaFontSize) Fl_Browser *o = new Fl_Browser (2 * WB, 2 * WB + 1 * BH, width - 4 * WB, height - 4 * WB - BH); o->add(" "); - add_multiline_in_browser(o, "@c@b@.", SINFO[solverIndex].name, false); + add_multiline_in_browser(o, "@c@b@.", SINFO[solverIndex].name.c_str(), false); o->add(" "); - add_multiline_in_browser(o, "@c@. ", SINFO[solverIndex].help, false); + add_multiline_in_browser(o, "@c@. ", SINFO[solverIndex].help.c_str(), false); g->end(); } diff --git a/Graphics/drawAxes.cpp b/Graphics/drawAxes.cpp index e1d29b205f237879f0092bcfac9cac3c239ed7ac..e9afd8242f403207cdf90ae00c0a6211136401f0 100644 --- a/Graphics/drawAxes.cpp +++ b/Graphics/drawAxes.cpp @@ -3,6 +3,7 @@ // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. +#include <string> #include <string.h> #include <FL/gl.h> #include "drawContext.h" @@ -13,9 +14,9 @@ extern Context_T CTX; -static int drawTics(drawContext *ctx, int comp, int n, char *format, char *label, - double p1[3], double p2[3], double perp[3], int mikado, - double pixelfact) +static int drawTics(drawContext *ctx, int comp, int n, std::string &format, + std::string &label, double p1[3], double p2[3], + double perp[3], int mikado, double pixelfact) { // draws n tic marks (in direction perp) and labels along the line p1->p2 @@ -31,7 +32,7 @@ static int drawTics(drawContext *ctx, int comp, int n, char *format, char *label if(n < 2) return 0; - if(!strlen(format)) return n; + if(format.empty()) return n; double lp = norme(perp); if(!lp){ @@ -82,9 +83,9 @@ static int drawTics(drawContext *ctx, int comp, int n, char *format, char *label char str[256]; if(comp < 0) // display the length (ruler) - sprintf(str, format, d); + sprintf(str, format.c_str(), d); else // display the coordinate - sprintf(str, format, p[comp]); + sprintf(str, format.c_str(), p[comp]); double winp[3], winr[3]; ctx->world2Viewport(p, winp); ctx->world2Viewport(r, winr); @@ -171,8 +172,8 @@ void drawContext::drawAxis(double xmin, double ymin, double zmin, } } -void drawContext::drawAxes(int mode, int tics[3], char format[3][256], - char label[3][256], double bb[6], int mikado) +void drawContext::drawAxes(int mode, int tics[3], std::string format[3], + std::string label[3], double bb[6], int mikado) { // mode 0: nothing // 1: axes @@ -258,8 +259,8 @@ void drawContext::drawAxes(int mode, int tics[3], char format[3][256], } } -void drawContext::drawAxes(int mode, int tics[3], char format[3][256], - char label[3][256], SBoundingBox3d &bb, int mikado) +void drawContext::drawAxes(int mode, int tics[3], std::string format[3], + std::string label[3], SBoundingBox3d &bb, int mikado) { double bbox[6] = {bb.min().x(), bb.max().x(), bb.min().y(), bb.max().y(), diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h index b3f757ea40fb904ccf87aaa6018513b44d1ee804..6ffcb864f465c2a7910452bb54beb48c5a5e7e38 100644 --- a/Graphics/drawContext.h +++ b/Graphics/drawContext.h @@ -145,14 +145,14 @@ class drawContext { void drawAxis(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, int nticks, int mikado); - void drawAxes(int mode, int tics[3], char format[3][256], - char label[3][256], double bb[6], int mikado); - void drawAxes(int mode, int tics[3], char format[3][256], - char label[3][256], SBoundingBox3d &bb, int mikado); + void drawAxes(int mode, int tics[3], std::string format[3], + std::string label[3], double bb[6], int mikado); + void drawAxes(int mode, int tics[3], std::string format[3], + std::string label[3], SBoundingBox3d &bb, int mikado); void drawAxes(); void drawSmallAxes(); void drawScales(); - void drawString(std::string s, const char *font_name, int font_enum, + void drawString(std::string s, std::string &font_name, int font_enum, int font_size, int align); void drawString(std::string s); void drawStringCenter(std::string s); diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index 80789d92579c727b290df160f1d89418ea2211af..74db235e7548faecc451f55fd040104e5adad8ac 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -15,7 +15,7 @@ extern Context_T CTX; -void drawContext::drawString(std::string s, const char *font_name, int font_enum, +void drawContext::drawString(std::string s, std::string &font_name, int font_enum, int font_size, int align) { if(CTX.printing && !CTX.print.text) return; @@ -66,13 +66,13 @@ void drawContext::drawString(std::string s, const char *font_name, int font_enum case 8: opt = GL2PS_TEXT_CR; break; // center right default: opt = GL2PS_TEXT_BL; break; // bottom left } - gl2psTextOpt(tmp.c_str(), font_name, font_size, opt, 0.); + gl2psTextOpt(tmp.c_str(), font_name.c_str(), font_size, opt, 0.); } else if(CTX.print.eps_quality && (CTX.print.format == FORMAT_PS || CTX.print.format == FORMAT_EPS || CTX.print.format == FORMAT_PDF || CTX.print.format == FORMAT_SVG)){ - gl2psText(s.c_str(), font_name, font_size); + gl2psText(s.c_str(), font_name.c_str(), font_size); } else{ gl_font(font_enum, font_size); @@ -108,7 +108,7 @@ void drawContext::drawString(std::string s, double style) int font = (bits>>8 & 0xff); int align = (bits>>16 & 0xff); int font_enum = GetFontEnum(font); - const char *font_name = GetFontName(font); + std::string font_name = GetFontName(font); if(!size) size = CTX.gl_fontsize; drawString(s, font_name, font_enum, size, align); } diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp index 1e6feaeb73977a28fac88d3b402872dd39746c8c..2a6f58847f889fa0e4b9a6cab32d33ef03fdbb4d 100644 --- a/Graphics/drawGraph2d.cpp +++ b/Graphics/drawGraph2d.cpp @@ -181,7 +181,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, int nt = data->getNumTimeSteps(); if((opt->ShowTime == 1 && nt > 1) || opt->ShowTime == 2){ char tmp[256]; - sprintf(tmp, opt->Format, data->getTime(opt->TimeStep)); + sprintf(tmp, opt->Format.c_str(), data->getTime(opt->TimeStep)); sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else if((opt->ShowTime == 3 && nt > 1) || opt->ShowTime == 4){ @@ -196,7 +196,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, ctx->drawStringCenter(label); // x label - sprintf(label, "%s", opt->AxesLabel[0]); + sprintf(label, "%s", opt->AxesLabel[0].c_str()); glRasterPos2d(xleft + width / 2, ytop - height - 2 * font_h - 2 * tic); ctx->drawStringCenter(label); @@ -232,7 +232,8 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, } } if(opt->ShowScale){ - sprintf(label, opt->Format, (i == nb) ? opt->TmpMin : (opt->TmpMax - i * dv)); + sprintf(label, opt->Format.c_str(), (i == nb) ? opt->TmpMin : + (opt->TmpMax - i * dv)); glRasterPos2d(xleft - 2 * tic, ytop - i * dy - font_a / 3.); ctx->drawStringRight(label); } @@ -243,7 +244,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, if(opt->AxesTics[0] > 0){ int nb = opt->AxesTics[0]; if(opt->Axes){ - sprintf(label, opt->AxesFormat[0], - M_PI * 1.e-4); + sprintf(label, opt->AxesFormat[0].c_str(), - M_PI * 1.e-4); if((nb - 1) * gl_width(label) > width) nb = (int)(width / gl_width(label)) + 1; } @@ -277,9 +278,9 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, } if(nb == 1) - sprintf(label, opt->AxesFormat[0], xmin); + sprintf(label, opt->AxesFormat[0].c_str(), xmin); else - sprintf(label, opt->AxesFormat[0], + sprintf(label, opt->AxesFormat[0].c_str(), xmin + i * (xmax - xmin) / (double)(nb - 1)); glRasterPos2d(xleft + i * dx, ybot - font_h - tic); ctx->drawStringCenter(label); @@ -316,7 +317,7 @@ static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, if(numeric){ glRasterPos2d(px + 3, py + 3); char label[256]; - sprintf(label, opt->Format, y); + sprintf(label, opt->Format.c_str(), y); ctx->drawString(label); } else @@ -420,7 +421,7 @@ void drawContext::drawGraph2d() char label[1024]; for(unsigned int i = 0; i < graphs.size(); i++){ PViewOptions *opt = graphs[i]->getOptions(); - sprintf(label, opt->Format, -M_PI * 1.e-4); + sprintf(label, opt->Format.c_str(), -M_PI * 1.e-4); xsep = std::max(xsep, gl_width(label)); } diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp index 6def33887cd45e75d593439e5fa25c248181b4c7..3aec99009ba084d104390c6750a9bc86da5ad77e 100644 --- a/Graphics/drawPost.cpp +++ b/Graphics/drawPost.cpp @@ -1104,7 +1104,8 @@ static void drawVectorArray(drawContext *ctx, PView *p, VertexArray *va) } } -static std::string stringValue(int numComp, double d[9], double norm, char *format) +static std::string stringValue(int numComp, double d[9], double norm, + const char *format) { char label[100]; if(numComp == 1) @@ -1143,9 +1144,9 @@ static void drawNumberGlyphs(drawContext *ctx, PView *p, int numNodes, int numCo glColor4ubv((GLubyte *) & col); glRasterPos3d(pc.x(), pc.y(), pc.z()); if(opt->CenterGlyphs) - ctx->drawStringCenter(stringValue(numComp, d, v, opt->Format)); + ctx->drawStringCenter(stringValue(numComp, d, v, opt->Format.c_str())); else - ctx->drawString(stringValue(numComp, d, v, opt->Format)); + ctx->drawString(stringValue(numComp, d, v, opt->Format.c_str())); } } else if(opt->GlyphLocation == PViewOptions::Vertex){ @@ -1156,9 +1157,9 @@ static void drawNumberGlyphs(drawContext *ctx, PView *p, int numNodes, int numCo glColor4ubv((GLubyte *) & col); glRasterPos3d(xyz[i][0], xyz[i][1], xyz[i][2]); if(opt->CenterGlyphs) - ctx->drawStringCenter(stringValue(numComp, val[i], v, opt->Format)); + ctx->drawStringCenter(stringValue(numComp, val[i], v, opt->Format.c_str())); else - ctx->drawString(stringValue(numComp, val[i], v, opt->Format)); + ctx->drawString(stringValue(numComp, val[i], v, opt->Format.c_str())); } } } diff --git a/Graphics/drawScales.cpp b/Graphics/drawScales.cpp index 3cff148e7b7895995ccd77a9c1f90c6f46e7e011..620f3037d6ec9c3b2f1fb0ccf4a97368b2878e4b 100644 --- a/Graphics/drawScales.cpp +++ b/Graphics/drawScales.cpp @@ -96,7 +96,7 @@ static void drawScaleValues(drawContext *ctx, PView *p, double xmin, double ymin double font_a = gl_height() - gl_descent(); // height above ref pt char label[1024]; - sprintf(label, opt->Format, -M_PI * 1.e-4); + sprintf(label, opt->Format.c_str(), -M_PI * 1.e-4); double maxw = gl_width(label); int nbv = opt->NbIso; @@ -123,7 +123,7 @@ static void drawScaleValues(drawContext *ctx, PView *p, double xmin, double ymin opt->IntervalsType == PViewOptions::Continuous){ for(int i = 0; i < nbv + 1; i++) { double v = opt->getScaleValue(i, nbv + 1, opt->TmpMin, opt->TmpMax); - sprintf(label, opt->Format, v); + sprintf(label, opt->Format.c_str(), v); if(horizontal){ glRasterPos2d(xmin + i * vbox, ymin + height + tic); ctx->drawStringCenter(label); @@ -141,7 +141,7 @@ static void drawScaleValues(drawContext *ctx, PView *p, double xmin, double ymin } for(int i = 0; i < nbv; i++) { double v = opt->getScaleValue(i, nbv, opt->TmpMin, opt->TmpMax); - sprintf(label, opt->Format, v); + sprintf(label, opt->Format.c_str(), v); if(horizontal){ glRasterPos2d(xmin + box / 2. + i * vbox, ymin + height + tic); ctx->drawStringCenter(label); @@ -168,7 +168,7 @@ static void drawScaleLabel(drawContext *ctx, PView *p, double xmin, double ymin, int nt = data->getNumTimeSteps(); if((opt->ShowTime == 1 && nt > 1) || opt->ShowTime == 2){ char tmp[256]; - sprintf(tmp, opt->Format, data->getTime(opt->TimeStep)); + sprintf(tmp, opt->Format.c_str(), data->getTime(opt->TimeStep)); sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else if((opt->ShowTime == 3 && nt > 1) || opt->ShowTime == 4){ @@ -234,7 +234,7 @@ void drawContext::drawScales() double maxw = 0.; for(unsigned int i = 0; i < scales.size(); i++) { PViewOptions *opt = scales[i]->getOptions(); - sprintf(label, opt->Format, -M_PI * 1.e-4); + sprintf(label, opt->Format.c_str(), -M_PI * 1.e-4); maxw = std::max(maxw, gl_width(label)); } @@ -292,11 +292,11 @@ void drawContext::drawScales() } // compute width width_prev = width; - sprintf(label, opt->Format, -M_PI * 1.e-4); + sprintf(label, opt->Format.c_str(), -M_PI * 1.e-4); width = bar_size + tic + gl_width(label); if(opt->ShowTime){ char tmp[256]; - sprintf(tmp, opt->Format, data->getTime(opt->TimeStep)); + sprintf(tmp, opt->Format.c_str(), data->getTime(opt->TimeStep)); sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index 30058f3b1162b4bcd02aa9648bae106129251dee..3394417942a9c9fa406ac7e632e92d0fffb986ec 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -325,9 +325,9 @@ static void PrintMesh2dStatistics(GModel *m) { FILE *statreport = 0; if(CTX.create_append_statreport == 1) - statreport = fopen(CTX.statreport, "w"); + statreport = fopen(CTX.statreport.c_str(), "w"); else if(CTX.create_append_statreport == 2) - statreport = fopen(CTX.statreport, "a"); + statreport = fopen(CTX.statreport.c_str(), "a"); else return; double worst = 1, best = 0, avg = 0; diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 9e1b843065c5534aa793876ca2ff9fd4293f4b7d..11694f8edfc489a359403ca29670c37974eb7a6c 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -4375,18 +4375,18 @@ yyreduce: case 69: #line 752 "Gmsh.y" { - std::string dummy; - StringOption(GMSH_SET|GMSH_GUI, (yyvsp[(1) - (6)].c), 0, (yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].c), dummy); - Free((yyvsp[(1) - (6)].c)); Free((yyvsp[(3) - (6)].c)); + std::string tmp((yyvsp[(5) - (6)].c)); + StringOption(GMSH_SET|GMSH_GUI, (yyvsp[(1) - (6)].c), 0, (yyvsp[(3) - (6)].c), tmp); + Free((yyvsp[(1) - (6)].c)); Free((yyvsp[(3) - (6)].c)); Free((yyvsp[(5) - (6)].c)) ;} break; case 70: #line 758 "Gmsh.y" { - std::string dummy; - StringOption(GMSH_SET|GMSH_GUI, (yyvsp[(1) - (9)].c), (int)(yyvsp[(3) - (9)].d), (yyvsp[(6) - (9)].c), (yyvsp[(8) - (9)].c), dummy); - Free((yyvsp[(1) - (9)].c)); Free((yyvsp[(6) - (9)].c)); + std::string tmp((yyvsp[(8) - (9)].c)); + StringOption(GMSH_SET|GMSH_GUI, (yyvsp[(1) - (9)].c), (int)(yyvsp[(3) - (9)].d), (yyvsp[(6) - (9)].c), tmp); + Free((yyvsp[(1) - (9)].c)); Free((yyvsp[(6) - (9)].c)); Free((yyvsp[(8) - (9)].c)) ;} break; @@ -7735,7 +7735,7 @@ yyreduce: #line 3380 "Gmsh.y" { std::string out; - StringOption(GMSH_GET, (yyvsp[(1) - (3)].c), 0, (yyvsp[(3) - (3)].c), "", out); + StringOption(GMSH_GET, (yyvsp[(1) - (3)].c), 0, (yyvsp[(3) - (3)].c), out); (yyval.c) = (char*)Malloc((out.size() + 1) * sizeof(char)); strcpy((yyval.c), out.c_str()); Free((yyvsp[(1) - (3)].c)); Free((yyvsp[(3) - (3)].c)); @@ -7746,7 +7746,7 @@ yyreduce: #line 3388 "Gmsh.y" { std::string out; - StringOption(GMSH_GET, (yyvsp[(1) - (6)].c), (int)(yyvsp[(3) - (6)].d), (yyvsp[(6) - (6)].c), "", out); + StringOption(GMSH_GET, (yyvsp[(1) - (6)].c), (int)(yyvsp[(3) - (6)].d), (yyvsp[(6) - (6)].c), out); (yyval.c) = (char*)Malloc((out.size() + 1) * sizeof(char)); strcpy((yyval.c), out.c_str()); Free((yyvsp[(1) - (6)].c)); Free((yyvsp[(6) - (6)].c)); diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index f0e52196a8fcd83e54de5768a8f77be1e037f37e..7b652351fba291e340e419eba220d21a62622732 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -750,15 +750,15 @@ Affectation : | tSTRING '.' tSTRING tAFFECT StringExpr tEND { - std::string dummy; - StringOption(GMSH_SET|GMSH_GUI, $1, 0, $3, $5, dummy); - Free($1); Free($3); + std::string tmp($5); + StringOption(GMSH_SET|GMSH_GUI, $1, 0, $3, tmp); + Free($1); Free($3); Free($5) } | tSTRING '[' FExpr ']' '.' tSTRING tAFFECT StringExpr tEND { - std::string dummy; - StringOption(GMSH_SET|GMSH_GUI, $1, (int)$3, $6, $8, dummy); - Free($1); Free($6); + std::string tmp($8); + StringOption(GMSH_SET|GMSH_GUI, $1, (int)$3, $6, tmp); + Free($1); Free($6); Free($8) } // Option Numbers @@ -3379,7 +3379,7 @@ StringExprVar : | tSTRING '.' tSTRING { std::string out; - StringOption(GMSH_GET, $1, 0, $3, "", out); + StringOption(GMSH_GET, $1, 0, $3, out); $$ = (char*)Malloc((out.size() + 1) * sizeof(char)); strcpy($$, out.c_str()); Free($1); Free($3); @@ -3387,7 +3387,7 @@ StringExprVar : | tSTRING '[' FExpr ']' '.' tSTRING { std::string out; - StringOption(GMSH_GET, $1, (int)$3, $6, "", out); + StringOption(GMSH_GET, $1, (int)$3, $6, out); $$ = (char*)Malloc((out.size() + 1) * sizeof(char)); strcpy($$, out.c_str()); Free($1); Free($6); diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp index 04732ef4b796c54f8542c0834f34d56a1bb37472..665cfd609c47b3e256cbf594935903374c9a045e 100644 --- a/Plugin/Annotate.cpp +++ b/Plugin/Annotate.cpp @@ -44,8 +44,8 @@ static double getStyle() { int fontsize = (int)AnnotateOptions_Number[4].def, font = 0, align = 0; #if defined(HAVE_FLTK) - font = GetFontIndex(AnnotateOptions_String[1].def); - align = GetFontAlign(AnnotateOptions_String[2].def); + font = GetFontIndex(AnnotateOptions_String[1].def.c_str()); + align = GetFontAlign(AnnotateOptions_String[2].def.c_str()); #endif return (double)((align<<16)|(font<<8)|(fontsize)); } @@ -115,14 +115,14 @@ double GMSH_AnnotatePlugin::callback(int num, int action, double value, double * return 0.; } -const char *GMSH_AnnotatePlugin::callbackStr(int num, int action, const char *value, - const char **opt) +std::string GMSH_AnnotatePlugin::callbackStr(int num, int action, std::string value, + std::string &opt) { - *opt = value; + opt = value; #if defined(HAVE_FLTK) DrawPlugin(draw); #endif - return NULL; + return opt; } double GMSH_AnnotatePlugin::callbackX(int num, int action, double value) @@ -167,19 +167,19 @@ double GMSH_AnnotatePlugin::callbackFontSize(int num, int action, double value) 1, 5, 100); } -const char *GMSH_AnnotatePlugin::callbackText(int num, int action, const char *value) +std::string GMSH_AnnotatePlugin::callbackText(int num, int action, std::string value) { - return callbackStr(num, action, value, &AnnotateOptions_String[0].def); + return callbackStr(num, action, value, AnnotateOptions_String[0].def); } -const char *GMSH_AnnotatePlugin::callbackFont(int num, int action, const char *value) +std::string GMSH_AnnotatePlugin::callbackFont(int num, int action, std::string value) { - return callbackStr(num, action, value, &AnnotateOptions_String[1].def); + return callbackStr(num, action, value, AnnotateOptions_String[1].def); } -const char *GMSH_AnnotatePlugin::callbackAlign(int num, int action, const char *value) +std::string GMSH_AnnotatePlugin::callbackAlign(int num, int action, std::string value) { - return callbackStr(num, action, value, &AnnotateOptions_String[2].def); + return callbackStr(num, action, value, AnnotateOptions_String[2].def); } void GMSH_AnnotatePlugin::getName(char *name) const @@ -238,7 +238,7 @@ PView *GMSH_AnnotatePlugin::execute(PView *v) double Z = AnnotateOptions_Number[2].def; int dim3 = (int)AnnotateOptions_Number[3].def; int iView = (int)AnnotateOptions_Number[5].def; - const char *text = AnnotateOptions_String[0].def; + const char *text = AnnotateOptions_String[0].def.c_str(); double style = getStyle(); PView *v1 = getView(iView, v); diff --git a/Plugin/Annotate.h b/Plugin/Annotate.h index f5212d707dec02b4abfdb2fe2d20c5532d1c42cc..5ae512f4415a34ac14be4db2acdb43685a70f8fc 100644 --- a/Plugin/Annotate.h +++ b/Plugin/Annotate.h @@ -6,6 +6,7 @@ #ifndef _ANNOTATE_H_ #define _ANNOTATE_H_ +#include <string> #include "Plugin.h" extern "C" @@ -18,7 +19,8 @@ class GMSH_AnnotatePlugin : public GMSH_Post_Plugin private: static double callback(int num, int action, double value, double *opt, double step, double min, double max); - static const char *callbackStr(int num, int action, const char *value, const char **opt); + static std::string callbackStr(int num, int action, std::string value, + std::string &opt); public: GMSH_AnnotatePlugin(){} void getName(char *name) const; @@ -35,9 +37,9 @@ public: static double callbackZ(int, int, double); static double callback3D(int, int, double); static double callbackFontSize(int, int, double); - static const char *callbackText(int, int, const char *); - static const char *callbackFont(int, int, const char *); - static const char *callbackAlign(int, int, const char *); + static std::string callbackText(int, int, std::string); + static std::string callbackFont(int, int, std::string); + static std::string callbackAlign(int, int, std::string); static void draw(void *context); }; diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp index 75bbc159cc5e67518d3d0ee92745198cd62e35ad..349b98db9fdcd60d494cd406b50fbf61f2d8b521 100644 --- a/Plugin/CutParametric.cpp +++ b/Plugin/CutParametric.cpp @@ -66,9 +66,9 @@ int GMSH_CutParametricPlugin::fillXYZ() Msg::Error("MathEval is not compiled in this version of Gmsh"); return 0; #else - const char *exprx = CutParametricOptions_String[0].def; - const char *expry = CutParametricOptions_String[1].def; - const char *exprz = CutParametricOptions_String[2].def; + const char *exprx = CutParametricOptions_String[0].def.c_str(); + const char *expry = CutParametricOptions_String[1].def.c_str(); + const char *exprz = CutParametricOptions_String[2].def.c_str(); int nbU = (int)CutParametricOptions_Number[2].def; x.resize(nbU); @@ -144,15 +144,15 @@ double GMSH_CutParametricPlugin::callback(int num, int action, double value, dou return 0.; } -const char *GMSH_CutParametricPlugin::callbackStr(int num, int action, const char *value, - const char **opt) +std::string GMSH_CutParametricPlugin::callbackStr(int num, int action, std::string value, + std::string &opt) { - *opt = value; + opt = value; #if defined(HAVE_FLTK) recompute = 1; DrawPlugin(draw); #endif - return NULL; + return opt; } double GMSH_CutParametricPlugin::callbackMinU(int num, int action, double value) @@ -179,19 +179,19 @@ double GMSH_CutParametricPlugin::callbackConnect(int num, int action, double val 1, 0, 1); } -const char *GMSH_CutParametricPlugin::callbackX(int num, int action, const char *value) +std::string GMSH_CutParametricPlugin::callbackX(int num, int action, std::string value) { - return callbackStr(num, action, value, &CutParametricOptions_String[0].def); + return callbackStr(num, action, value, CutParametricOptions_String[0].def); } -const char *GMSH_CutParametricPlugin::callbackY(int num, int action, const char *value) +std::string GMSH_CutParametricPlugin::callbackY(int num, int action, std::string value) { - return callbackStr(num, action, value, &CutParametricOptions_String[1].def); + return callbackStr(num, action, value, CutParametricOptions_String[1].def); } -const char *GMSH_CutParametricPlugin::callbackZ(int num, int action, const char *value) +std::string GMSH_CutParametricPlugin::callbackZ(int num, int action, std::string value) { - return callbackStr(num, action, value, &CutParametricOptions_String[2].def); + return callbackStr(num, action, value, CutParametricOptions_String[2].def); } void GMSH_CutParametricPlugin::getName(char *name) const diff --git a/Plugin/CutParametric.h b/Plugin/CutParametric.h index e69b33c057553a0068919afa818415e9c54407e6..cfe3a4494d1dd0b749a8d3f44974d897f378d5ca 100644 --- a/Plugin/CutParametric.h +++ b/Plugin/CutParametric.h @@ -6,6 +6,7 @@ #ifndef _CUT_PARAMETRIC_H_ #define _CUT_PARAMETRIC_H_ +#include <string> #include <vector> #include "Plugin.h" @@ -19,8 +20,8 @@ class GMSH_CutParametricPlugin : public GMSH_Post_Plugin private: static double callback(int num, int action, double value, double *opt, double step, double min, double max); - static const char *callbackStr(int num, int action, const char *value, - const char **opt); + static std::string callbackStr(int num, int action, std::string value, + std::string &opt); static int fillXYZ(); static int recompute; static std::vector<double> x, y, z; @@ -39,9 +40,9 @@ public: static double callbackMaxU(int, int, double); static double callbackN(int, int, double); static double callbackConnect(int, int, double); - static const char *callbackX(int, int, const char *); - static const char *callbackY(int, int, const char *); - static const char *callbackZ(int, int, const char *); + static std::string callbackX(int, int, std::string); + static std::string callbackY(int, int, std::string); + static std::string callbackZ(int, int, std::string); static void draw(void *context); }; diff --git a/Plugin/Evaluate.cpp b/Plugin/Evaluate.cpp index 91c3f7cf8e3132e0099a934a95b1fee032184eb8..a6fa85999469af2772a180389f0458ed09b5c023 100644 --- a/Plugin/Evaluate.cpp +++ b/Plugin/Evaluate.cpp @@ -202,7 +202,7 @@ PView *GMSH_EvaluatePlugin::execute(PView *v) int externalView = (int)EvaluateOptions_Number[2].def; int externalTimeStep = (int)EvaluateOptions_Number[3].def; int iView = (int)EvaluateOptions_Number[4].def; - const char *expr = EvaluateOptions_String[0].def; + const char *expr = EvaluateOptions_String[0].def.c_str(); PView *v1 = getView(iView, v); if(!v1) return v; diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp index 30f11b296dba4cb350c9ef43c5f61dfe81e1b1d8..df92ea29cd7e763b8ae8f395cee658b89e806e53 100644 --- a/Plugin/Extract.cpp +++ b/Plugin/Extract.cpp @@ -206,15 +206,15 @@ PView *GMSH_ExtractPlugin::execute(PView *v) { int step = (int)ExtractOptions_Number[0].def; int iView = (int)ExtractOptions_Number[1].def; - const char *expr[9] = { ExtractOptions_String[0].def, - ExtractOptions_String[1].def, - ExtractOptions_String[2].def, - ExtractOptions_String[3].def, - ExtractOptions_String[4].def, - ExtractOptions_String[5].def, - ExtractOptions_String[6].def, - ExtractOptions_String[7].def, - ExtractOptions_String[8].def }; + const char *expr[9] = { ExtractOptions_String[0].def.c_str(), + ExtractOptions_String[1].def.c_str(), + ExtractOptions_String[2].def.c_str(), + ExtractOptions_String[3].def.c_str(), + ExtractOptions_String[4].def.c_str(), + ExtractOptions_String[5].def.c_str(), + ExtractOptions_String[6].def.c_str(), + ExtractOptions_String[7].def.c_str(), + ExtractOptions_String[8].def.c_str() }; PView *v1 = getView(iView, v); if(!v1) return v; diff --git a/Plugin/GSHHS.cpp b/Plugin/GSHHS.cpp index 25b2803fc9ab75a489b628d89bb8da619626f8e5..ee055f22376eb5159d581b41055efd0cb98d7193 100644 --- a/Plugin/GSHHS.cpp +++ b/Plugin/GSHHS.cpp @@ -51,7 +51,7 @@ class GMSH_GSHHSPlugin:public GMSH_Post_Plugin } }; class reader_gshhs:public reader{ - /* $Id: GSHHS.cpp,v 1.24 2009-01-19 11:57:29 remacle Exp $ + /* $Id: GSHHS.cpp,v 1.25 2009-01-30 21:37:43 geuzaine Exp $ * * Include file defining structures used in gshhs.c * @@ -920,8 +920,8 @@ PView *GMSH_GSHHSPlugin::execute(PView * v) { void projector(SPoint2,SPoint3); int iField = (int)GSHHSOptions_Number[0].def; - char *filename = (char *)GSHHSOptions_String[0].def; - char *outfilename = (char *)GSHHSOptions_String[1].def; + char *filename = (char *)GSHHSOptions_String[0].def.c_str(); + char *outfilename = (char *)GSHHSOptions_String[1].def.c_str(); std::string format(GSHHSOptions_String[2].def); std::string coordinate_name(GSHHSOptions_String[3].def); int utm_zone=(int)GSHHSOptions_Number[1].def; diff --git a/Post/PView.cpp b/Post/PView.cpp index 8f6509ad510c1dd7c7e8db9c0970bef5687d46a2..c995774715de4a4c1aa4530d20d6edc6190b6b65 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -90,7 +90,7 @@ PView::PView(std::string xname, std::string yname, _options = new PViewOptions(PViewOptions::reference); _options->Type = PViewOptions::Plot2DSpace; _options->Axes = 2; - strcpy(_options->AxesLabel[0], xname.c_str()); + _options->AxesLabel[0] = xname; } PView::PView(std::string name, std::string type, diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index 7c9189e2ef313e15af164f5f88647fbd590edbac..9493620e15e5fa3f0d0360095252e30065c6c805 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -318,17 +318,16 @@ bool PViewDataList::writePOS(std::string fileName, bool binary, bool parsed, boo fprintf(fp, "$EndPostFormat\n"); } - char str[256]; - strcpy(str, getName().c_str()); - for(int i = 0; i < (int)strlen(str); i++) + std::string str = getName(); + for(unsigned int i = 0; i < str.size(); i++) if(str[i] == ' ') str[i] = '^'; if(!parsed){ fprintf(fp, "$View /* %s */\n", getName().c_str()); - if (strlen(str) == 0) + if (str.empty()) fprintf(fp, "noname "); else - fprintf(fp, "%s ", str); + fprintf(fp, "%s ", str.c_str()); fprintf(fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " "%d %d %d %d %d %d %d %d %d %d %d %d\n", List_Nbr(Time), diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp index bbe16a7d3deaf701a4d8027a163fd9de2080c531..f42412efb302b219bfa4e1ea2d8ca0c949496bcc 100644 --- a/Post/PViewOptions.cpp +++ b/Post/PViewOptions.cpp @@ -113,11 +113,11 @@ void PViewOptions::createGeneralRaise() { destroyGeneralRaise(); - char *expr[3] = {GenRaiseX, GenRaiseY, GenRaiseZ}; + const char *expr[3] = {GenRaiseX.c_str(), GenRaiseY.c_str(), GenRaiseZ.c_str()}; #if defined(HAVE_MATH_EVAL) for(int i = 0; i < 3; i++) { if(strlen(expr[i])) { - if(!(GenRaise_f[i] = evaluator_create(expr[i]))) + if(!(GenRaise_f[i] = evaluator_create((char*)expr[i]))) Msg::Error("Invalid expression '%s'", expr[i]); } } diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index bf8eb7c6e398a3860e1a19ec2d01f4b801ff79a7..7332cfe572bd4cf2fa10a5d393226022be86b760 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -51,9 +51,9 @@ class PViewOptions { int Type; int Position[2], Size[2], AutoPosition; - char Format[256]; + std::string Format; int Axes, AxesAutoPosition, AxesMikado, AxesTics[3]; - char AxesFormat[3][256], AxesLabel[3][256]; + std::string AxesFormat[3], AxesLabel[3]; double AxesPosition[6]; double CustomMin, CustomMax, TmpMin, TmpMax, ExternalMin, ExternalMax; SBoundingBox3d TmpBBox; @@ -77,11 +77,11 @@ class PViewOptions { double PointSize, LineWidth; GmshColorTable CT; int UseStipple, Stipple[10][2]; - char StippleString[10][32]; + std::string StippleString[10]; int ExternalViewIndex, ViewIndexForGenRaise; int UseGenRaise; double GenRaiseFactor; - char GenRaiseX[256], GenRaiseY[256], GenRaiseZ[256]; + std::string GenRaiseX, GenRaiseY, GenRaiseZ; void *GenRaise_f[3]; int AdaptVisualizationGrid, MaxRecursionLevel; double TargetError;