Skip to content

Commit 2e9f676

Browse files
committed
File.separator vs File.pathSeparator
1 parent 82f9c4b commit 2e9f676

6 files changed

Lines changed: 13 additions & 21 deletions

File tree

src/g2html/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static void load(String[] args) {
7171

7272
// returns the input dot file for a given C file, and function
7373
public static File getFunDotFile(String path, String fun) {
74-
path = path.replaceAll(File.pathSeparator,"%2F");
74+
path = path.replaceAll(File.separator,"%2F");
7575
File f = new File(new File(new File(conf.getCfgDir()), path), fun + ".dot");
7676
return f;
7777
}

src/g2html/Loc.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ static public void parseLocNode(XMLStreamReader parser, Result res, ResultStats
1717
String id = parser.getAttributeValue("", "id");
1818

1919
// compute the file-id from the full path
20-
String shortFile = null;
21-
try {
22-
shortFile = URLEncoder.encode(file, "UTF-8");
23-
} catch (UnsupportedEncodingException e) {
24-
e.printStackTrace();
25-
System.exit(255);
26-
}
20+
String shortFile = file.replaceAll(File.separator,"%2F");
2721

2822
// look up the database for the file
2923
FileStats fileStats = resultStats.getStats(shortFile);

src/g2html/Result.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ private static void copyFromJar(String f,File t) throws IOException{
6464
}
6565
} finally {
6666
stream.close();
67-
resStreamOut.close();
67+
if (resStreamOut != null) {
68+
resStreamOut.close();
69+
}
6870
}
6971
}
7072

@@ -100,8 +102,9 @@ public Result(String resDir) throws IOException {
100102
}
101103

102104
// return a listing file to be created
103-
public File getListingFile(String file) {
104-
File f = new File(filDir, file+".xml");
105+
public File getListingFile(String path) {
106+
path = path.replaceAll(File.separator,"%2F");
107+
File f = new File(filDir, path+".xml");
105108
return f;
106109
}
107110

src/g2html/ResultStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void printReport(Result r)
5757
continue;
5858
// write the file-name
5959
report.writeStartElement("file");
60-
report.writeAttribute("name", URLDecoder.decode(file,"UTF-8"));
60+
report.writeAttribute("name", file.replaceAll("%2F",File.separator));
6161

6262
// for each function
6363
for (String fun : fm.get(file).getFunctions()){

src/g2html/Structure.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javax.xml.stream.XMLStreamConstants;
44
import javax.xml.stream.XMLStreamException;
55
import javax.xml.stream.XMLStreamReader;
6+
import java.io.File;
67
import java.io.UnsupportedEncodingException;
78
import java.net.URLEncoder;
89

@@ -12,13 +13,7 @@ public static void parseFileNode(XMLStreamReader parser, ResultStats resultStats
1213
throws XMLStreamException {
1314

1415
// get basic information
15-
String name = null;
16-
try {
17-
name = URLEncoder.encode(parser.getAttributeValue("", "path"), "UTF-8");
18-
} catch (UnsupportedEncodingException e) {
19-
e.printStackTrace();
20-
System.exit(255);
21-
}
16+
String name = parser.getAttributeValue("", "path").replaceAll(File.separator,"%2F");;
2217
String fun = "";
2318

2419
// parse the file and

src/g2html/Warning.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ static public void parseWarningNode(XMLStreamReader parser, Result res, ResultSt
4141
// for each text element, store the id of the warning with the text location
4242
if (readcc.getEventType()== XMLStreamConstants.START_ELEMENT &&
4343
readcc.getLocalName()=="text"){
44-
String file = readcc.getAttributeValue("","file");
44+
String path = readcc.getAttributeValue("","file");
4545
String line = readcc.getAttributeValue("","line");
46-
String shortFile = new File(file).getName();
46+
String shortFile = path.replaceAll(File.separator,"%2F");;
4747

4848
resultStats.getStats(shortFile).addWarning(id,Integer.valueOf(line));
4949
}

0 commit comments

Comments
 (0)