Skip to content

Commit 2ace3b0

Browse files
RaphaelAndroid (Google) Code Review
authored andcommitted
Merge "Merge "AAPT fix printf %zd crash on Windows". Do not merge." into ics-mr1
2 parents ed0830c + 7c3bef8 commit 2ace3b0

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

tools/aapt/Resource.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
#include "FileFinder.h"
1515
#include "CacheUpdater.h"
1616

17+
#if HAVE_PRINTF_ZD
18+
# define ZD "%zd"
19+
# define ZD_TYPE ssize_t
20+
#else
21+
# define ZD "%ld"
22+
# define ZD_TYPE long
23+
#endif
24+
1725
#define NOISY(x) // x
1826

1927
// ==========================================================================
@@ -566,11 +574,11 @@ static bool applyFileOverlay(Bundle *bundle,
566574
DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > baseFiles =
567575
baseGroup->getFiles();
568576
for (size_t i=0; i < baseFiles.size(); i++) {
569-
printf("baseFile %zd has flavor %s\n", i,
577+
printf("baseFile " ZD " has flavor %s\n", (ZD_TYPE) i,
570578
baseFiles.keyAt(i).toString().string());
571579
}
572580
for (size_t i=0; i < overlayFiles.size(); i++) {
573-
printf("overlayFile %zd has flavor %s\n", i,
581+
printf("overlayFile " ZD " has flavor %s\n", (ZD_TYPE) i,
574582
overlayFiles.keyAt(i).toString().string());
575583
}
576584
}
@@ -584,8 +592,8 @@ static bool applyFileOverlay(Bundle *bundle,
584592
keyAt(overlayGroupIndex));
585593
if (baseFileIndex < UNKNOWN_ERROR) {
586594
if (bundle->getVerbose()) {
587-
printf("found a match (%zd) for overlay file %s, for flavor %s\n",
588-
baseFileIndex,
595+
printf("found a match (" ZD ") for overlay file %s, for flavor %s\n",
596+
(ZD_TYPE) baseFileIndex,
589597
overlayGroup->getLeaf().string(),
590598
overlayFiles.keyAt(overlayGroupIndex).toString().string());
591599
}

tools/aapt/StringPool.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
#include <utils/ByteOrder.h>
1010

11+
#if HAVE_PRINTF_ZD
12+
# define ZD "%zd"
13+
# define ZD_TYPE ssize_t
14+
#else
15+
# define ZD "%ld"
16+
# define ZD_TYPE long
17+
#endif
18+
1119
#define NOISY(x) //x
1220

1321
void strcpy16_htod(uint16_t* dst, const uint16_t* src)
@@ -30,7 +38,7 @@ void printStringPool(const ResStringPool* pool)
3038
str = String8(pool->stringAt(s, &len)).string();
3139
}
3240

33-
printf("String #%zd: %s\n", s, str);
41+
printf("String #" ZD ": %s\n", (ZD_TYPE) s, str);
3442
}
3543
}
3644

0 commit comments

Comments
 (0)