Skip to content

Commit 406033a

Browse files
committed
0.9
1 parent 20fe0ef commit 406033a

File tree

8 files changed

+69
-64
lines changed

8 files changed

+69
-64
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PACKAGE := pcpp
2-
VERSION := 0.8
2+
VERSION := 0.9
33
AUTHOR := R.Jaksa 2008,2024 GPLv3
4-
SUBVERSION := c
4+
SUBVERSION :=
55

66
SHELL := /bin/bash
77
PATH := usr/bin:$(PATH)
@@ -16,10 +16,10 @@ DOC := $(BIN:%=%.md)
1616
all: $(BIN) $(DOC)
1717

1818
$(BIN): %: %.pl .%.d .version.pl .%.built.pl Makefile
19-
echo -e '#!/usr/bin/perl' > $@
20-
echo -e "# $@ generated from $(PKGNAME)/$< $(DATE)" >> $@
19+
@echo -e '#!/usr/bin/perl' > $@
20+
@echo -e "# $@ generated from $(PKGNAME)/$< $(DATE)" >> $@
2121
usr/bin/pcpp $< >> $@
22-
chmod 755 $@
22+
@chmod 755 $@
2323
@sync # to ensure pcpp is saved before used in the next rule
2424
@echo
2525

@@ -34,12 +34,12 @@ $(DOC): %.md: %
3434
@echo 'our $$VERSION = "$(VERSION)";' >> $@
3535
@echo 'our $$AUTHOR = "$(AUTHOR)";' >> $@
3636
@echo 'our $$SUBVERSION = "$(SUBVERSION)";' >> $@
37-
@echo "update $@"
37+
@echo "make $@"
3838

3939
.PRECIOUS: .%.built.pl
4040
.%.built.pl: %.pl .version.pl Makefile
4141
@echo 'our $$BUILT = "$(DATE)";' > $@
42-
@echo "update $@"
42+
@echo "make $@"
4343

4444
# /map install, requires /map directory and getversion and mapinstall tools
4545
ifneq ($(wildcard /map),)

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
0.9 - -d shows nonexistent files too
12
- better -l output
23
0.8 - raised version number to be above perlpp
34
- added -d to generate Makefile dependencies lists

README.md

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Simple Perl (Python/C/C++) preprocessor
22

3-
This simple preprocessor handles in-comments include directive. Such include
4-
statements that are contained inside comments provide additional level of code
5-
organization, above the Perl's `require` and `use`, or Python's `import`, or
6-
C/C++ `#include` native mechanisms. However, these both mechanisms (native and
3+
This simple preprocessor handles in-comments include directives. Such include
4+
statements that are contained inside comments provide an additional level of
5+
code organization, above Perl's `require` and `use`, Python's `import`, or
6+
C/C++ `#include` native mechanisms. However, both these mechanisms (native and
77
pcpp) can coexist together. Or, the pcpp can be used instead of the native
88
mechanism.
99

10-
In following Perl and C examples the "abc" code will be copy-pasted into source
11-
code by the pcpp, while the "xyz" code will be handled be native include
12-
mechanisms:
10+
In the following Perl and C examples the "abc" code will be copy-pasted into
11+
the source code by the pcpp, while the "xyz" code will be handled by native
12+
include mechanisms:
1313

1414
``` perl
1515
# Perl usage
@@ -47,26 +47,26 @@ perl abc.pl
4747
```
4848

4949
This looks as if we first "compile" the bunch of Perl source files into the
50-
"executable" Perl file and only then run it. Similarly to a c code, which has
51-
to be compiled before it can be executed. It is a disadvantage as it requires
52-
the extra step `pcpp abc.in.pl`. But the following step `perl abc.pl` becomes
53-
actually simpler:
50+
"executable" Perl file and only then run it. Similarly, a C code has to be
51+
compiled before it can be executed. It is a disadvantage as it requires the
52+
extra step `pcpp abc.in.pl`. But the following step `perl abc.pl` becomes
53+
simpler:
5454

5555
* now the abc\.pl doesn't require the dependent .pl files to be installed,
56-
* the abc\.pl stays a interpreted language code which can be fixed if needed
56+
* the abc\.pl stays an interpreted language code that can be fixed if needed
5757
(comments stay in as well).
5858

59-
The same holds for Python. Pcpp-ing is some kind of simple code amalgamation,
59+
The same holds for Python. Pcpp-ing is some kind of simple code amalgamation
6060
or a "static linker" for Perl/Python. In C/C++ the pcpp is useful if you want
6161
to hide something from the cpp preprocessor.
6262

63-
Other reason to use pcpp instead of native require/use/import is that the pcpp
64-
processing logic is simpler. And one more reason is that such include process
65-
cannot be skewed at the use-time, run-time.
63+
Another reason to use pcpp instead of native require/use/import is that the
64+
pcpp processing logic is simpler. One more reason is that such include process
65+
cannot be skewed at the use-time and run-time.
6666

6767
### In-comment directives
6868

69-
Hidding the pcpp directives in comments allows to avoid conflicts with the main
69+
Hiding the pcpp directives in comments allows to avoid conflicts with the main
7070
language interpreter/compiler/preprocessor, with IDEs or editing modes.
7171
Further, this increases the number of comments ;-)
7272

@@ -79,15 +79,15 @@ optional, whitespace between the hash and the "include" word is optional:
7979

8080
The additional text after the filename(s) is a comment and is ignored,
8181
filenames have to be identified by the .pl (or .py/.h) suffix or have to be
82-
quoted for the parser to find the begin of comment:
82+
quoted for the parser to find the beginning of the comment:
8383

8484
```
8585
# include abc.pl xyz.pl comment text which is ignored
8686
# include abc.py xyz.py # visualy more noticeable comment
8787
// include abc.h comment in C/C++
8888
```
8989

90-
Multiple hashes (slashes) are not accepted, thus following code are just
90+
Multiple hashes (slashes) are not accepted, the following code are just
9191
comments without any effect:
9292

9393
```
@@ -107,15 +107,16 @@ Included content in the pcpp output is "watermarked" by the `# included` and
107107
# end "abc.pl"
108108
```
109109

110-
Indentation of the include statement is propagated into output. For instance
111-
a two-spaces indentation of the hash of include statement in perl code:
110+
Indentation of the include statement is propagated into output. For instance a
111+
two-space indentation of the hash of the include statement in perl code:
112112

113113
``` perl
114114
some(code);
115115
# include abc.pl
116116
```
117117

118-
will lead to added two spaces to the original indentation in included file:
118+
will lead to adding two spaces to the original indentation in the included
119+
file:
119120

120121
``` perl
121122
some(code);
@@ -126,26 +127,26 @@ some(code);
126127
```
127128

128129
The language is autodetected according to the suffix of the input file: `.pl`,
129-
`.py`, `.c` or `.c++`.
130+
`.py`, `.c`, or `.c++`.
130131

131132
### Paths resolving
132133

133-
Include paths can be spcified as a filename only `# include abc.pl` or
134+
Include paths can be specified as a filename only `# include abc.pl` or
134135
specifying also a part of the path `# include xy/abc.pl` or `# include
135136
yz/abc.pl` to distinguish between equal filenames in different directories.
136137
The resolving algorithm is:
137138

138-
1. trying direct path from current working directory,
139-
2. trying path from directory of file from which the include is called,
140-
3. try to find file recursively in any subdirectory of current working directory (in the depth order),
141-
4. strip the directory part from include file name, and try to find it just by the filename.
139+
1. trying direct path from the current working directory,
140+
2. trying the path from the directory of the file from which the include is called,
141+
3. try to find files recursively in any subdirectory of the current working directory (in the depth order),
142+
4. strip the directory part from the included file name, and try to find it just by the filename.
142143

143144
In the case of conflict, i.e. `# include "abc.pl"` where two `abc.pl` are
144-
available, the first one is chosen: `./abc.pl` is direct path so has higher
145-
priority than the `xy/abc.pl`.
145+
available, the first one is chosen: `./abc.pl` is the direct path so it has a
146+
higher priority than the `xy/abc.pl`.
146147

147-
Double includes are avoided, so the file from given path is copy-pasted to the
148-
output only once, on the place of the firste appearance of the include
148+
Double includes are avoided, so the file from the given path is copy-pasted to
149+
the output only once, on the place of the first appearance of the include
149150
statement.
150151

151152
Missing include files are by default silently ignored, or reported in the
@@ -154,9 +155,9 @@ verbose mode (-v switch).
154155
### Triple comments
155156

156157
Pcpp preserves comments to allow the Perl or Python output code to be readable
157-
as best as possible in order to allow the output to be hacked/fixed.
158+
as best as possible to allow the output to be hacked/fixed.
158159

159-
However, to allow programmer to request the removal of comments from the
160+
However, to allow the programmer to request the removal of comments from the
160161
output, we introduce the "triple comments":
161162

162163
```
@@ -176,7 +177,7 @@ the pcpp processed code, not the code you wrote.
176177

177178
### Uninclude
178179

179-
Watermarked pcpp output allows to remove included parts and return to the
180+
Watermarked pcpp output allows the removal of included parts and return to the
180181
original source code using the `uninclude` tool. This can be useful when
181182
building "libraries" which can recursively pack all dependencies, which can be
182183
stripped off when not needed (when already provided by another "library").
@@ -194,7 +195,7 @@ instance the following included content:
194195
# end abc.pl
195196
```
196197

197-
will be flattend by uninclude to:
198+
will be flattened by uninclude to:
198199

199200
```
200201
# include abc.pl
@@ -215,20 +216,20 @@ which when included back will become:
215216

216217
### Pcpp in Makefile
217218

218-
Example to make `xyz` from from its source `xyz.pl` and two included files:
219+
Example to make `xyz` from its source `xyz.pl` and two included files:
219220

220221
``` makefile
221222
xyz: xyz.pl inc1.pl inc2.pl
222223
echo '#!/usr/bin/perl' > $@
223224
pcpp $< >> $@
224225
@chmod 755 $@
225-
@sync # to ensure the result is saved before used in the next rule
226+
@sync # to ensure the result is saved before being used in the next rule
226227
```
227228

228229
1. generate #! interpreter identifier
229230
2. build `xyz` from `xyz.pl`
230231
3. make it executable
231-
4. sync the result before it is used by other makefile rule (otherwise it can be incomplete)
232+
4. sync the result before it is used by another makefile rule (otherwise it can be incomplete)
232233

233234
More complex example:
234235

@@ -248,13 +249,16 @@ $(OUTPUT): %: %.pl $(DEPENDENCIES) Makefile
248249
```
249250

250251
* `DEPENDENCIES` are a list of files to be included obtained by `pcpp -lp`
251-
* `SIGN` is a variable made available from Makefile into script
252+
* `SIGN` is a variable made available from Makefile into the script
252253

253254
### Dependency files
254255

255256
The `pcpp -d target_name` can be used to generate a dependency file for
256257
Makefile. Compared to the `-lp` option, the `-d` and `-dd` options also add
257-
the input file into the list. Example Makefile:
258+
the input file into the list and nonexistent files too. Nonexistent include
259+
files are files that will be generated by the Makefile. A full path is
260+
required for them to work properly (relative path is ok if it is complete).
261+
Example Makefile:
258262

259263
``` makefile
260264
# require rebuild of the dependencies file .abc.d when processing abc.pl
@@ -282,7 +286,7 @@ to any `/bin` directory for a system-wide installation.
282286

283287
### Under the hood
284288

285-
The pcpp itself is processed by the pcpp, so its source code is example how to
286-
use the pcpp.
289+
The pcpp itself is processed by the pcpp, so its source code is an example of
290+
how to use the pcpp.
287291

288292
<br><div align=right><i>R.Jaksa 2008,2024</i></div>

include.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
elsif($ok==3) { report $CC_,beautify($path) } # OK
8080
else { report $CR_,$file } # not found
8181

82-
# deps
83-
$DEPLIST.=beautify($path)." " if $DEPS and $ok;
82+
# deps (show also nonexistent files, to allow to be generated)
83+
$DEPLIST.=beautify($path)." " if $DEPS;
8484

8585
return if $ok==0; # file not found
8686
return if $ok==1; # file already included (TODO: accept if requested, but avoid recursion)

pcpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/perl
2-
# pcpp generated from pcpp-0.8c/pcpp.pl 2024-06-30
2+
# pcpp generated from pcpp-0.9/pcpp.pl 2024-07-06
33

44
# included ".version.pl"
55
our $PACKAGE = "pcpp";
6-
our $VERSION = "0.8";
6+
our $VERSION = "0.9";
77
our $AUTHOR = "R.Jaksa 2008,2024 GPLv3";
8-
our $SUBVERSION = "c";
8+
our $SUBVERSION = "";
99
# end ".version.pl"
1010

1111
# included ".pcpp.built.pl"
12-
our $BUILT = "2024-06-30";
12+
our $BUILT = "2024-07-06";
1313
# end ".pcpp.built.pl"
1414

1515
$HELP=<<EOF;
@@ -433,8 +433,8 @@ our sub addfile {
433433
elsif($ok==3) { report $CC_,beautify($path) } # OK
434434
else { report $CR_,$file } # not found
435435

436-
# deps
437-
$DEPLIST.=beautify($path)." " if $DEPS and $ok;
436+
# deps (show also nonexistent files, to allow to be generated)
437+
$DEPLIST.=beautify($path)." " if $DEPS;
438438

439439
return if $ok==0; # file not found
440440
return if $ok==1; # file already included (TODO: accept if requested, but avoid recursion)

pcpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ Simple Perl/Python/C/C++ preprocessor for in-comment directives.
5858
pcpp -d pcpp pcpp.pl > .pcpp.d
5959

6060
### VERSION
61-
pcpp-0.8c R.Jaksa 2008,2024 GPLv3 built 2024-06-30
61+
pcpp-0.9 R.Jaksa 2008,2024 GPLv3 built 2024-07-06
6262

uninclude

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/perl
2-
# uninclude generated from pcpp-0.8c/uninclude.pl 2024-06-30
2+
# uninclude generated from pcpp-0.9/uninclude.pl 2024-07-06
33

44
# included ".version.pl"
55
our $PACKAGE = "pcpp";
6-
our $VERSION = "0.8";
6+
our $VERSION = "0.9";
77
our $AUTHOR = "R.Jaksa 2008,2024 GPLv3";
8-
our $SUBVERSION = "c";
8+
our $SUBVERSION = "";
99
# end ".version.pl"
1010

1111
# included ".uninclude.built.pl"
12-
our $BUILT = "2024-06-30";
12+
our $BUILT = "2024-07-06";
1313
# end ".uninclude.built.pl"
1414

1515
$HELP=<<EOF;

uninclude.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ but they are flattened to a single level direct includes.
1616
-ni Don't return back #include statements.
1717

1818
### VERSION
19-
pcpp-0.8c R.Jaksa 2008,2024 GPLv3 built 2024-06-30
19+
pcpp-0.9 R.Jaksa 2008,2024 GPLv3 built 2024-07-06
2020

0 commit comments

Comments
 (0)