summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.md6
-rwxr-xr-xconfigure.sh4
-rw-r--r--include/status.h4
-rw-r--r--include/version.h2
-rw-r--r--locales/de_DE.ISO8859-1.msg10
-rw-r--r--locales/de_DE.UTF-8.msg10
-rw-r--r--locales/en_US.msg10
-rw-r--r--locales/es_ES.ISO8859-1.msg10
-rw-r--r--locales/es_ES.UTF-8.msg10
-rw-r--r--locales/fr_FR.ISO8859-1.msg10
-rw-r--r--locales/fr_FR.UTF-8.msg10
-rw-r--r--locales/ja_JP.UTF-8.msg10
-rw-r--r--locales/ja_JP.eucJP.msg10
-rw-r--r--locales/nl_NL.ISO8859-1.msg10
-rw-r--r--locales/nl_NL.UTF-8.msg10
-rw-r--r--locales/pl_PL.ISO8859-2.msg10
-rw-r--r--locales/pl_PL.UTF-8.msg10
-rw-r--r--locales/pt_PT.ISO8859-1.msg10
-rw-r--r--locales/pt_PT.UTF-8.msg10
-rw-r--r--locales/ru_RU.CP1251.msg10
-rw-r--r--locales/ru_RU.CP866.msg10
-rw-r--r--locales/ru_RU.ISO8859-5.msg10
-rw-r--r--locales/ru_RU.KOI8-R.msg10
-rw-r--r--locales/ru_RU.UTF-8.msg10
-rw-r--r--locales/zh_CN.GB18030.msg10
-rw-r--r--locales/zh_CN.GB2312.msg10
-rw-r--r--locales/zh_CN.GBK.msg10
-rw-r--r--locales/zh_CN.UTF-8.msg10
-rw-r--r--locales/zh_CN.eucCN.msg10
-rw-r--r--src/bc_parse.c28
-rw-r--r--src/data.c3
-rw-r--r--tests/bc/all.txt1
-rw-r--r--tests/bc/misc8.txt8
-rw-r--r--tests/bc/misc8_results.txt3
-rw-r--r--tests/bc/posix_errors.txt1
35 files changed, 206 insertions, 104 deletions
diff --git a/NEWS.md b/NEWS.md
index fa2df6749783..5d0126b821a8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,11 @@
# News
+## 5.2.1
+
+This is a production release that fixes two parse bugs when in POSIX standard
+mode. One of these bugs was due to a quirk of the POSIX grammar, and the other
+was because `bc` was too strict.
+
## 5.2.0
This is a production release that adds a new feature, fixes some bugs, and adds
diff --git a/configure.sh b/configure.sh
index 8a6a7817fd2a..76ffb2b9a18e 100755
--- a/configure.sh
+++ b/configure.sh
@@ -52,13 +52,15 @@ usage() {
printf 'usage:\n'
printf ' %s -h\n' "$script"
printf ' %s --help\n' "$script"
- printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNPtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
+ printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script"
+ printf ' [-s SETTING] [-S SETTING]\n'
printf ' %s \\\n' "$script"
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n'
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls --disable-strip] \\\n'
printf ' [--install-all-locales] [--opt=OPT_LEVEL] \\\n'
printf ' [--karatsuba-len=KARATSUBA_LEN] \\\n'
+ printf ' [--set-default-on=SETTING] [--set-default-off=SETTING] \\\n'
printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
printf '\n'
diff --git a/include/status.h b/include/status.h
index 3a23b09dc873..993b5e698fb3 100644
--- a/include/status.h
+++ b/include/status.h
@@ -480,6 +480,10 @@ typedef enum BcErr {
/// Empty statements in POSIX for loop error.
BC_ERR_POSIX_FOR,
+ /// POSIX's grammar does not allow a function definition right after a
+ /// semicolon.
+ BC_ERR_POSIX_FUNC_AFTER_SEMICOLON,
+
/// Non-POSIX exponential (scientific or engineering) number used error.
BC_ERR_POSIX_EXP_NUM,
diff --git a/include/version.h b/include/version.h
index 296dbc79b547..eca73baf508f 100644
--- a/include/version.h
+++ b/include/version.h
@@ -37,6 +37,6 @@
#define BC_VERSION_H
/// The current version.
-#define VERSION 5.2.0
+#define VERSION 5.2.1
#endif // BC_VERSION_H
diff --git a/locales/de_DE.ISO8859-1.msg b/locales/de_DE.ISO8859-1.msg
index 76f2ac4190f6..dc7545e3ed72 100644
--- a/locales/de_DE.ISO8859-1.msg
+++ b/locales/de_DE.ISO8859-1.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX erlaubt keine Vergleichsoperatoren au遝rhalb von if-Anweisungen oder Schleifen"
23 "POSIX ben鰐igt 0 oder 1 Vergleichsoperatoren pro Bedingung"
24 "POSIX erlaubt keinen leeren Ausdruck in einer for-Schleife"
-25 "POSIX erlaubt keine exponentielle Notation"
-26 "POSIX erlaubt keine Feld-Referenzen als Funktionsparameter"
-27 "POSIX erfordert, dass die linke Klammer auf der gleichen Linie wie der Funktionskopf steht"
-28 "POSIX erlaubt keine Zuweisung von Strings an Variablen oder Arrays"
+25 "POSIX verlangt einen Zeilenumbruch zwischen einem Semikolon und einer Funktionsdefinition"
+26 "POSIX erlaubt keine exponentielle Notation"
+27 "POSIX erlaubt keine Feld-Referenzen als Funktionsparameter"
+28 "POSIX erlaubt keine ung黮tigen Funktionen"
+29 "POSIX erfordert, dass die linke Klammer auf der gleichen Linie wie der Funktionskopf steht"
+30 "POSIX erlaubt keine Zuweisung von Strings an Variablen oder Arrays"
$ Runtime errors.
$set 5
diff --git a/locales/de_DE.UTF-8.msg b/locales/de_DE.UTF-8.msg
index c4dad4cd3a60..7956615e849f 100644
--- a/locales/de_DE.UTF-8.msg
+++ b/locales/de_DE.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX erlaubt keine Vergleichsoperatoren au脽erhalb von if-Anweisungen oder Schleifen"
23 "POSIX ben枚tigt 0 oder 1 Vergleichsoperatoren pro Bedingung"
24 "POSIX erlaubt keinen leeren Ausdruck in einer for-Schleife"
-25 "POSIX erlaubt keine exponentielle Notation"
-26 "POSIX erlaubt keine Feld-Referenzen als Funktionsparameter"
-27 "POSIX erfordert, dass die linke Klammer auf der gleichen Linie wie der Funktionskopf steht"
-28 "POSIX erlaubt keine Zuweisung von Strings an Variablen oder Arrays"
+25 "POSIX verlangt einen Zeilenumbruch zwischen einem Semikolon und einer Funktionsdefinition"
+26 "POSIX erlaubt keine exponentielle Notation"
+27 "POSIX erlaubt keine Feld-Referenzen als Funktionsparameter"
+28 "POSIX erlaubt keine ung眉ltigen Funktionen"
+29 "POSIX erfordert, dass die linke Klammer auf der gleichen Linie wie der Funktionskopf steht"
+30 "POSIX erlaubt keine Zuweisung von Strings an Variablen oder Arrays"
$ Runtime errors.
$set 5
diff --git a/locales/en_US.msg b/locales/en_US.msg
index 707950a5767d..adc1cc4537b9 100644
--- a/locales/en_US.msg
+++ b/locales/en_US.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX does not allow comparison operators outside if statements or loops"
23 "POSIX requires 0 or 1 comparison operators per condition"
24 "POSIX requires all 3 parts of a for loop to be non-empty"
-25 "POSIX does not allow exponential notation"
-26 "POSIX does not allow array references as function parameters"
-27 "POSIX requires the left brace be on the same line as the function header"
-28 "POSIX does not allow strings to be assigned to variables or arrays"
+25 "POSIX requires a newline between a semicolon and a function definition",
+26 "POSIX does not allow exponential notation"
+27 "POSIX does not allow array references as function parameters"
+28 "POSIX does not allow void functions",
+29 "POSIX requires the left brace be on the same line as the function header"
+30 "POSIX does not allow strings to be assigned to variables or arrays"
$ Runtime errors.
$set 5
diff --git a/locales/es_ES.ISO8859-1.msg b/locales/es_ES.ISO8859-1.msg
index 8d74f884f811..30c965111de6 100644
--- a/locales/es_ES.ISO8859-1.msg
+++ b/locales/es_ES.ISO8859-1.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX no permite operadores de comparaci髇 aparte de \"if\" expresi髇 o bucles"
23 "POSIX requiere 0 o 1 operadores de comparis髇 para cada condici髇"
24 "POSIX requiere todos 3 partes de una bucla que no esta vac韔"
-25 "POSIX no permite una notaci髇 exponencial"
-26 "POSIX no permite una referencia a una matriz como un par醡etro de funci髇"
-27 "POSIX requiere el llave de la izquierda que sea en la misma l韓ea que los par醡etros de la funci髇"
-28 "POSIX no permite asignar cadenas a variables o matrices"
+25 "POSIX requiere una nueva l韓ea entre un punto y coma y una definici髇 de funci髇"
+26 "POSIX no permite una notaci髇 exponencial"
+27 "POSIX no permite una referencia a una matriz como un par醡etro de funci髇"
+28 "POSIX no permite funciones void"
+29 "POSIX requiere el llave de la izquierda que sea en la misma l韓ea que los par醡etros de la funci髇"
+30 "POSIX no permite asignar cadenas a variables o matrices"
$ Runtime errors.
$set 5
diff --git a/locales/es_ES.UTF-8.msg b/locales/es_ES.UTF-8.msg
index 26559e6e9b88..1721dd3d8f2a 100644
--- a/locales/es_ES.UTF-8.msg
+++ b/locales/es_ES.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX no permite operadores de comparaci贸n aparte de \"if\" expresi贸n o bucles"
23 "POSIX requiere 0 o 1 operadores de comparis贸n para cada condici贸n"
24 "POSIX requiere todos 3 partes de una bucla que no esta vac铆o"
-25 "POSIX no permite una notaci贸n exponencial"
-26 "POSIX no permite una referencia a una matriz como un par谩metro de funci贸n"
-27 "POSIX requiere el llave de la izquierda que sea en la misma l铆nea que los par谩metros de la funci贸n"
-28 "POSIX no permite asignar cadenas a variables o matrices"
+25 "POSIX requiere una nueva l铆nea entre un punto y coma y una definici贸n de funci贸n"
+26 "POSIX no permite una notaci贸n exponencial"
+27 "POSIX no permite una referencia a una matriz como un par谩metro de funci贸n"
+28 "POSIX no permite funciones void"
+29 "POSIX requiere el llave de la izquierda que sea en la misma l铆nea que los par谩metros de la funci贸n"
+30 "POSIX no permite asignar cadenas a variables o matrices"
$ Runtime errors.
$set 5
diff --git a/locales/fr_FR.ISO8859-1.msg b/locales/fr_FR.ISO8859-1.msg
index 8e894e043bbc..5d772abcc4ef 100644
--- a/locales/fr_FR.ISO8859-1.msg
+++ b/locales/fr_FR.ISO8859-1.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX interdit les op茅rateurs de comparaison en dehors des expressions 'if' ou des boucles"
23 "POSIX impose 0 ou 1 op茅rateur de comparaison par condition"
24 "POSIX interdit une expression vide dans une boucle 'for'"
-25 "POSIX interdit la notation exponentielle"
-26 "POSIX interdit les r茅f茅rences 脿 un tableau dans les param猫tres d'une fonction"
-27 "POSIX impose que l'en-t锚te de la fonction et le '{' soient sur la m锚me ligne"
-28 "POSIX interdit pas d'assigner des cha卯nes de caract猫res 脿 des variables ou 脿 des tableaux"
+25 "POSIX exige une nouvelle ligne entre un point-virgule et une d茅finition de fonction"
+26 "POSIX interdit la notation exponentielle"
+27 "POSIX interdit les r茅f茅rences 脿 un tableau dans les param猫tres d'une fonction"
+28 "POSIX n'autorise pas les fonctions void"
+29 "POSIX impose que l'en-t锚te de la fonction et le '{' soient sur la m锚me ligne"
+30 "POSIX interdit pas d'assigner des cha卯nes de caract猫res 脿 des variables ou 脿 des tableaux"
$ Runtime errors.
$set 5
diff --git a/locales/fr_FR.UTF-8.msg b/locales/fr_FR.UTF-8.msg
index 8e894e043bbc..6393ab0e5f70 100644
--- a/locales/fr_FR.UTF-8.msg
+++ b/locales/fr_FR.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX interdit les op茅rateurs de comparaison en dehors des expressions 'if' ou des boucles"
23 "POSIX impose 0 ou 1 op茅rateur de comparaison par condition"
24 "POSIX interdit une expression vide dans une boucle 'for'"
-25 "POSIX interdit la notation exponentielle"
-26 "POSIX interdit les r茅f茅rences 脿 un tableau dans les param猫tres d'une fonction"
-27 "POSIX impose que l'en-t锚te de la fonction et le '{' soient sur la m锚me ligne"
-28 "POSIX interdit pas d'assigner des cha卯nes de caract猫res 脿 des variables ou 脿 des tableaux"
+25 "POSIX exige une nouvelle ligne entre un point-virgule et une d茅finition de fonction."
+26 "POSIX interdit la notation exponentielle"
+27 "POSIX interdit les r茅f茅rences 脿 un tableau dans les param猫tres d'une fonction"
+28 "POSIX n'autorise pas les fonctions void"
+29 "POSIX impose que l'en-t锚te de la fonction et le '{' soient sur la m锚me ligne"
+30 "POSIX interdit pas d'assigner des cha卯nes de caract猫res 脿 des variables ou 脿 des tableaux"
$ Runtime errors.
$set 5
diff --git a/locales/ja_JP.UTF-8.msg b/locales/ja_JP.UTF-8.msg
index 4477f2bc548b..3c51aca8194f 100644
--- a/locales/ja_JP.UTF-8.msg
+++ b/locales/ja_JP.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX 銇 if 鏂囥倓銉兗銉椼伄澶栥伄姣旇純婕旂畻瀛愩倰瑷卞彲銇椼伨銇涖倱銆"
23 "POSIX銇潯浠躲仈銇ㄣ伀0銇俱仧銇1銇瘮杓冩紨绠楀瓙銈掑繀瑕併仺銇椼伨銇欍"
24 "POSIX銇痜or銉兗銉椼伄3銇ゃ伄閮ㄥ垎銇屻仚銇广仸绌恒仹銇亜銇撱仺銈掕姹傘仐銇俱仚銆"
-25 "POSIX銇寚鏁拌〃瑷樸倰瑷卞彲銇椼伨銇涖倱銆"
-26 "POSIX 銇枹鏁般儜銉┿儭銉笺偪銇ㄣ仐銇﹂厤鍒楀弬鐓с倰瑷卞彲銇椼伨銇涖倱銆"
-27 "POSIX銇с伅銆侀枹鏁般儤銉冦儉銇ㄥ悓銇樿銇乏涓嫭寮с亴銇傘倠銇撱仺銇屽繀瑕併仹銇欍"
-28 "POSIX銇с伅銆佸鏁般倓閰嶅垪銇枃瀛楀垪銈掑壊銈婂綋銇︺倠銇撱仺銇仹銇嶃伨銇涖倱銆"
+25 "POSIX銇с伅銆併偦銉熴偝銉兂銇ㄩ枹鏁板畾缇┿伄闁撱伀鏀硅銈掑叆銈屻倠蹇呰銇屻亗銈娿伨銇欍"
+26 "POSIX銇寚鏁拌〃瑷樸倰瑷卞彲銇椼伨銇涖倱銆"
+27 "POSIX 銇枹鏁般儜銉┿儭銉笺偪銇ㄣ仐銇﹂厤鍒楀弬鐓с倰瑷卞彲銇椼伨銇涖倱銆"
+28 "POSIX銇с伅void闁㈡暟銈掕獚銈併仸銇勩伨銇涖倱銆"
+29 "POSIX銇с伅銆侀枹鏁般儤銉冦儉銇ㄥ悓銇樿銇乏涓嫭寮с亴銇傘倠銇撱仺銇屽繀瑕併仹銇欍"
+30 "POSIX銇с伅銆佸鏁般倓閰嶅垪銇枃瀛楀垪銈掑壊銈婂綋銇︺倠銇撱仺銇仹銇嶃伨銇涖倱銆"
$ 銉┿兂銈裤偆銉犮偍銉┿兗銆
$set 5
diff --git a/locales/ja_JP.eucJP.msg b/locales/ja_JP.eucJP.msg
index a907cd7cf0e3..74bd09c27fd5 100644
--- a/locales/ja_JP.eucJP.msg
+++ b/locales/ja_JP.eucJP.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX は if 矢やル〖プの嘲の孺秤遍换灰を钓材しません。"
23 "POSIXは掘凤ごとに0または1の孺秤遍换灰を涩妥とします。"
24 "POSIXはforル〖プの3つの婶尸がすべて鄂でないことを妥滇します。"
-25 "POSIXは回眶山淡を钓材しません。"
-26 "POSIX は簇眶パラメ〖タとして芹误徊救を钓材しません。"
-27 "POSIXでは、簇眶ヘッダと票じ乖に焊面崇柑があることが涩妥です。"
-28 "POSIXでは、恃眶や芹误に矢机误を充り碰てることはできません。"
+25 "POSIXでは、セミコロンと簇眶年盗の粗に猖乖を掐れる涩妥があります。"
+26 "POSIXは回眶山淡を钓材しません。"
+27 "POSIX は簇眶パラメ〖タとして芹误徊救を钓材しません。"
+28 "POSIXではvoid簇眶を千めていません。"
+29 "POSIXでは、簇眶ヘッダと票じ乖に焊面崇柑があることが涩妥です。"
+30 "POSIXでは、恃眶や芹误に矢机误を充り碰てることはできません。"
$ ランタイムエラ〖。
$set 5
diff --git a/locales/nl_NL.ISO8859-1.msg b/locales/nl_NL.ISO8859-1.msg
index 76b8577108e8..2f60de23cca1 100644
--- a/locales/nl_NL.ISO8859-1.msg
+++ b/locales/nl_NL.ISO8859-1.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX laat geen vergelijking toe tussen operatoren buiten als verklaringen of lussen"
23 "POSIX vereist 0 of 1 vergelijkingsoperator per conditie"
24 "POSIX vereist dat alle 3 de delen van een lus niet leeg zijn"
-25 "POSIX laat geen exponenti雔e notatie toe"
-26 "POSIX staat geen arrayreferenties toe als functieparameters"
-27 "POSIX vereist dat de linkse beugel op dezelfde regel staat als de functiehoofding"
-28 "POSIX staat niet toe dat strings worden toegewezen aan variabelen of arrays"
+25 "POSIX vereist een nieuwe regel tussen een puntkomma en een functiedefinitie"
+26 "POSIX laat geen exponenti雔e notatie toe"
+27 "POSIX staat geen arrayreferenties toe als functieparameters"
+28 "POSIX staat geen lege functies toe"
+29 "POSIX vereist dat de linkse beugel op dezelfde regel staat als de functiehoofding"
+30 "POSIX staat niet toe dat strings worden toegewezen aan variabelen of arrays"
$ Runtime fouten.
$set 5
diff --git a/locales/nl_NL.UTF-8.msg b/locales/nl_NL.UTF-8.msg
index 51acb9867e22..599628a6cc51 100644
--- a/locales/nl_NL.UTF-8.msg
+++ b/locales/nl_NL.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX laat geen vergelijking toe tussen operatoren buiten als verklaringen of lussen"
23 "POSIX vereist 0 of 1 vergelijkingsoperator per conditie"
24 "POSIX vereist dat alle 3 de delen van een lus niet leeg zijn"
-25 "POSIX laat geen exponenti毛le notatie toe"
-26 "POSIX staat geen arrayreferenties toe als functieparameters"
-27 "POSIX vereist dat de linkse beugel op dezelfde regel staat als de functiehoofding"
-28 "POSIX staat niet toe dat strings worden toegewezen aan variabelen of arrays"
+25 "POSIX vereist een nieuwe regel tussen een puntkomma en een functiedefinitie"
+26 "POSIX laat geen exponenti毛le notatie toe"
+27 "POSIX staat geen arrayreferenties toe als functieparameters"
+28 "POSIX staat geen lege functies toe"
+29 "POSIX vereist dat de linkse beugel op dezelfde regel staat als de functiehoofding"
+30 "POSIX staat niet toe dat strings worden toegewezen aan variabelen of arrays"
$ Runtime fouten.
$set 5
diff --git a/locales/pl_PL.ISO8859-2.msg b/locales/pl_PL.ISO8859-2.msg
index d1d77d7e0b57..a36d5fe8beb5 100644
--- a/locales/pl_PL.ISO8859-2.msg
+++ b/locales/pl_PL.ISO8859-2.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX nie pozwala na por體nywanie operator體 na zewn眛rz, je秎i deklaracje lub p阾le"
23 "POSIX wymaga 0 lub 1 operatora por體nawczego na jeden warunek"
24 "POSIX wymaga, aby wszystkie 3 cz甓ci p阾li nie by硑 puste"
-25 "POSIX nie pozwala na notacj wyk砤dnicz"
-26 "POSIX nie zezwala na odniesienia do tablicy jako parametr體 funkcji"
-27 "POSIX wymaga, aby lewe usztywnienie znajdowa硂 si na tej samej linii co nag丑wek funkcji"
-28 "POSIX nie pozwala na przypisywanie ci眊體 znak體 do zmiennych lub tablic"
+25 "POSIX wymaga nowej linii pomi阣zy 秗ednikiem a definicj funkcji"
+26 "POSIX nie pozwala na notacj wyk砤dnicz"
+27 "POSIX nie zezwala na odniesienia do tablicy jako parametr體 funkcji"
+28 "POSIX nie dopuszcza funkcji void"
+29 "POSIX wymaga, aby lewe usztywnienie znajdowa硂 si na tej samej linii co nag丑wek funkcji"
+30 "POSIX nie pozwala na przypisywanie ci眊體 znak體 do zmiennych lub tablic"
$ B酬dy Runtime'u.
$set 5
diff --git a/locales/pl_PL.UTF-8.msg b/locales/pl_PL.UTF-8.msg
index a23a98edd1d2..ee297161a895 100644
--- a/locales/pl_PL.UTF-8.msg
+++ b/locales/pl_PL.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX nie pozwala na por贸wnywanie operator贸w na zewn膮trz, je艣li deklaracje lub p臋tle"
23 "POSIX wymaga 0 lub 1 operatora por贸wnawczego na jeden warunek"
24 "POSIX wymaga, aby wszystkie 3 cz臋艣ci p臋tli nie by艂y puste"
-25 "POSIX nie pozwala na notacj臋 wyk艂adnicz膮"
-26 "POSIX nie zezwala na odniesienia do tablicy jako parametr贸w funkcji"
-27 "POSIX wymaga, aby lewe usztywnienie znajdowa艂o si臋 na tej samej linii co nag艂贸wek funkcji"
-28 "POSIX nie pozwala na przypisywanie ci膮g贸w znak贸w do zmiennych lub tablic"
+25 "POSIX wymaga nowej linii pomi臋dzy 艣rednikiem a definicj膮 funkcji"
+26 "POSIX nie pozwala na notacj臋 wyk艂adnicz膮"
+27 "POSIX nie zezwala na odniesienia do tablicy jako parametr贸w funkcji"
+28 "POSIX nie dopuszcza funkcji void"
+29 "POSIX wymaga, aby lewe usztywnienie znajdowa艂o si臋 na tej samej linii co nag艂贸wek funkcji"
+30 "POSIX nie pozwala na przypisywanie ci膮g贸w znak贸w do zmiennych lub tablic"
$ B艂臋dy Runtime'u.
$set 5
diff --git a/locales/pt_PT.ISO8859-1.msg b/locales/pt_PT.ISO8859-1.msg
index 7a17f0642cc9..6197a73d0fe2 100644
--- a/locales/pt_PT.ISO8859-1.msg
+++ b/locales/pt_PT.ISO8859-1.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX n鉶 permite operadores de compara玢o fora das express鮡s 'if' ou loops"
23 "POSIX requer operadores 0 ou 1 de compara玢o por condi玢o"
24 "POSIX n鉶 permite uma express鉶 vazia em um loop 'for'"
-25 "POSIX n鉶 permite nota玢o exponencial"
-26 "POSIX n鉶 permite refer阯cias de matriz como par鈓etros de fun玢o"
-27 "POSIX requer que o cabe鏰lho da fun玢o '{' estejam na mesma linha"
-28 "POSIX n鉶 permite a atribui玢o de cadeias de caracteres a vari醰eis ou matrizes"
+25 "POSIX requer uma nova linha entre um ponto-e-v韗gula e uma defini玢o de fun玢o"
+26 "POSIX n鉶 permite nota玢o exponencial"
+27 "POSIX n鉶 permite refer阯cias de matriz como par鈓etros de fun玢o"
+28 "POSIX n鉶 permite fun珲es nulas"
+29 "POSIX requer que o cabe鏰lho da fun玢o '{' estejam na mesma linha"
+30 "POSIX n鉶 permite a atribui玢o de cadeias de caracteres a vari醰eis ou matrizes"
$ Runtime errors.
$set 5
diff --git a/locales/pt_PT.UTF-8.msg b/locales/pt_PT.UTF-8.msg
index 2f6a4683a376..768f8807ebfc 100644
--- a/locales/pt_PT.UTF-8.msg
+++ b/locales/pt_PT.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX n茫o permite operadores de compara莽茫o fora das express玫es 'if' ou loops"
23 "POSIX requer operadores 0 ou 1 de compara莽茫o por condi莽茫o"
24 "POSIX n茫o permite uma express茫o vazia em um loop 'for'"
-25 "POSIX n茫o permite nota莽茫o exponencial"
-26 "POSIX n茫o permite refer锚ncias de matriz como par芒metros de fun莽茫o"
-27 "POSIX requer que o cabe莽alho da fun莽茫o '{' estejam na mesma linha"
-28 "POSIX n茫o permite a atribui莽茫o de cadeias de caracteres a vari谩veis ou matrizes"
+25 "POSIX requer uma nova linha entre um ponto-e-v铆rgula e uma defini莽茫o de fun莽茫o"
+26 "POSIX n茫o permite nota莽茫o exponencial"
+27 "POSIX n茫o permite refer锚ncias de matriz como par芒metros de fun莽茫o"
+28 "POSIX n茫o permite fun莽玫es nulas"
+29 "POSIX requer que o cabe莽alho da fun莽茫o '{' estejam na mesma linha"
+30 "POSIX n茫o permite a atribui莽茫o de cadeias de caracteres a vari谩veis ou matrizes"
$ Runtime errors.
$set 5
diff --git a/locales/ru_RU.CP1251.msg b/locales/ru_RU.CP1251.msg
index 6b1d93aa2110..a094e08e4afb 100644
--- a/locales/ru_RU.CP1251.msg
+++ b/locales/ru_RU.CP1251.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX 礤 疣琊屮噱 铒屦囹铕囔 耩噔礤龛 恹躅滂螯 玎 镳邃咫, 羼腓 篁忮疰溴龛 桦 鲨觌"
23 "POSIX 蝠遽箦 0 桦 1 铒屦囹铕 耩噔礤龛 磬 篑腩忤"
24 "POSIX 蝠遽箦, 黩钺 怦 3 鬣耱 镥螂 猁腓 礤矬耱"
-25 "POSIX 礤 漕矬耜噱 耧铐屙鲨嚯铋 眍蜞鲨"
-26 "POSIX 礤 漕矬耜噱 耨觇 磬 爨耨桠 赅麇耱忮 镟疣戾蝠钼 趔黻鲨"
-27 "POSIX 蝠遽箦, 黩钺 脲忄 耜钺赅 猁豚 磬 蝾 驽 腓龛, 黩 玎泐腩忸 趔黻鲨"
-28 "POSIX 礤 镱玮铍弪 镳桉忄桠囹 耱痤觇 镥疱戾眄 桦 爨耨桠囔"
+25 "POSIX 蝠遽箦 磬腓麒 眍忸 耱痤觇 戾驿 蝾麝铋 玎蝾 铒疱溴脲龛屐 趔黻鲨"
+26 "POSIX 礤 漕矬耜噱 耧铐屙鲨嚯铋 眍蜞鲨"
+27 "POSIX 礤 漕矬耜噱 耨觇 磬 爨耨桠 赅麇耱忮 镟疣戾蝠钼 趔黻鲨"
+28 "POSIX 礤 疣琊屮噱 趔黻鲨 矬耱铗"
+29 "POSIX 蝠遽箦, 黩钺 脲忄 耜钺赅 猁豚 磬 蝾 驽 腓龛, 黩 玎泐腩忸 趔黻鲨"
+30 "POSIX 礤 镱玮铍弪 镳桉忄桠囹 耱痤觇 镥疱戾眄 桦 爨耨桠囔"
$ 硒栳觇 恹镱腠屙.
$set 5
diff --git a/locales/ru_RU.CP866.msg b/locales/ru_RU.CP866.msg
index b693428b9a3c..79070cda2e0c 100644
--- a/locales/ru_RU.CP866.msg
+++ b/locales/ru_RU.CP866.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX  酄оヨ牓 ム犫牞 徉牏 ㈦瀹え忪  イカ, メ 汊ⅴ唳ぅ ǐ 妯"
23 "POSIX 忄ァ悭 0 ǐ 1 ム犫 徉牏 瓲 汜ⅷ"
24 "POSIX 忄ァ悭, 玮 ⑨ 3 鐮徕 猥 ‰ 徕氍"
-25 "POSIX  ぎ岐牓 愍岑キ妯牜飙 鉅妯"
-26 "POSIX  ぎ岐牓 後氆 瓲 瑺後á 獱绁徕ⅴ 癄酄忄 溷妯"
-27 "POSIX 忄ァ悭, 玮  岐獱 ‰珷 瓲 猱 Ε , 玮 . 溷妯"
-28 "POSIX  Б铳 ㄡá犫 徕喈 啷氍 ǐ 瑺後á牞"
+25 "POSIX 忄ァ悭 瓲绋  徕喈 Δ 猱绐 猱 啷ぅガ 溷妯"
+26 "POSIX  ぎ岐牓 愍岑キ妯牜飙 鉅妯"
+27 "POSIX  ぎ岐牓 後氆 瓲 瑺後á 獱绁徕ⅴ 癄酄忄 溷妯"
+28 "POSIX  酄оヨ牓 溷妯 徕"
+29 "POSIX 忄ァ悭, 玮  岐獱 ‰珷 瓲 猱 Ε , 玮 . 溷妯"
+30 "POSIX  Б铳 ㄡá犫 徕喈 啷氍 ǐ 瑺後á牞"
$ 庤ā ㈦キ.
$set 5
diff --git a/locales/ru_RU.ISO8859-5.msg b/locales/ru_RU.ISO8859-5.msg
index 35af400c5831..4c544e94f846 100644
--- a/locales/ru_RU.ISO8859-5.msg
+++ b/locales/ru_RU.ISO8859-5.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX 菡 嘈奏砧姓 捱锗锈捺熊 徉幸菡葚 译遛载忪 仔 哙赵折, 蔗圬 汊艺嘀哉葚 刿 尕谯"
23 "POSIX 忄昭阏 0 刿 1 捱锗锈捺 徉幸菡葚 菪 汜坜邑"
24 "POSIX 忄昭阏, 玮扪 裔 3 缧徕 哒廑 央圬 菡咩徕胲"
-25 "POSIX 菡 赞咩嶷姓 碲徇掭蛰尕雄燧拶 蒉庑尕"
-26 "POSIX 菡 赞咩嶷姓 後脎谪 菪 苄後匾 谛缯徕艺 咝嘈苷忄抟 溷葳尕"
-27 "POSIX 忄昭阏, 玮扪 壅倚 嶷扪谛 央坌 菪 廪 终 圬葚, 玮 仔愚坜肄 溷葳尕"
-28 "POSIX 菡 咿滓捋镎 哙蒯倚匾锈 徕噢谪 哒嗾苷葺胲 刿 苄後匾熊"
+25 "POSIX 忄昭阏 菪圬缲 蒉肄 徕噢谪 苷衷 廪缵拶 仔唢廪 捱嗾哉壅葚哲 溷葳尕"
+26 "POSIX 菡 赞咩嶷姓 碲徇掭蛰尕雄燧拶 蒉庑尕"
+27 "POSIX 菡 赞咩嶷姓 後脎谪 菪 苄後匾 谛缯徕艺 咝嘈苷忄抟 溷葳尕"
+28 "POSIX 菡 嘈奏砧姓 溷葳尕 咩徕掴"
+29 "POSIX 忄昭阏, 玮扪 壅倚 嶷扪谛 央坌 菪 廪 终 圬葚, 玮 仔愚坜肄 溷葳尕"
+30 "POSIX 菡 咿滓捋镎 哙蒯倚匾锈 徕噢谪 哒嗾苷葺胲 刿 苄後匾熊"
$ 捐匮谪 译咿圯蛰仫.
$set 5
diff --git a/locales/ru_RU.KOI8-R.msg b/locales/ru_RU.KOI8-R.msg
index 98c667095852..50c716b5ca2e 100644
--- a/locales/ru_RU.KOI8-R.msg
+++ b/locales/ru_RU.KOI8-R.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX 闻 伊谝袍僚 闲乓猎弦镣 右磷闻紊 踪认纳载 诹 幸拍盘, 庞躺 赵着抑呐紊 商 蒙颂"
23 "POSIX 砸怕张 0 商 1 闲乓猎弦 右磷闻紊 瘟 沼滔咨"
24 "POSIX 砸怕张, 拊下 子 3 蘖釉 信蕴 沦躺 闻姓釉偻"
-25 "POSIX 闻 南姓铀僚 芩有衔盼蒙撂匚鲜 蜗粤蒙"
-26 "POSIX 闻 南姓铀僚 佑偬松 瘟 土佑勺 肆夼釉着 辛伊团砸献 普嗡蒙"
-27 "POSIX 砸怕张, 拊下 膛琢 铀下肆 沦塘 瘟 韵 峙 躺紊, 拊 诹窍滔紫 普嗡蒙"
-28 "POSIX 闻 邢谧咸雅 幸捎琢勺猎 釉蚁松 信遗团挝偻 商 土佑勺镣"
+25 "POSIX 砸怕张 瘟躺奚 蜗紫 釉蚁松 团帜 韵匏鲜 诹醒韵 闲遗呐膛紊磐 普嗡蒙"
+26 "POSIX 闻 南姓铀僚 芩有衔盼蒙撂匚鲜 蜗粤蒙"
+27 "POSIX 闻 南姓铀僚 佑偬松 瘟 土佑勺 肆夼釉着 辛伊团砸献 普嗡蒙"
+28 "POSIX 闻 伊谝袍僚 普嗡蒙 姓釉显"
+29 "POSIX 砸怕张, 拊下 膛琢 铀下肆 沦塘 瘟 韵 峙 躺紊, 拊 诹窍滔紫 普嗡蒙"
+30 "POSIX 闻 邢谧咸雅 幸捎琢勺猎 釉蚁松 信遗团挝偻 商 土佑勺镣"
$ 镗陕松 踪邢涛盼裳.
$set 5
diff --git a/locales/ru_RU.UTF-8.msg b/locales/ru_RU.UTF-8.msg
index f7c1dc58c4db..e37bb2182caf 100644
--- a/locales/ru_RU.UTF-8.msg
+++ b/locales/ru_RU.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX 薪械 褉邪蟹褉械褕邪械褌 芯锌械褉邪褌芯褉邪屑 褋褉邪胁薪械薪懈褟 胁褘褏芯写懈褌褜 蟹邪 锌褉械写械谢褘, 械褋谢懈 褍褌胁械褉卸写械薪懈褟 懈谢懈 褑懈泻谢褘"
23 "POSIX 褌褉械斜褍械褌 0 懈谢懈 1 芯锌械褉邪褌芯褉邪 褋褉邪胁薪械薪懈褟 薪邪 褍褋谢芯胁懈械"
24 "POSIX 褌褉械斜褍械褌, 褔褌芯斜褘 胁褋械 3 褔邪褋褌懈 锌械褌谢懈 斜褘谢懈 薪械锌褍褋褌褘屑懈"
-25 "POSIX 薪械 写芯锌褍褋泻邪械褌 褝泻褋锌芯薪械薪褑懈邪谢褜薪芯泄 薪芯褌邪褑懈懈"
-26 "POSIX 薪械 写芯锌褍褋泻邪械褌 褋褋褘谢泻懈 薪邪 屑邪褋褋懈胁 胁 泻邪褔械褋褌胁械 锌邪褉邪屑械褌褉芯胁 褎褍薪泻褑懈懈"
-27 "POSIX 褌褉械斜褍械褌, 褔褌芯斜褘 谢械胁邪褟 褋泻芯斜泻邪 斜褘谢邪 薪邪 褌芯泄 卸械 谢懈薪懈懈, 褔褌芯 懈 蟹邪谐芯谢芯胁芯泻 褎褍薪泻褑懈懈"
-28 "POSIX 薪械 锌芯蟹胁芯谢褟械褌 锌褉懈褋胁邪懈胁邪褌褜 褋褌褉芯泻懈 锌械褉械屑械薪薪褘屑 懈谢懈 屑邪褋褋懈胁邪屑"
+25 "POSIX 褌褉械斜褍械褌 薪邪谢懈褔懈褟 薪芯胁芯泄 褋褌褉芯泻懈 屑械卸写褍 褌芯褔泻芯泄 褋 蟹邪锌褟褌芯泄 懈 芯锌褉械写械谢械薪懈械屑 褎褍薪泻褑懈懈"
+26 "POSIX 薪械 写芯锌褍褋泻邪械褌 褝泻褋锌芯薪械薪褑懈邪谢褜薪芯泄 薪芯褌邪褑懈懈"
+27 "POSIX 薪械 写芯锌褍褋泻邪械褌 褋褋褘谢泻懈 薪邪 屑邪褋褋懈胁 胁 泻邪褔械褋褌胁械 锌邪褉邪屑械褌褉芯胁 褎褍薪泻褑懈懈"
+28 "POSIX 薪械 褉邪蟹褉械褕邪械褌 褎褍薪泻褑懈懈 锌褍褋褌芯褌褘"
+29 "POSIX 褌褉械斜褍械褌, 褔褌芯斜褘 谢械胁邪褟 褋泻芯斜泻邪 斜褘谢邪 薪邪 褌芯泄 卸械 谢懈薪懈懈, 褔褌芯 懈 蟹邪谐芯谢芯胁芯泻 褎褍薪泻褑懈懈"
+30 "POSIX 薪械 锌芯蟹胁芯谢褟械褌 锌褉懈褋胁邪懈胁邪褌褜 褋褌褉芯泻懈 锌械褉械屑械薪薪褘屑 懈谢懈 屑邪褋褋懈胁邪屑"
$ 袨褕懈斜泻懈 胁褘锌芯谢薪械薪懈褟.
$set 5
diff --git a/locales/zh_CN.GB18030.msg b/locales/zh_CN.GB18030.msg
index fb80db7de55d..a2210b19ed29 100644
--- a/locales/zh_CN.GB18030.msg
+++ b/locales/zh_CN.GB18030.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX不允许在if语句或循环之外的比较运算符"
23 "POSIX要求每个条件的比较运算符为0或1个"
24 "POSIX要求for循环的所有3个部分必须是非空的"
-25 "POSIX不允许使用指数符号"
-26 "POSIX不允许数组引用作为函数参数"
-27 "POSIX要求左边的括号和函数头在同一行上"
-28 "POSIX不允许将字符串分配给变量或数组"
+25 "POSIX要求在分号和函数定义之间使用换行符"
+26 "POSIX不允许使用指数符号"
+27 "POSIX不允许数组引用作为函数参数"
+28 "POSIX不允许无效函数"
+29 "POSIX要求左边的括号和函数头在同一行上"
+30 "POSIX不允许将字符串分配给变量或数组"
$ 运行时错误。
$set 5
diff --git a/locales/zh_CN.GB2312.msg b/locales/zh_CN.GB2312.msg
index fb80db7de55d..a2210b19ed29 100644
--- a/locales/zh_CN.GB2312.msg
+++ b/locales/zh_CN.GB2312.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX不允许在if语句或循环之外的比较运算符"
23 "POSIX要求每个条件的比较运算符为0或1个"
24 "POSIX要求for循环的所有3个部分必须是非空的"
-25 "POSIX不允许使用指数符号"
-26 "POSIX不允许数组引用作为函数参数"
-27 "POSIX要求左边的括号和函数头在同一行上"
-28 "POSIX不允许将字符串分配给变量或数组"
+25 "POSIX要求在分号和函数定义之间使用换行符"
+26 "POSIX不允许使用指数符号"
+27 "POSIX不允许数组引用作为函数参数"
+28 "POSIX不允许无效函数"
+29 "POSIX要求左边的括号和函数头在同一行上"
+30 "POSIX不允许将字符串分配给变量或数组"
$ 运行时错误。
$set 5
diff --git a/locales/zh_CN.GBK.msg b/locales/zh_CN.GBK.msg
index fb80db7de55d..a2210b19ed29 100644
--- a/locales/zh_CN.GBK.msg
+++ b/locales/zh_CN.GBK.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX不允许在if语句或循环之外的比较运算符"
23 "POSIX要求每个条件的比较运算符为0或1个"
24 "POSIX要求for循环的所有3个部分必须是非空的"
-25 "POSIX不允许使用指数符号"
-26 "POSIX不允许数组引用作为函数参数"
-27 "POSIX要求左边的括号和函数头在同一行上"
-28 "POSIX不允许将字符串分配给变量或数组"
+25 "POSIX要求在分号和函数定义之间使用换行符"
+26 "POSIX不允许使用指数符号"
+27 "POSIX不允许数组引用作为函数参数"
+28 "POSIX不允许无效函数"
+29 "POSIX要求左边的括号和函数头在同一行上"
+30 "POSIX不允许将字符串分配给变量或数组"
$ 运行时错误。
$set 5
diff --git a/locales/zh_CN.UTF-8.msg b/locales/zh_CN.UTF-8.msg
index c327c0b1b98c..92d1bb767cb0 100644
--- a/locales/zh_CN.UTF-8.msg
+++ b/locales/zh_CN.UTF-8.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX涓嶅厑璁稿湪if璇彞鎴栧惊鐜箣澶栫殑姣旇緝杩愮畻绗"
23 "POSIX瑕佹眰姣忎釜鏉′欢鐨勬瘮杈冭繍绠楃涓0鎴1涓"
24 "POSIX瑕佹眰for寰幆鐨勬墍鏈3涓儴鍒嗗繀椤绘槸闈炵┖鐨"
-25 "POSIX涓嶅厑璁镐娇鐢ㄦ寚鏁扮鍙"
-26 "POSIX涓嶅厑璁告暟缁勫紩鐢ㄤ綔涓哄嚱鏁板弬鏁"
-27 "POSIX瑕佹眰宸﹁竟鐨勬嫭鍙峰拰鍑芥暟澶村湪鍚屼竴琛屼笂"
-28 "POSIX涓嶅厑璁稿皢瀛楃涓插垎閰嶇粰鍙橀噺鎴栨暟缁"
+25 "POSIX瑕佹眰鍦ㄥ垎鍙峰拰鍑芥暟瀹氫箟涔嬮棿浣跨敤鎹㈣绗"
+26 "POSIX涓嶅厑璁镐娇鐢ㄦ寚鏁扮鍙"
+27 "POSIX涓嶅厑璁告暟缁勫紩鐢ㄤ綔涓哄嚱鏁板弬鏁"
+28 "POSIX涓嶅厑璁告棤鏁堝嚱鏁"
+29 "POSIX瑕佹眰宸﹁竟鐨勬嫭鍙峰拰鍑芥暟澶村湪鍚屼竴琛屼笂"
+30 "POSIX涓嶅厑璁稿皢瀛楃涓插垎閰嶇粰鍙橀噺鎴栨暟缁"
$ 杩愯鏃堕敊璇
$set 5
diff --git a/locales/zh_CN.eucCN.msg b/locales/zh_CN.eucCN.msg
index fb80db7de55d..a2210b19ed29 100644
--- a/locales/zh_CN.eucCN.msg
+++ b/locales/zh_CN.eucCN.msg
@@ -77,10 +77,12 @@ $set 4
22 "POSIX不允许在if语句或循环之外的比较运算符"
23 "POSIX要求每个条件的比较运算符为0或1个"
24 "POSIX要求for循环的所有3个部分必须是非空的"
-25 "POSIX不允许使用指数符号"
-26 "POSIX不允许数组引用作为函数参数"
-27 "POSIX要求左边的括号和函数头在同一行上"
-28 "POSIX不允许将字符串分配给变量或数组"
+25 "POSIX要求在分号和函数定义之间使用换行符"
+26 "POSIX不允许使用指数符号"
+27 "POSIX不允许数组引用作为函数参数"
+28 "POSIX不允许无效函数"
+29 "POSIX要求左边的括号和函数头在同一行上"
+30 "POSIX不允许将字符串分配给变量或数组"
$ 运行时错误。
$set 5
diff --git a/src/bc_parse.c b/src/bc_parse.c
index 91de31ad5389..8849c1b8e9c7 100644
--- a/src/bc_parse.c
+++ b/src/bc_parse.c
@@ -79,6 +79,7 @@ static bool bc_parse_inst_isLeaf(BcInst t) {
* that can legally end a statement. In bc's case, it could be a newline, a
* semicolon, and a brace in certain cases.
* @param p The parser.
+ * @return True if the token is a legal delimiter.
*/
static bool bc_parse_isDelimiter(const BcParse *p) {
@@ -128,6 +129,23 @@ static bool bc_parse_isDelimiter(const BcParse *p) {
}
/**
+ * Returns true if we are in top level of a function body. The POSIX grammar
+ * is defined such that anything is allowed after a function body, so we must
+ * use this function to detect that case when ending a function body.
+ * @param p The parser.
+ * @return True if we are in the top level of parsing a function body.
+ */
+static bool bc_parse_TopFunc(const BcParse *p) {
+
+ bool good = p->flags.len == 2;
+
+ uint16_t val = BC_PARSE_FLAG_BRACE | BC_PARSE_FLAG_FUNC_INNER;
+ val |= BC_PARSE_FLAG_FUNC;
+
+ return good && BC_PARSE_TOP_FLAG(p) == val;
+}
+
+/**
* Sets a previously defined exit label. What are labels? See the bc Parsing
* section of the Development manual (manuals/development.md).
* @param p The parser.
@@ -881,7 +899,7 @@ static void bc_parse_endBody(BcParse *p, bool brace) {
bc_lex_next(&p->l);
// If the next token is not a delimiter, that is a problem.
- if (BC_ERR(!bc_parse_isDelimiter(p)))
+ if (BC_ERR(!bc_parse_isDelimiter(p) && !bc_parse_TopFunc(p)))
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
@@ -1741,6 +1759,14 @@ static void bc_parse_stmt(BcParse *p) {
// Make sure semicolons are eaten.
while (p->l.t == BC_LEX_SCOLON) bc_lex_next(&p->l);
+
+ // POSIX's grammar does not allow a function definition after a semicolon
+ // without a newline, so check specifically for that case and error if
+ // the POSIX standard flag is set.
+ if (p->l.last == BC_LEX_SCOLON && p->l.t == BC_LEX_KW_DEFINE && BC_IS_POSIX)
+ {
+ bc_parse_err(p, BC_ERR_POSIX_FUNC_AFTER_SEMICOLON);
+ }
}
void bc_parse_parse(BcParse *p) {
diff --git a/src/data.c b/src/data.c
index 82475299ed78..959af600c1af 100644
--- a/src/data.c
+++ b/src/data.c
@@ -202,7 +202,7 @@ const uchar bc_err_ids[] = {
BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE,
BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE,
BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE,
- BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE,
+ BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE, BC_ERR_IDX_PARSE,
#endif // BC_ENABLED
};
@@ -273,6 +273,7 @@ const char* const bc_err_msgs[] = {
"POSIX does not allow comparison operators outside if statements or loops",
"POSIX requires 0 or 1 comparison operators per condition",
"POSIX requires all 3 parts of a for loop to be non-empty",
+ "POSIX requires a newline between a semicolon and a function definition",
#if BC_ENABLE_EXTRA_MATH
"POSIX does not allow exponential notation",
#else
diff --git a/tests/bc/all.txt b/tests/bc/all.txt
index 23244773b933..f85491d12424 100644
--- a/tests/bc/all.txt
+++ b/tests/bc/all.txt
@@ -43,6 +43,7 @@ misc4
misc5
misc6
misc7
+misc8
void
rand
recursive_arrays
diff --git a/tests/bc/misc8.txt b/tests/bc/misc8.txt
new file mode 100644
index 000000000000..8bef63316ef8
--- /dev/null
+++ b/tests/bc/misc8.txt
@@ -0,0 +1,8 @@
+define a(){
+ return 5
+}define b(){
+ return 6
+}
+24
+a()
+b()
diff --git a/tests/bc/misc8_results.txt b/tests/bc/misc8_results.txt
new file mode 100644
index 000000000000..daee0f1b2fbf
--- /dev/null
+++ b/tests/bc/misc8_results.txt
@@ -0,0 +1,3 @@
+24
+5
+6
diff --git a/tests/bc/posix_errors.txt b/tests/bc/posix_errors.txt
index d880600f7bb1..584a0198b5b3 100644
--- a/tests/bc/posix_errors.txt
+++ b/tests/bc/posix_errors.txt
@@ -7,6 +7,7 @@ halt
define x(e) { return 0; }
define x(e) { return 4*(e+e); }
define x(e) { return (e+e)*4; }
+define a() { return (5); };define b() { return (6); }
limits
.
if (q!=0) { x=3; } else { x=4; }