diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2019-06-19 22:35:59 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2019-06-19 22:35:59 +0300 |
commit | d5a252444627be4d98cd6b49b948f159512952bf (patch) | |
tree | 8396e83cef7260351d299b3ced693011918c2ac6 | |
parent | 395fc520934d5f01589ca4c966f3c9e9bb1203fd (diff) | |
parent | 69f851227e35c5aa31f89306bf37369b3acad483 (diff) | |
download | egawk-d5a252444627be4d98cd6b49b948f159512952bf.tar.gz egawk-d5a252444627be4d98cd6b49b948f159512952bf.tar.bz2 egawk-d5a252444627be4d98cd6b49b948f159512952bf.zip |
Merge branch 'gawk-5.0-stable'
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/it/ChangeLog | 4 | ||||
-rw-r--r-- | doc/it/gawktexi.in | 82 | ||||
-rw-r--r-- | re.c | 4 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 7 | ||||
-rw-r--r-- | test/Makefile.in | 12 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/escapebrace.awk | 2 | ||||
-rw-r--r-- | test/escapebrace.in | 1 | ||||
-rw-r--r-- | test/escapebrace.ok | 1 |
11 files changed, 87 insertions, 41 deletions
@@ -1,3 +1,8 @@ +2019-06-19 Arnold D. Robbins <arnold@skeeve.com> + + * re.c (make_regexp): If do_posix, have {} in ok_to_escape. + Thanks to Ed Morton <mortoneccc@comcast.net> for the report. + 2019-06-18 Arnold D. Robbins <arnold@skeeve.com> * 5.0.1: Release tar ball made. diff --git a/doc/it/ChangeLog b/doc/it/ChangeLog index 2224bb7f..8cd76f6f 100644 --- a/doc/it/ChangeLog +++ b/doc/it/ChangeLog @@ -1,3 +1,7 @@ +2019-06-18 Antonio Giovanni Colombo <azc100@gmail.com> + + * gawktexi.in: Updated. + 2019-06-18 Arnold D. Robbins <arnold@skeeve.com> * 5.0.1: Release tar ball made. diff --git a/doc/it/gawktexi.in b/doc/it/gawktexi.in index 158bc1a7..b3f0395a 100644 --- a/doc/it/gawktexi.in +++ b/doc/it/gawktexi.in @@ -56,7 +56,7 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH Maggio 2019 +@set UPDATE-MONTH Giugno 2019 @set VERSION 5.0 @set PATCHLEVEL 1 @@ -5986,6 +5986,14 @@ che contengono l'operatore alternativa, @samp{|}. Per esempio, Il significato di @samp{+} @`e spiegato pi@`u avanti in questa lista.) +La parentesi sinistra (di apertura) @`e sempre un metacarattere; +per cercare una corrispondenza letterale con una tale parentesi, +occorre farla precedere da una barra inversa. Comunque, la +parentesi destra (di chiusura), @`e speciale solo se eesiste la +relativa parentesi sinistra; una parentesi destra senza la +corrispondente parentesi sinistra @`e considerata (senza dare +alcun messaggio di avviso) come un normale carattere. + @cindex @code{*} (asterisco), operatore @code{*}, come operatore @dfn{regexp} @cindex asterisco (@code{*}), operatore @code{*}, come operatore @dfn{regexp} @item @code{*} @@ -8774,32 +8782,25 @@ finita l'elaborarezione del record corrente, e si vogliono fare delle elaborazioni particolari sul record successivo @emph{proprio adesso}. Per esempio: +@c 6/2019: Thanks to Mark Krauze <daburashka@ya.ru> for suggested +@c improvements (the inner while loop). @example # rimuovere il testo tra /* e */, compresi @{ - if ((i = index($0, "/*")) != 0) @{ - prima = substr($0, 1, i - 1) # la parte iniziale della stringa - dopo = substr($0, i + 2) # ... */ ... - j = index(dopo, "*/") # */ @`e nella parte finale? - if (j > 0) @{ - dopo = substr(dopo, j + 2) # rimozione del commento - @} else @{ - while (j == 0) @{ - # passa ai record seguenti - if (getline <= 0) @{ - print("Fine file inattesa o errore:", ERRNO) > "/dev/stderr" - exit - @} - # incrementare la riga usando la concatenazione di stringhe - dopo = dopo $0 - j = index(dopo, "*/") # @`e */ nella parte finale? - if (j != 0) @{ - dopo = substr(dopo, j + 2) - break - @} - @} + while ((inizio = index($0, "/*")) != 0) @{ + prima = substr($0, 1, inizio - 1) # parte iniziale della stringa + dopo = substr($0, inizio + 2) # ... */ ... + while ((fine = index(dopo, "*/")) == 0) @{ # */ @`e nella parte finale? + # passa ai record seguenti + if (getline <= 0) @{ + print("Fine file inattesa o errore:", ERRNO) > "/dev/stderr" + exit + @} + # costruisce la riga usando la concatenazione di stringhe + dopo = dopo $0 @} - # incrementare la riga di output usando la concatenazione + dopo = substr(dopo, fine + 2) # rimuove il commento + # costruisce la riga di output usando la concatenazione # di stringhe $0 = prima dopo @} @@ -8807,16 +8808,6 @@ Per esempio: @} @end example -@c 8/2014: Here is some sample input: -@ignore -mon/*comment*/key -rab/*commen -t*/bit -horse /*comment*/more text -part 1 /*comment*/part 2 /*comment*/part 3 -no comment -@end ignore - Questo programma @command{awk} cancella i commenti in stile C (@samp{/* @dots{} */}) dall'input. Usa diverse funzionalit@`a che non sono ancora state trattate, incluse la @@ -8827,9 +8818,28 @@ e le funzioni predefinite @code{index()} e @code{substr()} Sostituendo @samp{print $0} con altre istruzioni, si possono effettuare elaborazioni pi@`u complesse sull'input decommentato, come ricercare corrispondenze di un'espressione regolare. -(Questo programma ha un piccolo problema: non funziona se c'@`e pi@`u di un -commento che inizia e finisce -sulla stessa riga.) + +Ecco un esempio di file in input: + +@example +mon/*comment*/key +rab/*commen +t*/bit +horse /*comment*/more text +part 1 /*comment*/part 2 /*comment*/part 3 +no comment +@end example + +Quando lo si esegue, l'output @`e: + +@example +$ @kbd{awk -f strip_comments.awk example_text} +@print{} monkey +@print{} rabbit +@print{} horse more text +@print{} part 1 part 2 part 3 +@print{} no comment +@end example Questa forma del comando @code{getline} imposta @code{NF}, @code{NR}, @code{FNR}, @code{RT} e il valore di @code{$0}. @@ -107,7 +107,9 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) } const char *ok_to_escape; - if (do_traditional) + if (do_posix) + ok_to_escape = "{}()|*+?.^$\\[]/-"; + else if (do_traditional) ok_to_escape = "()|*+?.^$\\[]/-"; else ok_to_escape = "<>`'BywWsS{}()|*+?.^$\\[]/-"; diff --git a/test/ChangeLog b/test/ChangeLog index 9d8f0d03..a53c2d13 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2019-06-19 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (EXTRA_DIST): New test: escapebrace. + * escapebrace.awk, escapebrace.in, escapebrace.ok: New files. + 2019-06-18 Arnold D. Robbins <arnold@skeeve.com> * 5.0.1: Release tar ball made. diff --git a/test/Makefile.am b/test/Makefile.am index 3db7c04d..58ee1304 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -266,6 +266,9 @@ EXTRA_DIST = \ dumpvars.ok \ dynlj.awk \ dynlj.ok \ + escapebrace.awk \ + scapebrace.in \ + scapebrace.ok \ eofsplit.awk \ eofsplit.ok \ eofsrc1a.awk \ @@ -1295,7 +1298,7 @@ BASIC_TESTS = \ callparam childin clobber closebad clsflnam compare compare2 \ concat1 concat2 concat3 concat4 concat5 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ - eofsplit eofsrc1 exit2 exitval1 exitval2 exitval3 \ + escapebrace eofsplit eofsrc1 exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fldterm fnamedat fnarray fnarray2 \ fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \ fsrs fsspcoln fstabplus funsemnl funsmnam funstack \ @@ -1408,7 +1411,7 @@ NEED_MPFR = mpfrbigint mpfrbigint2 mpfrexprange mpfrfield mpfrieee mpfrmemok1 \ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum # List of tests that need --posix -NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix +NEED_POSIX = escapebrace printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix # List of tests that need --pretty-print NEED_PRETTY = nsprof1 nsprof2 \ diff --git a/test/Makefile.in b/test/Makefile.in index 5496d3cf..ce5b2e26 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -525,6 +525,9 @@ EXTRA_DIST = \ dumpvars.ok \ dynlj.awk \ dynlj.ok \ + escapebrace.awk \ + scapebrace.in \ + scapebrace.ok \ eofsplit.awk \ eofsplit.ok \ eofsrc1a.awk \ @@ -1554,7 +1557,7 @@ BASIC_TESTS = \ callparam childin clobber closebad clsflnam compare compare2 \ concat1 concat2 concat3 concat4 concat5 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ - eofsplit eofsrc1 exit2 exitval1 exitval2 exitval3 \ + escapebrace eofsplit eofsrc1 exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fldterm fnamedat fnarray fnarray2 \ fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \ fsrs fsspcoln fstabplus funsemnl funsmnam funstack \ @@ -1666,7 +1669,7 @@ NEED_MPFR = mpfrbigint mpfrbigint2 mpfrexprange mpfrfield mpfrieee mpfrmemok1 \ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum # List of tests that need --posix -NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix +NEED_POSIX = escapebrace printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix # List of tests that need --pretty-print NEED_PRETTY = nsprof1 nsprof2 \ @@ -3023,6 +3026,11 @@ dynlj: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +escapebrace: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + eofsplit: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index cf85ef8d..a17bf90e 100644 --- a/test/Maketests +++ b/test/Maketests @@ -272,6 +272,11 @@ dynlj: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +escapebrace: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + eofsplit: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/escapebrace.awk b/test/escapebrace.awk new file mode 100644 index 00000000..bda73431 --- /dev/null +++ b/test/escapebrace.awk @@ -0,0 +1,2 @@ +/\{/ +# should be no warning diff --git a/test/escapebrace.in b/test/escapebrace.in new file mode 100644 index 00000000..b1d2cc0f --- /dev/null +++ b/test/escapebrace.in @@ -0,0 +1 @@ +foo{bar diff --git a/test/escapebrace.ok b/test/escapebrace.ok new file mode 100644 index 00000000..b1d2cc0f --- /dev/null +++ b/test/escapebrace.ok @@ -0,0 +1 @@ +foo{bar |