1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00
Commit Graph

21 Commits

Author SHA1 Message Date
Christophe CURIS
f030ab7664 wmmenugen: Fix memory leaks in XDG menu generation when getting locale-dependant name
As reported by Coverity as CID #50142, #50143, #50144 and #50145, all the
strings allocated by 'parse_locale' were never freed.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
2a8fc1df9a wmmenugen: Fix memory leak when parsing names for menus in XDG format
As reported by Coverity (CID #50146), if the function getLocalizedStringValue
returns without matching the entry, the storage for the entry's locale was
leaked.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
296456f361 wmmenugen: Fix memory leak when parsing categories in an XDG menu
Reported by Coverity (CID #50147)

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Jeremy Sowden
4477ae4da4 Prefer TryExec to Exec when generating menu entries from XDG desktop files.
From the comments at the top of wmmenugen_parse_xdg.c:

  Since there is no passing of file name arguments or anything of the
  sort to applications from the menu, execname is determined as follows:

   - If `TryExec' is present, use that;
   - else use `Exec' with any switches stripped

However, Exec used to be preferred.  Changed code to prefer TryExec.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2019-06-20 22:06:36 +01:00
Jeremy Sowden
9330a021e5 Omit field-code in Exec fields when generating menu-entries from XDG desktop-files.
Exec fields in desktop-files may include field-codes which act as
place-holders for command-line arguments.  Previously the Exec arguments
were being passed through intact.  However, since Window Maker has no
support for expanding the field-codes, we now remove them and preserve
the remaining arguments.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2019-06-20 22:06:36 +01:00
Jeremy Sowden
41ab926090 Parse Exec fields when generating menu-entries from XDG desktop-files.
Exec fields in desktop-files are subject to escaping.  Unescape them.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2019-06-20 22:06:36 +01:00
Jeremy Sowden
b32ccee5cb Undo XDG string-escaping when generating menu-entries.
In XDG desktop files, string values are subject to escaping.  Undo this
when parsing them.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2019-06-20 22:06:36 +01:00
Jeremy Sowden
6734646265 Use pointers as parameters instead of pointer-to-pointers.
Some functions expected pointers-to-pointers where pointers would do.
Changed them to use pointers.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2019-06-20 22:06:36 +01:00
Doug Torrance
ff865c31f0 wmmenugen: Sort menu entries with no category into 'Other'. 2017-07-07 09:59:29 +01:00
Doug Torrance
adc1687f98 wmmenugen: Use 'Other' instead of 'Applications' for unknown categories.
From https://standards.freedesktop.org/menu-spec/latest/apa.html:

 Category-based menus based on the Main Categories listed in this
 specification do not provide a complete ontology for all available
 applications. Category-based menu implementations SHOULD therefore provide
 a "catch-all" submenu for applications that cannot be appropriately placed
 elsewhere.

Emphasis on *submenu*.  By using 'Applications', these menu entries were
sorted into the top level.
2017-07-07 09:59:29 +01:00
Doug Torrance
ac0690b324 wmmenugen: Add reserved categories.
From https://standards.freedesktop.org/menu-spec/latest/apas03.html:

Reserved Categories have a desktop-specific meaning that has not been
standardized (yet). Desktop entry files that use a reserved category MUST
also include an appropriate OnlyShowIn= entry to restrict themselves to
those environments that properly support the reserved category as used.
2017-07-07 09:59:29 +01:00
Doug Torrance
c261f8ec35 wmmenugen: Add missing 'Science' menu category.
See https://standards.freedesktop.org/menu-spec/latest/apa.html
2017-07-07 09:59:29 +01:00
Christophe CURIS
e037ae3684 util: fix parsing of XDG menus with multiple groups
The specification for XDG menu files allows having more than one group and
assumes no constraint on their order. The original code assumed that once
the proper group marker was found, everything after was part of it, causing
misinterpretation of some data, like taking the wrong launch command.

This patch stops the parsing of the menu XDG file when a new group is
found, hence implementing the expected behaviour.

Reported-by: Andreas Metzler <ametzler@bebt.de>
2017-07-03 14:45:26 +01:00
Christophe CURIS
765814e393 util: add explicit types for calback functions definitions
It makes the code easier to read to explicitly define a type for the
functions that are used for callbacks, so this patch does this for the
wmmenugen tool.

It was an opportunity to highlight some variable definitions that looked
like function prototypes, and were as such misplaced in the code, being a
source of confusion.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-06 01:07:55 +01:00
Amadeusz Sławiński
677117276c util: Value stored to 'ret' is never read
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2014-05-18 23:00:17 +01:00
Alexey I. Froloff
d53b43608a wmmenugen: properly skip NoDispaly entries
Last group from a desktop file is always added to menu regardless of
NoDisplay property.  Properly handle the NoDisplay and Hidden properties
at the end of file.

Signed-off-by: Alexey I. Froloff <raorn@raorn.name>
2012-06-18 23:34:46 +01:00
Brad Jorsch
a06b0673d8 Fix some "'var' may be used uninitialized" warnings
The one in WPrefs.app/Appearance.c is indirect: the function might
be inlined and might return an uninitialized value, which causes gcc to
complain that the caller might use that uninitialized return value.
2011-08-09 23:45:34 +02:00
Tamas TEVESZ
f65b99e615 Remove warnings
* Remove assigned but not used variables (GCC 4.6)
* Bump _XOPEN_SOURCE to 600, ridding of FreeBSD warnings (this probably need
  to be tweaked on a per-implementation basis as problems arise)
2011-03-24 16:19:52 +01:00
Tamas TEVESZ
4f853ce3b6 wmmenugen: Finish the XDG parser
Recognize the freedesktop.org-mandated Main Categories in .desktop files
and put menu entries in the appropriate categories.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-10 19:38:14 +02:00
Tamas TEVESZ
a23b72c32a wmmenugen: Add file name validator function
Add optional interface parsers may choose to implement that, when
a directory is being scanned for files to parse, may, based on
the file name, decide whether or not said file should be parsed.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-10 19:36:34 +02:00
Tamas TEVESZ
8b68042b30 Add wmmenugen, an extensible PropList-format menu generator
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-08 18:13:56 +02:00