Bug 73272 - hwdb: fails on empty lines/comments in hwdb files
Summary: hwdb: fails on empty lines/comments in hwdb files
Status: RESOLVED NOTABUG
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-04 01:34 UTC by Enrico Scholz
Modified: 2014-01-06 15:05 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Enrico Scholz 2014-01-04 01:34:13 UTC
I am about to convert old keymap files to the new hwdb format but entries like

| pci:v1131p7160*
|  KEYBOARD_KEY_160001=power
|  KEYBOARD_KEY_160018=mute
|
|  KEYBOARD_KEY_160003=kp1

get rejected by '/sbin/udevadm hwdb --update --root=../../..' with

|  Error, MATCH expected but got ' KEYBOARD_KEY_160003=kp1' in ...

Replacing empty lines (which splits basically function blocks or rows of the remote control) with comments does not help.

As this is a complex ruleset defining >100 keys, I need some markup/documentation in the file so that I do not lose overview.

Things worked fine with old keymap files.

Tested with systemd-208
Comment 1 Kay Sievers 2014-01-04 04:08:01 UTC
That's just the very basic rules of the file format, a feature and expected
behavior. \n is the record separator, only leading whitespace declares
continuation lines.

Try inserting a comment line starting with '#'.

If you want/need more fancy comment placements, just change the parser and
send a patch; but we cannot just allow completely empty lines in records, that wouldn't be valid any more.
Comment 2 Enrico Scholz 2014-01-04 14:07:30 UTC
comments do not work:

| pci:v1131p7160*
|  KEYBOARD_KEY_160001=power
|  # row 1
|  KEYBOARD_KEY_160003=kp1

$ /sbin/udevadm hwdb --update --root=.
Error, MATCH expected but got ' KEYBOARD_KEY_160003=kp1' in './etc/udev/hwdb.d/x.hwdb':
Comment 3 Kay Sievers 2014-01-04 16:00:17 UTC
They do, don't indent them. As said, if you need more fancy comment stuff,
send a patch for the parser.
Comment 4 Zbigniew Jedrzejewski-Szmek 2014-01-05 21:52:43 UTC
Would it be acceptable to treat empty lines as non-entry-terminating if the first following non-empty line is indented? This would follow Python style a bit. I think this would be nicer than forcing fake comments, especially that those comments cannot be indented, which makes the whole thing awkward for long lists.
Comment 5 Kay Sievers 2014-01-06 15:05:54 UTC
The records are kind of rfc0822-style, which wouldn't allow that.

We should allow indented '#' lines, so they align naturally. But I'm not
sure if we really should allow one record to be split up and have newlines
in it. It kind of looks invalid from the general rules what a record is.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.