Remove useless space after list "[" first item

This commit is contained in:
Grégory Soutadé 2023-08-08 20:06:44 +02:00
parent f5f257685c
commit c5ce75b9ee
2 changed files with 23 additions and 8 deletions

View File

@ -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

View File

@ -73,12 +73,27 @@ namespace uPDFParser
for(it = _value.begin(); it!=_value.end(); it++)
{
if (res.size() > 1 &&
(*it)->type() != DataType::TYPE::INTEGER &&
(*it)->type() != DataType::TYPE::REAL)
/* 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 + "]";
}