Commit 5e3e46ec authored by Albert Astals Cid's avatar Albert Astals Cid

Enable modernize-loop-convert

parent f6071f61
Pipeline #84830 failed with stages
in 2 minutes and 10 seconds
......@@ -40,7 +40,7 @@ build_clang_libcpp:
script:
- git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data
- mkdir -p build && cd build
- CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-use-bool-literals,modernize-redundant-void-arg,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation;-warnings-as-errors=*" ..
- CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-use-bool-literals,modernize-redundant-void-arg,modernize-loop-convert,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation;-warnings-as-errors=*" ..
- ninja
- ctest --output-on-failure
......
/*
* Copyright (C) 2009-2010, Pino Toscano <pino@kde.org>
* Copyright (C) 2017, 2018, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2017-2019, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2017, Jason Alan Palmer <jalanpalmer@gmail.com>
* Copyright (C) 2018, Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
* Copyright (C) 2019, Masamichi Hosoda <trueroad@trueroad.jp>
......@@ -426,9 +426,9 @@ static void print_page_text_list(poppler::page *p)
auto text_list = p->text_list();
std::cout << "---" << std::endl;
for (size_t i = 0; i < text_list.size(); i ++) {
poppler::rectf bbox = text_list[i].bbox();
poppler::ustring ustr = text_list[i].text();
for (const poppler::text_box &text : text_list) {
poppler::rectf bbox = text.bbox();
poppler::ustring ustr = text.text();
std::cout << "[" << ustr << "] @ ";
std::cout << "( x=" << bbox.x() << " y=" << bbox.y() << " w=" << bbox.width() << " h=" << bbox.height() << " )";
std::cout << std::endl;
......
/*
* Copyright (C) 2010, Pino Toscano <pino@kde.org>
* Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2017, 2019, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -65,8 +65,8 @@ int main(int argc, char *argv[])
if (show_formats) {
const std::vector<std::string> formats = poppler::image::supported_image_formats();
std::cout << "Supported image formats:" << std::endl;
for (size_t i = 0; i < formats.size(); ++i) {
std::cout << " " << formats[i] << std::endl;
for (const std::string &format : formats) {
std::cout << " " << format << std::endl;
}
exit(0);
}
......
......@@ -588,8 +588,7 @@ build_ocg_state (PopplerDocument *document,
return;
}
for (std::size_t i = 0; i < st_list->size(); ++i) {
LinkOCGState::StateList *list = (*st_list)[i];
for (const LinkOCGState::StateList *list : *st_list) {
PopplerActionLayer *action_layer = g_slice_new0 (PopplerActionLayer);
switch (list->st) {
......@@ -604,8 +603,7 @@ build_ocg_state (PopplerDocument *document,
break;
}
for (std::size_t j = 0; j < list->list->size(); ++j) {
Ref *ref = (*list->list)[j];
for (Ref *ref : (*list->list)) {
PopplerLayer *layer = get_layer_for_ref (document, document->layers, ref, preserve_rb);
action_layer->layers = g_list_prepend (action_layer->layers, layer);
......
......@@ -88,10 +88,10 @@ int PopplerCachedFileLoader::load(const std::vector<ByteRange> &ranges, CachedFi
return 0;
size = 0;
for (size_t i = 0; i < ranges.size(); i++) {
bytesToRead = MIN(CachedFileChunkSize, ranges[i].length);
for (const ByteRange &range : ranges) {
bytesToRead = MIN(CachedFileChunkSize, range.length);
rangeBytesRead = 0;
g_seekable_seek(G_SEEKABLE(inputStream), ranges[i].offset, G_SEEK_SET, cancellable, nullptr);
g_seekable_seek(G_SEEKABLE(inputStream), range.offset, G_SEEK_SET, cancellable, nullptr);
do {
bytesRead = g_input_stream_read(inputStream, buf, bytesToRead, cancellable, nullptr);
if (bytesRead == -1)
......@@ -100,7 +100,7 @@ int PopplerCachedFileLoader::load(const std::vector<ByteRange> &ranges, CachedFi
writer->write(buf, bytesRead);
size += bytesRead;
rangeBytesRead += bytesRead;
bytesToRead = ranges[i].length - rangeBytesRead;
bytesToRead = range.length - rangeBytesRead;
} while (bytesRead > 0 && bytesToRead > 0);
}
......
......@@ -693,8 +693,7 @@ poppler_page_get_selection_region (PopplerPage *page,
std::vector<PDFRectangle*>* list = text->getSelectionRegion(&poppler_selection,
selection_style, scale);
for (std::size_t i = 0; i < list->size(); i++) {
PDFRectangle *selection_rect = (*list)[i];
for (const PDFRectangle *selection_rect : *list) {
PopplerRectangle *rect;
rect = poppler_rectangle_new ();
......@@ -782,8 +781,7 @@ poppler_page_get_selected_region (PopplerPage *page,
region = cairo_region_create ();
for (std::size_t i = 0; i < list->size(); i++) {
PDFRectangle *selection_rect = (*list)[i];
for (const PDFRectangle *selection_rect : *list) {
cairo_rectangle_int_t rect;
rect.x = (gint) ((selection_rect->x1 * scale) + 0.5);
......@@ -2217,9 +2215,8 @@ poppler_page_get_text_layout_for_area (PopplerPage *page,
{
std::vector<TextWordSelection*> *line_words = word_list[i];
n_rects += line_words->size() - 1;
for (std::size_t j = 0; j < line_words->size(); j++)
for (const TextWordSelection *word_sel : *line_words)
{
TextWordSelection *word_sel = (*line_words)[j];
n_rects += word_sel->getEnd() - word_sel->getBegin();
}
}
......
......@@ -1152,8 +1152,8 @@ poppler_structure_element_get_text_spans (PopplerStructureElement *poppler_struc
PopplerTextSpan **text_spans = g_new0 (PopplerTextSpan*, spans.size ());
size_t i = 0;
for (TextSpanArray::const_iterator s = spans.begin (); s != spans.end (); ++s)
text_spans[i++] = text_span_poppler_text_span (*s);
for (const TextSpan &s : spans)
text_spans[i++] = text_span_poppler_text_span (s);
*n_text_spans = spans.size ();
......
......@@ -4230,8 +4230,8 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
// write the DA string
if (daToks) {
for (int i = 0; i < (int)daToks->size(); ++i) {
appearBuf->append((*daToks)[i])->append(' ');
for (const GooString *daTok : *daToks) {
appearBuf->append(daTok)->append(' ');
}
}
......@@ -4421,8 +4421,8 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
// write the DA string
if (daToks) {
for (std::size_t i = 0; i < daToks->size(); ++i) {
appearBuf->append((*daToks)[i])->append(' ');
for (const GooString *daTok : *daToks) {
appearBuf->append(daTok)->append(' ');
}
}
......@@ -4610,8 +4610,8 @@ bool AnnotAppearanceBuilder::drawListBox(const FormFieldChoice *fieldChoice, con
// write the DA string
if (daToks) {
for (std::size_t k = 0; k < daToks->size(); ++k) {
appearBuf->append((*daToks)[k])->append(' ');
for (const GooString *daTok : *daToks) {
appearBuf->append(daTok)->append(' ');
}
}
......
......@@ -96,13 +96,13 @@ int CachedFile::cache(const std::vector<ByteRange> &origRanges)
for (int i = 0; i < numChunks; ++i)
chunkNeeded[i] = false;
for (size_t i = 0; i < ranges->size(); i++) {
for (const ByteRange &r : *ranges) {
if ((*ranges)[i].length == 0) continue;
if ((*ranges)[i].offset >= length) continue;
if (r.length == 0) continue;
if (r.offset >= length) continue;
size_t start = (*ranges)[i].offset;
size_t end = start + (*ranges)[i].length - 1;
const size_t start = r.offset;
size_t end = start + r.length - 1;
if (end >= length) end = length - 1;
startChunk = start / CachedFileChunkSize;
......
......@@ -278,8 +278,8 @@ bool Catalog::cachePageTree(int page)
}
bool loop = false;;
for (size_t i = 0; i < pagesRefList->size(); i++) {
if (((*pagesRefList)[i]).num == kidRef.getRefNum()) {
for (const Ref &pageRef : *pagesRefList) {
if (pageRef.num == kidRef.getRefNum()) {
loop = true;
break;
}
......
......@@ -6,7 +6,7 @@
//
// Copyright 2009 Stefan Thomas <thomas@eload24.com>
// Copyright 2010, 2011 Hib Eris <hib@hiberis.nl>
// Copyright 2010 Albert Astals Cid <aacid@kde.org>
// Copyright 2010, 2019 Albert Astals Cid <aacid@kde.org>
//
//========================================================================
......@@ -75,10 +75,10 @@ int CurlCachedFileLoader::load(const std::vector<ByteRange> &ranges, CachedFileW
{
CURLcode r = CURLE_OK;
size_t fromByte, toByte;
for (size_t i = 0; i < ranges.size(); i++) {
for (const ByteRange &bRange : ranges) {
fromByte = ranges[i].offset;
toByte = fromByte + ranges[i].length - 1;
fromByte = bRange.offset;
toByte = fromByte + bRange.length - 1;
GooString *range = GooString::format("{0:ud}-{1:ud}", fromByte, toByte);
curl_easy_setopt(curl, CURLOPT_URL, url->c_str());
......
......@@ -1325,8 +1325,8 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
//----- get the character widths -----
// initialize all widths
for (int code = 0; code < 256; ++code) {
widths[code] = missingWidth * 0.001;
for (double &width : widths) {
width = missingWidth * 0.001;
}
// use widths from font dict, if present
......
......@@ -2916,8 +2916,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
auto sepsCSA = new std::vector<GfxSeparationColorSpace*>();
sepsCSA->reserve(sepsCS->size());
for (std::size_t i = 0; i < sepsCS->size(); i++) {
GfxSeparationColorSpace *scs = (*sepsCS)[i];
for (GfxSeparationColorSpace *scs : *sepsCS) {
if (likely(scs != nullptr)) {
sepsCSA->push_back((GfxSeparationColorSpace*)scs->copy());
}
......@@ -3105,8 +3104,7 @@ void GfxDeviceNColorSpace::createMapping(std::vector<GfxSeparationColorSpace*> *
if (nComps == 1)
sepFunc = func;
else {
for (std::size_t k = 0; k < sepsCS->size(); k++) {
GfxSeparationColorSpace *sepCS = (*sepsCS)[k];
for (GfxSeparationColorSpace *sepCS : *sepsCS) {
if (!sepCS->getName()->cmp(names[i])) {
sepFunc = sepCS->getFunc();
break;
......@@ -3145,8 +3143,7 @@ void GfxDeviceNColorSpace::createMapping(std::vector<GfxSeparationColorSpace*> *
if (nComps == 1)
separationList->push_back(new GfxSeparationColorSpace(new GooString(names[i]),alt->copy(), func->copy()));
else {
for (std::size_t k = 0; k < sepsCS->size(); k++) {
GfxSeparationColorSpace *sepCS = (*sepsCS)[k];
for (GfxSeparationColorSpace *sepCS : *sepsCS) {
if (!sepCS->getName()->cmp(names[i])) {
found = true;
separationList->push_back((GfxSeparationColorSpace*)sepCS->copy());
......
......@@ -263,7 +263,6 @@ SysFontList::~SysFontList() {
SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exact) {
GooString *name2;
bool bold, italic, oblique;
SysFontInfo *fi;
int n;
name2 = name->copy();
......@@ -340,9 +339,9 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
}
// search for the font
fi = nullptr;
for (std::size_t i = 0; i < fonts->size(); ++i) {
fi = (*fonts)[i];
SysFontInfo *fi = nullptr;
for (SysFontInfo *f : *fonts) {
fi = f;
if (fi->match(name2, bold, italic, oblique, fixedWidth)) {
break;
}
......@@ -350,8 +349,8 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
}
if (!fi && !exact && bold) {
// try ignoring the bold flag
for (std::size_t i = 0; i < fonts->size(); ++i) {
fi = (*fonts)[i];
for (SysFontInfo *f : *fonts) {
fi = f;
if (fi->match(name2, false, italic)) {
break;
}
......@@ -360,8 +359,8 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
}
if (!fi && !exact && (bold || italic)) {
// try ignoring the bold and italic flags
for (std::size_t i = 0; i < fonts->size(); ++i) {
fi = (*fonts)[i];
for (SysFontInfo *f : *fonts) {
fi = f;
if (fi->match(name2, false, false)) {
break;
}
......@@ -635,12 +634,11 @@ FILE *GlobalParams::findCMapFile(const GooString *collection, const GooString *c
}
FILE *GlobalParams::findToUnicodeFile(const GooString *name) {
GooString *dir, *fileName;
GooString *fileName;
FILE *f;
globalParamsLocker();
for (std::size_t i = 0; i < toUnicodeDirs->size(); ++i) {
dir = (*toUnicodeDirs)[i];
for (GooString *dir : *toUnicodeDirs) {
fileName = appendToPath(dir->copy(), name->c_str());
f = openFile(fileName->c_str(), "r");
delete fileName;
......
......@@ -4194,16 +4194,12 @@ void JBIG2Stream::readExtensionSeg(unsigned int length) {
}
JBIG2Segment *JBIG2Stream::findSegment(unsigned int segNum) {
JBIG2Segment *seg;
for (std::size_t i = 0; i < globalSegments->size(); ++i) {
seg = (*globalSegments)[i];
for (JBIG2Segment *seg : *globalSegments) {
if (seg->getSegNum() == segNum) {
return seg;
}
}
for (std::size_t i = 0; i < segments->size(); ++i) {
seg = (*segments)[i];
for (JBIG2Segment *seg : *segments) {
if (seg->getSegNum() == segNum) {
return seg;
}
......
......@@ -1326,8 +1326,7 @@ void PSOutputDev::postInit()
}
paperSizes = new std::vector<PSOutPaperSize*>();
for (size_t pgi = 0; pgi < pages.size(); ++pgi) {
const int pg = pages[pgi];
for (const int pg : pages) {
Page *page = catalog->getPage(pg);
if (page == nullptr)
paperMatch = false;
......@@ -1673,8 +1672,7 @@ void PSOutputDev::writeDocSetup(Catalog *catalog,
} else {
writePS("xpdf begin\n");
}
for (size_t pgi = 0; pgi < pageList.size(); ++pgi) {
const int pg = pageList[pgi];
for (const int pg : pageList) {
page = doc->getPage(pg);
if (!page) {
error(errSyntaxError, -1, "Failed writing resources for page {0:d}", pg);
......
......@@ -1418,8 +1418,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
color[0] = color[1] = color[2] = color[3] = 0;
break;
case splashModeDeviceN8:
for (int i = 0; i < 4 + SPOT_NCOMPS; i++)
color[i] = 0;
splashClearColor(color);
break;
}
splash->setStrokePattern(new SplashSolidColor(color));
......
......@@ -829,8 +829,8 @@ StructElement::StructData::~StructData()
delete id;
delete title;
delete language;
for (ElemPtrArray::iterator i = elements.begin(); i != elements.end(); ++i) delete *i;
for (AttrPtrArray::iterator i = attributes.begin(); i != attributes.end(); ++i) delete *i;
for (StructElement *element : elements) delete element;
for (Attribute *attribute : attributes) delete attribute;
}
......@@ -975,8 +975,8 @@ GooString* StructElement::appendSubTreeText(GooString *string, bool recursive) c
if (!string)
string = new GooString();
for (TextSpanArray::const_iterator i = spans.begin(); i != spans.end(); ++i)
string->append(i->getText());
for (const TextSpan &span : spans)
string->append(span.getText());
return string;
}
......
......@@ -33,8 +33,8 @@ StructTreeRoot::StructTreeRoot(PDFDoc *docA, Dict *structTreeRootDict):
StructTreeRoot::~StructTreeRoot()
{
for (ElemPtrArray::iterator i = elements.begin(); i != elements.end(); ++i)
delete *i;
for (StructElement *element : elements)
delete element;
}
void StructTreeRoot::parse(Dict *root)
......
......@@ -2506,8 +2506,8 @@ void TextPage::updateFont(const GfxState *state) {
// get the font info object
curFont = nullptr;
for (std::size_t i = 0; i < fonts->size(); ++i) {
curFont = (*fonts)[i];
for (TextFontInfo *f : *fonts) {
curFont = f;
if (curFont->matches(state)) {
break;
}
......@@ -2824,8 +2824,6 @@ void TextPage::coalesce(bool physLayout, double fixedPitch, bool doHTML) {
TextLine *line;
TextBlock *blkList, *blk, *lastBlk, *blk0, *blk1, *blk2;
TextFlow *flow, *lastFlow;
TextUnderline *underline;
TextLink *link;
int rot, poolMinBaseIdx, baseIdx, startBaseIdx, endBaseIdx;
double minBase, maxBase, newMinBase, newMaxBase;
double fontSize, colSpace1, colSpace2, lineSpace, intraLineSpace, blkSpace;
......@@ -2878,8 +2876,7 @@ void TextPage::coalesce(bool physLayout, double fixedPitch, bool doHTML) {
if (doHTML) {
//----- handle underlining
for (std::size_t i = 0; i < underlines->size(); ++i) {
underline = (*underlines)[i];
for (const TextUnderline *underline : *underlines) {
if (underline->horiz) {
// rot = 0
if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) {
......@@ -2941,9 +2938,7 @@ void TextPage::coalesce(bool physLayout, double fixedPitch, bool doHTML) {
}
//----- handle links
for (std::size_t i = 0; i < links->size(); ++i) {
link = (*links)[i];
for (const TextLink *link : *links) {
// rot = 0
if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) {
startBaseIdx = pools[0]->getBaseIdx(link->yMin);
......@@ -4786,8 +4781,7 @@ void TextSelectionPainter::endPage()
state->setFillColor(glyph_color);
out->updateFillColor(state);
for (std::size_t i = 0; i < selectionList->size(); i++) {
TextWordSelection *sel = (*selectionList)[i];
for (const TextWordSelection *sel : *selectionList) {
int begin = sel->begin;
while (begin < sel->end) {
......
......@@ -1518,8 +1518,8 @@ void XRef::readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum)
std::vector<Goffset> followedPrev;
while (prevXRefOffset && (untilEntryNum == -1 || (untilEntryNum < size && entries[untilEntryNum].type == xrefEntryNone))) {
bool followed = false;
for (size_t j = 0; j < followedPrev.size(); j++) {
if (followedPrev.at(j) == prevXRefOffset) {
for (long long j : followedPrev) {
if (j == prevXRefOffset) {
followed = true;
break;
}
......@@ -1682,8 +1682,7 @@ void XRef::scanSpecialFlags() {
}
// Mark XRef streams objects as Unencrypted and DontRewrite
for (size_t i = 0; i < xrefStreamObjNums.size(); ++i) {
const int objNum = xrefStreamObjNums.at(i);
for (const int objNum : xrefStreamObjNums) {
getEntry(objNum)->setFlag(XRefEntry::Unencrypted, true);
getEntry(objNum)->setFlag(XRefEntry::DontRewrite, true);
}
......
......@@ -39,6 +39,9 @@
namespace Poppler
{
// TODO use qAsConst when we can depend on Qt 5.7
// or std::as_const when we can depend on C++17
template <class T> constexpr std::add_const_t<T>& as_const(T& t) noexcept { return t; }
RadioButtonGroup::RadioButtonGroup( OptContentModelPrivate *ocModel, Array *rbarray )
{
......@@ -51,8 +54,7 @@ namespace Poppler
OptContentItem *item = ocModel->itemFromRef( QString::number(ref.getRefNum() ) );
itemsInGroup.append( item );
}
for (int i = 0; i < itemsInGroup.size(); ++i) {
OptContentItem *item = itemsInGroup.at(i);
for (OptContentItem *item : as_const(itemsInGroup)) {
item->appendRBGroup( this );
}
}
......@@ -64,8 +66,7 @@ namespace Poppler
QSet<OptContentItem *> RadioButtonGroup::setItemOn( OptContentItem *itemToSetOn )
{
QSet<OptContentItem *> changedItems;
for (int i = 0; i < itemsInGroup.size(); ++i) {
OptContentItem *thisItem = itemsInGroup.at(i);
for (OptContentItem *thisItem : as_const(itemsInGroup)) {
if (thisItem != itemToSetOn) {
QSet<OptContentItem *> newChangedItems;
thisItem->setState(OptContentItem::Off, false /*obeyRadioGroups*/, newChangedItems);
......@@ -137,8 +138,7 @@ namespace Poppler
if ( state == OptContentItem::On ) {
m_group->setState( OptionalContentGroup::On );
if (obeyRadioGroups) {
for (int i = 0; i < m_rbGroups.size(); ++i) {
RadioButtonGroup *rbgroup = m_rbGroups.at(i);
for (RadioButtonGroup *rbgroup : as_const(m_rbGroups)) {
changedItems += rbgroup->setItemOn( this );
}
}
......@@ -402,12 +402,9 @@ namespace Poppler
QSet<OptContentItem *> changedItems;
const std::vector<::LinkOCGState::StateList*> *statesList = popplerLinkOCGState->getStateList();
for (std::size_t i = 0; i < statesList->size(); ++i) {
::LinkOCGState::StateList *stateList = (*statesList)[i];
std::vector<Ref*> *refsList = stateList->list;
for (std::size_t j = 0; j < refsList->size(); ++j) {
Ref *ref = (*refsList)[j];
for (const ::LinkOCGState::StateList *stateList : *statesList) {
const std::vector<Ref*> *refsList = stateList->list;
for (const Ref *ref : *refsList) {
OptContentItem *item = d->itemFromRef(QString::number(ref->num));
if (stateList->st == ::LinkOCGState::On) {
......
......@@ -364,9 +364,9 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
if ( nextActions )
{
QVector<Link *> links;
for ( std::size_t i = 0; i < nextActions->size(); ++i )
for ( ::LinkAction *nextAction : *nextActions )
{
links << convertLinkActionToLink( (*nextActions)[ i ], parentDoc, linkArea );
links << convertLinkActionToLink( nextAction, parentDoc, linkArea );
}
LinkPrivate::get(popplerLink)->nextLinks = links;
}
......
......@@ -274,10 +274,9 @@ namespace Debug {
void DocumentData::addTocChildren( QDomDocument * docSyn, QDomNode * parent, const std::vector<::OutlineItem*> * items )
{
for ( std::size_t i = 0; i < items->size(); ++i )
for ( ::OutlineItem * outlineItem : *items )
{
// iterate over every object in 'items'
::OutlineItem * outlineItem = (*items)[ i ];
// 1. create element using outlineItem's title as tagName
QString name;
......
......@@ -4520,8 +4520,8 @@ void Splash::scaleImageYdXu(SplashImageSource src, void *srcData,
break;
case splashModeDeviceN8:
for (i = 0; i < xStep; ++i) {
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
for (unsigned int cp : pix)
*destPtr++ = (unsigned char)cp;
}
break;
}
......@@ -4672,8 +4672,8 @@ void Splash::scaleImageYuXd(SplashImageSource src, void *srcData,
case splashModeDeviceN8:
for (i = 0; i < yStep; ++i) {
destPtr = destPtr0 + (i * scaledWidth + x) * nComps;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
for (unsigned int cp : pix)
*destPtr++ = (unsigned char)cp;
}
break;
}
......@@ -4826,8 +4826,8 @@ void Splash::scaleImageYuXu(SplashImageSource src, void *srcData,
for (i = 0; i < yStep; ++i) {
for (j = 0; j < xStep; ++j) {
destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
for (unsigned int cp : pix)
*destPtr++ = (unsigned char)cp;
}
}
break;
......@@ -4977,8 +4977,8 @@ void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[3];
break;
case splashModeDeviceN8:
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
for (unsigned int cp : pix)
*destPtr++ = (unsigned char)cp;
break;
}
......
......@@ -124,8 +124,8 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA,
}
separationList = new std::vector<GfxSeparationColorSpace*>();
if (separationListA != nullptr)
for (std::size_t i = 0; i < separationListA->size(); i++)
separationList->push_back((GfxSeparationColorSpace*)( (*separationListA)[i])->copy());
for (GfxSeparationColorSpace *separation : *separationListA)
separationList->push_back((GfxSeparationColorSpace*)separation->copy());
}
SplashBitmap *SplashBitmap::copy(SplashBitmap *src) {
......
......@@ -13,6 +13,7 @@
//
// Copyright (C) 2009, 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2019 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -81,8 +82,9 @@ SplashState::SplashState(int width, int height, bool vectorAntialias,
cmykTransferM[i] = (unsigned char)i;
cmykTransferY[i] = (unsigned char)i;
cmykTransferK[i] = (unsigned char)i;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
deviceNTransfer[cp][i] = (unsigned char)i;
for (auto &cp : deviceNTransfer) {
cp[i] = (unsigned char)i;
}
}
overprintMask = 0xffffffff;
overprintAdditive = false;
......@@ -132,8 +134,9 @@ SplashState::SplashState(int width, int height, bool vectorAntialias,
cmykTransferM[i] = (unsigned char)i;
cmykTransferY[i] = (unsigned char)i;
cmykTransferK[i] = (unsigned char)i;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
deviceNTransfer[cp][i] = (unsigned char)i;
for (auto &cp : deviceNTransfer) {
cp[i] = (unsigned char)i;
}
}
overprintMask = 0xffffffff;
overprintAdditive = false;
......
......@@ -1009,7 +1009,7 @@ HtmlMetaVar::~HtmlMetaVar()
delete content;
}
GooString* HtmlMetaVar::toString()
GooString* HtmlMetaVar::toString()
{
GooString *result = new GooString("<meta name=\"");
result->append(name);
......@@ -1659,10 +1659,9 @@ void HtmlOutputDev::dumpMetaVars(FILE *file)
{
GooString *var;
for(std::size_t i = 0; i < glMetaVars->size(); i++)
for(HtmlMetaVar *t : *glMetaVars)
{
HtmlMetaVar *t = (*glMetaVars)[i];
var = t->toString();
var = t->toString();
fprintf(file, "%s\n", var->c_str());
delete var;
}
......@@ -1747,9 +1746,8 @@ bool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, const std::vector<OutlineI
}
fputs("<ul>\n",output);
for (std::size_t i = 0; i < outlines->size(); i++)
for (OutlineItem *item : *outlines)
{
OutlineItem *item = (*outlines)[i];
GooString *titleStr = HtmlFont::HtmlFilter(item->getTitle(),
item->getTitleLength());
......@@ -1806,9 +1804,8 @@ void HtmlOutputDev::newXmlOutlineLevel(FILE *output, const std::vector<OutlineIt
{