Re: [PATCH v1] CONTRIBUTING.d/style/c: Add coding style for the example programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Branden,

On Sat, Feb 08, 2025 at 05:46:19PM -0600, G. Branden Robinson wrote:
> _If_ you advise the use of tab characters _only_ when filling is
> disabled, as, apropos of the Subject line, is the case in (displayed)
> code examples, you should be fine.

Yes, I'm proposing using tabs exclusively within EX/EE.

> However, you will get 8 character cells per tab stop and I am _not_ sure
> it's portable to expect, or to try to configure, anything else.

Are you sure?  I'm getting 5 characters per cell, which is what has
prevented me from doing it more happily.  I would have done it already
if I had seen 8 chars-per-tab.

	alx@devuan:~/tmp$ cat c.man 
	.TH a s d f
	.SH g
	.EX
	if (foo)
		bar();
	.EE
	alx@devuan:~/tmp$ hd c.man 
	00000000  2e 54 48 20 61 20 73 20  64 20 66 0a 2e 53 48 20  |.TH a s d f..SH |
	00000010  67 0a 2e 45 58 0a 69 66  20 28 66 6f 6f 29 0a 09  |g..EX.if (foo)..|
	00000020  62 61 72 28 29 3b 0a 2e  45 45 0a                 |bar();..EE.|
	0000002b
	alx@devuan:~/tmp$ groff -man -Tutf8 c.man 
	a(s)                                                                        a(s)

	g
	     if (foo)
		  bar();

	f                                       d                                   a(s)
	alx@devuan:~/tmp$ groff -man -Tutf8 c.man | hd
	00000000  1b 5b 34 6d 61 1b 5b 32  34 6d 28 73 29 20 20 20  |.[4ma.[24m(s)   |
	00000010  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
	*
	00000050  20 20 20 20 20 1b 5b 34  6d 61 1b 5b 32 34 6d 28  |     .[4ma.[24m(|
	00000060  73 29 0a 0a 1b 5b 31 6d  67 1b 5b 30 6d 0a 20 20  |s)...[1mg.[0m.  |
	00000070  20 20 20 69 66 20 28 66  6f 6f 29 0a 20 20 20 20  |   if (foo).    |
	00000080  20 20 20 20 20 20 62 61  72 28 29 3b 0a 0a 66 20  |      bar();..f |
	00000090  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
	*
	000000b0  20 20 20 20 20 20 64 20  20 20 20 20 20 20 20 20  |      d         |
	000000c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
	000000d0  20 20 20 20 20 20 20 20  20 20 1b 5b 34 6d 61 1b  |          .[4ma.|
	000000e0  5b 32 34 6d 28 73 29 0a                           |[24m(s).|
	000000e8

Why am I not seeing 8-char indents?

> Finally, I have a vague memory--perhaps not a correct one--that Michael
> Kerrisk preferred 4-cell tab stops over 8-cell ones (however obtained)
> because he found that the latter caused lines to overrun too frequently.
> Keep in mind that displayed code examples in man pages will always be
> significantly indented, unlike in real C source where we start
> everything at column 0.  Things to consider.

Yeah, that's one consideration.  I'd try to make sure that examples fit
in 80 columns before switching to tabs.  On the other hand, once I have
all the examples fit in there with tabs, the code will be more readable
(less nesting).

> I would proceed with caution, and test with multiple formatters.  (Maybe
> you already do.)

Yup.  :-)


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux