diff --git a/Common/GetOptions.cpp b/Common/GetOptions.cpp index e45422bcd1b09ba4640f13ac2b37b0b61da5d1e1..5c9a1769cf9b3239ab48d95981864a5d7ab6a6b9 100644 --- a/Common/GetOptions.cpp +++ b/Common/GetOptions.cpp @@ -1,5 +1,6 @@ -// $Id: GetOptions.cpp,v 1.28 2001-06-29 07:27:16 geuzaine Exp $ +// $Id: GetOptions.cpp,v 1.29 2001-07-08 15:45:47 geuzaine Exp $ +#include <unistd.h> #include "Gmsh.h" #include "GmshUI.h" #include "GmshVersion.h" @@ -10,11 +11,12 @@ #include "Mesh.h" #include "Views.h" #include "OpenFile.h" +#include "Parser.h" extern Context_T CTX; char *TheFileNameTab[MAX_OPEN_FILES]; -char *TheBgmFileName=NULL; +char *TheBgmFileName=NULL, *TheOptString=NULL; char gmsh_progname[] = "This is Gmsh" ; char gmsh_copyright[] = "Copyright (C) 1997-2001 Jean-Francois Remacle and Christophe Geuzaine"; @@ -77,6 +79,7 @@ void Print_Usage(char *name){ #ifdef _XMOTIF Msg(DIRECT, " -nothreads disable threads"); #endif + Msg(DIRECT, " -opt \"string\" parse string before project file"); Msg(DIRECT, " -version show version number"); Msg(DIRECT, " -info show detailed version information"); Msg(DIRECT, " -help show this message"); @@ -88,6 +91,9 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { // Parse session and option files + InitSymbols(); //this symbol context is local to option parsing (the + //symbols will not interfere with subsequent OpenFiles) + ParseFile(CTX.sessionrc_filename); ParseFile(CTX.optionsrc_filename); @@ -100,7 +106,15 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { if (argv[i][0] == '-') { - if(!strcmp(argv[i]+1, "a")){ + if(!strcmp(argv[i]+1, "opt")){ + i++; + if(argv[i]!=NULL) TheOptString = argv[i++]; + else{ + fprintf(stderr, ERROR_STR "Missing string\n"); + exit(1); + } + } + else if(!strcmp(argv[i]+1, "a")){ CTX.initial_context = 0; i++; } else if(!strcmp(argv[i]+1, "g")){ diff --git a/Common/GetOptions.h b/Common/GetOptions.h index ef63b0b98a0fccbbf812fbf6ee05bae0067a903d..d5ded2855cf26bf46770dc7889cdc6bf679631b4 100644 --- a/Common/GetOptions.h +++ b/Common/GetOptions.h @@ -5,7 +5,7 @@ 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[]; -extern char *TheFileNameTab[MAX_OPEN_FILES], *TheBgmFileName; +extern char *TheFileNameTab[MAX_OPEN_FILES], *TheBgmFileName, *TheOptString; void Get_Options(int argc, char *argv[], int *nbfiles); void Print_Usage(char *name); diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp index 63b75a257acdc584616d5d2a3bb311e3fbde7576..f12be1be99cb17a94b90f020db766c656cb8fdc9 100644 --- a/Fltk/Message.cpp +++ b/Fltk/Message.cpp @@ -1,5 +1,6 @@ -// $Id: Message.cpp,v 1.21 2001-05-25 14:27:20 geuzaine Exp $ +// $Id: Message.cpp,v 1.22 2001-07-08 15:45:47 geuzaine Exp $ +#include <unistd.h> #include <signal.h> #if !defined(WIN32) || defined(__CYGWIN__) #include <sys/resource.h> @@ -158,6 +159,7 @@ void Exit(int level){ if(CTX.options_save) Print_Options(0, GMSH_OPTIONSRC, CTX.optionsrc_filename); } + unlink(CTX.tmp_filename);//delete temp file exit(level); } diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index b664d465a750a60b63875c6f205e59ababe69853..64b42604eb93a539d664a482dd84841047465993 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -169,7 +169,7 @@ #line 1 "Gmsh.y" -// $Id: Gmsh.tab.cpp,v 1.89 2001-06-03 11:25:09 geuzaine Exp $ +// $Id: Gmsh.tab.cpp,v 1.90 2001-07-08 15:45:47 geuzaine Exp $ // // Generaliser sprintf avec des chaines de caracteres @@ -202,7 +202,7 @@ #include <alloca.h> #endif -List_T *Symbol_L; +List_T *Symbol_L=NULL; extern Context_T CTX; extern Mesh *THEM; @@ -5871,7 +5871,10 @@ yyerrhandle: void InitSymbols(void){ - Symbol_L = List_Create(10,1,sizeof(Symbol)); + if(!Symbol_L) + Symbol_L = List_Create(50,10,sizeof(Symbol)); + else + List_Reset(Symbol_L); } void DeleteSymbols(void){ diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 395a2df2dc2c288c90366c4a6c6f099375de72d0..ca92084c653f8f8c05d1491f2f34365d9d72b12e 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1,6 +1,6 @@ %{ -// $Id: Gmsh.y,v 1.78 2001-06-03 11:21:36 geuzaine Exp $ +// $Id: Gmsh.y,v 1.79 2001-07-08 15:45:48 geuzaine Exp $ // // Generaliser sprintf avec des chaines de caracteres @@ -33,7 +33,7 @@ #include <alloca.h> #endif -List_T *Symbol_L; +List_T *Symbol_L=NULL; extern Context_T CTX; extern Mesh *THEM; @@ -2518,7 +2518,10 @@ StringExpr : %% void InitSymbols(void){ - Symbol_L = List_Create(10,1,sizeof(Symbol)); + if(!Symbol_L) + Symbol_L = List_Create(50,10,sizeof(Symbol)); + else + List_Reset(Symbol_L); } void DeleteSymbols(void){ diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp index 93f5746826cf2e55b7cc4123f6d38712689a09da..23dd6c55802f75cfe88c95ac63285d53104e734e 100644 --- a/Parser/Gmsh.yy.cpp +++ b/Parser/Gmsh.yy.cpp @@ -2,7 +2,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.89 2001-06-03 11:25:09 geuzaine Exp $ + * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.90 2001-07-08 15:45:48 geuzaine Exp $ */ #define FLEX_SCANNER @@ -978,7 +978,7 @@ char *yytext; #define INITIAL 0 #line 2 "Gmsh.l" -// $Id: Gmsh.yy.cpp,v 1.89 2001-06-03 11:25:09 geuzaine Exp $ +// $Id: Gmsh.yy.cpp,v 1.90 2001-07-08 15:45:48 geuzaine Exp $ #include <stdio.h> #include <stdlib.h> diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 5a9d5b2b25980116a48c33a2c937467b750833e3..403a640d562705aab82681c5359efe60966586e5 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,9 +1,10 @@ -// $Id: OpenFile.cpp,v 1.17 2001-05-29 13:49:32 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.18 2001-07-08 15:45:48 geuzaine Exp $ #include "Gmsh.h" #include "Const.h" #include "Context.h" #include "Parser.h" #include "OpenFile.h" +#include "GetOptions.h" #include "Geo.h" #include "Mesh.h" #include "Views.h" @@ -72,6 +73,17 @@ int ParseFile(char *f){ return status; } + +void ParseString(char *str){ + FILE *f; + if(!str)return; + if((f = fopen(CTX.tmp_filename,"w"))){ + fprintf(f,"%s\n", str); + fclose(f); + ParseFile(CTX.tmp_filename); + } +} + void MergeProblem(char *name){ ParseFile(name); @@ -98,6 +110,8 @@ void OpenProblem(char *name){ InitSymbols(); Init_Mesh(&M, 1); + ParseString(TheOptString); + strncpy(CTX.filename,name,NAME_STR_L); strncpy(CTX.base_filename,name,NAME_STR_L); diff --git a/Parser/OpenFile.h b/Parser/OpenFile.h index 0cddf0bb8585a46ebc713ba522ba21a6d140046e..add2da5ef0bcd417731a401ab7cfcac62d36a186 100644 --- a/Parser/OpenFile.h +++ b/Parser/OpenFile.h @@ -4,6 +4,7 @@ #include "Const.h" int ParseFile(char *filename); +void ParseString(char *str); void OpenProblem(char *filename); void MergeProblem(char *filename); diff --git a/doc/VERSIONS b/doc/VERSIONS index a68c32550aa8cdcaa11905c2a1baa2ac729b18c4..8561ebbd6bd76722279907776b8b13fe1d0c7c17 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,7 @@ -$Id: VERSIONS,v 1.26 2001-06-28 07:53:32 geuzaine Exp $ +$Id: VERSIONS,v 1.27 2001-07-08 15:45:48 geuzaine Exp $ + +New in 1.21: Fixed more memory leaks; added -opt command line option +to parse definitions directly from the command line; New in 1.20: Fixed various bugs (memory leaks, functions in included files, solver command selection, ColorTable option, duplicate nodes in