vigna / ne

ne, the nice editor
http://ne.di.unimi.it/
GNU General Public License v3.0
474 stars 33 forks source link

build fails in archlinux #109

Closed valr closed 1 year ago

valr commented 1 year ago

Hello,

I'm trying to build ne in archlinux and I'm facing an issue that enums.h is not generated due to an error in info2src.pl When in the /src directory, if I run make I have this error:

valr@cartman in ~/ne/src via C v12.2.0-gcc via 🐪 v5.36.0 via 💎
❯ make
makeinfo -D autohelp ne.texinfo
perl info2src.pl
info2src.pl: HASH_TABLE_SIZE = 1511
info2src.pl [364]: $commands{SYNTAX}->{"abbr"} undefined.
make: *** [makefile:156: enums.h] Error 2

I'm not clear about what's going wrong and how to fix it. Could you help me on this?

Thanks

utoddl commented 1 year ago

makeinfo -D autohelp ne.texinfo is supposed to create ne.info, which is then read by info2src.pl to produce a small handful of .c and .h files.

The first thing that strikes me is that your info2src.pl is generating a hash table from the documented commands that has only 1511 entries, whereas when I run it here my hash table size is 3361. This makes me wonder if you've got a recent version... Where did you get your source from?

In your src directory, is ne.texinfo a symbolic link to ../doc/ne.texinfo? It's supposed to be.

What output do you get if you run the following command?

grep -C4 "^Syntax: .Syntax" ne.info

I get this:


4.9.31 Syntax
-------------

Syntax: 'Syntax [NAME|*]'
Abbreviation: 'SY'

loads the syntax with the given name, and colors the current document
accordingly.

I've never seen info2src.pl fail to read command / abbreviation pairs like that, so something is clearly wrong, but I don't know what yet.

valr commented 1 year ago

Thanks for the reply. I'm trying to build ne with the latest 3.2.2 tarball (https://ne.di.unimi.it/ne-3.3.2.tar.gz). As it was failing, I've cloned the github repo to try and have the same problem. The above report has been done from the git cloned repo.

ne.texinfo is indeed a symlink to ..doc/ne.texinfo

-rw-r--r-- 1 valr valr  23478 2022-12-15 21:47 ne.h
-rw-r--r-- 1 valr valr 264306 2022-12-15 22:01 ne.info
lrwxrwxrwx 1 valr valr     17 2022-12-15 21:47 ne.texinfo -> ../doc/ne.texinfo
-rw-r--r-- 1 valr valr  18084 2022-12-15 21:47 prefs.c
-rw-r--r-- 1 valr valr  13652 2022-12-15 21:47 protos.h

Output of grep -C4 "^Syntax: .Syntax" ne.info:

❯ grep -C4 "^Syntax: .Syntax" ne.info

4.9.31 Syntax
-------------

Syntax: ‘Syntax [NAME|*]’
Abbreviation: ‘SY’

loads the syntax with the given name, and colors the current document
accordingly.
utoddl commented 1 year ago

Your version of makeinfo is producing "smart single quote pairs" (U+2018 and U+2019) rather than the expected apostrophe (U+0027). What do you get for makeinfo --version?

You can work around it by replacing the smart left and right single quotes with the dumb apostrophes. There are some examples to follow in the doc/makefile, but it would look something like this:

enums.h names.c names.h hash.c hash.h help.c help.h ext.c: ne.texinfo version.texinfo info2src.pl
        makeinfo -D autohelp ne.texinfo
        sed -i -e "s/[‘’]/'/g" ne.info*
        perl info2src.pl
        rm -f ne.info*

I have not tested this, but it's pretty close. The only intentional change above is the addition of the sed command. And note: because this is a makefile, the leading white space on those lines should be a single tab, but I can't seem to insert tabs into github comments.

Another way to fix this would be to handle the smart quotes properly in info2src.pl when they exist. But as I can't produce them with my version of makeinfo that would be tricky. That's probably a better fix in the long run though.

Do let us know how/if that works for you.

valr commented 1 year ago

Excellent, thanks a lot for the direction to look at, indeed that's the problem.

The makeinfo version is the following:

❯ makeinfo --version
texi2any (GNU texinfo) 7.0.1

Looking at the NEWS of texinfo, I see this as possible root cause of this format change in the version 7.0:

. Info output
      . quote problematic node names (with :, comma...) by default
      . new customization variable ASCII_PUNCTUATION to use plain ASCII
        characters for quotation marks and a few other symbols

So, this works as solution:

makeinfo -c ASCII_PUNCTUATION=1 -D autohelp ne.texinfo

And here is the code of texinfo itself using that variable, we can see where the conversion happens:

  if ($self->get_conf('ASCII_PUNCTUATION')) {
    $self->{'convert_text_options'}->{'ascii_punctuation'} = 1;
    # cache to avoid calling get_conf
    $self->{'ascii_punctuation'} = 1;
  } else {
    $self->{'ascii_punctuation'} = 0;
  }

  if ($self->get_conf('ENABLE_ENCODING')
      and $self->get_conf('OUTPUT_ENCODING_NAME')
      and $self->get_conf('OUTPUT_ENCODING_NAME') eq 'utf-8') {
    # cache this to avoid redoing calls to get_conf
    $self->{'to_utf8'} = 1;
    if (!$self->{'ascii_punctuation'}) {
      foreach my $quoted_command (@quoted_commands) {
        # Directed single quotes
        $self->{'style_map'}->{$quoted_command} = ["\x{2018}", "\x{2019}"];
      }
      # Directed double quotes
      $self->{'style_map'}->{'dfn'} = ["\x{201C}", "\x{201D}"];
    }
  }

Another possible solution that works, but maybe more violent is to do this:

makeinfo --disable-encoding -D autohelp ne.texinfo

From the texinfo doc:

--enable-encoding
--disable-encoding
     By default, or with ‘--enable-encoding’, output accented and
     special characters in Info and plain text output based on the
     document encoding.  With ‘--disable-encoding’, 7-bit ASCII
     transliterations are output.

     By default, or with ‘--disable-encoding’, output accented and
     special characters in HTML, XML and DocBook using XML entities.
     With ‘--enable-encoding’, output accented characters in HTML, XML
     and DocBook output and special characters in HTML output based on
     the document encoding.  *Note @documentencoding::, and *note
     Inserting Accents::.

What's your makeinfo version? I guess you have an older one than mine, so you may face the same issue in the future. Thanks

utoddl commented 1 year ago

This is excellent information. Thank you very much.

Mine is version 6.8 as shipped with Fedora 37; texinfo-6.8-4.fc37 to be exact. I'd certainly like to give 7 a try.

Given that it's going to all the trouble to give us "nice" quotes, in the long run I'd prefer to keep the quotes and fix the tooling in ne to preserve and use them properly when they're available. Your workaround in the mean time seems perfectly reasonable.

I'm going to leave this issue open until it gets dealt with on our side. Thanks again for reaching out.

valr commented 1 year ago

It's perfect, thanks a lot for your help.

utoddl commented 1 year ago

There's now an updated src/info2src.pl on the master branch that supports the unicode smart quotes produced by texinfo > 6 while still working with the older format. Quoted strings in the help pages look much nicer with the smart quotes.

Closing this issue.

valr commented 1 year ago

Thanks for all!