All of lore.kernel.org
 help / color / mirror / Atom feed
* [NOT YET PULL] Trial of labeling lines in code snippets
@ 2018-07-21  0:19 Akira Yokosawa
  2018-07-21 16:51 ` Paul E. McKenney
                   ` (4 more replies)
  0 siblings, 5 replies; 30+ messages in thread
From: Akira Yokosawa @ 2018-07-21  0:19 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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?

        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(-)


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
@ 2018-07-21 16:51 ` Paul E. McKenney
  2018-07-22 15:43   ` Akira Yokosawa
  2018-07-30 16:04 ` [NOT YET PULL v2] " Akira Yokosawa
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-07-21 16:51 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
> 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

>         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(-)
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-21 16:51 ` Paul E. McKenney
@ 2018-07-22 15:43   ` Akira Yokosawa
  2018-07-22 22:49     ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-07-22 15:43 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/07/21 09:51:03 -0700, Paul E. McKenney wrote:
> On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
>> 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.

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

> 
> Again, looks promising, thank you!
> 
> 							Thanx, Paul
> 
>>         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(-)
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-22 15:43   ` Akira Yokosawa
@ 2018-07-22 22:49     ` Paul E. McKenney
  2018-07-23 15:09       ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-07-22 22:49 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Mon, Jul 23, 2018 at 12:43:05AM +0900, Akira Yokosawa wrote:
> On 2018/07/21 09:51:03 -0700, Paul E. McKenney wrote:
> > On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
> >> 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.
> 
> 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.

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

> Thoughts?
> 
>         Thanks, Akira
> 
> > 
> > Again, looks promising, thank you!
> > 
> > 							Thanx, Paul
> > 
> >>         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(-)
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-22 22:49     ` Paul E. McKenney
@ 2018-07-23 15:09       ` Akira Yokosawa
  2018-07-23 15:12         ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-07-23 15:09 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/07/22 15:49:06 -0700, Paul E. McKenney wrote:
> On Mon, Jul 23, 2018 at 12:43:05AM +0900, Akira Yokosawa wrote:
>> On 2018/07/21 09:51:03 -0700, Paul E. McKenney wrote:
>>> On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
>>>> 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.
>>
>> 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.
> 
> 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

> 
> Seem reasonable?
> 
> 							Thanx, Paul
> 
>> Thoughts?
>>
>>         Thanks, Akira
>>
>>>
>>> Again, looks promising, thank you!
>>>
>>> 							Thanx, Paul
>>>
>>>>         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(-)
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-23 15:09       ` Akira Yokosawa
@ 2018-07-23 15:12         ` Akira Yokosawa
  2018-07-23 21:03           ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-07-23 15:12 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/07/24 00:09:37 +0900, Akira Yokosawa wrote:
> On 2018/07/22 15:49:06 -0700, Paul E. McKenney wrote:
>> On Mon, Jul 23, 2018 at 12:43:05AM +0900, Akira Yokosawa wrote:
>>> On 2018/07/21 09:51:03 -0700, Paul E. McKenney wrote:
>>>> On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
>>>>> 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.
>>>
>>> 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.
>>
>> 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

> 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
>  
>>
>> Seem reasonable?
>>
>> 							Thanx, Paul
>>
>>> Thoughts?
>>>
>>>         Thanks, Akira
>>>
>>>>
>>>> Again, looks promising, thank you!
>>>>
>>>> 							Thanx, Paul
>>>>
>>>>>         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(-)
>>>>>
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL] Trial of labeling lines in code snippets
  2018-07-23 15:12         ` Akira Yokosawa
@ 2018-07-23 21:03           ` Paul E. McKenney
  0 siblings, 0 replies; 30+ messages in thread
From: Paul E. McKenney @ 2018-07-23 21:03 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Tue, Jul 24, 2018 at 12:12:17AM +0900, Akira Yokosawa wrote:
> On 2018/07/24 00:09:37 +0900, Akira Yokosawa wrote:
> > On 2018/07/22 15:49:06 -0700, Paul E. McKenney wrote:
> >> On Mon, Jul 23, 2018 at 12:43:05AM +0900, Akira Yokosawa wrote:
> >>> On 2018/07/21 09:51:03 -0700, Paul E. McKenney wrote:
> >>>> On Sat, Jul 21, 2018 at 09:19:53AM +0900, Akira Yokosawa wrote:
> >>>>> 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.
> >>>
> >>> 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.
> >>
> >> 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"

Sounds very good, thank you!!!

							Thanx, Paul

> Akira
> 
> > 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
> >  
> >>
> >> Seem reasonable?
> >>
> >> 							Thanx, Paul
> >>
> >>> Thoughts?
> >>>
> >>>         Thanks, Akira
> >>>
> >>>>
> >>>> Again, looks promising, thank you!
> >>>>
> >>>> 							Thanx, Paul
> >>>>
> >>>>>         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(-)
> >>>>>
> >>>>
> >>>
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
  2018-07-21 16:51 ` Paul E. McKenney
@ 2018-07-30 16:04 ` Akira Yokosawa
  2018-07-31 15:10   ` Paul E. McKenney
  2018-08-02 22:34 ` [GIT PULL v3] " Akira Yokosawa
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-07-30 16:04 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-07-30 16:04 ` [NOT YET PULL v2] " Akira Yokosawa
@ 2018-07-31 15:10   ` Paul E. McKenney
  2018-08-01 15:24     ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-07-31 15:10 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Tue, Jul 31, 2018 at 01:04:18AM +0900, Akira Yokosawa wrote:
> 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:

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

>   [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
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-07-31 15:10   ` Paul E. McKenney
@ 2018-08-01 15:24     ` Akira Yokosawa
  2018-08-01 15:59       ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-01 15:24 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/07/31 08:10:27 -0700, Paul E. McKenney wrote:
> On Tue, Jul 31, 2018 at 01:04:18AM +0900, Akira Yokosawa wrote:
>> 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:
> 
> 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

> 
> 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
> 
>>   [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
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-08-01 15:24     ` Akira Yokosawa
@ 2018-08-01 15:59       ` Paul E. McKenney
  2018-08-01 22:14         ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-01 15:59 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Thu, Aug 02, 2018 at 12:24:50AM +0900, Akira Yokosawa wrote:
> On 2018/07/31 08:10:27 -0700, Paul E. McKenney wrote:
> > On Tue, Jul 31, 2018 at 01:04:18AM +0900, Akira Yokosawa wrote:
> >> 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:
> > 
> > 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.

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

							Thanx, Paul

>         Thanks, Akira
> 
> > 
> > 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
> > 
> >>   [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
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-08-01 15:59       ` Paul E. McKenney
@ 2018-08-01 22:14         ` Akira Yokosawa
  2018-08-02  0:22           ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-01 22:14 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/01 08:59:39 -0700, Paul E. McKenney wrote:
> On Thu, Aug 02, 2018 at 12:24:50AM +0900, Akira Yokosawa wrote:
>> On 2018/07/31 08:10:27 -0700, Paul E. McKenney wrote:
>>> On Tue, Jul 31, 2018 at 01:04:18AM +0900, Akira Yokosawa wrote:
>>>> 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:
>>>
>>> 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.
> 
> 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

> 
> 							Thanx, Paul
> 
>>         Thanks, Akira
>>
>>>
>>> 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
>>>
>>>>   [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
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [NOT YET PULL v2] Trial of labeling lines in code snippets
  2018-08-01 22:14         ` Akira Yokosawa
@ 2018-08-02  0:22           ` Paul E. McKenney
  0 siblings, 0 replies; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-02  0:22 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Thu, Aug 02, 2018 at 07:14:25AM +0900, Akira Yokosawa wrote:
> On 2018/08/01 08:59:39 -0700, Paul E. McKenney wrote:
> > On Thu, Aug 02, 2018 at 12:24:50AM +0900, Akira Yokosawa wrote:
> >> On 2018/07/31 08:10:27 -0700, Paul E. McKenney wrote:
> >>> On Tue, Jul 31, 2018 at 01:04:18AM +0900, Akira Yokosawa wrote:
> >>>> 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:
> >>>
> >>> 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.
> > 
> > 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

> >>         Thanks, Akira
> >>
> >>>
> >>> 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
> >>>
> >>>>   [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
> >>>>
> >>>
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [GIT PULL v3] Trial of labeling lines in code snippets
  2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
  2018-07-21 16:51 ` Paul E. McKenney
  2018-07-30 16:04 ` [NOT YET PULL v2] " Akira Yokosawa
@ 2018-08-02 22:34 ` Akira Yokosawa
  2018-08-03 14:35   ` Paul E. McKenney
  2018-08-04 11:57 ` [GIT PULL v4] " Akira Yokosawa
  2018-08-05  0:06 ` [GIT PULL v5] " Akira Yokosawa
  4 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-02 22:34 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-02 22:34 ` [GIT PULL v3] " Akira Yokosawa
@ 2018-08-03 14:35   ` Paul E. McKenney
  2018-08-03 15:02     ` Akira Yokosawa
  2018-08-03 15:49     ` Akira Yokosawa
  0 siblings, 2 replies; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-03 14:35 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
> 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

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):

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

diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
index 1580478fe2f9..642451d9e880 100644
--- a/CodeSamples/toolsoftrade/forkjoinvar.c
+++ b/CodeSamples/toolsoftrade/forkjoinvar.c
@@ -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


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 14:35   ` Paul E. McKenney
@ 2018-08-03 15:02     ` Akira Yokosawa
  2018-08-03 15:49     ` Akira Yokosawa
  1 sibling, 0 replies; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-03 15:02 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
> On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
>> 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
> 
> 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):
> 
> ------------------------------------------------------------------------
> 
> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> index 1580478fe2f9..642451d9e880 100644
> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> @@ -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.

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.

> 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!!!

Glad to know you liked it! ;-)

        Akira

> 
> 							Thanx, Paul
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 14:35   ` Paul E. McKenney
  2018-08-03 15:02     ` Akira Yokosawa
@ 2018-08-03 15:49     ` Akira Yokosawa
  2018-08-03 16:45       ` Paul E. McKenney
  1 sibling, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-03 15:49 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
> On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
>> 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
> 
> 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):
> 
> ------------------------------------------------------------------------
> 
> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> index 1580478fe2f9..642451d9e880 100644
> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> @@ -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
> 
> ------------------------------------------------------------------------
> 

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.

> 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...

> 
> 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

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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 15:49     ` Akira Yokosawa
@ 2018-08-03 16:45       ` Paul E. McKenney
  2018-08-03 23:12         ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-03 16:45 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sat, Aug 04, 2018 at 12:49:34AM +0900, Akira Yokosawa wrote:
> On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
> > On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
> >> 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
> > 
> > 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):
> > 
> > ------------------------------------------------------------------------
> > 
> > diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> > index 1580478fe2f9..642451d9e880 100644
> > --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> > +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> > @@ -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
> > 
> > ------------------------------------------------------------------------
> 
> 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.

> 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/pcreate@mythread.fcv
 --> 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.

> 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.

> 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.

> > 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...
> 
> > 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/pcreate@mythread.fcv
 --> 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.

> 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

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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 16:45       ` Paul E. McKenney
@ 2018-08-03 23:12         ` Akira Yokosawa
  2018-08-03 23:43           ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-03 23:12 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/03 09:45:11 -0700, Paul E. McKenney wrote:
> On Sat, Aug 04, 2018 at 12:49:34AM +0900, Akira Yokosawa wrote:
>> On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
>>> On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
>>>> 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
>>>
>>> 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):
>>>
>>> ------------------------------------------------------------------------
>>>
>>> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
>>> index 1580478fe2f9..642451d9e880 100644
>>> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
>>> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
>>> @@ -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
>>>
>>> ------------------------------------------------------------------------
>>
>> 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.
> 
>> 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/pcreate@mythread.fcv
>  --> 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?

> 3.	Type "make" again.  Builds fine.
> 
>> 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.
> 
>> 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.
> 
>>> 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...
>>
>>> 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:

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

> 
> $ 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/pcreate@mythread.fcv
>  --> 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

> Then another "make" works fine.> 
>> 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
> 
>>         Thanks, Akira
>>
>>>
>>> But even so, this is -way- more convenient than my old approach of doing
>>> all the changes by hand!!!
>>>
>>> 							Thanx, Paul
>>>
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 23:12         ` Akira Yokosawa
@ 2018-08-03 23:43           ` Paul E. McKenney
  2018-08-04  0:00             ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-03 23:43 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sat, Aug 04, 2018 at 08:12:09AM +0900, Akira Yokosawa wrote:
> On 2018/08/03 09:45:11 -0700, Paul E. McKenney wrote:
> > On Sat, Aug 04, 2018 at 12:49:34AM +0900, Akira Yokosawa wrote:
> >> On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
> >>> On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
> >>>> 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
> >>>
> >>> 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):
> >>>
> >>> ------------------------------------------------------------------------
> >>>
> >>> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> index 1580478fe2f9..642451d9e880 100644
> >>> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> @@ -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
> >>>
> >>> ------------------------------------------------------------------------
> >>
> >> 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.
> > 
> >> 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/pcreate@mythread.fcv
> >  --> 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?

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.

> > 3.	Type "make" again.  Builds fine.
> > 
> >> 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.
> > 
> >> 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.
> > 
> >>> 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...
> >>
> >>> 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:
> 
> 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
> 
> > 
> > $ 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/pcreate@mythread.fcv
> >  --> 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...

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

							Thanx, Paul

> > Then another "make" works fine.> 
> >> 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
> > 
> >>         Thanks, Akira
> >>
> >>>
> >>> But even so, this is -way- more convenient than my old approach of doing
> >>> all the changes by hand!!!
> >>>
> >>> 							Thanx, Paul
> >>>
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v3] Trial of labeling lines in code snippets
  2018-08-03 23:43           ` Paul E. McKenney
@ 2018-08-04  0:00             ` Akira Yokosawa
  0 siblings, 0 replies; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-04  0:00 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/04 8:43, Paul E. McKenney wrote:
> On Sat, Aug 04, 2018 at 08:12:09AM +0900, Akira Yokosawa wrote:
>> On 2018/08/03 09:45:11 -0700, Paul E. McKenney wrote:
>>> On Sat, Aug 04, 2018 at 12:49:34AM +0900, Akira Yokosawa wrote:
>>>> On 2018/08/03 07:35:57 -0700, Paul E. McKenney wrote:
>>>>> On Fri, Aug 03, 2018 at 07:34:51AM +0900, Akira Yokosawa wrote:
>>>>>> 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
>>>>>
>>>>> 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):
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
>>>>> index 1580478fe2f9..642451d9e880 100644
>>>>> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
>>>>> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
>>>>> @@ -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
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>
>>>> 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.
>>>
>>>> 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/pcreate@mythread.fcv
>>>  --> 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?
> 
> 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.
> 

Exactly the same for me on Ubuntu 14.04.

>>> 3.	Type "make" again.  Builds fine.
>>>
>>>> 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.
>>>
>>>> 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.
>>>
>>>>> 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...
>>>>
>>>>> 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:
>>
>> 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
>>
>>>
>>> $ 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/pcreate@mythread.fcv
>>>  --> 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...
> 
> 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

> 
> 							Thanx, Paul
> 
>>> Then another "make" works fine.> 
>>>> 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
>>>
>>>>         Thanks, Akira
>>>>
>>>>>
>>>>> But even so, this is -way- more convenient than my old approach of doing
>>>>> all the changes by hand!!!
>>>>>
>>>>> 							Thanx, Paul
>>>>>
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [GIT PULL v4] Trial of labeling lines in code snippets
  2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
                   ` (2 preceding siblings ...)
  2018-08-02 22:34 ` [GIT PULL v3] " Akira Yokosawa
@ 2018-08-04 11:57 ` Akira Yokosawa
  2018-08-04 15:15   ` Akira Yokosawa
  2018-08-05  0:06 ` [GIT PULL v5] " Akira Yokosawa
  4 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-04 11:57 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v4] Trial of labeling lines in code snippets
  2018-08-04 11:57 ` [GIT PULL v4] " Akira Yokosawa
@ 2018-08-04 15:15   ` Akira Yokosawa
  0 siblings, 0 replies; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-04 15:15 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/04 20:57:55 +0900, Akira Yokosawa wrote:
> 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?

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

> 
>         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
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [GIT PULL v5] Trial of labeling lines in code snippets
  2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
                   ` (3 preceding siblings ...)
  2018-08-04 11:57 ` [GIT PULL v4] " Akira Yokosawa
@ 2018-08-05  0:06 ` Akira Yokosawa
  2018-08-05 16:35   ` Paul E. McKenney
  4 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-05  0:06 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05  0:06 ` [GIT PULL v5] " Akira Yokosawa
@ 2018-08-05 16:35   ` Paul E. McKenney
  2018-08-05 16:54     ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-05 16:35 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
> 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...

Hmmmm...

	$ make
	sh ./utilities/gen_snippet_d.sh
	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv

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

>         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
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05 16:35   ` Paul E. McKenney
@ 2018-08-05 16:54     ` Paul E. McKenney
  2018-08-05 21:58       ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-05 16:54 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sun, Aug 05, 2018 at 09:35:08AM -0700, Paul E. McKenney wrote:
> On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
> > 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...
> 
> Hmmmm...
> 
> 	$ make
> 	sh ./utilities/gen_snippet_d.sh
> 	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv
> 
> 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

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

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

diff --git a/Makefile b/Makefile
index fe9f63f43e55..3e9e2c2ebf3c 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
index 1580478fe2f9..642451d9e880 100644
--- a/CodeSamples/toolsoftrade/forkjoinvar.c
+++ b/CodeSamples/toolsoftrade/forkjoinvar.c
@@ -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 */


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05 16:54     ` Paul E. McKenney
@ 2018-08-05 21:58       ` Akira Yokosawa
  2018-08-05 22:47         ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-05 21:58 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/05 09:54:48 -0700, Paul E. McKenney wrote:
> On Sun, Aug 05, 2018 at 09:35:08AM -0700, Paul E. McKenney wrote:
>> On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
>>> 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...
>>
>> Hmmmm...
>>
>> 	$ make
>> 	sh ./utilities/gen_snippet_d.sh
>> 	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv
>>
>> 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.

>>
>> 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
> 
> 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
> 
> ------------------------------------------------------------------------
> 
> diff --git a/Makefile b/Makefile
> index fe9f63f43e55..3e9e2c2ebf3c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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

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

Acked-by: Akira Yokosawa <akiyks@gmail.com>

Of course, the following diff should be omitted.

        Thanks, Akira

> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> index 1580478fe2f9..642451d9e880 100644
> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> @@ -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 */
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05 21:58       ` Akira Yokosawa
@ 2018-08-05 22:47         ` Paul E. McKenney
  2018-08-05 23:26           ` Akira Yokosawa
  0 siblings, 1 reply; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-05 22:47 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Mon, Aug 06, 2018 at 06:58:20AM +0900, Akira Yokosawa wrote:
> On 2018/08/05 09:54:48 -0700, Paul E. McKenney wrote:
> > On Sun, Aug 05, 2018 at 09:35:08AM -0700, Paul E. McKenney wrote:
> >> On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
> >>> 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...
> >>
> >> Hmmmm...
> >>
> >> 	$ make
> >> 	sh ./utilities/gen_snippet_d.sh
> >> 	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv
> >>
> >> 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.

Been there, done that!  ;-)

> >> 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
> > 
> > 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
> > 
> > ------------------------------------------------------------------------
> > 
> > diff --git a/Makefile b/Makefile
> > index fe9f63f43e55..3e9e2c2ebf3c 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -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
> 
> 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
> 
> Acked-by: Akira Yokosawa <akiyks@gmail.com>
> 
> 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

>         Thanks, Akira
> 
> > diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> > index 1580478fe2f9..642451d9e880 100644
> > --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> > +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> > @@ -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 */
> > 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05 22:47         ` Paul E. McKenney
@ 2018-08-05 23:26           ` Akira Yokosawa
  2018-08-05 23:40             ` Paul E. McKenney
  0 siblings, 1 reply; 30+ messages in thread
From: Akira Yokosawa @ 2018-08-05 23:26 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On 2018/08/05 15:47:19 -0700, Paul E. McKenney wrote:
> On Mon, Aug 06, 2018 at 06:58:20AM +0900, Akira Yokosawa wrote:
>> On 2018/08/05 09:54:48 -0700, Paul E. McKenney wrote:
>>> On Sun, Aug 05, 2018 at 09:35:08AM -0700, Paul E. McKenney wrote:
>>>> On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
>>>>> 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...
>>>>
>>>> Hmmmm...
>>>>
>>>> 	$ make
>>>> 	sh ./utilities/gen_snippet_d.sh
>>>> 	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv
>>>>
>>>> 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.
> 
> Been there, done that!  ;-)
> 
>>>> 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
>>>
>>> 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
>>>
>>> ------------------------------------------------------------------------
>>>
>>> diff --git a/Makefile b/Makefile
>>> index fe9f63f43e55..3e9e2c2ebf3c 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -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
>>
>> 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
>>
>> Acked-by: Akira Yokosawa <akiyks@gmail.com>
>>
>> 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

> 
> Either way, please let me know!
> 
> 							Thanx, Paul
> 
>>         Thanks, Akira
>>
>>> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
>>> index 1580478fe2f9..642451d9e880 100644
>>> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
>>> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
>>> @@ -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



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [GIT PULL v5] Trial of labeling lines in code snippets
  2018-08-05 23:26           ` Akira Yokosawa
@ 2018-08-05 23:40             ` Paul E. McKenney
  0 siblings, 0 replies; 30+ messages in thread
From: Paul E. McKenney @ 2018-08-05 23:40 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Mon, Aug 06, 2018 at 08:26:03AM +0900, Akira Yokosawa wrote:
> On 2018/08/05 15:47:19 -0700, Paul E. McKenney wrote:
> > On Mon, Aug 06, 2018 at 06:58:20AM +0900, Akira Yokosawa wrote:
> >> On 2018/08/05 09:54:48 -0700, Paul E. McKenney wrote:
> >>> On Sun, Aug 05, 2018 at 09:35:08AM -0700, Paul E. McKenney wrote:
> >>>> On Sun, Aug 05, 2018 at 09:06:27AM +0900, Akira Yokosawa wrote:
> >>>>> 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...
> >>>>
> >>>> Hmmmm...
> >>>>
> >>>> 	$ make
> >>>> 	sh ./utilities/gen_snippet_d.sh
> >>>> 	CodeSamples/toolsoftrade/pcreate.c --> CodeSamples/toolsoftrade/pcreate@mythread.fcv
> >>>>
> >>>> 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.
> > 
> > Been there, done that!  ;-)
> > 
> >>>> 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
> >>>
> >>> 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
> >>>
> >>> ------------------------------------------------------------------------
> >>>
> >>> diff --git a/Makefile b/Makefile
> >>> index fe9f63f43e55..3e9e2c2ebf3c 100644
> >>> --- a/Makefile
> >>> +++ b/Makefile
> >>> @@ -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
> >>
> >> 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
> >>
> >> Acked-by: Akira Yokosawa <akiyks@gmail.com>
> >>
> >> 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.

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

							Thanx, Paul

>         Thanks, Akira
> 
> > 
> > Either way, please let me know!
> > 
> > 							Thanx, Paul
> > 
> >>         Thanks, Akira
> >>
> >>> diff --git a/CodeSamples/toolsoftrade/forkjoinvar.c b/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> index 1580478fe2f9..642451d9e880 100644
> >>> --- a/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> +++ b/CodeSamples/toolsoftrade/forkjoinvar.c
> >>> @@ -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
> 
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2018-08-06  1:47 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-21  0:19 [NOT YET PULL] Trial of labeling lines in code snippets Akira Yokosawa
2018-07-21 16:51 ` Paul E. McKenney
2018-07-22 15:43   ` Akira Yokosawa
2018-07-22 22:49     ` Paul E. McKenney
2018-07-23 15:09       ` Akira Yokosawa
2018-07-23 15:12         ` Akira Yokosawa
2018-07-23 21:03           ` Paul E. McKenney
2018-07-30 16:04 ` [NOT YET PULL v2] " Akira Yokosawa
2018-07-31 15:10   ` Paul E. McKenney
2018-08-01 15:24     ` Akira Yokosawa
2018-08-01 15:59       ` Paul E. McKenney
2018-08-01 22:14         ` Akira Yokosawa
2018-08-02  0:22           ` Paul E. McKenney
2018-08-02 22:34 ` [GIT PULL v3] " Akira Yokosawa
2018-08-03 14:35   ` Paul E. McKenney
2018-08-03 15:02     ` Akira Yokosawa
2018-08-03 15:49     ` Akira Yokosawa
2018-08-03 16:45       ` Paul E. McKenney
2018-08-03 23:12         ` Akira Yokosawa
2018-08-03 23:43           ` Paul E. McKenney
2018-08-04  0:00             ` Akira Yokosawa
2018-08-04 11:57 ` [GIT PULL v4] " Akira Yokosawa
2018-08-04 15:15   ` Akira Yokosawa
2018-08-05  0:06 ` [GIT PULL v5] " Akira Yokosawa
2018-08-05 16:35   ` Paul E. McKenney
2018-08-05 16:54     ` Paul E. McKenney
2018-08-05 21:58       ` Akira Yokosawa
2018-08-05 22:47         ` Paul E. McKenney
2018-08-05 23:26           ` Akira Yokosawa
2018-08-05 23:40             ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.