Skip to contentSkip to conversation

Trial of labeling lines in code snippets

GIT PULL Akira Yokosawa 2 participants 30 messages Jul 21, 2018 – Aug 6, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Does this approach look reasonable to you?

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#1 lore raw
Quoted 11 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#2 lore raw
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Quoted 6 lines
Quoted 1 line

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

One idea is to embed meta labels in code samples.
When converting them to a proper Verbatim sources, short labels such as " //\lnlbl{foo}" can be converted to long ones such as "%lnlbl[ln:<chapter>:<basename of snippet file>:foo]" in the script to remove " //".

To do this, we need to embed extra meta data as comments in sample code.

For example, the source of waitall() function (in api-pthread.h) can be written as the following (in the form of \lnlbl{}):

----
/*
* Wait on all child processes.
*/
static __inline__ void waitall(void)
{
// \begin{snippet}[chapter=toolsoftrade,name=waitall,commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {				//\lnlbl{loopa}
		pid = wait(&status);		//\lnlb{wait}
		if (pid == -1) {
			if (errno == ECHILD)	//\lnlb{ECHILD}
				break;		//\lnlbl{break}
			perror("wait");		//\lnlbl{perror}
			exit(EXIT_FAILURE);	//\lnlbl{exit}
		}
		poll(NULL, 0, 1);
	}					//\lnlbl{loopb}
}

// \end{snippet}
...
----

, and it can be extracted and converted into CodeSamples/api-pthread/waitall.tex in the following way (including substitution of escape charactors):

\begin{Verbatim}[commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {%lnlbl[ln:toolsoftrade:waitall:loopa]
		pid = wait(&status);%lnlbl[ln:toolsoftrade:waitall:wait]
		if (pid == -1) {
			if (errno == ECHILD)%lnlbl[ln:toolsoftrade:waitall:ECHILD]
				break;%lnlbl[ln:toolsoftrade:break]
			perror("wait");%lnlbl[ln:toolsoftrade:perror]
			exit(EXIT_FAILURE);%lnlbl[ln:toolsoftrade:exit]
		}
		poll(NULL, 0, 1);
	}%lnlbl[ln:toolsoftrade:loopb]
}

\end{Verbatim}

This file can be read in toolsoftrade.tex in the following way:

---
\begin{listing}[tbp] \input{CodeSamples/api-pthread/waitall} \caption{Using the \tco{wait()} Primitive} \label{lst:toolsoftrade:Using the wait() Primitive} \end{listing}
---

The conversion script should not be so hard to implement. Update of build scripts should also be possible to automate these conversions.

If you'd like to use the caption of the listing in the final labels, the caption should also be given in the meta \begin{snippet} command. But for lines in code snippets, using file names as labels sounds reasonable to me.

Thoughts?

Thanks, Akira

Quoted 35 lines

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#3 lore raw
Quoted 86 lines · Akira Yokosawa
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Quoted 6 lines
Quoted 1 line

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

One idea is to embed meta labels in code samples.
When converting them to a proper Verbatim sources, short labels such as " //\lnlbl{foo}" can be converted to long ones such as "%lnlbl[ln:<chapter>:<basename of snippet file>:foo]" in the script to remove " //".

To do this, we need to embed extra meta data as comments in sample code.

For example, the source of waitall() function (in api-pthread.h) can be written as the following (in the form of \lnlbl{}):

----
/*
* Wait on all child processes.
*/
static __inline__ void waitall(void)
{
// \begin{snippet}[chapter=toolsoftrade,name=waitall,commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {				//\lnlbl{loopa}
		pid = wait(&status);		//\lnlb{wait}
		if (pid == -1) {
			if (errno == ECHILD)	//\lnlb{ECHILD}
				break;		//\lnlbl{break}
			perror("wait");		//\lnlbl{perror}
			exit(EXIT_FAILURE);	//\lnlbl{exit}
		}
		poll(NULL, 0, 1);
	}					//\lnlbl{loopb}
}

// \end{snippet}
...
----

, and it can be extracted and converted into CodeSamples/api-pthread/waitall.tex in the following way (including substitution of escape charactors):

\begin{Verbatim}[commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {%lnlbl[ln:toolsoftrade:waitall:loopa]
		pid = wait(&status);%lnlbl[ln:toolsoftrade:waitall:wait]
		if (pid == -1) {
			if (errno == ECHILD)%lnlbl[ln:toolsoftrade:waitall:ECHILD]
				break;%lnlbl[ln:toolsoftrade:break]
			perror("wait");%lnlbl[ln:toolsoftrade:perror]
			exit(EXIT_FAILURE);%lnlbl[ln:toolsoftrade:exit]
		}
		poll(NULL, 0, 1);
	}%lnlbl[ln:toolsoftrade:loopb]
}

\end{Verbatim}

This file can be read in toolsoftrade.tex in the following way:

---
\begin{listing}[tbp] \input{CodeSamples/api-pthread/waitall} \caption{Using the \tco{wait()} Primitive} \label{lst:toolsoftrade:Using the wait() Primitive} \end{listing}
---

Quoted 8 lines

The conversion script should not be so hard to implement. Update of build scripts should also be possible to automate these conversions.

If you'd like to use the caption of the listing in the final labels, the caption should also be given in the meta \begin{snippet} command. But for lines in code snippets, using file names as labels sounds reasonable to me.

I believe that your scheme is pretty close. My thought is directory, file, function, label. You have all but file already. That allows captions to change without changing the line label, which seems like a good thing.

Seem reasonable?

Thanx, Paul

Quoted 40 lines

Thoughts?

Thanks, Akira

Quoted 35 lines

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#5 lore raw
In reply to Akira Yokosawa
Quoted 97 lines · Akira Yokosawa
Quoted 96 lines · Paul E. McKenney
Quoted 94 lines · Akira Yokosawa
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Quoted 6 lines
Quoted 1 line

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

One idea is to embed meta labels in code samples.
When converting them to a proper Verbatim sources, short labels such as " //\lnlbl{foo}" can be converted to long ones such as "%lnlbl[ln:<chapter>:<basename of snippet file>:foo]" in the script to remove " //".

To do this, we need to embed extra meta data as comments in sample code.

For example, the source of waitall() function (in api-pthread.h) can be written as the following (in the form of \lnlbl{}):

----
/*
* Wait on all child processes.
*/
static __inline__ void waitall(void)
{
// \begin{snippet}[chapter=toolsoftrade,name=waitall,commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {				//\lnlbl{loopa}
		pid = wait(&status);		//\lnlb{wait}
		if (pid == -1) {
			if (errno == ECHILD)	//\lnlb{ECHILD}
				break;		//\lnlbl{break}
			perror("wait");		//\lnlbl{perror}
			exit(EXIT_FAILURE);	//\lnlbl{exit}
		}
		poll(NULL, 0, 1);
	}					//\lnlbl{loopb}
}

// \end{snippet}
...
----

, and it can be extracted and converted into CodeSamples/api-pthread/waitall.tex in the following way (including substitution of escape charactors):

\begin{Verbatim}[commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {%lnlbl[ln:toolsoftrade:waitall:loopa]
		pid = wait(&status);%lnlbl[ln:toolsoftrade:waitall:wait]
		if (pid == -1) {
			if (errno == ECHILD)%lnlbl[ln:toolsoftrade:waitall:ECHILD]
				break;%lnlbl[ln:toolsoftrade:break]
			perror("wait");%lnlbl[ln:toolsoftrade:perror]
			exit(EXIT_FAILURE);%lnlbl[ln:toolsoftrade:exit]
		}
		poll(NULL, 0, 1);
	}%lnlbl[ln:toolsoftrade:loopb]
}

\end{Verbatim}

This file can be read in toolsoftrade.tex in the following way:

---
\begin{listing}[tbp] \input{CodeSamples/api-pthread/waitall} \caption{Using the \tco{wait()} Primitive} \label{lst:toolsoftrade:Using the wait() Primitive} \end{listing}
---

The conversion script should not be so hard to implement. Update of build scripts should also be possible to automate these conversions.

If you'd like to use the caption of the listing in the final labels, the caption should also be given in the meta \begin{snippet} command. But for lines in code snippets, using file names as labels sounds reasonable to me.

Quoted 7 lines
Quoted 4 lines

I believe that your scheme is pretty close. My thought is directory, file, function, label. You have all but file already. That allows captions to change without changing the line label, which seems like a good thing.

In the end, "chapter=foo,name=bar,func=baz" can be expressed as "labelprefix=foo:bar:baz in the option to meta \begin{snippet} command.

I meant:

"labelprefix=foo:bar:baz"

Akira

Quoted 54 lines

So you can put any string you like there.

I'll do v2 of the trial branch along this scheme, hopefully including build script/Makefile updates. Maybe in a week or so.

Thanks, Akira

Quoted 46 lines

Seem reasonable?

Thanx, Paul

Quoted 40 lines

Thoughts?

Thanks, Akira

Quoted 35 lines

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#4 lore raw
In reply to Paul E. McKenney
Quoted 96 lines · Paul E. McKenney
Quoted 86 lines · Akira Yokosawa
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Quoted 6 lines
Quoted 1 line

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

One idea is to embed meta labels in code samples.
When converting them to a proper Verbatim sources, short labels such as " //\lnlbl{foo}" can be converted to long ones such as "%lnlbl[ln:<chapter>:<basename of snippet file>:foo]" in the script to remove " //".

To do this, we need to embed extra meta data as comments in sample code.

For example, the source of waitall() function (in api-pthread.h) can be written as the following (in the form of \lnlbl{}):

----
/*
* Wait on all child processes.
*/
static __inline__ void waitall(void)
{
// \begin{snippet}[chapter=toolsoftrade,name=waitall,commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {				//\lnlbl{loopa}
		pid = wait(&status);		//\lnlb{wait}
		if (pid == -1) {
			if (errno == ECHILD)	//\lnlb{ECHILD}
				break;		//\lnlbl{break}
			perror("wait");		//\lnlbl{perror}
			exit(EXIT_FAILURE);	//\lnlbl{exit}
		}
		poll(NULL, 0, 1);
	}					//\lnlbl{loopb}
}

// \end{snippet}
...
----

, and it can be extracted and converted into CodeSamples/api-pthread/waitall.tex in the following way (including substitution of escape charactors):

\begin{Verbatim}[commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {%lnlbl[ln:toolsoftrade:waitall:loopa]
		pid = wait(&status);%lnlbl[ln:toolsoftrade:waitall:wait]
		if (pid == -1) {
			if (errno == ECHILD)%lnlbl[ln:toolsoftrade:waitall:ECHILD]
				break;%lnlbl[ln:toolsoftrade:break]
			perror("wait");%lnlbl[ln:toolsoftrade:perror]
			exit(EXIT_FAILURE);%lnlbl[ln:toolsoftrade:exit]
		}
		poll(NULL, 0, 1);
	}%lnlbl[ln:toolsoftrade:loopb]
}

\end{Verbatim}

This file can be read in toolsoftrade.tex in the following way:

---
\begin{listing}[tbp] \input{CodeSamples/api-pthread/waitall} \caption{Using the \tco{wait()} Primitive} \label{lst:toolsoftrade:Using the wait() Primitive} \end{listing}
---

Quoted 8 lines

The conversion script should not be so hard to implement. Update of build scripts should also be possible to automate these conversions.

If you'd like to use the caption of the listing in the final labels, the caption should also be given in the meta \begin{snippet} command. But for lines in code snippets, using file names as labels sounds reasonable to me.

Quoted 4 lines

I believe that your scheme is pretty close. My thought is directory, file, function, label. You have all but file already. That allows captions to change without changing the line label, which seems like a good thing.

In the end, "chapter=foo,name=bar,func=baz" can be expressed as "labelprefix=foo:bar:baz in the option to meta \begin{snippet} command. So you can put any string you like there.

I'll do v2 of the trial branch along this scheme, hopefully including build script/Makefile updates. Maybe in a week or so.

Thanks, Akira

Quoted 46 lines

Seem reasonable?

Thanx, Paul

Quoted 40 lines

Thoughts?

Thanks, Akira

Quoted 35 lines

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#6 lore raw
In reply to Akira Yokosawa
Quoted 103 lines · Akira Yokosawa
Quoted 102 lines · Akira Yokosawa
Quoted 100 lines · Paul E. McKenney
Quoted 86 lines · Akira Yokosawa
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Akira Yokosawa

Hi Paul,

So, an experimental branch to label particular lines in code snippets is ready for review.
The branch is based on current master of yours.

I've converted 4 code snippets in Section 4.2. and updated corresponding code samples (sans forkjoin.c because it is quite simplified in Listing 4.1).

Quoted 6 lines
Quoted 1 line

Does this approach look reasonable to you?

This does look promising, thank you! Please give me some time to think this over a bit. My normal approach would end up with very long labels in the code, which might be OK. The argument against is that tying the listing caption to the actual code might not be a great thing.

One idea is to embed meta labels in code samples.
When converting them to a proper Verbatim sources, short labels such as " //\lnlbl{foo}" can be converted to long ones such as "%lnlbl[ln:<chapter>:<basename of snippet file>:foo]" in the script to remove " //".

To do this, we need to embed extra meta data as comments in sample code.

For example, the source of waitall() function (in api-pthread.h) can be written as the following (in the form of \lnlbl{}):

----
/*
* Wait on all child processes.
*/
static __inline__ void waitall(void)
{
// \begin{snippet}[chapter=toolsoftrade,name=waitall,commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {				//\lnlbl{loopa}
		pid = wait(&status);		//\lnlb{wait}
		if (pid == -1) {
			if (errno == ECHILD)	//\lnlb{ECHILD}
				break;		//\lnlbl{break}
			perror("wait");		//\lnlbl{perror}
			exit(EXIT_FAILURE);	//\lnlbl{exit}
		}
		poll(NULL, 0, 1);
	}					//\lnlbl{loopb}
}

// \end{snippet}
...
----

, and it can be extracted and converted into CodeSamples/api-pthread/waitall.tex in the following way (including substitution of escape charactors):

\begin{Verbatim}[commandchars=[\%\[\]]

	int pid;
	int status;

	for (;;) {%lnlbl[ln:toolsoftrade:waitall:loopa]
		pid = wait(&status);%lnlbl[ln:toolsoftrade:waitall:wait]
		if (pid == -1) {
			if (errno == ECHILD)%lnlbl[ln:toolsoftrade:waitall:ECHILD]
				break;%lnlbl[ln:toolsoftrade:break]
			perror("wait");%lnlbl[ln:toolsoftrade:perror]
			exit(EXIT_FAILURE);%lnlbl[ln:toolsoftrade:exit]
		}
		poll(NULL, 0, 1);
	}%lnlbl[ln:toolsoftrade:loopb]
}

\end{Verbatim}

This file can be read in toolsoftrade.tex in the following way:

---
\begin{listing}[tbp] \input{CodeSamples/api-pthread/waitall} \caption{Using the \tco{wait()} Primitive} \label{lst:toolsoftrade:Using the wait() Primitive} \end{listing}
---

Quoted 8 lines

The conversion script should not be so hard to implement. Update of build scripts should also be possible to automate these conversions.

If you'd like to use the caption of the listing in the final labels, the caption should also be given in the meta \begin{snippet} command. But for lines in code snippets, using file names as labels sounds reasonable to me.

I believe that your scheme is pretty close. My thought is directory, file, function, label. You have all but file already. That allows captions to change without changing the line label, which seems like a good thing.

Quoted 6 lines
Quoted 2 lines

In the end, "chapter=foo,name=bar,func=baz" can be expressed as "labelprefix=foo:bar:baz in the option to meta \begin{snippet} command.

I meant:

"labelprefix=foo:bar:baz"

Sounds very good, thank you!!!

Thanx, Paul

Quoted 57 lines

Akira

Quoted 54 lines

So you can put any string you like there.

I'll do v2 of the trial branch along this scheme, hopefully including build script/Makefile updates. Maybe in a week or so.

Thanks, Akira

Quoted 46 lines

Seem reasonable?

Thanx, Paul

Quoted 40 lines

Thoughts?

Thanks, Akira

Quoted 35 lines

Again, looks promising, thank you!

Thanx, Paul

Quoted 29 lines

Thanks, Akira

---
The following changes since commit e3191997557e0d33b862e267fb4d5971e879ca07:

utilities: Provide scripts instead of broken symlinks (2018-07-18 11:40:57 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook trial-fancyvrb

for you to fetch changes up to 2154a175e469e6238c89d4c494d204a9ddbaa20a:

[EXP] Update hyphen2endash (2018-07-21 09:17:34 +0900)

----------------------------------------------------------------
Akira Yokosawa (3):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash

 CodeSamples/api-pthreads/api-pthreads.h |  14 +-
 CodeSamples/toolsoftrade/forkjoinvar.c  |  10 +-
 CodeSamples/toolsoftrade/pcreate.c      |   5 +-
 perfbook.tex                            |   6 +
 toolsoftrade/toolsoftrade.tex           | 221 +++++++++++++++++---------------
 utilities/hyphen2endash.sh              |   3 +
 6 files changed, 141 insertions(+), 118 deletions(-)
#7 lore raw
In reply to Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#8 lore raw
Quoted 7 lines · Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Quoted 7 lines

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

Looks very nice!

So the effect of these are to establish a "label name environment"?

\renewcommand{\lnlblbase}{ln:toolsoftrade:forkjoin:main} \renewcommand{\lnrefbase}{ln:toolsoftrade:forkjoin:main}

This is very good -- allows use of short names, but also avoids managing a very large flat global namespace.

Then the C++ comments containing the "snippet" commands automate code extraction, plus those containing the "lnlbl" commands to automate label generation.

This looks extremely good to me. It makes it much easier to modify the code and the discussion of that code.

Any thoughts from others?

Thanx, Paul

Quoted 53 lines

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#9 lore raw
Quoted 14 lines · Paul E. McKenney
Quoted 13 lines · Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

Quoted 8 lines
Quoted 1 line

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

Looks very nice!

So the effect of these are to establish a "label name environment"?

\renewcommand{\lnlblbase}{ln:toolsoftrade:forkjoin:main} \renewcommand{\lnrefbase}{ln:toolsoftrade:forkjoin:main}

Yes.
Another approach would be to define a *real* environment and enclose those parts where \lnref{} commands are used inside the environment.

If we name the environment "lineref", the LaTeX source would look like:

\begin{lineref}[ln:toolsoftrade:forkjoin:main]
If \co{fork()} succeeds, it returns twice, once for the parent and again for the child.
[...]
Otherwise, the \co{fork()} has executed successfully, and the parent therefore executes line~\lnref{parent} with the variable \co{pid} containing the process ID of the child.
\end{lineref}

This might be clearer to see where the label-base string is effective.

\lnlblbase could also have its own environment defined.

I'll try this approach in v3 of this branch.

Thanks, Akira

Quoted 69 lines

This is very good -- allows use of short names, but also avoids managing a very large flat global namespace.

Then the C++ comments containing the "snippet" commands automate code extraction, plus those containing the "lnlbl" commands to automate label generation.

This looks extremely good to me. It makes it much easier to modify the code and the discussion of that code.

Any thoughts from others?

Thanx, Paul

Quoted 53 lines

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#10 lore raw
Quoted 41 lines · Akira Yokosawa
Quoted 14 lines · Paul E. McKenney
Quoted 13 lines · Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

Quoted 8 lines
Quoted 1 line

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

Looks very nice!

So the effect of these are to establish a "label name environment"?

\renewcommand{\lnlblbase}{ln:toolsoftrade:forkjoin:main} \renewcommand{\lnrefbase}{ln:toolsoftrade:forkjoin:main}

Yes.
Another approach would be to define a *real* environment and enclose those parts where \lnref{} commands are used inside the environment.

If we name the environment "lineref", the LaTeX source would look like:

\begin{lineref}[ln:toolsoftrade:forkjoin:main]
If \co{fork()} succeeds, it returns twice, once for the parent and again for the child.
[...]
Otherwise, the \co{fork()} has executed successfully, and the parent therefore executes line~\lnref{parent} with the variable \co{pid} containing the process ID of the child.
\end{lineref}

Quoted 6 lines

This might be clearer to see where the label-base string is effective.

\lnlblbase could also have its own environment defined.

I'll try this approach in v3 of this branch.

That wasn't actually intended as a criticism, but I do agree that the \begin-\end style is more clear. ;-)

Thanx, Paul

Quoted 72 lines

Thanks, Akira

Quoted 69 lines

This is very good -- allows use of short names, but also avoids managing a very large flat global namespace.

Then the C++ comments containing the "snippet" commands automate code extraction, plus those containing the "lnlbl" commands to automate label generation.

This looks extremely good to me. It makes it much easier to modify the code and the discussion of that code.

Any thoughts from others?

Thanx, Paul

Quoted 53 lines

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#11 lore raw
Quoted 45 lines · Paul E. McKenney
Quoted 44 lines · Akira Yokosawa
Quoted 14 lines · Paul E. McKenney
Quoted 13 lines · Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

Quoted 8 lines
Quoted 1 line

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

Looks very nice!

So the effect of these are to establish a "label name environment"?

\renewcommand{\lnlblbase}{ln:toolsoftrade:forkjoin:main} \renewcommand{\lnrefbase}{ln:toolsoftrade:forkjoin:main}

Yes.
Another approach would be to define a *real* environment and enclose those parts where \lnref{} commands are used inside the environment.

If we name the environment "lineref", the LaTeX source would look like:

\begin{lineref}[ln:toolsoftrade:forkjoin:main]
If \co{fork()} succeeds, it returns twice, once for the parent and again for the child.
[...]
Otherwise, the \co{fork()} has executed successfully, and the parent therefore executes line~\lnref{parent} with the variable \co{pid} containing the process ID of the child.
\end{lineref}

This might be clearer to see where the label-base string is effective.

Quoted 6 lines
Quoted 3 lines

\lnlblbase could also have its own environment defined.

I'll try this approach in v3 of this branch.

That wasn't actually intended as a criticism, but I do agree that the \begin-\end style is more clear. ;-)

No, there was no way I took it as a criticism.
Your mention of a "label name environment" was a cue for me to think "Why not make it a real environment". ;-)

Thanks, Akira

Quoted 76 lines

Thanx, Paul

Quoted 72 lines

Thanks, Akira

Quoted 69 lines

This is very good -- allows use of short names, but also avoids managing a very large flat global namespace.

Then the C++ comments containing the "snippet" commands automate code extraction, plus those containing the "lnlbl" commands to automate label generation.

This looks extremely good to me. It makes it much easier to modify the code and the discussion of that code.

Any thoughts from others?

Thanx, Paul

Quoted 53 lines

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#12 lore raw
Quoted 48 lines · Akira Yokosawa
Quoted 47 lines · Paul E. McKenney
Quoted 46 lines · Akira Yokosawa
Quoted 14 lines · Paul E. McKenney
Quoted 13 lines · Akira Yokosawa

Hi Paul,

This is v2 of the trial of fancyvrb scheme.

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180730a

Quoted 8 lines
Quoted 1 line

for you to fetch changes up to 3361b7331cf0f08a75bf6a9f69b7ea2f126e3b75:

Looks very nice!

So the effect of these are to establish a "label name environment"?

\renewcommand{\lnlblbase}{ln:toolsoftrade:forkjoin:main} \renewcommand{\lnrefbase}{ln:toolsoftrade:forkjoin:main}

Yes.
Another approach would be to define a *real* environment and enclose those parts where \lnref{} commands are used inside the environment.

If we name the environment "lineref", the LaTeX source would look like:

\begin{lineref}[ln:toolsoftrade:forkjoin:main]
If \co{fork()} succeeds, it returns twice, once for the parent and again for the child.
[...]
Otherwise, the \co{fork()} has executed successfully, and the parent therefore executes line~\lnref{parent} with the variable \co{pid} containing the process ID of the child.
\end{lineref}

This might be clearer to see where the label-base string is effective.

\lnlblbase could also have its own environment defined.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I'll try this approach in v3 of this branch.

That wasn't actually intended as a criticism, but I do agree that the \begin-\end style is more clear. ;-)

No, there was no way I took it as a criticism.
Your mention of a "label name environment" was a cue for me to think "Why not make it a real environment". ;-)

Fair enough! ;-)

Thanx, Paul

Quoted 74 lines
Quoted 73 lines
Quoted 72 lines

Thanks, Akira

Quoted 69 lines

This is very good -- allows use of short names, but also avoids managing a very large flat global namespace.

Then the C++ comments containing the "snippet" commands automate code extraction, plus those containing the "lnlbl" commands to automate label generation.

This looks extremely good to me. It makes it much easier to modify the code and the discussion of that code.

Any thoughts from others?

Thanx, Paul

Quoted 53 lines

[EXP] Automate sub makefile update (2018-07-31 00:31:56 +0900)

----------------------------------------------------------------
Akira Yokosawa (6):
[EXP] toolsoftrade: Add labels in code samples as comments [EXP] Add script to extract code snippet from code sample [EXP] toolsoftrade: Reference line in code snippets by label [EXP] Update hyphen2endash
[EXP] Add *.fcv to .gitignore
[EXP] Automate sub makefile update

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 ++--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 ++-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  12 +++
 toolsoftrade/toolsoftrade.tex           | 174 ++++++++++----------------------
 utilities/fcvextract.pl                 | 166 ++++++++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 ++++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 322 insertions(+), 141 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

---

There are quite a few changes since v1:

o Rebased to current master.
o Use line label format of "ln:directory:filename:function:linelabel"
o To avoid repetitive use of long labels in reference, introduce \lnlblbase and \lnrefbase macros. By this change, now \lnlbl{} and \lnref{} can have simple line labels.
o Add a script to extract VerbatimL sources from code samples.
o Add a script to generate sub makefile for snippet extraction.
o Update Makefile accordingly.

The scheme looks like to work for 90% of code snippets.

TODO list for me to improve:

o Support of code snippets other than "C".
o Support option to meta command \begin{snippet} other than labelbase and commandchars.
o Support of commandchars option with no escape charactor required

If this looks ready for you to merge, I'll amend commit logs and add header comment to gen_snippets_mk.pl and send a proper pull request. Please try this branch and let me know what you think.

Thanks, Akika

#13 lore raw
In reply to Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl
#15 lore raw
In reply to Paul E. McKenney
Quoted 85 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

Quoted 7 lines

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.

Thanks for testing!

Looks like gen_snippet_mk.pl need some brush up. Or there might be missing dependencies in Makefile.
I admit the new scripts have been tested only in a limited circumstances... I will respin soon.

Quoted 16 lines

echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
--> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115. make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

------------------------------------------------------------------------

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Quoted 6 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Glad to know you liked it! ;-)

Akira

Quoted 3 lines

Thanx, Paul

#16 lore raw
In reply to Paul E. McKenney
Quoted 103 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2
Quoted 2 lines

------------------------------------------------------------------------

There is one thing I'd like to confirm.
Did you do "make" just after checking out the trial branch (before modifying forkjoinvar.c)?

I can't reproduce the above issue on the head of the branch.

In the middle of the branch, there is a point when CodeSamples/snippets.mk resides in the repository. It might have newer time stamp than the modified forkjoinvar.c. (Well, I'don't think this is likely...)

I'll add a recipe to remove CodeSamples/snippets.mk by "make clean". You'll be able to do "make clean; make" if something goes wrong.

Quoted 2 lines

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Ah, you don't reproduce it once "make" succeeds. Hmm...

Quoted 4 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

Build script changes might need "make clean" after "git pull". (Current HEAD doesn't remove snippets.mk even by "make neatfreak", though.)

I also have some other updates in build scripts to add dependencies to code/makefile generation scripts themselves. Will submit another pull request when it's ready.

Thanks, Akira

Quoted 6 lines

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#14 lore raw
In reply to Akira Yokosawa
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */

------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2

------------------------------------------------------------------------

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#17 lore raw
In reply to Akira Yokosawa
Quoted 104 lines · Akira Yokosawa
Quoted 103 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2
Quoted 5 lines
Quoted 1 line

------------------------------------------------------------------------

There is one thing I'd like to confirm.
Did you do "make" just after checking out the trial branch (before modifying forkjoinvar.c)?

Yes. I pulled your changes, typed "make", modified forkjoinvar.c, typed "make" again, and then saw the failure. When I next modified forkjoinvar.c yet again and yet again typed "make", no failure.

Quoted 1 line

I can't reproduce the above issue on the head of the branch.

Hmmm... Let me try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". Builds fine.

3. Apply diff. Builds fine.

So I cannot reproduce, either. Hate it when that happens. :-/

But all the .fcv files would be left around, which might be influencing things. Let's remove those and try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". This now fails:

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

3. Type "make" again. Builds fine.

Quoted 3 lines

In the middle of the branch, there is a point when CodeSamples/snippets.mk resides in the repository. It might have newer time stamp than the modified forkjoinvar.c. (Well, I'don't think this is likely...)

I didn't test any but your last commit, if that is what you are asking.

Quoted 2 lines

I'll add a recipe to remove CodeSamples/snippets.mk by "make clean". You'll be able to do "make clean; make" if something goes wrong.

Adding that and the .fcv files to "make clean" sounds like a good thing in general. Give or take my experience when the .fcv files were missing, anyway. ;-)

Except that "make clean" already removes at least some of the .fcv files. And the top-level snippets.mk file. Ah, but not CodeSamples/snippets.mk.

Quoted 11 lines
Quoted 2 lines

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Ah, you don't reproduce it once "make" succeeds. Hmm...

Quoted 3 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

Build script changes might need "make clean" after "git pull". (Current HEAD doesn't remove snippets.mk even by "make neatfreak", though.)

If I do "rm CodeSamples/toolsoftrade/*.fcv", "make clean", and then "make", I get this:

$ make
sh utilities/autodate.sh >autodate.tex
future/ibmqx2-labeled.svg --> future/ibmqx2-labeled.png
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

Then another "make" works fine.

Quoted 3 lines

I also have some other updates in build scripts to add dependencies to code/makefile generation scripts themselves. Will submit another pull request when it's ready.

Sounds very good!

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 6 lines

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#18 lore raw
Quoted 134 lines · Paul E. McKenney
Quoted 104 lines · Akira Yokosawa
Quoted 103 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2
Quoted 5 lines
Quoted 1 line

------------------------------------------------------------------------

There is one thing I'd like to confirm.
Did you do "make" just after checking out the trial branch (before modifying forkjoinvar.c)?

Yes. I pulled your changes, typed "make", modified forkjoinvar.c, typed "make" again, and then saw the failure. When I next modified forkjoinvar.c yet again and yet again typed "make", no failure.

Quoted 1 line

I can't reproduce the above issue on the head of the branch.

Hmmm... Let me try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". Builds fine.

3. Apply diff. Builds fine.

So I cannot reproduce, either. Hate it when that happens. :-/

But all the .fcv files would be left around, which might be influencing things. Let's remove those and try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". This now fails:

Quoted 17 lines
$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

Hmm... I still can't reproduce.
The error message suggests failure to generate CodeSamples/snippets.mk

Might be a mismatch in perl version.

I've tested perl 5.18.2 on Ubuntu 14.04 and 5.22.1 on Ubuntu 16.04. perl 5.16.3 on CentOS 7 also works fine.

What version of perl are you using?

Quoted 27 lines

3. Type "make" again. Builds fine.

Quoted 3 lines

In the middle of the branch, there is a point when CodeSamples/snippets.mk resides in the repository. It might have newer time stamp than the modified forkjoinvar.c. (Well, I'don't think this is likely...)

I didn't test any but your last commit, if that is what you are asking.

Quoted 2 lines

I'll add a recipe to remove CodeSamples/snippets.mk by "make clean". You'll be able to do "make clean; make" if something goes wrong.

Adding that and the .fcv files to "make clean" sounds like a good thing in general. Give or take my experience when the .fcv files were missing, anyway. ;-)

Except that "make clean" already removes at least some of the .fcv files. And the top-level snippets.mk file. Ah, but not CodeSamples/snippets.mk.

Quoted 9 lines
Quoted 2 lines

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Ah, you don't reproduce it once "make" succeeds. Hmm...

Quoted 3 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

Quoted 5 lines
Quoted 2 lines

Build script changes might need "make clean" after "git pull". (Current HEAD doesn't remove snippets.mk even by "make neatfreak", though.)

If I do "rm CodeSamples/toolsoftrade/*.fcv", "make clean", and then "make", I get this:

Actually, "make clean" removes those generated "*.fcv" files. In the recipe of "clean", CodeSamples/snippets.mk is invoked by

	$(MAKE) -C CodeSamples -f snippets.mk clean
Quoted 16 lines
$ make
sh utilities/autodate.sh >autodate.tex
future/ibmqx2-labeled.svg --> future/ibmqx2-labeled.png
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

This means removing CodeSamples/snippets.mk in "make clean" does not help you.

Hmm...

Akira

Quoted 19 lines

Then another "make" works fine.>

Quoted 3 lines

I also have some other updates in build scripts to add dependencies to code/makefile generation scripts themselves. Will submit another pull request when it's ready.

Sounds very good!

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 6 lines

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#19 lore raw
Quoted 156 lines · Akira Yokosawa
Quoted 134 lines · Paul E. McKenney
Quoted 104 lines · Akira Yokosawa
Quoted 103 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2
Quoted 5 lines
Quoted 1 line

------------------------------------------------------------------------

There is one thing I'd like to confirm.
Did you do "make" just after checking out the trial branch (before modifying forkjoinvar.c)?

Yes. I pulled your changes, typed "make", modified forkjoinvar.c, typed "make" again, and then saw the failure. When I next modified forkjoinvar.c yet again and yet again typed "make", no failure.

Quoted 1 line

I can't reproduce the above issue on the head of the branch.

Hmmm... Let me try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". Builds fine.

3. Apply diff. Builds fine.

So I cannot reproduce, either. Hate it when that happens. :-/

But all the .fcv files would be left around, which might be influencing things. Let's remove those and try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". This now fails:

Quoted 17 lines
$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

Hmm... I still can't reproduce.
The error message suggests failure to generate CodeSamples/snippets.mk

Quoted 6 lines

Might be a mismatch in perl version.

I've tested perl 5.18.2 on Ubuntu 14.04 and 5.22.1 on Ubuntu 16.04. perl 5.16.3 on CentOS 7 also works fine.

What version of perl are you using?

Here is what "perl -v" tells me:

This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi (with 53 registered patches, see perl -V for more detail)

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Quoted 54 lines
Quoted 27 lines

3. Type "make" again. Builds fine.

Quoted 3 lines

In the middle of the branch, there is a point when CodeSamples/snippets.mk resides in the repository. It might have newer time stamp than the modified forkjoinvar.c. (Well, I'don't think this is likely...)

I didn't test any but your last commit, if that is what you are asking.

Quoted 2 lines

I'll add a recipe to remove CodeSamples/snippets.mk by "make clean". You'll be able to do "make clean; make" if something goes wrong.

Adding that and the .fcv files to "make clean" sounds like a good thing in general. Give or take my experience when the .fcv files were missing, anyway. ;-)

Except that "make clean" already removes at least some of the .fcv files. And the top-level snippets.mk file. Ah, but not CodeSamples/snippets.mk.

Quoted 9 lines
Quoted 2 lines

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Ah, you don't reproduce it once "make" succeeds. Hmm...

Quoted 3 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

Quoted 5 lines
Quoted 2 lines

Build script changes might need "make clean" after "git pull". (Current HEAD doesn't remove snippets.mk even by "make neatfreak", though.)

If I do "rm CodeSamples/toolsoftrade/*.fcv", "make clean", and then "make", I get this:

Actually, "make clean" removes those generated "*.fcv" files. In the recipe of "clean", CodeSamples/snippets.mk is invoked by

	$(MAKE) -C CodeSamples -f snippets.mk clean
Quoted 16 lines
$ make
sh utilities/autodate.sh >autodate.tex
future/ibmqx2-labeled.svg --> future/ibmqx2-labeled.png
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2
Quoted 4 lines

This means removing CodeSamples/snippets.mk in "make clean" does not help you.

Hmm...

Well, it is usable, albeit a bit obnoxious, so perhaps we should move ahead. Perhaps additional use will provide more clues.

Thanx, Paul

Quoted 20 lines
Quoted 19 lines

Then another "make" works fine.>

Quoted 3 lines

I also have some other updates in build scripts to add dependencies to code/makefile generation scripts themselves. Will submit another pull request when it's ready.

Sounds very good!

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 6 lines

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#20 lore raw
Quoted 169 lines · Paul E. McKenney
Quoted 156 lines · Akira Yokosawa
Quoted 134 lines · Paul E. McKenney
Quoted 104 lines · Akira Yokosawa
Quoted 103 lines · Paul E. McKenney
Quoted 40 lines · Akira Yokosawa

Hi Paul,

This is v3 of the trial of fancyvrb scheme.

Changes in v2 -> v3

o Define "linelabel" and "lineref" environments and use them in the early part of toolsoftrade.
o Define "VerbatimU" env for short snippet with no line count and use it for a couple of snippet in toolsoftrade.
o Rename "VerbatimM" to "VerbatimN".
o Remove "[EXP]" in commit log titles.

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180802a

for you to fetch changes up to 6bf7a51b7b9dadf54a0b1edc8959fafed0fcf671:

Add 'linelabel' and 'lineref' environment (2018-08-03 07:21:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (9):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment

Quoted 13 lines
 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  14 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 166 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  55 +++++++++
 utilities/hyphen2endash.sh              |   3 +
 10 files changed, 351 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl

Looks nice!

However, I tried updating a label in CodeSamples/toolsoftrade/forkjoinvar.c like this (and yes, this is a nonsensical change just for testing):

------------------------------------------------------------------------

CodeSamples/toolsoftrade/forkjoinvar.c +2 -3
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
 
------------------------------------------------------------------------

When I typed "make", I got this:

------------------------------------------------------------------------

$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
 --> toolsoftrade/toolsoftrade.fcv
 Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
 make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
 make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
 make: *** [perfbook_flat.tex] Error 2
Quoted 5 lines
Quoted 1 line

------------------------------------------------------------------------

There is one thing I'd like to confirm.
Did you do "make" just after checking out the trial branch (before modifying forkjoinvar.c)?

Yes. I pulled your changes, typed "make", modified forkjoinvar.c, typed "make" again, and then saw the failure. When I next modified forkjoinvar.c yet again and yet again typed "make", no failure.

Quoted 1 line

I can't reproduce the above issue on the head of the branch.

Hmmm... Let me try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". Builds fine.

3. Apply diff. Builds fine.

So I cannot reproduce, either. Hate it when that happens. :-/

But all the .fcv files would be left around, which might be influencing things. Let's remove those and try again.

1. Checkout origin/master, type "make". Builds fine.

2. Checkout your most recent branch, type "make". This now fails:

Quoted 17 lines
$ make
sh utilities/autodate.sh >autodate.tex
./utilities/gen_snippet_mk.pl > CodeSamples/snippets.mk
Use of uninitialized value $_ in substitution (s///) at ./utilities/gen_snippet_mk.pl line 47.
Use of uninitialized value $_ in concatenation (.) or string at ./utilities/gen_snippet_mk.pl line 48.
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2

Hmm... I still can't reproduce.
The error message suggests failure to generate CodeSamples/snippets.mk

Quoted 6 lines

Might be a mismatch in perl version.

I've tested perl 5.18.2 on Ubuntu 14.04 and 5.22.1 on Ubuntu 16.04. perl 5.16.3 on CentOS 7 also works fine.

What version of perl are you using?

Here is what "perl -v" tells me:

This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi (with 53 registered patches, see perl -V for more detail)

Quoted 9 lines

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Exactly the same for me on Ubuntu 14.04.

Quoted 54 lines
Quoted 54 lines
Quoted 27 lines

3. Type "make" again. Builds fine.

Quoted 3 lines

In the middle of the branch, there is a point when CodeSamples/snippets.mk resides in the repository. It might have newer time stamp than the modified forkjoinvar.c. (Well, I'don't think this is likely...)

I didn't test any but your last commit, if that is what you are asking.

Quoted 2 lines

I'll add a recipe to remove CodeSamples/snippets.mk by "make clean". You'll be able to do "make clean; make" if something goes wrong.

Adding that and the .fcv files to "make clean" sounds like a good thing in general. Give or take my experience when the .fcv files were missing, anyway. ;-)

Except that "make clean" already removes at least some of the .fcv files. And the top-level snippets.mk file. Ah, but not CodeSamples/snippets.mk.

Quoted 9 lines
Quoted 2 lines

I typed "make" again and no errors. Plus it did update as I expected it to. And when I changed it back, it built the first time without errors.

Ah, you don't reproduce it once "make" succeeds. Hmm...

Quoted 3 lines

Do I perhaps have a shortcoming in my (admittedly ancient) environment? Or is this something that happens the first time the new functionality is exercised on a change?

Quoted 5 lines
Quoted 2 lines

Build script changes might need "make clean" after "git pull". (Current HEAD doesn't remove snippets.mk even by "make neatfreak", though.)

If I do "rm CodeSamples/toolsoftrade/*.fcv", "make clean", and then "make", I get this:

Actually, "make clean" removes those generated "*.fcv" files. In the recipe of "clean", CodeSamples/snippets.mk is invoked by

	$(MAKE) -C CodeSamples -f snippets.mk clean
Quoted 16 lines
$ make
sh utilities/autodate.sh >autodate.tex
future/ibmqx2-labeled.svg --> future/ibmqx2-labeled.png
echo > qqz.tex
echo > contrib.tex
echo > origpub.tex
make -C CodeSamples -f snippets.mk
make[1]: Entering directory `/home/git/perfbook/CodeSamples'
toolsoftrade/pcreate.c --> toolsoftrade/[email protected]
 --> toolsoftrade/toolsoftrade.fcv
Use of uninitialized value $extract_labelbase in concatenation (.) or string at ../utilities/fcvextract.pl line 115.
make[1]: *** [toolsoftrade/toolsoftrade.fcv] Error 1
make[1]: Leaving directory `/home/git/perfbook/CodeSamples'
make: *** [perfbook_flat.tex] Error 2
Quoted 7 lines
Quoted 4 lines

This means removing CodeSamples/snippets.mk in "make clean" does not help you.

Hmm...

Well, it is usable, albeit a bit obnoxious, so perhaps we should move ahead. Perhaps additional use will provide more clues.

Let me try to update gen_snippet_mk.pl to catch your failure pattern and to spit message to suggest doing "make" again. Well, I won't be able to test such changes myself, though...

Thanks, Akira

Quoted 24 lines

Thanx, Paul

Quoted 20 lines
Quoted 19 lines

Then another "make" works fine.>

Quoted 3 lines

I also have some other updates in build scripts to add dependencies to code/makefile generation scripts themselves. Will submit another pull request when it's ready.

Sounds very good!

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 6 lines

But even so, this is -way- more convenient than my old approach of doing all the changes by hand!!!

Thanx, Paul

#21 lore raw
In reply to Akira Yokosawa

Hi Paul,

This is v4 of the trial of fancyvrb scheme.

Changes since v3:

o gen_snippet_mk.pl: Add check of failure mode observed by Paul.
o gen_snippet.mk.sh: Remove broken CodeSamples/snippets.mk when the failure is caught.
o Add dependencies in Makefile regarding the generation and extraction scripts/sub makefile.
o Change "make clean" so that it does not depend on CodeSamples/snippets.mk and remove the sub makefile.

I'm not sure these changes resolve the issue you encountered. Does "make clean; make" work for you now?

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180804a

for you to fetch changes up to dd1559612728fcf8726a5b367147cc51ca8f27a8:

Add dependencis to scripts for extracting code snippets (2018-08-04 19:36:07 +0900)

----------------------------------------------------------------
Akira Yokosawa (11):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  15 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  72 +++++++++++
 utilities/gen_snippet_mk.sh             |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 379 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl
 create mode 100644 utilities/gen_snippet_mk.sh
#22 lore raw
Quoted 14 lines · Akira Yokosawa

Hi Paul,

This is v4 of the trial of fancyvrb scheme.

Changes since v3:

o gen_snippet_mk.pl: Add check of failure mode observed by Paul.
o gen_snippet.mk.sh: Remove broken CodeSamples/snippets.mk when the failure is caught.
o Add dependencies in Makefile regarding the generation and extraction scripts/sub makefile.
o Change "make clean" so that it does not depend on CodeSamples/snippets.mk and remove the sub makefile.

Quoted 2 lines

I'm not sure these changes resolve the issue you encountered. Does "make clean; make" work for you now?

I think I found another set of missing dependencies. At the HEAD of this branch, after the 1st make succeeds,

(1) remove *.fcv files, and
(2) just do "make"

does nothing.

This is because the main Makefile does not know the dependencies of perfbook_flat.tex to *.fcv files.

Those dependencies require yet another sub-makefile to be generated. I'll append another commit to do so.

I think "make clean; make" should still work as the current form.

Thanks, Akira

Quoted 46 lines

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180804a

for you to fetch changes up to dd1559612728fcf8726a5b367147cc51ca8f27a8:

Add dependencis to scripts for extracting code snippets (2018-08-04 19:36:07 +0900)

----------------------------------------------------------------
Akira Yokosawa (11):
toolsoftrade: Add labels in code samples as comments Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet Add 'linelabel' and 'lineref' environment Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  15 ++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_mk.pl             |  72 +++++++++++
 utilities/gen_snippet_mk.sh             |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 379 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_mk.pl
 create mode 100644 utilities/gen_snippet_mk.sh
#23 lore raw
In reply to Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180804b

for you to fetch changes up to d9a36224084b2e4ba55797eff0c37de528b59d6b:

Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files (2018-08-05 08:44:02 +0900)

----------------------------------------------------------------
Akira Yokosawa (12):
toolsoftrade: Add labels in code samples as comments
Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet
Add 'linelabel' and 'lineref' environment
Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  25 +++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_d.pl              |  65 ++++++++++
 utilities/gen_snippet_d.sh              |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 382 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_d.pl
 create mode 100644 utilities/gen_snippet_d.sh
#24 lore raw
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

Thanx, Paul

Quoted 46 lines

Thanks, Akira

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180804b

for you to fetch changes up to d9a36224084b2e4ba55797eff0c37de528b59d6b:

Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files (2018-08-05 08:44:02 +0900)

----------------------------------------------------------------
Akira Yokosawa (12):
toolsoftrade: Add labels in code samples as comments
Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet
Add 'linelabel' and 'lineref' environment
Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  25 +++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_d.pl              |  65 ++++++++++
 utilities/gen_snippet_d.sh              |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 382 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_d.pl
 create mode 100644 utilities/gen_snippet_d.sh
#25 lore raw
Quoted 30 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

Quoted 7 lines

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

And the diff below restores the behavior I would expect for "make", even when modifying tags in CodeSamples/toolsoftrade/forkjoinvar.c, though of course it might well break something else. (And the diff happens to include my test change to forkjoinvar.c.)

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

Makefile +7 -7
index fe9f63f43e55..3e9e2c2ebf3c 100644
@@ -85,13 +85,6 @@ endif
 SOURCES_OF_SNIPPET := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
 GEN_SNIPPET_D  = utilities/gen_snippet_d.pl utilities/gen_snippet_d.sh
 
-ifeq ($(MAKECMDGOALS),clean)
-else ifeq ($(MAKECMDGOALS),distclean)
-else ifeq ($(MAKECMDGOALS),neatfreak)
-else
--include CodeSamples/snippets.d
-endif
-
 default = $(PERFBOOK_DEFAULT)
 
 ifeq ($(default),)
@@ -103,6 +96,13 @@ endif
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 
+ifeq ($(MAKECMDGOALS),clean)
+else ifeq ($(MAKECMDGOALS),distclean)
+else ifeq ($(MAKECMDGOALS),neatfreak)
+else
+-include CodeSamples/snippets.d
+endif
+
 2c: perfbook.pdf
 
 mslm: perfbook-mslm.pdf
CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
author Acked-by
#26 lore raw
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

Quoted 8 lines
Quoted 8 lines
	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

No. It was my fault. I failed to test the simple "make". To override my env variable setting of "PERFBOOK_DEFUALT=msnt 1csf", I tend to use one of "make msnt" or "make msnt 1csf" or "make 2c".

I see the same behavior when I do simple "make" regardless of PERFBOOK_DEFAULT is set or unset.

Quoted 47 lines
Quoted 6 lines

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

Quoted 7 lines

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

And the diff below restores the behavior I would expect for "make", even when modifying tags in CodeSamples/toolsoftrade/forkjoinvar.c, though of course it might well break something else. (And the diff happens to include my test change to forkjoinvar.c.)

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

Makefile +0 -7
index fe9f63f43e55..3e9e2c2ebf3c 100644
@@ -85,13 +85,6 @@ endif
 SOURCES_OF_SNIPPET := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
 GEN_SNIPPET_D  = utilities/gen_snippet_d.pl utilities/gen_snippet_d.sh
 
-ifeq ($(MAKECMDGOALS),clean)
-else ifeq ($(MAKECMDGOALS),distclean)
-else ifeq ($(MAKECMDGOALS),neatfreak)
-else
--include CodeSamples/snippets.d
-endif
-
 default = $(PERFBOOK_DEFAULT)
 
 ifeq ($(default),)
@@ -103,6 +96,13 @@ endif
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 

Makefile endif · line 108

Quoted 10 lines
Makefile +7 -0
+ifeq ($(MAKECMDGOALS),clean)
+else ifeq ($(MAKECMDGOALS),distclean)
+else ifeq ($(MAKECMDGOALS),neatfreak)
+else
+-include CodeSamples/snippets.d
+endif
+
 2c: perfbook.pdf
 
 mslm: perfbook-mslm.pdf

This change works for me too.

Do you want me to add the change to the trial branch? I don't mind if you add the change yourself with my

Of course, the following diff should be omitted.

Thanks, Akira

Quoted 19 lines
CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
#28 lore raw
In reply to Paul E. McKenney
Quoted 101 lines · Paul E. McKenney
Quoted 27 lines · Akira Yokosawa
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

Quoted 8 lines
Quoted 8 lines
	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

Quoted 6 lines

No. It was my fault. I failed to test the simple "make". To override my env variable setting of "PERFBOOK_DEFUALT=msnt 1csf", I tend to use one of "make msnt" or "make msnt 1csf" or "make 2c".

I see the same behavior when I do simple "make" regardless of PERFBOOK_DEFAULT is set or unset.

Been there, done that! ;-)

Quoted 64 lines
Quoted 46 lines
Quoted 5 lines

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

Quoted 7 lines

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

And the diff below restores the behavior I would expect for "make", even when modifying tags in CodeSamples/toolsoftrade/forkjoinvar.c, though of course it might well break something else. (And the diff happens to include my test change to forkjoinvar.c.)

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

Makefile +0 -7
index fe9f63f43e55..3e9e2c2ebf3c 100644
@@ -85,13 +85,6 @@ endif
 SOURCES_OF_SNIPPET := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
 GEN_SNIPPET_D  = utilities/gen_snippet_d.pl utilities/gen_snippet_d.sh
 
-ifeq ($(MAKECMDGOALS),clean)
-else ifeq ($(MAKECMDGOALS),distclean)
-else ifeq ($(MAKECMDGOALS),neatfreak)
-else
--include CodeSamples/snippets.d
-endif
-
 default = $(PERFBOOK_DEFAULT)
 
 ifeq ($(default),)
@@ -103,6 +96,13 @@ endif
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 

Makefile endif · line 108

Quoted 10 lines
Makefile +7 -0
+ifeq ($(MAKECMDGOALS),clean)
+else ifeq ($(MAKECMDGOALS),distclean)
+else ifeq ($(MAKECMDGOALS),neatfreak)
+else
+-include CodeSamples/snippets.d
+endif
+
 2c: perfbook.pdf
 
 mslm: perfbook-mslm.pdf

This change works for me too.

Do you want me to add the change to the trial branch? I don't mind if you add the change yourself with my

Quoted 8 lines
Quoted 1 line

Of course, the following diff should be omitted.

I pushed out an akiyks.2018.08.05a branch with the commit (but without the forkjoinvar.c change), and with your ack.

When you say it is ready, I will bring my master branch out to that commit. Or if you have another pull request for an updated version of this series, I will replace it with that.

I amended the commit log.
Appended is the pull request. See below.

Thanks, Akira

Quoted 28 lines

Either way, please let me know!

Thanx, Paul

Quoted 22 lines

Thanks, Akira

Quoted 19 lines
CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180805a

for you to fetch changes up to 78141e64d4629b29643634fc1d334233f108f656:

Makefile: Fix "make" behavior (2018-08-06 08:18:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (12):
toolsoftrade: Add labels in code samples as comments
Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet
Add 'linelabel' and 'lineref' environment
Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files

Paul E. McKenney (1):
Makefile: Fix "make" behavior

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  25 +++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_d.pl              |  65 ++++++++++
 utilities/gen_snippet_d.sh              |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 382 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_d.pl
 create mode 100644 utilities/gen_snippet_d.sh
#27 lore raw
In reply to Akira Yokosawa
Quoted 27 lines · Akira Yokosawa
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

Quoted 8 lines
Quoted 8 lines
	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

Quoted 6 lines

No. It was my fault. I failed to test the simple "make". To override my env variable setting of "PERFBOOK_DEFUALT=msnt 1csf", I tend to use one of "make msnt" or "make msnt 1csf" or "make 2c".

I see the same behavior when I do simple "make" regardless of PERFBOOK_DEFAULT is set or unset.

Been there, done that! ;-)

Quoted 59 lines
Quoted 46 lines
Quoted 5 lines

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

Quoted 7 lines

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

And the diff below restores the behavior I would expect for "make", even when modifying tags in CodeSamples/toolsoftrade/forkjoinvar.c, though of course it might well break something else. (And the diff happens to include my test change to forkjoinvar.c.)

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

Makefile +0 -7
index fe9f63f43e55..3e9e2c2ebf3c 100644
@@ -85,13 +85,6 @@ endif
 SOURCES_OF_SNIPPET := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
 GEN_SNIPPET_D  = utilities/gen_snippet_d.pl utilities/gen_snippet_d.sh
 
-ifeq ($(MAKECMDGOALS),clean)
-else ifeq ($(MAKECMDGOALS),distclean)
-else ifeq ($(MAKECMDGOALS),neatfreak)
-else
--include CodeSamples/snippets.d
-endif
-
 default = $(PERFBOOK_DEFAULT)
 
 ifeq ($(default),)
@@ -103,6 +96,13 @@ endif
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 

Makefile endif · line 108

Quoted 10 lines
Makefile +7 -0
+ifeq ($(MAKECMDGOALS),clean)
+else ifeq ($(MAKECMDGOALS),distclean)
+else ifeq ($(MAKECMDGOALS),neatfreak)
+else
+-include CodeSamples/snippets.d
+endif
+
 2c: perfbook.pdf
 
 mslm: perfbook-mslm.pdf

This change works for me too.

Quoted 6 lines

Do you want me to add the change to the trial branch? I don't mind if you add the change yourself with my

Of course, the following diff should be omitted.

I pushed out an akiyks.2018.08.05a branch with the commit (but without the forkjoinvar.c change), and with your ack.

When you say it is ready, I will bring my master branch out to that commit. Or if you have another pull request for an updated version of this series, I will replace it with that.

Either way, please let me know!

Thanx, Paul

Quoted 22 lines

Thanks, Akira

Quoted 19 lines
CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */
#29 lore raw
In reply to Akira Yokosawa
Quoted 107 lines · Akira Yokosawa
Quoted 106 lines · Paul E. McKenney
Quoted 27 lines · Akira Yokosawa
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

This is hopefully the final version of this trial branch.

Quoted 8 lines

Changes since v4:

o Instead of generating CodeSamples/snippets.mk and calling it from main Makefile, generate CodeSamples/snippets.d which contains only dependencies and include it in the Makefile.

This change can fix the error you encountered in the previous version. I'm just hoping...

Hmmmm...

Quoted 8 lines
Quoted 8 lines
	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/[email protected]

But "make 2c" works. This might be because I don't have the PERFBOOK_DEFAULT environment variable set? Except that the Makefile code looks like this would have the default "make all" have the same effect as "make 2c". Color me confused.

Quoted 6 lines

No. It was my fault. I failed to test the simple "make". To override my env variable setting of "PERFBOOK_DEFUALT=msnt 1csf", I tend to use one of "make msnt" or "make msnt 1csf" or "make 2c".

I see the same behavior when I do simple "make" regardless of PERFBOOK_DEFAULT is set or unset.

Been there, done that! ;-)

Quoted 59 lines
Quoted 46 lines
Quoted 5 lines

Anyway, yes, when I do "make 2c" it correctly reacts to moving labels around in CodeSamples/toolsoftrade/forkjoinvar.c, so that is good!

Here is the output of "make -v", in case that matters:

Quoted 7 lines

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

And the diff below restores the behavior I would expect for "make", even when modifying tags in CodeSamples/toolsoftrade/forkjoinvar.c, though of course it might well break something else. (And the diff happens to include my test change to forkjoinvar.c.)

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

Makefile +0 -7
index fe9f63f43e55..3e9e2c2ebf3c 100644
@@ -85,13 +85,6 @@ endif
 SOURCES_OF_SNIPPET := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
 GEN_SNIPPET_D  = utilities/gen_snippet_d.pl utilities/gen_snippet_d.sh
 
-ifeq ($(MAKECMDGOALS),clean)
-else ifeq ($(MAKECMDGOALS),distclean)
-else ifeq ($(MAKECMDGOALS),neatfreak)
-else
--include CodeSamples/snippets.d
-endif
-
 default = $(PERFBOOK_DEFAULT)
 
 ifeq ($(default),)
@@ -103,6 +96,13 @@ endif
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 

Makefile endif · line 108

Quoted 10 lines
Makefile +7 -0
+ifeq ($(MAKECMDGOALS),clean)
+else ifeq ($(MAKECMDGOALS),distclean)
+else ifeq ($(MAKECMDGOALS),neatfreak)
+else
+-include CodeSamples/snippets.d
+endif
+
 2c: perfbook.pdf
 
 mslm: perfbook-mslm.pdf

This change works for me too.

Quoted 6 lines

Do you want me to add the change to the trial branch? I don't mind if you add the change yourself with my

Of course, the following diff should be omitted.

I pushed out an akiyks.2018.08.05a branch with the commit (but without the forkjoinvar.c change), and with your ack.

Quoted 6 lines
Quoted 3 lines

When you say it is ready, I will bring my master branch out to that commit. Or if you have another pull request for an updated version of this series, I will replace it with that.

I amended the commit log.
Appended is the pull request. See below.

Looks good, thank you! I have pulled this and pushed it as my master branch.

Thanx, Paul

Quoted 79 lines

Thanks, Akira

Quoted 28 lines

Either way, please let me know!

Thanx, Paul

Quoted 22 lines

Thanks, Akira

Quoted 19 lines
CodeSamples/toolsoftrade/forkjoinvar.c +2 -2
index 1580478fe2f9..642451d9e880 100644
@@ -35,11 +35,11 @@ int main(int argc, char *argv[])
 	if (pid == 0) { /* child */
 		x = 1;					//\lnlbl{setx}
 		printf("Child process set x=1\n");	//\lnlbl{print:c}
-		exit(EXIT_SUCCESS);			//\lnlbl{exit:s}
+		exit(EXIT_SUCCESS);
 	}
 	if (pid < 0) { /* parent, upon error */
 		perror("fork");
-		exit(EXIT_FAILURE);
+		exit(EXIT_FAILURE);			//\lnlbl{exit:s}
 	}
 
 	/* parent */

---
The following changes since commit 3b62f67a76e15f8d8f8190a4252362d4ac0cdf23:

Regenerating the atomic counter graph on a more modern CPU (2018-07-23 13:47:51 -0700)

are available in the git repository at:

https://github.com/akiyks/perfbook.git trial-fancyvrb-20180805a

for you to fetch changes up to 78141e64d4629b29643634fc1d334233f108f656:

Makefile: Fix "make" behavior (2018-08-06 08:18:49 +0900)

----------------------------------------------------------------
Akira Yokosawa (12):
toolsoftrade: Add labels in code samples as comments
Add script to extract code snippet from code sample
toolsoftrade: Reference line in code snippets by label Update hyphen2endash
Add *.fcv to .gitignore
Automate sub makefile update
Specify lmtt font for VerbatimM env
toolsoftrade: Use \lnlbl in inline code snippet
Add 'linelabel' and 'lineref' environment
Catch failure in genaration of CodeSamples/snippets.mk Add dependencis to scripts for extracting code snippets Add dependencies of perfbook_flat.tex to CodeSamples/.../*.fcv files

Paul E. McKenney (1):
Makefile: Fix "make" behavior

 .gitignore                              |   2 +
 CodeSamples/api-pthreads/api-pthreads.h |  18 +--
 CodeSamples/toolsoftrade/forkjoinvar.c  |  12 +-
 CodeSamples/toolsoftrade/pcreate.c      |   7 +-
 Makefile                                |  25 +++-
 perfbook.tex                            |  21 ++++
 toolsoftrade/toolsoftrade.tex           | 211 +++++++++++---------------------
 utilities/fcvextract.pl                 | 168 +++++++++++++++++++++++++
 utilities/gen_snippet_d.pl              |  65 ++++++++++
 utilities/gen_snippet_d.sh              |   8 ++
 utilities/hyphen2endash.sh              |   3 +
 11 files changed, 382 insertions(+), 158 deletions(-)
 create mode 100755 utilities/fcvextract.pl
 create mode 100755 utilities/gen_snippet_d.pl
 create mode 100644 utilities/gen_snippet_d.sh