Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e9d6601

Browse files
author
Federico Fissore
committed
Windows: reg query uses different separators on xp, fooling parser. Fixed
1 parent 3c98275 commit e9d6601

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎app/test/processing/app/windows/RegQueryParserTest.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,17 @@ public void testRegQueryParser2() throws Exception {
2626
String folderPath = new RegQueryParser(output).getValueOfKey();
2727
assertEquals("C:\\Users\\username\\AppData\\Local", folderPath);
2828
}
29+
30+
@Test
31+
public void testRegQueryParserXP() throws Exception {
32+
String output = "! REG.EXE VERSION 3.0\n" +
33+
"\n" +
34+
"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\n" +
35+
"\n" +
36+
"\tLocal AppData REG_SZ C:\\Documents and Settings\\username\\My Documents";
37+
38+
String folderPath = new RegQueryParser(output).getValueOfKey();
39+
assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath);
40+
}
41+
2942
}

‎arduino-core/src/processing/app/windows/RegQueryParser.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ public RegQueryParser(String regQueryOutput) {
1515
}
1616

1717
private void parse(String regQueryOutput) {
18-
List<String> rows = Arrays.asList(regQueryOutput.replace("\r", "\n").replace("\n\n", "\n").split("\n"));
18+
List<String> rows = Arrays.asList(regQueryOutput.replace(" ", "\t").replace("\r", "\n").replace("\n\n", "\n").split("\n"));
1919

2020
String row = Iterables.find(rows, new Predicate<String>() {
2121
@Override
2222
public boolean apply(String input) {
23-
return input.startsWith("");
23+
return input.startsWith("\t");
2424
}
2525
});
2626

27-
String[] cols = row.split("");
27+
String[] cols = row.split("\t");
2828
assert cols.length == 4;
2929
this.valueOfKey = cols[3];
3030
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /