Skip to content

Commit

Permalink
Separate from inilike library
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed May 31, 2015
1 parent 65ae11d commit 8c51930
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 842 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: d
matrix:
allow_failures:
- d: gdc-4.9.2
- d: ldc-0.15.1
- d: dmd-2.065.0
- d: gdc-4.8.2
- d: ldc-0.14.0
- d: dmd-2.065.0
include:
- d: dmd-2.067.1
- d: gdc-4.9.2
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ Use this example to check if the desktopfile library can parse all .desktop file

dub run desktopfile:desktoptest --build=release

To print all directories examined by desktoptest to stdout, build it in non-release mode:


dub run desktopfile:desktoptest
1 change: 1 addition & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"license" : "BSL-1.0",
"authors": ["Roman Chistokhodov"],
"dependencies": {
"inilike": "~>0.1.0"
},
"targetName" : "desktopfile",
"targetPath" : "lib",
Expand Down
27 changes: 24 additions & 3 deletions source/desktopfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ version(Posix)
alias IniLikeGroup DesktopGroup;


@trusted string unescapeExec(string str) nothrow pure
{
static immutable Tuple!(char, char)[] pairs = [
tuple('"', '"'),
tuple('\'', '\''),
tuple('\\', '\\'),
tuple('>', '>'),
tuple('<', '<'),
tuple('~', '~'),
tuple('|', '|'),
tuple('&', '&'),
tuple(';', ';'),
tuple('$', '$'),
tuple('*', '*'),
tuple('?', '?'),
tuple('#', '#'),
tuple('(', '('),
tuple(')', ')'),
];
return doUnescape(str, pairs);
}

/**
* Represents .desktop file.
*
Expand Down Expand Up @@ -102,8 +124,7 @@ public:
{
super(byLine, options, fileName);
auto groups = byGroup();
enforce(!groups.empty, "no groups");
enforce(groups.front.name == "Desktop Entry", "the first group must be Desktop Entry");
enforce(!groups.empty, new DesktopFileException("no groups", 0));

_desktopEntry = groups.front;
}
Expand Down Expand Up @@ -310,7 +331,7 @@ public:
* Join range of multiple values into a string using semicolon as separator. Adds trailing semicolon.
* If range is empty, then the empty string is returned.
*/
static @trusted string joinValues(Range)(Range values) if (isInputRange!Range && isSomeString!(ElementType!Range)) {
@trusted static string joinValues(Range)(Range values) if (isInputRange!Range && isSomeString!(ElementType!Range)) {
auto result = values.filter!( s => s.length != 0 ).joiner(";");
if (result.empty) {
return null;
Expand Down
Loading

0 comments on commit 8c51930

Please sign in to comment.