Skip to content

Commit

Permalink
[CWEB] Add option '-F' for CWEAVE/CTWILL.
Browse files Browse the repository at this point in the history
This alternative layout places the first line of a 'compound statement',
a.k.a. 'block', next to the opening curly brace.

Control statements like 'if', 'for', 'while', or 'switch' still appear
on a new line, in order to preserve visual control flow.

git-svn-id: svn://tug.org/texlive/trunk/Build/source@70550 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
Andreas Scherer committed Mar 10, 2024
1 parent 098e2a3 commit 446d5d9
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 95 deletions.
4 changes: 4 additions & 0 deletions texk/web2c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-03-10 Andreas Scherer <https://ascherer.github.io>

* help.h: Add new option '-F' for CWEAVE/CTWILL.

2024-02-28 Akira Kakuto <kakuto@jcom.zaq.ne.jp>

* eptexdir/unbalanced-braces-eptex.ch: avoid crashing with devious
Expand Down
16 changes: 15 additions & 1 deletion texk/web2c/cwebdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
2024-03-10 Andreas Scherer <https://ascherer.github.io>

* ctwill-hint.ch,
* ctwill-mini.ch,
* cweave.w,
* cweb.1,
* cwebman-w2c.ch,
* cwebman.tex,
* po/de/web2c-help.po,
* po/web2c-help.pot,
* prod-cweave.w,
* prod-twill.w,
* prod.w: Add new option '-F' for CWEAVE/CTWILL.

2024-02-14 Andreas Scherer <https://ascherer.github.io>

* cwtwill-proofsort: In-place invocation.
* ctwill-proofsort: In-place invocation.

2024-01-24 Andreas Scherer <https://ascherer.github.io>

Expand Down
6 changes: 4 additions & 2 deletions texk/web2c/cwebdir/ctwill-hint.ch
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,12 @@ Section 155.

@x
@d force_lines flags['f'] /* should each statement be on its own line? */
@d force_first flags['F'] /* should compound statement start on new line? */
@y
@d force_lines flags['f'] /* should each statement be on its own line? */
@-force_lines@>
@$force_lines {CTWILL}155 =\\{flags}[\.{'f'}]@>
@-force_lines@> @$force_lines {CTWILL}155 =\\{flags}[\.{'f'}]@>
@d force_first flags['F'] /* should compound statement start on new line? */
@-force_first@> @$force_first {CTWILL}155 =\\{flags}[\.{'F'}]@>
@z

Section 185.
Expand Down
11 changes: 9 additions & 2 deletions texk/web2c/cwebdir/ctwill-mini.ch
Original file line number Diff line number Diff line change
Expand Up @@ -1352,10 +1352,17 @@ Section 170.
@x
@d force_lines flags['f'] /* should each statement be on its own line? */
@d force_first flags['F'] /* should compound statement start on new line? */
@<Set init...@>=
force_lines=force_first=true;
@y
@d force_lines flags['f'] /* should each statement be on its own line? */
@-force_lines@>
@$force_lines {CTWILL}170 =\\{flags}[\.{'f'}]@>
@-force_lines@> @$force_lines {CTWILL}170 =\\{flags}[\.{'f'}]@>
@d force_first flags['F'] /* should compound statement start on new line? */
@-force_first@> @$force_first {CTWILL}170 =\\{flags}[\.{'F'}]@>
@<Set init...@>=@+force_lines=force_first=true;
@z
Section 173.
Expand Down
10 changes: 7 additions & 3 deletions texk/web2c/cwebdir/cweave.w
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,8 @@ if (cat1==rbrace) {
reduce(pp,2,stmt,-1,54);
}
else if ((cat1==stmt||cat1==decl||cat1==function) && cat2==rbrace) {
big_app(force); big_app1(pp); big_app(indent); big_app(force);
big_app(force); big_app1(pp); big_app(indent);
big_app(force_first ? force : break_space);
big_app1(pp+1); big_app(force); big_app(backup); big_app1(pp+2);
big_app(outdent); big_app(force); reduce(pp,3,stmt,-1,55);
}
Expand Down Expand Up @@ -2948,12 +2949,15 @@ else if (cat1==stmt||cat1==decl||cat1==function) {
else if (cat1==rbrace) reduce(pp,0,decl,-1,156);

@ The user can decide at run-time whether short statements should be
grouped together on the same line.
grouped together on the same line. Another form of compaction places
the first line of a `compound statement', a.k.a.\ `block', next to
the opening curly brace.

@d force_lines flags['f'] /* should each statement be on its own line? */
@d force_first flags['F'] /* should compound statement start on new line? */

@<Set init...@>=
force_lines=true;
force_lines=force_first=true;

@ @<Cases for |stmt|@>=
if (cat1==stmt || cat1==decl || cat1==function) {
Expand Down
9 changes: 6 additions & 3 deletions texk/web2c/cwebdir/cweb.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH CWEB 1 2023-Aug-20
.TH CWEB 1 2024-Mar-09
.
.SH NAME
ctangle, cweave \- translate CWEB to C and/or TeX
Expand All @@ -14,7 +14,7 @@ ctangle, cweave \- translate CWEB to C and/or TeX
.br
.B cweave
[
.B \-befhpx
.B \-befFhpx
] [
.B +st
] webfile[.w] [{changefile[.ch]|-} [outputfile[.tex]]]
Expand Down Expand Up @@ -86,11 +86,14 @@ only:
.B +k
means keep '-separators in numeric literals in the C/C++\ output.
.PP
There are four other options applicable to
There are five other options applicable to
.I cweave
only:
.B \-f
means do not force a newline after every statement in the formatted output.
.B \-F
means do not force a compound statement to start on a new line in the
formatted output.
.B \-e
inhibits the enclosure of C\ material formatted by
.I cweave
Expand Down
10 changes: 9 additions & 1 deletion texk/web2c/cwebdir/cwebman-w2c.ch
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,22 @@ argument to switch between different user languages and macro packages.
(Off by default.) (Has no effect on \.{CTANGLE}.)
\hfil\vskip\normallineskip
\option o Separate declarations and the first statement in a function block.
(On by default.) (Has no effect on \.{CTANGLE}.)
(On by default.) (\.{CWEAVE} only.)
\hfil\vskip\normallineskip
\option u Transliteration of UTF-8 multi-byte characters.
(Off by default.) (Has no effect on \.{CWEAVE}.)}

\yskip
@z

@x
\option x Include indexes and a table of contents in the \TEX/ file
output by \.{CWEAVE}. (On by default.) (Has no effect on \.{CTANGLE}.)
@y
\option x Include indexes and a table of contents in the \TEX/ file
output by \.{CWEAVE}. (On by default.) (\.{CWEAVE} only.)
@z

@x
Sometimes things don't work as smoothly, and you get a bunch of
@y
Expand Down
4 changes: 4 additions & 0 deletions texk/web2c/cwebdir/cwebman.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,10 @@
by \.{CWEAVE}. (On by default; \.{-f} saves paper but looks less \CEE/-like
to some people.) (Has no effect on \.{CTANGLE}.)

\option F Force the first statement in a `compound statement' (a.k.a.\
`block') on a line of its own. (On by default; some people prefer the
\.{-F} layout.) (Has no effect on \.{CTANGLE}.)

\option h Print a happy message at the conclusion of a successful
run. (On by default.)

Expand Down
86 changes: 47 additions & 39 deletions texk/web2c/cwebdir/po/de/web2c-help.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: CWEBbin 2021\n"
"Project-Id-Version: CWEBbin 2024\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-27 09:00+0200\n"
"PO-Revision-Date: 2021-07-27 09:00+0200\n"
"POT-Creation-Date: 2024-03-10 16:35+0100\n"
"PO-Revision-Date: 2024-03-10 16:35+0100\n"
"Last-Translator: Andreas Scherer <andreas_github@freenet.de>\n"
"Language-Team: German\n"
"Language: de\n"
Expand All @@ -27,122 +27,130 @@ msgstr ""
msgid " Tangle WEBFILE with CHANGEFILE into a C/C++ program."
msgstr " Verknüpfe WEBFILE mit CHANGEFILE in ein C/C++ Programm."

#: help.h:54 help.h:74 help.h:100
#: help.h:54 help.h:77 help.h:106
msgid " Default CHANGEFILE is /dev/null;"
msgstr " Vorgabe für CHANGEFILE ist /dev/null;"

#: help.h:55
msgid " C output goes to the basename of WEBFILE extended with `.c'"
msgstr " C Ausgabe geht in den Hauptnamen des WEBFILE erweitert um `.c',"

#: help.h:56 help.h:76 help.h:102
#: help.h:56 help.h:79 help.h:108
msgid " unless otherwise specified by OUTFILE; in this case, '-' specifies"
msgstr " sofern nicht ein anderes OUTFILE angegeben ist; in diesem Fall"

#: help.h:57 help.h:77 help.h:103
#: help.h:57 help.h:80 help.h:109
msgid " a null CHANGEFILE."
msgstr " bezeichnet '-' ein leeres CHANGEFILE."

#: help.h:59 help.h:79 help.h:105
#: help.h:59 help.h:82 help.h:111
msgid "+b print banner line on terminal"
msgstr "+b schreibe die Startmeldung"

#: help.h:64 help.h:85 help.h:112
msgid "-dN set 'kpathsea_debug' to N (0..127)"
msgstr "-dN setze 'kpathsea_debug' auf N (0..127)"

#: help.h:60 help.h:80 help.h:106
#: help.h:60 help.h:83 help.h:112
msgid "+h print success message on completion"
msgstr "+h schreibe die Erfolgsmeldung am Ende"

#: help.h:66
msgid "+k keep separators in numeric literals in the output"
msgstr "+k konserviere '-Trenner in Zahlen in der Ausgabe"

#: help.h:61 help.h:81 help.h:107
#: help.h:61 help.h:84 help.h:113
msgid "+p print progress report messages"
msgstr "+p schreibe die Fortschrittsmeldungen"

#: help.h:62 help.h:82 help.h:108
#: help.h:62 help.h:85 help.h:114
msgid "+/-q shortcut for '-bhp'; also '--quiet' (default)"
msgstr "+/-q Kurzform für '-bhp'; auch '--quiet' (Vorgabe)"

#: help.h:63 help.h:83 help.h:109
#: help.h:63 help.h:86 help.h:115
msgid "+/-v shortcut for '+bhp'; also '--verbose'"
msgstr "+/-v Kurzform für '+bhp'; auch '--verbose'"

#: help.h:64 help.h:85 help.h:112
#: help.h:64 help.h:87 help.h:116
msgid "+c check temporary output for changes"
msgstr "+c prüfe temporäre Ausgabe auf Änderungen"

#: help.h:66 help.h:93 help.h:121
#: help.h:65 help.h:88 help.h:117
msgid "-dN set 'kpathsea_debug' to N (0..127)"
msgstr "-dN setze 'kpathsea_debug' auf N (0..127)"

#: help.h:66
msgid "+k keep separators in numeric literals in the output"
msgstr "+k konserviere '-Trenner in Zahlen in der Ausgabe"

#: help.h:67 help.h:96 help.h:126
msgid "+s print usage statistics"
msgstr "+s melde die Verbrauchsstatistik"

#: help.h:95 help.h:124
msgid "+t treat 'typename' in a template like 'typedef'"
msgstr "+t behandle 'typename' in Templates wie 'typedef'"
#: help.h:68
msgid "+u transliterate UTF-8 characters in C code"
msgstr "+u ersetze UTF-8 Zeichen in C-Code"

#: help.h:66 help.h:92 help.h:119
#: help.h:69 help.h:98 help.h:128
msgid "--help display this help and exit"
msgstr "--help zeige diesen Hilfetext und ende"

#: help.h:67 help.h:93 help.h:120
#: help.h:70 help.h:99 help.h:129
msgid "--version output version information and exit"
msgstr "--version zeige die Versionsinformation und ende"

#: help.h:72
#: help.h:75
msgid ""
"Usage: cweave [OPTIONS] WEBFILE[.w] [{CHANGEFILE[.ch]|-} [OUTFILE[.tex]]]"
msgstr ""
"Aufruf: cweave [OPTIONS] WEBFILE[.w] [{CHANGEFILE[.ch]|-} [OUTFILE[.tex]]]"

#: help.h:73
#: help.h:76 help.h:638
msgid " Weave WEBFILE with CHANGEFILE into a TeX document."
msgstr " Verwebe WEBFILE mit CHANGEFILE in ein TeX Dokument."

#: help.h:75 help.h:101
#: help.h:78 help.h:107
msgid " TeX output goes to the basename of WEBFILE extended with `.tex'"
msgstr " TeX Ausgabe geht in den Hauptnamen des WEBFILE erweitert um `.tex',"

#: help.h:84 help.h:110
#: help.h:89 help.h:118
msgid "-e do not enclose C material in \\PB{...}"
msgstr "-e schließe C Material nicht in \\PB{...} ein"

#: help.h:85 help.h:111
#: help.h:90 help.h:119
msgid "-f do not force a newline after every C statement in output"
msgstr "-f erzwinge keinen Zeilenumbruch nach jedem C Statement"

#: help.h:86 help.h:112
#: help.h:91 help.h:120
msgid "-F do not force a compound statement to start on a new line"
msgstr "-F erzwinge keine neue Zeile am Beginn eines Code-Blocks"

#: help.h:92 help.h:121
msgid "-i suppress indentation of parameter declarations"
msgstr "-i unterdrücke die Einrückung von Parameterdeklarationen"

#: help.h:87 help.h:113
#: help.h:93 help.h:122
msgid "-o suppress separation of declarations and statements"
msgstr "-o unterdrücke die Trennung von Deklarationen und Statements"

#: help.h:88 help.h:114
#: help.h:94 help.h:123
msgid "-x omit indices, section names, table of contents"
msgstr "-x verzichte auf Indexe, Abschnittnamen und Inhaltsverzeichnis"

#: help.h:89
#: help.h:95
msgid "+lX use macros for language X as of Xcwebmac.tex"
msgstr "+lX benutze Macros für Sprache X aus Xcwebmac.tex"

#: help.h:98
#: help.h:97 help.h:127
msgid "+t treat 'typename' in a template like 'typedef'"
msgstr "+t behandle 'typename' in Templates wie 'typedef'"

#: help.h:104
msgid ""
"Usage: ctwill [OPTIONS] WEBFILE[.w] [{CHANGEFILE[.ch]|-} [OUTFILE[.tex]]]"
msgstr ""
"Aufruf: ctwill [OPTIONS] WEBFILE[.w] [{CHANGEFILE[.ch]|-} [OUTFILE[.tex]]]"

#: help.h:99
#: help.h:105 help.h:655
msgid " Weave WEBFILE with CHANGEFILE into a TeX document with mini-indexes."
msgstr " Verwebe WEBFILE mit CHANGEFILE in ein TeX Dokument mit Miniindexen."

#: help.h:115
#: help.h:124
msgid "+P \\input ctproofmac.tex instead of ctwimac.tex"
msgstr "+P \\input ctproofmac.tex an Stelle von ctwimac.tex"

#: help.h:116
#: help.h:125
msgid "+/-lX use macros for language X as of Xct{wi|proof}mac.tex"
msgstr "+/-lX benutze Macros für Sprache X aus Xct{wi|proof}mac.tex"
Loading

0 comments on commit 446d5d9

Please sign in to comment.