Skip to content

Commit

Permalink
Fixed issue #1023.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Mar 15, 2024
1 parent 363b264 commit 432e319
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public static String fix(int lineNumber, String sort, String line, String text,
case 1: // Duplicated line
text = QuickFixer.setLine(lineNumber + 1, "<rm>", text); //$NON-NLS-1$
break;
case 5: // Contains slash
{
text = QuickFixer.setLine(lineNumber + 1,line.replace('/', '\\'), text);
}
break;
case 10, 11, 12: // INVERTNEXT (Flat subfile)
{
text = QuickFixer.setLine(lineNumber + 1, "<rm>", text); //$NON-NLS-1$
Expand Down
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/i18n/DatParser.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ MULTIPLE_BFC = Multiple occurrences of BFC CERTIFY
NEAR_COPLANARITY = Quadrilateral near coplanarity
RECURSIVE = Recursive File Reference
SINGULAR_MATRIX = Singular matrix
SLASH = Invalid use of '/'. Needs to be replaced by a backslash.
SPLIT_BFC = The additional BFC statement is split apart
SPLIT_COMMMENT = The user comment is split apart
SPLIT_HELP = The help information is split apart
Expand Down
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ private static void adjust() { // Calculate line offset
public static final String DATPARSER_NEAR_COPLANARITY = DATPARSER.getString(getProperty());
public static final String DATPARSER_RECURSIVE = DATPARSER.getString(getProperty());
public static final String DATPARSER_SINGULAR_MATRIX = DATPARSER.getString(getProperty());
public static final String DATPARSER_SLASH = DATPARSER.getString(getProperty());
public static final String DATPARSER_SPLIT_BFC = DATPARSER.getString(getProperty());
public static final String DATPARSER_SPLIT_COMMMENT = DATPARSER.getString(getProperty());
public static final String DATPARSER_SPLIT_HELP = DATPARSER.getString(getProperty());
Expand Down
4 changes: 4 additions & 0 deletions src/org/nschmidt/ldparteditor/text/DatParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ private static List<ParsingResult> parseReference(String[] dataSegments, int dep
sb.append(dataSegments[dataSegments.length - 1]);
String shortFilename = sb.toString();
boolean isLowercase = shortFilename.equals(shortFilename.toLowerCase(Locale.ENGLISH));
boolean containsSlash = shortFilename.chars().anyMatch(c -> c == '/');
if (containsSlash) {
result.add(new ParsingResult(I18n.DATPARSER_SLASH, "[E05] " + I18n.DATPARSER_SYNTAX_ERROR, ResultType.ERROR)); //$NON-NLS-1$
}
shortFilename = shortFilename.toLowerCase(Locale.ENGLISH);
shortFilename = shortFilename.replace("s\\", "S" + File.separator).replace("\\", File.separator); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (alreadyParsed.contains(shortFilename)) {
Expand Down
3 changes: 2 additions & 1 deletion src/org/nschmidt/ldparteditor/text/SyntaxFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ private void formatReference(List<StyleRange> styles, LineStyleEvent e, String[]
sb.append(dataSegments[dataSegments.length - 1]);
String shortFilename = sb.toString();
boolean isLowercase = shortFilename.equals(shortFilename.toLowerCase(Locale.ENGLISH));
boolean containsSlash = shortFilename.chars().anyMatch(c -> c == '/');
shortFilename = shortFilename.toLowerCase(Locale.ENGLISH);
shortFilename = shortFilename.replace("s\\", "S" + File.separator).replace("\\", File.separator); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String shortFilename2 = shortFilename.startsWith("S" + File.separator) ? "s" + shortFilename.substring(1) : shortFilename; //$NON-NLS-1$ //$NON-NLS-2$
Expand Down Expand Up @@ -718,7 +719,7 @@ private void formatReference(List<StyleRange> styles, LineStyleEvent e, String[]
}
}
// [WARNING] Check spaces in dat file name
if (!fileExists || dataSegments.length > 15 || !isLowercase) {
if (!fileExists || dataSegments.length > 15 || !isLowercase || containsSlash) {
for (int s = 15; s < styles.size(); s++) {
setWarningStyle(styles.get(s));
}
Expand Down

0 comments on commit 432e319

Please sign in to comment.