bugGNU nano - Bugs: bug #56478, delayed syntax parsing is...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #56478: delayed syntax parsing is problematic for included files with multiple syntaxes

Submitter:  Benno Schulenberg <bens>
Submitted:  Wed 12 Jun 2019 10:14:58 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Fri 14 Jun 2019 09:21:16 AM UTC, comment #8: 

Fixed in git, commit 7028adf2.

And closing because unreleased.

Benno Schulenberg <bens>
Group administrator
Thu 13 Jun 2019 02:30:15 PM UTC, comment #7: 

Last version also did not report anything for two successive syntax commands in an included file.  Attached is a version that handles that case too, thus reporting any empty syntax (and other rcfile errors) at startup.

(file #47085)

Benno Schulenberg <bens>
Group administrator
Thu 13 Jun 2019 10:18:50 AM UTC, comment #6: 

It didn't report disallowed commands in included files any more.

Attached version is better, although I don't like it much that all these commands get compared in two different places, but I don't know how to do it better/shorter.

(And a small disadvantage is that a syntax without color commands gets reported only when the syntax gets used.)

(file #47083)

Benno Schulenberg <bens>
Group administrator
Thu 13 Jun 2019 07:11:38 AM UTC, comment #5: 

Looks good to me, what doesn't work?

Brand Huntsman <brand>
Wed 12 Jun 2019 06:11:56 PM UTC, comment #4: 

Here's one that mostly works.  Debugging stuff still present.

(file #47081)

Benno Schulenberg <bens>
Group administrator
Wed 12 Jun 2019 04:15:16 PM UTC, comment #3: 

This is what I have so far.  It properly gets multiple syntaxes from an included file, but doesn't get any syntaxes any more from a main file, nor does it process any extendsyntax commands.

(file #47080)

Benno Schulenberg <bens>
Group administrator
Wed 12 Jun 2019 03:07:19 PM UTC, comment #2: 

I didn't think there would be any syntax files out there that defined multiple syntaxes, but looking at the Scopatz collection https://github.com/scopatz/nanorc/, there are a few that do.  :|

If we don't want to break that, then nano will have to store not just the filename but also the line number at which the 'syntax' command was found, and upon the second reading (the full parsing) it should first fast-forward to the stored line number.  This would have the small advantage that we don't need to fully parse syntaxes that are defined a main nanorc file either.

Benno Schulenberg <bens>
Group administrator
Wed 12 Jun 2019 12:23:32 PM UTC, comment #1: 

Ah, I didn't know that was even possible. It might not be too hard to continue reading the file and ignore commands other than syntax, header and magic. When one of the syntaxes in the file is used, the normal processing of the file would load all syntaxes in that file and mark them as loaded. The only problem is that set_syntax_colorpairs() would only be called for the syntax being used, so syntaxtype would need some other way to mark syntaxes that have been loaded but colorpairs aren't initialized.

It would of course slow down loading a little because all files would now be fully scanned.

Disallowing multiple syntaxes per file would break any user or package syntaxes. The colors from additional syntaxes are also added to the first syntax in the file. Attached patch produces an error message when the first syntax in the file is used and parsing encounters an additional syntax. Anyone who wrote their own syntax would probably know enough to test if the other syntaxes in the file worked, and would see the error.

Regarding distro syntaxes, wouldn't it be better to store them in a distro-syntaxes directory that isn't installed. The build script for the distro can manually copy the syntaxes it wants to the same directory that contains the other syntaxes. That way existing nanorc files would still load the distro syntax files.

The extra/ subdirectory could still be added for lesser known file types. And if they become popular just move up and symlink it from extra to avoid breaking nanorcs that loaded it.

(file #47079)

Brand Huntsman <brand>
Wed 12 Jun 2019 10:14:58 AM UTC, original submission:  

To reproduce, run:

  src/nano -Y/etc/portage

It reports on the status bar: "[ Unknown syntax name: /etc/portage ]".  It works fine in 4.2 and before.

The delayed syntax parsing has made that nano doesn't find any second or later syntax in an included file.  The solution is simple, of course: split up the file into two.  And add in the documentation that included files may contain just one syntax definition.

But... it is strange that nano includes a syntax that is specific to Gentoo, and another that is specific to Debian, and another specific to Fedora and its kin.  I think nano should include only syntaxes that are generally useful, for files that are likely to exist on the average Unix-like system.  If some distros want to include syntax definitions for files that are specific to them, that is fine, but I don't think they should be part of nano -- or at least, they should not be installed by default.  Maybe push all less-generally useful syntaxes to an extra/ subdirectory of syntax/?  This would also allow to pack several more syntaxes with nano without burdening the startup time for the average user with them.

Benno Schulenberg <bens>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by brand (Updated the item)
  • -email is unavailable- added by bens (Submitted the item)
  • -email is unavailable- added by bens
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-14 bens StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2019-06-13 bens Attached File- Added 0001-rcfile-fully-read-each-included-file-so-all-its-synt.patch, #47085
    2019-06-13 bens Attached File- Added multiple-syntaxes-in-one-file--3.diff, #47083
        Summarydelayed syntax parsing is problematic for gentoo.nanorc delayed syntax parsing is problematic for included files with multiple syntaxes
    2019-06-12 bens Attached File- Added multiple-syntaxes-in-one-file--2.diff, #47081
        StatusNone In Progress
    2019-06-12 bens Attached File- Added multiple-syntaxes-in-one-file.diff, #47080
    2019-06-12 brand Attached File- Added disallow-multiple-syntaxes-per-include-file.patch, #47079
    2019-06-12 bens Carbon-Copy- Added brand

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code