From 36696e0068bdddbcbb8340e5189dd8d8ba1c04f0 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 9 Nov 2008 08:41:20 +0000 Subject: [PATCH] *** empty log message *** --- Common/CommandLine.cpp | 105 +++++++++++++++++------------------------ Common/CommandLine.h | 7 +-- Common/StringUtils.cpp | 11 +++++ Common/StringUtils.h | 2 + Fltk/GUI.cpp | 29 ++++-------- Fltk/Main.cpp | 10 ++-- Fltk/Makefile | 2 +- 7 files changed, 73 insertions(+), 93 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index b6e7cfe517..093c38cd58 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.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 <stdlib.h> #include "GmshUI.h" @@ -30,35 +31,11 @@ extern Context_T CTX; -char gmsh_progname[] = "Gmsh, a 3D mesh generator with pre- and post-processing facilities" ; -char gmsh_copyright[] = "Copyright (C) 1997-2008 Christophe Geuzaine and Jean-Francois Remacle"; -char gmsh_version[] = "Version : " ; -char gmsh_license[] = "License : " GMSH_SHORT_LICENSE; -char gmsh_gui[] = "GUI toolkit : " ; -char gmsh_os[] = "Build OS : " GMSH_OS ; -char gmsh_options[] = "Build options : " ; -char gmsh_date[] = "Build date : " GMSH_DATE ; -char gmsh_host[] = "Build host : " GMSH_HOST ; -char gmsh_packager[] = "Packager : " GMSH_PACKAGER ; -char gmsh_url[] = "Web site : http://www.geuz.org/gmsh/" ; -char gmsh_email[] = "Mailing list : gmsh@geuz.org" ; - -int Get_GmshMajorVersion(){ return GMSH_MAJOR_VERSION; } -int Get_GmshMinorVersion(){ return GMSH_MINOR_VERSION; } -int Get_GmshPatchVersion(){ return GMSH_PATCH_VERSION; } -const char *Get_GmshExtraVersion(){ return GMSH_EXTRA_VERSION; } -const char *Get_GmshVersion(){ return GMSH_VERSION; } -const char *Get_GmshBuildDate(){ return GMSH_DATE; } -const char *Get_GmshBuildHost(){ return GMSH_HOST; } -const char *Get_GmshPackager(){ return GMSH_PACKAGER; } -const char *Get_GmshBuildOS(){ return GMSH_OS; } -const char *Get_GmshShortLicense(){ return GMSH_SHORT_LICENSE; } - void Print_Usage(const char *name) { // If you make changes in this routine, please also change the - // texinfo documentation (doc/texinfo/command_line.texi) as well as - // the man page (doc/gmsh.1) + // texinfo documentation (doc/texinfo/command_line.texi) and the man + // page (doc/gmsh.1) Msg::Direct("Usage: %s [options] [files]", name); Msg::Direct("Geometry options:"); Msg::Direct(" -0 Output unrolled geometry, then exit"); @@ -113,56 +90,61 @@ void Print_Usage(const char *name) Msg::Direct(" -help Show this message"); } -char *Get_BuildOptions(void) +int Get_GmshMajorVersion(){ return GMSH_MAJOR_VERSION; } +int Get_GmshMinorVersion(){ return GMSH_MINOR_VERSION; } +int Get_GmshPatchVersion(){ return GMSH_PATCH_VERSION; } +const char *Get_GmshExtraVersion(){ return GMSH_EXTRA_VERSION; } +const char *Get_GmshVersion(){ return GMSH_VERSION; } +const char *Get_GmshBuildDate(){ return GMSH_DATE; } +const char *Get_GmshBuildHost(){ return GMSH_HOST; } +const char *Get_GmshPackager(){ return GMSH_PACKAGER; } +const char *Get_GmshBuildOS(){ return GMSH_OS; } +const char *Get_GmshShortLicense(){ return GMSH_SHORT_LICENSE; } +std::string Get_GmshBuildOptions() { - static int first = 1; - static char opt[256] = ""; - - if(first){ + std::string opt; #if defined(HAVE_GSL) - strcat(opt, "GSL "); + opt += "GSL "; #endif #if defined(HAVE_NETGEN) - strcat(opt, "NETGEN "); + opt += "NETGEN "; #endif #if defined(HAVE_TETGEN) - strcat(opt, "TETGEN "); + opt += "TETGEN "; #endif #if defined(HAVE_LIBJPEG) - strcat(opt, "JPEG "); + opt += "JPEG "; #endif #if defined(HAVE_LIBPNG) - strcat(opt, "PNG "); + opt += "PNG "; #endif #if defined(HAVE_LIBZ) - strcat(opt, "ZLIB "); + opt += "ZLIB "; #endif #if defined(HAVE_MATH_EVAL) - strcat(opt, "MATHEVAL "); + opt += "MATHEVAL "; #endif #if defined(HAVE_METIS) - strcat(opt, "METIS "); + opt += "METIS "; #endif #if defined(HAVE_CHACO) - strcat(opt, "CHACO "); + opt += "CHACO "; #endif #if defined(HAVE_ANN) - strcat(opt, "ANN "); + opt += "ANN "; #endif #if defined(HAVE_CGNS) - strcat(opt, "CGNS "); + opt += "CGNS "; #endif #if defined(HAVE_OCC) - strcat(opt, "OCC "); + opt += "OCC "; #endif #if defined(HAVE_MED) - strcat(opt, "MED "); + opt += "MED "; #endif #if defined(HAVE_GMM) - strcat(opt, "GMM++ "); + opt += "GMM++ "; #endif - first = 0; - } return opt; } @@ -381,7 +363,8 @@ void Get_Options(int argc, char *argv[]) if(argv[i] != NULL) { 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)", CTX.mesh.tolerance_edge_length); + Msg::Fatal("Tolerance for model edge length must be > 0 (here %g)", + CTX.mesh.tolerance_edge_length); } else Msg::Fatal("Missing number"); @@ -521,26 +504,26 @@ void Get_Options(int argc, char *argv[]) Msg::Exit(0); } else if(!strcmp(argv[i] + 1, "info") || !strcmp(argv[i] + 1, "-info")) { - fprintf(stderr, "%s%s\n", gmsh_version, GMSH_VERSION); + fprintf(stderr, "Version : %s\n", GMSH_VERSION); #if defined(HAVE_FLTK) - fprintf(stderr, "%sFLTK %d.%d.%d\n", gmsh_gui, FL_MAJOR_VERSION, + fprintf(stderr, "GUI toolkit : FLTK %d.%d.%d\n", FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); #else - fprintf(stderr, "%snone\n", gmsh_gui); + fprintf(stderr, "GUI toolkit : none\n"); #endif - fprintf(stderr, "%s\n", gmsh_license); - fprintf(stderr, "%s\n", gmsh_os); - fprintf(stderr, "%s%s\n", gmsh_options, Get_BuildOptions()); - fprintf(stderr, "%s\n", gmsh_date); - fprintf(stderr, "%s\n", gmsh_host); - fprintf(stderr, "%s\n", gmsh_packager); - fprintf(stderr, "%s\n", gmsh_url); - fprintf(stderr, "%s\n", gmsh_email); + fprintf(stderr, "License : %s\n", GMSH_SHORT_LICENSE); + fprintf(stderr, "Build OS : %s\n", GMSH_OS); + fprintf(stderr, "Build options : %s\n", Get_GmshBuildOptions().c_str()); + fprintf(stderr, "Build date : %s\n", GMSH_DATE); + fprintf(stderr, "Build host : %s\n", GMSH_HOST); + fprintf(stderr, "Packager : %s\n", GMSH_PACKAGER); + fprintf(stderr, "Web site : http://www.geuz.org/gmsh/\n"); + fprintf(stderr, "Mailing list : gmsh@geuz.org\n"); Msg::Exit(0); } else if(!strcmp(argv[i] + 1, "help") || !strcmp(argv[i] + 1, "-help")) { - fprintf(stderr, "%s\n", gmsh_progname); - fprintf(stderr, "%s\n", gmsh_copyright); + fprintf(stderr, "Gmsh, a 3D mesh generator with pre- and post-processing facilities\n"); + fprintf(stderr, "Copyright (C) 1997-2008 Christophe Geuzaine and Jean-Francois Remacle\n"); Print_Usage(argv[0]); Msg::Exit(0); } diff --git a/Common/CommandLine.h b/Common/CommandLine.h index d2299eb242..9afed6db41 100644 --- a/Common/CommandLine.h +++ b/Common/CommandLine.h @@ -6,15 +6,11 @@ #ifndef _COMMAND_LINE_H_ #define _COMMAND_LINE_H_ -extern char gmsh_progname[], gmsh_copyright[], gmsh_version[], gmsh_os[]; -extern char gmsh_date[], gmsh_host[], gmsh_packager[], gmsh_url[]; -extern char gmsh_email[], gmsh_gui[], gmsh_options[], gmsh_license[]; +#include <string> void Get_Options(int argc, char *argv[]); void Print_Usage(const char *name); -char *Get_BuildOptions(); - int Get_GmshMajorVersion(); int Get_GmshMinorVersion(); int Get_GmshPatchVersion(); @@ -25,5 +21,6 @@ const char *Get_GmshBuildHost(); const char *Get_GmshPackager(); const char *Get_GmshBuildOS(); const char *Get_GmshShortLicense(); +std::string Get_GmshBuildOptions(); #endif diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index c56eae50b1..af8a6767fc 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -90,3 +90,14 @@ void SplitFileName(const char *name, char *no_ext, char *ext, char *base) } } } + +std::vector<std::string> SplitWhiteSpace(std::string in, int len) +{ + std::vector<std::string> out(1); + for(unsigned int i = 0; i < in.size(); i++){ + out.back() += in[i]; + if(out.back().size() > len && in[i] == ' ') + out.resize(out.size() + 1); + } + return out; +} diff --git a/Common/StringUtils.h b/Common/StringUtils.h index 66c543bb8a..b65bfce3c4 100644 --- a/Common/StringUtils.h +++ b/Common/StringUtils.h @@ -8,11 +8,13 @@ #include <string.h> #include <string> +#include <vector> void SwapBytes(char *array, int size, int n); std::string ExtractDoubleQuotedString(const char *str, int len); std::string SanitizeTeXString(const char *in, int equation); std::string FixWindowsPath(const char *in); void SplitFileName(const char *name, char *no_ext, char *ext, char *base); +std::vector<std::string> SplitWhiteSpace(std::string in, int len); #endif diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 1ade4671f5..4fcef5fe72 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -28,6 +28,7 @@ #include "Field.h" #include "GModel.h" #include "GeoStringInterface.h" +#include "StringUtils.h" #define NB_BUTT_SCROLL 25 #define NB_HISTORY_MAX 1000 @@ -4808,27 +4809,13 @@ void GUI::create_about_window() o->add(buffer); sprintf(buffer, "@c@.Build host: %s", Get_GmshBuildHost()); o->add(buffer); - { - char str1[1024]; - strcpy(str1, Get_BuildOptions()); - unsigned int len = 30; - if(strlen(str1) > len){ - int split; - for(split = len - 1; split >= 0; split--){ - if(str1[split] == ' '){ - str1[split] = '\0'; - break; - } - } - sprintf(buffer, "@c@.Build options: %s", str1); - o->add(buffer); - sprintf(buffer, "@c@.%s", &str1[split+1]); - o->add(buffer); - } - else{ - sprintf(buffer, "@c@.Options: %s", str1); - o->add(buffer); - } + std::vector<std::string> lines = SplitWhiteSpace(Get_GmshBuildOptions(), 30); + for(unsigned int i = 0; i < lines.size(); i++){ + if(!i) + sprintf(buffer, "@c@.Build options: %s", lines[i].c_str()); + else + sprintf(buffer, "@c@.%s", lines[i].c_str()); + o->add(buffer); } sprintf(buffer, "@c@.Packaged by: %s", Get_GmshPackager()); o->add(buffer); diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 378a40c116..f14a3525df 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -86,11 +86,11 @@ int main(int argc, char *argv[]) // Log the following for bug reports Msg::Info("-------------------------------------------------------"); Msg::Info("Gmsh version : %s", Get_GmshVersion()); - Msg::Info(gmsh_os); - Msg::Info("%s%s", gmsh_options, Get_BuildOptions()); - Msg::Info(gmsh_date); - Msg::Info(gmsh_host); - Msg::Info(gmsh_packager); + Msg::Info("Build OS : %s", Get_GmshBuildOS()); + Msg::Info("Build options : %s", Get_GmshBuildOptions().c_str()); + Msg::Info("Build date : %s", Get_GmshBuildDate()); + Msg::Info("Build host : %s", Get_GmshBuildHost()); + Msg::Info("Packager : %s", Get_GmshPackager()); Msg::Info("Home directory : %s", CTX.home_dir); Msg::Info("Launch date : %s", currtime.c_str()); Msg::Info("Command line : %s", cmdline.c_str()); diff --git a/Fltk/Makefile b/Fltk/Makefile index b80141eee7..b091e146d5 100644 --- a/Fltk/Makefile +++ b/Fltk/Makefile @@ -89,7 +89,7 @@ GUI.o: GUI.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \ ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \ ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/GeoStringInterface.h \ - ../Common/GmshSocket.h + ../Common/StringUtils.h ../Common/GmshSocket.h GUI_Extras.o: GUI_Extras.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \ ../Common/CreateFile.h ../Common/Options.h ../Post/ColorTable.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \ -- GitLab