From c5ce75b9eea8ebb2746b13eeb0f335813c615115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Tue, 8 Aug 2023 20:06:44 +0200 Subject: [PATCH] Remove useless space after list "[" first item --- Makefile | 4 ++-- src/uPDFTypes.cpp | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2573647..ddcb12b 100644 --- a/Makefile +++ b/Makefile @@ -41,10 +41,10 @@ $(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) $(CXX) $(CXXFLAGS) -c $^ -o $@ libupdfparser.a: $(OBJECTS) - $(AR) crs $@ obj/*.o + $(AR) crs $@ $^ libupdfparser.so: $(OBJECTS) - $(CXX) obj/*.o $(LDFLAGS) -o $@ -shared + $(CXX) $^ $(LDFLAGS) -o $@ -shared test: tests/test.cpp libupdfparser.a g++ -ggdb -O0 $^ -o $@ -Iinclude libupdfparser.a diff --git a/src/uPDFTypes.cpp b/src/uPDFTypes.cpp index a025f58..1da17cd 100644 --- a/src/uPDFTypes.cpp +++ b/src/uPDFTypes.cpp @@ -73,13 +73,28 @@ namespace uPDFParser for(it = _value.begin(); it!=_value.end(); it++) { - if (res.size() > 1 && - (*it)->type() != DataType::TYPE::INTEGER && - (*it)->type() != DataType::TYPE::REAL) - res += " "; - res += (*it)->str(); + /* These types has already a space in front */ + if ((*it)->type() != DataType::TYPE::INTEGER && + (*it)->type() != DataType::TYPE::REAL && + (*it)->type() != DataType::TYPE::REFERENCE) + { + if (res.size() > 1) + res += " "; + res += (*it)->str(); + } + else + { + if (res.size() > 1) + res += (*it)->str(); + /* First time, remove front space*/ + else + res += (*it)->str().substr(1); + } } - + + if (res.size() == 1) + res += " "; + return res + "]"; }