diff --git a/wmake/etc/lempar.c b/wmake/etc/lempar.c index e2d0de8cf2..7561d3783d 100644 --- a/wmake/etc/lempar.c +++ b/wmake/etc/lempar.c @@ -730,55 +730,6 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); -#ifndef NDEBUG - if( yyTraceFILE ){ - yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } - yymsp = yypParser->yytos; - } -#endif - } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -938,12 +889,56 @@ void Parse( } #endif - do{ + while(1){ /* Exit by "break" */ + assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); +#ifndef NDEBUG + if( yyTraceFILE ){ + int yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos[yysize].stateno); + }else{ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", + yyTracePrompt, yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == + (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + break; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + break; + } + } +#endif + } + yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -999,14 +994,13 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos >= yypParser->yystack - && (yyact = yy_find_reduce_action( - yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE - ){ + while( yypParser->yytos > yypParser->yystack ){ + yyact = yy_find_reduce_action(yypParser->yytos->stateno, + YYERRORSYMBOL); + if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } - if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY @@ -1056,7 +1050,7 @@ void Parse( break; #endif } - }while( yypParser->yytos>yypParser->yystack ); + } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/wmake/makefiles/apps b/wmake/makefiles/apps index 1673e8e1db..fbbb52f43c 100644 --- a/wmake/makefiles/apps +++ b/wmake/makefiles/apps @@ -8,8 +8,7 @@ # Copyright (C) 2011-2016 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # wmake/makefiles/apps diff --git a/wmake/rules/General/eigen b/wmake/rules/General/eigen new file mode 100644 index 0000000000..a47c3286f5 --- /dev/null +++ b/wmake/rules/General/eigen @@ -0,0 +1,14 @@ +# ---------------------------------------------------------------------------- +# Eigen definitions +# +# 0. missing +# 1. header-only +# ---------------------------------------------------------------------------- + +ifneq (,$(EIGEN_INC_DIR)) + EIGEN_INC := -I$(EIGEN_INC_DIR) +else + EIGEN_INC := +endif + +# --------------------------------------------------------------------------- diff --git a/wmake/scripts/dirToString b/wmake/scripts/dirToString index 55d027e044..2ed4ba7619 100755 --- a/wmake/scripts/dirToString +++ b/wmake/scripts/dirToString @@ -9,8 +9,7 @@ # Copyright (C) 2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # dirToString diff --git a/wmake/scripts/have_eigen b/wmake/scripts/have_eigen new file mode 100644 index 0000000000..a674e31e57 --- /dev/null +++ b/wmake/scripts/have_eigen @@ -0,0 +1,159 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2021 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# Script +# have_eigen +# +# Description +# Detection/setup of EIGEN (Eigen3) +# +# Expects +# config.sh/eigen +# +# Functions provided +# have_eigen, no_eigen, echo_eigen, query_eigen, search_eigen +# +# Variables set on success +# HAVE_EIGEN +# EIGEN_INC_DIR +# +#------------------------------------------------------------------------------ +. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions + +#------------------------------------------------------------------------------ + +# Reset +no_eigen() +{ + unset HAVE_EIGEN EIGEN_INC_DIR EIGEN_LIB_DIR +} + + +# Report +echo_eigen() +{ + echo "eigen=${HAVE_EIGEN:-false}" + echo "include=\"$EIGEN_INC_DIR\"" +} + + +# Search +# $1 : prefix (*_ARCH_PATH, system, ...) +# +# On success, return 0 and export variables +# -> HAVE_EIGEN, EIGEN_INC_DIR +search_eigen() +{ + local warn # warn="==> skip eigen" + local incName="Eigen/Eigen" + local pkgName="eigen3" + local sentinel="signature_of_eigen3_matrix_library" + + local prefix="${1:-system}" + local header incdir + + # ---------------------------------- + if isNone "$prefix" + then + [ -n "$warn" ] && echo "$warn (disabled)" + return 1 + elif hasAbsdir "$prefix" + then + header=$(findFirstFile "$prefix/include/$incName") + elif isSystem "$prefix" + then + header=$(findSystemInclude -name="eigen3/$incName") + + # No system header, attempt discovery with pkg-config + if [ -z "$header" ] && pkg-config --exists "$pkgName" 2>/dev/null + then + includeDirs=$(pkg-config --cflags-only-I "$pkgName" | sed -e 's/^-[IL]//; s/[ ]-[IL]/ /;') + header="${includeDirs% *}/$incName" # First entry (ie, split on space) + fi + else + unset prefix + fi + # ---------------------------------- + + # Header + [ -n "$header" ] || { + [ -n "$warn" ] && echo "$warn (no header)" + return 2 + } + + # ---------------------------------- + + header="${header%/*}" # Strip one-level (include/Eigen/...) + + # OK + export HAVE_EIGEN=true + export EIGEN_INC_DIR="${header%/*}" # Basename +} + + +# Output as per search_* function +have_eigen() +{ + local warn # warn="==> skip eigen" + local config="config.sh/eigen" + local path="$EIGEN_ARCH_PATH" + local file + + # Setup - current environment if set + if [ -z "$path" ] + then + if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")" + then + . "$file" + path="$EIGEN_ARCH_PATH" + fi + fi + + search_eigen "${path:-system}" +} + + +# Query settings +query_eigen() +{ + local config="config.sh/eigen" + local file + + if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")" + then + . "$file" + _process_query eigen "${EIGEN_ARCH_PATH:-system}" + else + echo "(no $config)" 1>&2 + echo "eigen=unknown" + _process_query eigen "system" + fi +} + + +#------------------------------------------------------------------------------ + +# Reset +no_eigen + +# Test/query +case "$1" in +-test) + have_eigen + echo_eigen + ;; +-query) + query_eigen + ;; +esac + +#------------------------------------------------------------------------------ diff --git a/wmake/scripts/makeDepend b/wmake/scripts/makeDepend index 1aa1f6f7e7..711275614d 100755 --- a/wmake/scripts/makeDepend +++ b/wmake/scripts/makeDepend @@ -9,8 +9,7 @@ # Copyright (C) 2018 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # makeDepend diff --git a/wmake/scripts/makeFiles b/wmake/scripts/makeFiles index 7fa9c69c3f..48112401ae 100755 --- a/wmake/scripts/makeFiles +++ b/wmake/scripts/makeFiles @@ -9,20 +9,7 @@ # Copyright (C) 2011-2016 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # makeFiles diff --git a/wmake/scripts/makeOptions b/wmake/scripts/makeOptions index 3d27c475f0..36c4eb2ef7 100755 --- a/wmake/scripts/makeOptions +++ b/wmake/scripts/makeOptions @@ -9,20 +9,7 @@ # Copyright (C) 2011 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # makeOptions diff --git a/wmake/scripts/makeParser b/wmake/scripts/makeParser index da094042ca..ee59ded895 100755 --- a/wmake/scripts/makeParser +++ b/wmake/scripts/makeParser @@ -9,8 +9,7 @@ # Copyright (C) 2019 OpenCFD Ltd. #------------------------------------------------------------------------------- # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # makeParser @@ -19,9 +18,7 @@ # Pregenerate ragel code and/or lemon parser headers # #------------------------------------------------------------------------------ -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done +printHelp() { cat</dev/null then echo "Generating ragel scanner" 1>&2 - ragel -G2 -o "$output" "$input" + ragel -G2 ${optNoLines:+-L} -o "$output" "$input" else echo "No ragel, leaving scanner intact" 1>&2 fi @@ -144,11 +146,13 @@ case "$parser" in then echo "Generating lemon parser code ($extCode)$message" 1>&2 "${WM_PROJECT_DIR:?}/wmake/scripts/wrap-lemon" \ - $optDryRun $optRemoveTmp -e"$extCode" -p -s "$input" + $optDryRun $optGrammar $optRemoveTmp \ + -e"$extCode" -p -s "$input" else echo "Generating lemon parser header$message" 1>&2 "${WM_PROJECT_DIR:?}/wmake/scripts/wrap-lemon" \ - $optDryRun $optRemoveTmp -header -p -s "$input" + $optDryRun $optGrammar $optRemoveTmp -header \ + -p -s "$input" fi fi echo diff --git a/wmake/scripts/makeTargetDir b/wmake/scripts/makeTargetDir index 44b778f9ba..18ecb22d2f 100755 --- a/wmake/scripts/makeTargetDir +++ b/wmake/scripts/makeTargetDir @@ -9,8 +9,7 @@ # Copyright (C) 2011 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # makeTargetDir diff --git a/wmake/scripts/wmakeFilesAndOptions b/wmake/scripts/wmakeFilesAndOptions index 8b35a52d04..48cf9f1032 100755 --- a/wmake/scripts/wmakeFilesAndOptions +++ b/wmake/scripts/wmakeFilesAndOptions @@ -9,20 +9,7 @@ # Copyright (C) 2011-2016 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wmakeFilesAndOptions diff --git a/wmake/scripts/wmakeWindowsDlOpenLibs b/wmake/scripts/wmakeWindowsDlOpenLibs index 52b24489f5..594183c389 100755 --- a/wmake/scripts/wmakeWindowsDlOpenLibs +++ b/wmake/scripts/wmakeWindowsDlOpenLibs @@ -10,20 +10,7 @@ # Copyright (C) 2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wmakeWindowsDlOpenLibs diff --git a/wmake/scripts/wrap-bison b/wmake/scripts/wrap-bison index c158e8acbe..f7484d2788 100755 --- a/wmake/scripts/wrap-bison +++ b/wmake/scripts/wrap-bison @@ -6,11 +6,10 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------- -# Copyright (C) 2019 OpenCFD Ltd. +# Copyright (C) 2019-2021 OpenCFD Ltd. #------------------------------------------------------------------------------- # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wrap-bison @@ -53,15 +52,14 @@ # Note # General idea lifted from swak #------------------------------------------------------------------------------ -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done +printHelp() { cat<&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done +printHelp() { cat<&2 + # Drop last argument (the parser input file) set -- "${@:1:${#}-1}" @@ -196,8 +204,7 @@ then rm -rf "$tmpDir" 2>/dev/null mkdir "$tmpDir" 2>/dev/null - # We may want this: - # trap 'rm -f $tmpDir 2>/dev/null; exit $exitCode' EXIT TERM INT + trap 'rm -rf $tmpDir; exit $exitCode' EXIT TERM INT if [ "$usingM4" = true ] then @@ -236,10 +243,10 @@ then done fi - rm -rf "$tmpDir" 2>/dev/null - elif [ "$usingM4" = true ] then + ## echo "${0##*/} : generate code (with m4 filtering)" 1>&2 + # Drop last argument (the parser input file) set -- "${@:1:${#}-1}" @@ -252,8 +259,10 @@ then fi tmpFile="${tmpFile%.*}$extParser" # Eg, from .lyy-m4 -> .lyy - # We may want this: - # trap 'rm -f $tmpFile 2>/dev/null; exit $exitCode' EXIT TERM INT + if [ -n "$optRemoveTmp" ] + then + trap 'rm -f $tmpFile; exit $exitCode' EXIT TERM INT + fi if m4 $m4Flags "$parser" > "$tmpFile" && [ -f "$tmpFile" ] then @@ -264,16 +273,16 @@ then exitCode=1 fi - if [ -n "$optRemoveTmp" ] + if [ -z "$optRemoveTmp" ] then - rm -f "$tmpFile" 2>/dev/null - else + echo 2>/dev/null echo "Retaining intermediate: $tmpFile" 2>/dev/null fi else # No special handling + ## echo "${0##*/} : generate code" 1>&2 "$lemon" "$skel" "$@" exitCode=$? diff --git a/wmake/src/lemon.c b/wmake/src/lemon.c index 216972677d..52fb402aea 100644 --- a/wmake/src/lemon.c +++ b/wmake/src/lemon.c @@ -1,7 +1,9 @@ -/* - * https://www.sqlite.org/src/artifact/70eedc31 - * Artifact 70eedc31614a58fe31a71025c17ebd1502a6ce9cfef0ed5e33acb0b5b737b291: - * File tool/lemon.c part of check-in [4591ee03] at 2020-09-21 +/* OPENFOAM note + * + * https://sqlite.org/src/raw/ + * https://www.sqlite.org/src/artifact/25888183 + * Artifact 258881835bd5bccd0c74fb110fe54244ff18e8e7ef3d949cbdab7187f02132bb: + * File tool/lemon.c part of check-in [f2f279b2]] at 2021-10-04 */ /* ** This file contains all sources (including headers) to the LEMON @@ -406,7 +408,7 @@ struct lemon { struct symbol *errsym; /* The error symbol */ struct symbol *wildcard; /* Token that matches anything */ char *name; /* Name of the generated parser */ - char *arg; /* Declaration of the 3th argument to parser */ + char *arg; /* Declaration of the 3rd argument to parser */ char *ctx; /* Declaration of 2nd argument to constructor */ char *tokentype; /* Type of terminal symbols in the parser stack */ char *vartype; /* The default type of non-terminal symbols */ @@ -923,8 +925,11 @@ void FindStates(struct lemon *lemp) lemp->errorcnt++; sp = lemp->startRule->lhs; } - }else{ + }else if( lemp->startRule ){ sp = lemp->startRule->lhs; + }else{ + ErrorMsg(lemp->filename,0,"Internal error - no start rule\n"); + exit(1); } /* Make sure the start symbol doesn't occur on the right-hand side of @@ -1033,7 +1038,7 @@ PRIVATE void buildshifts(struct lemon *lemp, struct state *stp) struct symbol *bsp; /* Symbol following the dot in configuration "bcfp" */ struct state *newstp; /* A pointer to a successor state */ - /* Each configuration becomes complete after it contibutes to a successor + /* Each configuration becomes complete after it contributes to a successor ** state. Initially, all configurations are incomplete */ for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE; @@ -1089,7 +1094,7 @@ void FindLinks(struct lemon *lemp) ** which the link is attached. */ for(i=0; instate; i++){ stp = lemp->sorted[i]; - for(cfp=stp->cfp; cfp; cfp=cfp->next){ + for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){ cfp->stp = stp; } } @@ -1098,7 +1103,7 @@ void FindLinks(struct lemon *lemp) ** links are used in the follow-set computation. */ for(i=0; instate; i++){ stp = lemp->sorted[i]; - for(cfp=stp->cfp; cfp; cfp=cfp->next){ + for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){ for(plp=cfp->bplp; plp; plp=plp->next){ other = plp->cfp; Plink_add(&other->fplp,cfp); @@ -1121,6 +1126,7 @@ void FindFollowSets(struct lemon *lemp) int change; for(i=0; instate; i++){ + assert( lemp->sorted[i]!=0 ); for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ cfp->status = INCOMPLETE; } @@ -1129,6 +1135,7 @@ void FindFollowSets(struct lemon *lemp) do{ progress = 0; for(i=0; instate; i++){ + assert( lemp->sorted[i]!=0 ); for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ if( cfp->status==COMPLETE ) continue; for(plp=cfp->fplp; plp; plp=plp->next){ @@ -1178,7 +1185,14 @@ void FindActions(struct lemon *lemp) /* Add the accepting token */ if( lemp->start ){ sp = Symbol_find(lemp->start); - if( sp==0 ) sp = lemp->startRule->lhs; + if( sp==0 ){ + if( lemp->startRule==0 ){ + fprintf(stderr, "internal error on source line %d: no start rule\n", + __LINE__); + exit(1); + } + sp = lemp->startRule->lhs; + } }else{ sp = lemp->startRule->lhs; } @@ -1305,21 +1319,7 @@ static struct config **basisend = 0; /* End of list of basis configs */ /* Return a pointer to a new configuration */ PRIVATE struct config *newconfig(void){ - struct config *newcfg; - if( freelist==0 ){ - int i; - int amt = 3; - freelist = (struct config *)calloc( amt, sizeof(struct config) ); - if( freelist==0 ){ - fprintf(stderr,"Unable to allocate memory for a new configuration."); - exit(1); - } - for(i=0; inext; - return newcfg; + return (struct config*)calloc(1, sizeof(struct config)); } /* The configuration "old" is no longer used */ @@ -1549,7 +1549,7 @@ static void handle_D_option(char *z){ *z = 0; } -/* Remember the name of the output directory +/* Rember the name of the output directory */ static char *outputDir = NULL; static void handle_d_option(char *z){ @@ -1912,7 +1912,7 @@ static char *merge( ** ** Return Value: ** A pointer to the head of a sorted list containing the elements -** orginally in list. +** originally in list. ** ** Side effects: ** The "next" pointers for elements in list are changed. @@ -1957,8 +1957,12 @@ static FILE *errstream; static void errline(int n, int k, FILE *err) { int spcnt, i; - if( g_argv[0] ) fprintf(err,"%s",g_argv[0]); - spcnt = lemonStrlen(g_argv[0]) + 1; + if( g_argv[0] ){ + fprintf(err,"%s",g_argv[0]); + spcnt = lemonStrlen(g_argv[0]) + 1; + }else{ + spcnt = 0; + } for(i=1; isp->index>=lemp->nterminal ){ + if( ap->sp->index>=lemp->nterminal + && (lemp->errsym==0 || ap->sp->index!=lemp->errsym->index) + ){ act = lemp->minReduce + ap->x.rp->iRule; }else{ act = lemp->minShiftReduce + ap->x.rp->iRule; @@ -3899,7 +3905,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ lhsdirect = 1; }else if( rp->rhsalias[0]==0 ){ /* The left-most RHS symbol has no value. LHS direct is ok. But - ** we have to call the distructor on the RHS symbol first. */ + ** we have to call the destructor on the RHS symbol first. */ lhsdirect = 1; if( has_destructor(rp->rhs[0],lemp) ){ append_str(0,0,0,0); @@ -4121,7 +4127,7 @@ void print_stack_union( int *plineno, /* Pointer to the line number */ int mhflag /* True if generating makeheaders output */ ){ - int lineno = *plineno; /* The line number of the output */ + int lineno; /* The line number of the output */ char **types; /* A hash table of datatypes */ int arraysize; /* Size of the "types" array */ int maxdtlength; /* Maximum length of any ".datatype" field. */ @@ -4883,7 +4889,7 @@ void ReportTable( ** yyRuleInfoNRhs[]. ** ** Note: This code depends on the fact that rules are number - ** sequentually beginning with 0. + ** sequentially beginning with 0. */ for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){ fprintf(out," %4d, /* (%d) ", rp->lhs->index, i); @@ -5371,7 +5377,8 @@ int Strsafe_insert(const char *data) newnp->from = &(array.ht[h]); array.ht[h] = newnp; } - free(x1a->tbl); + /* free(x1a->tbl); // This program was originally for 16-bit machines. + ** Don't worry about freeing memory on modern platforms. */ *x1a = array; } /* Insert the new data */ @@ -5539,7 +5546,9 @@ int Symbol_insert(struct symbol *data, const char *key) newnp->from = &(array.ht[h]); array.ht[h] = newnp; } - free(x2a->tbl); + /* free(x2a->tbl); // This program was originally written for 16-bit + ** machines. Don't worry about freeing this trivial amount of memory + ** on modern platforms. Just leak it. */ *x2a = array; } /* Insert the new data */ @@ -5875,7 +5884,9 @@ int Configtable_insert(struct config *data) newnp->from = &(array.ht[h]); array.ht[h] = newnp; } - free(x4a->tbl); + /* free(x4a->tbl); // This code was originall written for 16-bit machines. + ** on modern machines, don't worry about freeing this trival amount of + ** memory. */ *x4a = array; } /* Insert the new data */ diff --git a/wmake/src/lemon.help.txt b/wmake/src/lemon.help.txt new file mode 100644 index 0000000000..cf5ca2895c --- /dev/null +++ b/wmake/src/lemon.help.txt @@ -0,0 +1,41 @@ +# Snippets for documentation + + +3.1 Command-line options: + +* -eextension + + Output code extension, the default is 'c'. + Changing this will not change the type of code generated (it will + still be C) but it does allow triggering of different make rules + or diffferent compiler types. + + +3.2.2 Interface Summary + +Notes: + +* Use the %name directive to change the "Parse" prefix names of the + procedures in the interface. + +* Use the %static directive to change the interface type defined by + YYFUNCAPI to file `static` linkage. This can be useful if the entire + parser code is to be locally wrapped inside of a different caller. + + + +4.4 Special directives + +* %static + + + +4.4.xxx The %static directive + +By default, the functions generated by Lemon are exposed as globally +visible symbols. You can change this by specifying the %static +directive. + +This places parser routines in a static (ie, file-local) scope so that +they are not visible outside of the compilation unit. The parser +routines will then be wrapped with some other type of mechanism. diff --git a/wmake/wclean b/wmake/wclean index ca2fe7f81c..362bff0e08 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -10,20 +10,7 @@ # Copyright (C) 2017-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wclean diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll index 40b05d48eb..e9e2be271c 100755 --- a/wmake/wcleanLnIncludeAll +++ b/wmake/wcleanLnIncludeAll @@ -9,20 +9,7 @@ # Copyright (C) 2011-2016 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wcleanLnIncludeAll diff --git a/wmake/wdep b/wmake/wdep index 1680c5d48c..6319c8f92e 100755 --- a/wmake/wdep +++ b/wmake/wdep @@ -10,20 +10,7 @@ # Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wdep @@ -39,7 +26,7 @@ # #------------------------------------------------------------------------------ Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions # Source wmake functions +. "${0%/*}"/scripts/wmakeFunctions # Source wmake functions usage() { exec 1>&2 @@ -84,7 +71,7 @@ fi # Check environment variables checkEnv -sourceFile=$1 +sourceFile="$1" #------------------------------------------------------------------------------ # Check is in the current directory, diff --git a/wmake/wmake b/wmake/wmake index abb07294ed..7410841500 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -10,20 +10,7 @@ # Copyright (C) 2017-2021 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wmake diff --git a/wmake/wmakeCollect b/wmake/wmakeCollect index 392a3fc290..411e209315 100755 --- a/wmake/wmakeCollect +++ b/wmake/wmakeCollect @@ -9,20 +9,7 @@ # Copyright (C) 2016 OpenFOAM Foundation #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wmakeCollect @@ -95,7 +82,7 @@ done if [ -z "$WM_COLLECT_DIR" ] then - echo "$Script error: WM_COLLECT_DIR not set" + echo "$Script error: WM_COLLECT_DIR not set" 1>&2 exit 1 fi @@ -143,7 +130,7 @@ then echo -e "\t$E cd $PWD && \\" >> $file echo -e "\t${@:1:($#-1)} $objectFile" >> $file echo >> $file -elif [ -d $WM_COLLECT_DIR ] +elif [ -d "$WM_COLLECT_DIR" ] then # Collect all the makefiles into a single makefiles for this build (cd $WM_COLLECT_DIR && ls -1rt | xargs cat > $makefile) diff --git a/wmake/wmakeLnIncludeAll b/wmake/wmakeLnIncludeAll index 31e5480b4d..310daf243b 100755 --- a/wmake/wmakeLnIncludeAll +++ b/wmake/wmakeLnIncludeAll @@ -10,20 +10,7 @@ # Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wmakeLnIncludeAll diff --git a/wmake/wrmdep b/wmake/wrmdep index 7137af4729..ffd993657c 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -10,22 +10,10 @@ # Copyright (C) 2017-2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . -# -# Script wrmdep +# Script +# wrmdep # # Usage # wrmdep [-a | -all | all] [file1 [..fileN]] @@ -180,7 +168,7 @@ oldFolders) find "$objectsDir" -name '*.dep' -type f -print | while read depFile do - sourceFile=$(depToSource "$depFile") + sourceFile="$(depToSource "$depFile")" # Check C++ or Flex source file exists if [ ! -r "$sourceFile" ] diff --git a/wmake/wrmo b/wmake/wrmo index 93182bbb1b..0ce4bf548b 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -10,20 +10,7 @@ # Copyright (C) 2017-2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # wrmo