From 467241bf92738af707ffc1749e539625ddcc1534 Mon Sep 17 00:00:00 2001 From: a-krawciw Date: Thu, 23 Sep 2021 22:15:07 -0700 Subject: [PATCH 1/2] Change the output of a file to match the natural file structure. In reference to plantuml/plantuml#672 --- src/net/sourceforge/plantuml/Run.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index a599864b6..3b935a0c1 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -477,7 +477,7 @@ public class Run { } final ISourceFileReader sourceFileReader; if (option.getOutputFile() == null) { - File outputDir = option.getOutputDir(); + File outputDir = option.getOutputDir().getAbsoluteFile(); if (outputDir != null && outputDir.getPath().endsWith("$")) { final String path = outputDir.getPath(); outputDir = new File(path.substring(0, path.length() - 1)).getAbsoluteFile(); @@ -490,6 +490,7 @@ public class Run { } else { sourceFileReader = new SourceFileReaderHardFile(option.getDefaultDefines(f), f, option.getOutputFile(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); + System.out.println(option.getOutputFile().getAbsolutePath()); } sourceFileReader.setCheckMetadata(option.isCheckMetadata()); ((SourceFileReaderAbstract) sourceFileReader).setNoerror(option.isNoerror()); From b49d7db1e90162ba55e8921a7ce6ccf7d7faeb92 Mon Sep 17 00:00:00 2001 From: a-krawciw Date: Wed, 3 Nov 2021 15:49:53 -0700 Subject: [PATCH 2/2] Prevent index out of bound for 0 line ditaa files. References plantuml/plantuml#530 --- src/net/sourceforge/plantuml/Run.java | 3 +-- .../stathissideris/ascii2image/text/TextGrid.java | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 10a5da484..ff32156ec 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -477,7 +477,7 @@ public class Run { } final ISourceFileReader sourceFileReader; if (option.getOutputFile() == null) { - File outputDir = option.getOutputDir().getAbsoluteFile(); + File outputDir = option.getOutputDir(); if (outputDir != null && outputDir.getPath().endsWith("$")) { final String path = outputDir.getPath(); outputDir = new File(path.substring(0, path.length() - 1)).getAbsoluteFile(); @@ -490,7 +490,6 @@ public class Run { } else { sourceFileReader = new SourceFileReaderHardFile(option.getDefaultDefines(f), f, option.getOutputFile(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); - System.out.println(option.getOutputFile().getAbsolutePath()); } sourceFileReader.setCheckMetadata(option.isCheckMetadata()); ((SourceFileReaderAbstract) sourceFileReader).setNoerror(option.isNoerror()); diff --git a/src/org/stathissideris/ascii2image/text/TextGrid.java b/src/org/stathissideris/ascii2image/text/TextGrid.java index 4567cb374..d953d1803 100644 --- a/src/org/stathissideris/ascii2image/text/TextGrid.java +++ b/src/org/stathissideris/ascii2image/text/TextGrid.java @@ -1507,16 +1507,16 @@ public class TextGrid { public boolean initialiseWithLines(ArrayList lines, ProcessingOptions options) throws UnsupportedEncodingException { //remove blank rows at the bottom - boolean done = false; - int i; - for(i = lines.size() - 1; !done; i--){ - StringBuffer row = lines.get(i); - if(!StringUtils.isBlank(row.toString())) done = true; + + rows = new ArrayList<>(); + + for (StringBuffer row:lines) { + if(!StringUtils.isBlank(row.toString())) + rows.add(row); } - rows = new ArrayList(lines.subList(0, i + 2)); if(options != null) fixTabs(options.getTabSize()); - else fixTabs(options.DEFAULT_TAB_SIZE); + else fixTabs(ProcessingOptions.DEFAULT_TAB_SIZE); // make all lines of equal length