Skip to content
Snippets Groups Projects
Commit d35e9eb3 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Clean up recursive list code

Clean up stringb expressions
parent 0d6c2723
No related branches found
No related tags found
No related merge requests found
// $Id: CreateFile.cpp,v 1.19 2001-06-06 08:47:48 geuzaine Exp $
// $Id: CreateFile.cpp,v 1.20 2001-07-25 13:11:07 geuzaine Exp $
#include "Gmsh.h"
#include "GmshUI.h"
......@@ -35,8 +35,8 @@ void FillBuffer(void){
void CreateOutputFile (char *name, int format) {
FILE *fp;
GLint size3d;
char ext[10];
int res;
char ext[256];
int res, i;
#ifdef _XMOTIF
FILE *tmp;
......@@ -50,33 +50,28 @@ void CreateOutputFile (char *name, int format) {
switch(format){
case FORMAT_AUTO :
if(strlen(name) < 4)
Msg(GERROR, "Unknown extension for automatic format detection");
else{
strcpy(ext,name+(strlen(name)-4));
for(i=strlen(name)-1; i>=0; i--){
if(name[i] == '.'){
strcpy(ext,&name[i]);
break;
}
}
if(i<=0) strcpy(ext,"");
if (!strcmp(ext,".geo")) CreateOutputFile(name, FORMAT_GEO);
else if(!strcmp(ext,".msh")) CreateOutputFile(name, FORMAT_MSH);
else if(!strcmp(ext,".unv")) CreateOutputFile(name, FORMAT_UNV);
else if(!strcmp(ext,".gif")) CreateOutputFile(name, FORMAT_GIF);
else if(!strcmp(ext,".jpg")) CreateOutputFile(name, FORMAT_JPEG);
else if(!strcmp(ext,".jpeg")) CreateOutputFile(name, FORMAT_JPEG);
else if(!strcmp(ext,".ps")) CreateOutputFile(name, FORMAT_EPS);
else if(!strcmp(ext,".eps")) CreateOutputFile(name, FORMAT_EPS);
else if(!strcmp(ext,".xpm")) CreateOutputFile(name, FORMAT_XPM);
else if(!strcmp(ext,".ppm")) CreateOutputFile(name, FORMAT_PPM);
else if(!strcmp(ext,".yuv")) CreateOutputFile(name, FORMAT_YUV);
else {
if(strlen(name) < 5)
Msg(GERROR, "Unknown extension in \"%s\" for automatic format detection",
name);
else{
strcpy(ext,name+(strlen(name)-5));
if(!strcmp(ext,".jpeg")) CreateOutputFile(name, FORMAT_JPEG);
else if(!strcmp(ext,".gref")) CreateOutputFile(name, FORMAT_GREF);
else if(!strcmp(ext,".Gref")) CreateOutputFile(name, FORMAT_GREF);
else Msg(GERROR, "Unknown extension in \"%s\" for automatic format detection",
name);
}
}
}
else Msg(GERROR, "Unknown extension '%s' for automatic format detection", ext);
break;
case FORMAT_GEO :
......
%{
// $Id: Gmsh.l,v 1.31 2001-07-24 11:33:47 geuzaine Exp $
// $Id: Gmsh.l,v 1.32 2001-07-25 13:11:07 geuzaine Exp $
#include <stdio.h>
#include <stdlib.h>
......@@ -178,9 +178,8 @@ Spline return tSpline;
Surface return tSurface;
Symmetry return tSymmetry;
Sprintf return tSprintf ;
Strcat return tStrcat ;
Strdup return tStrdup ;
Strprefix return tStrprefix ;
StrCat return tStrCat ;
StrPrefix return tStrPrefix ;
Transfinite return tTransfinite;
Translate return tTranslate;
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -37,140 +37,139 @@ typedef union {
#define tHypot 284
#define tPrintf 285
#define tSprintf 286
#define tStrcat 287
#define tStrdup 288
#define tStrprefix 289
#define tDraw 290
#define tPoint 291
#define tCircle 292
#define tEllipsis 293
#define tLine 294
#define tSurface 295
#define tSpline 296
#define tVolume 297
#define tCharacteristic 298
#define tLength 299
#define tParametric 300
#define tElliptic 301
#define tPlane 302
#define tRuled 303
#define tTransfinite 304
#define tComplex 305
#define tPhysical 306
#define tUsing 307
#define tBump 308
#define tProgression 309
#define tRotate 310
#define tTranslate 311
#define tSymmetry 312
#define tDilate 313
#define tExtrude 314
#define tDuplicata 315
#define tLoop 316
#define tRecombine 317
#define tDelete 318
#define tCoherence 319
#define tIntersect 320
#define tAttractor 321
#define tLayers 322
#define tScalarTetrahedron 323
#define tVectorTetrahedron 324
#define tTensorTetrahedron 325
#define tScalarTriangle 326
#define tVectorTriangle 327
#define tTensorTriangle 328
#define tScalarLine 329
#define tVectorLine 330
#define tTensorLine 331
#define tScalarPoint 332
#define tVectorPoint 333
#define tTensorPoint 334
#define tBSpline 335
#define tNurbs 336
#define tOrder 337
#define tWith 338
#define tBounds 339
#define tKnots 340
#define tColor 341
#define tColorTable 342
#define tFor 343
#define tIn 344
#define tEndFor 345
#define tIf 346
#define tEndIf 347
#define tExit 348
#define tReturn 349
#define tCall 350
#define tFunction 351
#define tMesh 352
#define tB_SPLINE_SURFACE_WITH_KNOTS 353
#define tB_SPLINE_CURVE_WITH_KNOTS 354
#define tCARTESIAN_POINT 355
#define tTRUE 356
#define tFALSE 357
#define tUNSPECIFIED 358
#define tU 359
#define tV 360
#define tEDGE_CURVE 361
#define tVERTEX_POINT 362
#define tORIENTED_EDGE 363
#define tPLANE 364
#define tFACE_OUTER_BOUND 365
#define tEDGE_LOOP 366
#define tADVANCED_FACE 367
#define tVECTOR 368
#define tDIRECTION 369
#define tAXIS2_PLACEMENT_3D 370
#define tISO 371
#define tENDISO 372
#define tENDSEC 373
#define tDATA 374
#define tHEADER 375
#define tFILE_DESCRIPTION 376
#define tFILE_SCHEMA 377
#define tFILE_NAME 378
#define tMANIFOLD_SOLID_BREP 379
#define tCLOSED_SHELL 380
#define tADVANCED_BREP_SHAPE_REPRESENTATION 381
#define tFACE_BOUND 382
#define tCYLINDRICAL_SURFACE 383
#define tCONICAL_SURFACE 384
#define tCIRCLE 385
#define tTRIMMED_CURVE 386
#define tGEOMETRIC_SET 387
#define tCOMPOSITE_CURVE_SEGMENT 388
#define tCONTINUOUS 389
#define tCOMPOSITE_CURVE 390
#define tTOROIDAL_SURFACE 391
#define tPRODUCT_DEFINITION 392
#define tPRODUCT_DEFINITION_SHAPE 393
#define tSHAPE_DEFINITION_REPRESENTATION 394
#define tELLIPSE 395
#define tTrimmed 396
#define tSolid 397
#define tEndSolid 398
#define tVertex 399
#define tFacet 400
#define tNormal 401
#define tOuter 402
#define tLoopSTL 403
#define tEndLoop 404
#define tEndFacet 405
#define tAFFECTPLUS 406
#define tAFFECTMINUS 407
#define tAFFECTTIMES 408
#define tAFFECTDIVIDE 409
#define tOR 410
#define tAND 411
#define tEQUAL 412
#define tNOTEQUAL 413
#define tAPPROXEQUAL 414
#define tLESSOREQUAL 415
#define tGREATEROREQUAL 416
#define tCROSSPRODUCT 417
#define tPLUSPLUS 418
#define tMINUSMINUS 419
#define UNARYPREC 420
#define tStrCat 287
#define tStrPrefix 288
#define tDraw 289
#define tPoint 290
#define tCircle 291
#define tEllipsis 292
#define tLine 293
#define tSurface 294
#define tSpline 295
#define tVolume 296
#define tCharacteristic 297
#define tLength 298
#define tParametric 299
#define tElliptic 300
#define tPlane 301
#define tRuled 302
#define tTransfinite 303
#define tComplex 304
#define tPhysical 305
#define tUsing 306
#define tBump 307
#define tProgression 308
#define tRotate 309
#define tTranslate 310
#define tSymmetry 311
#define tDilate 312
#define tExtrude 313
#define tDuplicata 314
#define tLoop 315
#define tRecombine 316
#define tDelete 317
#define tCoherence 318
#define tIntersect 319
#define tAttractor 320
#define tLayers 321
#define tScalarTetrahedron 322
#define tVectorTetrahedron 323
#define tTensorTetrahedron 324
#define tScalarTriangle 325
#define tVectorTriangle 326
#define tTensorTriangle 327
#define tScalarLine 328
#define tVectorLine 329
#define tTensorLine 330
#define tScalarPoint 331
#define tVectorPoint 332
#define tTensorPoint 333
#define tBSpline 334
#define tNurbs 335
#define tOrder 336
#define tWith 337
#define tBounds 338
#define tKnots 339
#define tColor 340
#define tColorTable 341
#define tFor 342
#define tIn 343
#define tEndFor 344
#define tIf 345
#define tEndIf 346
#define tExit 347
#define tReturn 348
#define tCall 349
#define tFunction 350
#define tMesh 351
#define tB_SPLINE_SURFACE_WITH_KNOTS 352
#define tB_SPLINE_CURVE_WITH_KNOTS 353
#define tCARTESIAN_POINT 354
#define tTRUE 355
#define tFALSE 356
#define tUNSPECIFIED 357
#define tU 358
#define tV 359
#define tEDGE_CURVE 360
#define tVERTEX_POINT 361
#define tORIENTED_EDGE 362
#define tPLANE 363
#define tFACE_OUTER_BOUND 364
#define tEDGE_LOOP 365
#define tADVANCED_FACE 366
#define tVECTOR 367
#define tDIRECTION 368
#define tAXIS2_PLACEMENT_3D 369
#define tISO 370
#define tENDISO 371
#define tENDSEC 372
#define tDATA 373
#define tHEADER 374
#define tFILE_DESCRIPTION 375
#define tFILE_SCHEMA 376
#define tFILE_NAME 377
#define tMANIFOLD_SOLID_BREP 378
#define tCLOSED_SHELL 379
#define tADVANCED_BREP_SHAPE_REPRESENTATION 380
#define tFACE_BOUND 381
#define tCYLINDRICAL_SURFACE 382
#define tCONICAL_SURFACE 383
#define tCIRCLE 384
#define tTRIMMED_CURVE 385
#define tGEOMETRIC_SET 386
#define tCOMPOSITE_CURVE_SEGMENT 387
#define tCONTINUOUS 388
#define tCOMPOSITE_CURVE 389
#define tTOROIDAL_SURFACE 390
#define tPRODUCT_DEFINITION 391
#define tPRODUCT_DEFINITION_SHAPE 392
#define tSHAPE_DEFINITION_REPRESENTATION 393
#define tELLIPSE 394
#define tTrimmed 395
#define tSolid 396
#define tEndSolid 397
#define tVertex 398
#define tFacet 399
#define tNormal 400
#define tOuter 401
#define tLoopSTL 402
#define tEndLoop 403
#define tEndFacet 404
#define tAFFECTPLUS 405
#define tAFFECTMINUS 406
#define tAFFECTTIMES 407
#define tAFFECTDIVIDE 408
#define tOR 409
#define tAND 410
#define tEQUAL 411
#define tNOTEQUAL 412
#define tAPPROXEQUAL 413
#define tLESSOREQUAL 414
#define tGREATEROREQUAL 415
#define tCROSSPRODUCT 416
#define tPLUSPLUS 417
#define tMINUSMINUS 418
#define UNARYPREC 419
extern YYSTYPE yylval;
%{
// $Id: Gmsh.y,v 1.80 2001-07-24 11:33:48 geuzaine Exp $
// $Id: Gmsh.y,v 1.81 2001-07-25 13:11:07 geuzaine Exp $
//
// Generaliser sprintf avec des chaines de caracteres
......@@ -84,7 +84,7 @@ void skip_until (char *skip, char *until);
%token tEND tAFFECT tDOTS tPi
%token tExp tLog tLog10 tSqrt tSin tAsin tCos tAcos tTan tRand
%token tAtan tAtan2 tSinh tCosh tTanh tFabs tFloor tCeil
%token tFmod tModulo tHypot tPrintf tSprintf tStrcat tStrdup tStrprefix tDraw
%token tFmod tModulo tHypot tPrintf tSprintf tStrCat tStrPrefix tDraw
%token tPoint tCircle tEllipsis tLine tSurface tSpline tVolume
%token tCharacteristic tLength tParametric tElliptic
%token tPlane tRuled tTransfinite tComplex tPhysical
......@@ -2425,7 +2425,7 @@ StringExpr :
{
$$ = $1;
}
| tStrcat '(' StringExpr ',' StringExpr ')'
| tStrCat '(' StringExpr ',' StringExpr ')'
{
$$ = (char *)Malloc((strlen($3)+strlen($5)+1)*sizeof(char)) ;
strcpy($$, $3) ;
......@@ -2433,7 +2433,7 @@ StringExpr :
Free($3);
Free($5);
}
| tStrprefix '(' StringExpr ')'
| tStrPrefix '(' StringExpr ')'
{
$$ = (char *)Malloc((strlen($3)+1)*sizeof(char)) ;
for(i=strlen($3)-1; i>=0; i--){
......@@ -2475,11 +2475,7 @@ StringExpr :
List_Delete($5);
Free($3);
}
| tStrdup '(' StringExpr ')'
{
$$ = $3;
}
| tStrdup '(' tSTRING '.' tSTRING ')'
| tSprintf '(' tSTRING '.' tSTRING ')'
{
if(!(pStrCat = Get_StringOptionCategory($3)))
vyyerror("Unknown string option class '%s'", $3);
......@@ -2493,7 +2489,7 @@ StringExpr :
}
}
}
| tStrdup '(' tSTRING '[' FExpr ']' '.' tSTRING ')'
| tSprintf '(' tSTRING '[' FExpr ']' '.' tSTRING ')'
{
if(!(pStrCat = Get_StringOptionCategory($3)))
vyyerror("Unknown string option class '%s'", $3);
......
This diff is collapsed.
$Id: VERSIONS,v 1.29 2001-07-24 11:33:48 geuzaine Exp $
$Id: VERSIONS,v 1.30 2001-07-25 13:11:08 geuzaine Exp $
New in 1.21: Fixed more memory leaks; added -opt command line option
to parse definitions directly from the command line; fixed missing
screen refreshes during contour/surface selection; Added string
manipulation functions (Strdup, Strcat, Strprefix);
screen refreshes during contour/surface selection; Enhanced string
manipulation functions (Sprintf, StrCat, StrPrefix);
New in 1.20: Fixed various bugs (memory leaks, functions in included
files, solver command selection, ColorTable option, duplicate nodes in
......
......@@ -10,7 +10,7 @@ For num In {1:2}
General.RotationX += 10 ;
Print Strcat( Strprefix(Strdup(View[0].Name)) , Sprintf("-%g.jpg", num) ) ;
Print StrCat( StrPrefix(Sprintf(View[0].Name)) , Sprintf("-%g.jpg", num) ) ;
Draw ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment