tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: Re: mdocml: Renamed mandoc.c to libmandoc.c.
Date: Wed, 7 Jul 2010 01:30:17 +0200	[thread overview]
Message-ID: <20100706233016.GF19714@iris.usta.de> (raw)
In-Reply-To: <4C32F642.2090609@bsd.lv>

Hi Kristaps,

Kristaps Dzonsons wrote on Tue, Jul 06, 2010 at 11:24:18AM +0200:

[...]
> The fix is pretty mechanical (namely, doing it in mdoc_validate.c
> where the string pointer is reallocated on-the-fly if the escape is
> flagged), but I didn't have the energy to do it.

Hm, i shall wait and see what you are driving at, though i'm
a bit suspicious whether the parser backend it the best place
for this.

Apparently, groff supports constructs like the following,
see /usr/src/gnu/usr.bin/groff/tmac/tmac.doc:

.nr aP 3
.ds A3 Fl
.\*(A\n(aP

resolving via ".\*(A3" to ".Fl" which will be evaluated as -
the mdoc(7) flag macro.  Obfuscation, anybody?

I don't say we need to implement all that, probably most such
stuff will be rarely needed, but when we have the choice, it
is perhaps worthwhile doing some of the expansions on the
preprocessor level, maybe even iteratively.

Of course, things like special characters and font escapes,
which depend critically on the choice of the frontend, have
no business in the preprocessor, but belong into the frontend.
Yet, the escape sequence parsing logic for \*x, \*(xx, \*[xxx]
is the same for both cases.  Not sure how to organize the code
to deal with that situation, to minimize code duplication as
well as duplicate processing...

In any case, the one place where i would least expect to find
escape sequence parsing is in the mdoc/man parser backends.

[...]
>> * man.c implements man.h without explicitely including it;
>>   it is only included via libman.h

> So do all man_* and mdoc_* files (with libman.h and libmdoc.h,
> resp.). If this bothers you, it's a mechanical change.

I tend to directly include a header when i directly use symbols
defined there, even when another header i'm using implicitely
includes it anyway - but that is a matter of style and not so
important.

What i do find surprising is that a .c-file defining a function
(say, man.c defining man_parseln) does not explicitely include
the header declaring it (i.e., man.h declaring man_parseln),
but relies on another header it happens to be using (libman.h)
to implicitely include man.h.

As far as i see, that happens in two cases only:
  man.c   not including  man.h   directly
  mdoc.c  not including  mdoc.h  directly

But even that is certainly not critical.


[...]
> Ja.  I don't worry about this too much, as fixing it's
> (1) not necessary right now,

Yes, i agree there is no need to reshuffle the headers
right now.  I only looked at it because i was under the
impression you were about to start that kind of reshuffling,
and wanted to figure out how good or bad the situation
actually is, and whether one could expect perfect results
with reasonable effort.

Right now, let's not do more than simple fixes, let's not
move files around or change the basic structure, it works
well enough.


> For the record, there should ideally be a division as follows:
> 
>               +-----libmandoc----+
>            libmdoc   libman   libroff
>               |         |        |
>               +---------+--------+
>                         |
>                        main
>                         |
>             +-----------+-----------+
>             |           |           |
>           term---------html--------tree
>         ps/ascii    html/xhtml  pine/birch
> 
> It's clear that /all/ of these need the mdoc.h and man.h structures.
> Only the libmdoc/man/roff/main need the parse/access functions.

Yes, that basic picture is fine.  Except that many functions in man.h
and mdoc.h use pointers to struct man and struct mdoc, which contain
all the parser functions, so there is a bit of a looping.  But again,
no need to unwind that right now.

> Ingo, your thoughts: after the `Bk' stuff is checked in, I make
> another little tag, we clean up, fix this architectural cruft while
> it's fresh in our minds, then tag and make a real release?

Sounds good.  So i will do the main merging to OpenBSD after the
little tag, and perhaps we can then also put in two small fixes
to .Sm and .No i'm currently preparing.

Yours,
  Ingo
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

  parent reply	other threads:[~2010-07-06 23:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201007052000.o65K0uQH002309@krisdoz.my.domain>
2010-07-06  3:15 ` Ingo Schwarze
2010-07-06  9:24   ` Kristaps Dzonsons
2010-07-06 10:58     ` Kristaps Dzonsons
2010-07-06 22:01       ` Ingo Schwarze
2010-07-06 23:30     ` Ingo Schwarze [this message]
2010-07-07 10:56       ` Kristaps Dzonsons
2010-07-07 21:58         ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100706233016.GF19714@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=tech@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).