You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by gb...@apache.org on 2015/03/08 16:46:10 UTC
incubator-corinthia git commit: Globally change strdup() to xstrdup.
Repository: incubator-corinthia
Updated Branches:
refs/heads/master fe0974658 -> e3820933b
Globally change strdup() to xstrdup.
Files changed:
* DocFormats/platform/src/Wrapper.c
(xstrdup): New function.
* DocFormats/unittest/DFUnitTest.c
Add #include DFPlatform.h.
Change strdup() to xstrdup() in these files:
* DocFormats/core/src/css/CSS.c
* DocFormats/core/src/css/CSSParser.c
* DocFormats/core/src/css/CSSProperties.c
* DocFormats/core/src/css/CSSSelector.c
* DocFormats/core/src/css/CSSSheet.c
* DocFormats/core/src/css/CSSStyle.c
* DocFormats/core/src/html/DFHTML.c
* DocFormats/core/src/html/DFHTMLNormalization.c
* DocFormats/core/src/lib/DFBuffer.c
* DocFormats/core/src/lib/DFFilesystem.c
* DocFormats/core/src/lib/DFStorage.c
* DocFormats/core/src/lib/DFString.c
* DocFormats/core/src/lib/TextPackage.c
* DocFormats/core/src/xml/DFChanges.c
* DocFormats/core/src/xml/DFDOM.c
* DocFormats/core/src/xml/DFMarkupCompatibility.c
* DocFormats/core/src/xml/DFNameMap.c
* DocFormats/core/src/xml/DFXML.c
* DocFormats/core/tests/html/HTMLPlain.c
* DocFormats/filters/latex/src/HTMLToLaTeX.c
* DocFormats/filters/ooxml/src/common/OPC.c
* DocFormats/filters/ooxml/src/word/CSSClassNames.c
* DocFormats/filters/ooxml/src/word/WordConverter.c
* DocFormats/filters/ooxml/src/word/WordLists.c
* DocFormats/filters/ooxml/src/word/WordNumbering.c
* DocFormats/filters/ooxml/src/word/WordSheet.c
* DocFormats/filters/ooxml/src/word/WordStyles.c
* DocFormats/filters/ooxml/src/word/WordTheme.c
* DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c
* DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c
* DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c
* DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c
* DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
* DocFormats/filters/ooxml/src/word/lenses/WordField.c
* DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c
* DocFormats/filters/ooxml/tests/word/WordPlain.c
* DocFormats/filters/ooxml/tests/word/WordTests.c
* DocFormats/headers/DFPlatform.h
* DocFormats/platform/src/Linux.c
* DocFormats/platform/src/Unix.c
* DocFormats/platform/src/Win32.c
* DocFormats/unittest/DFUnitTest.c
* consumers/dftest/src/main.c
* consumers/dfutil/src/Commands.c
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/e3820933
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/e3820933
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/e3820933
Branch: refs/heads/master
Commit: e3820933b4f7c513d79e6aa6b9413f0392a5f75f
Parents: fe09746
Author: Gabriela Gibson <gb...@apache.org>
Authored: Sun Mar 8 15:46:24 2015 +0000
Committer: Gabriela Gibson <gb...@apache.org>
Committed: Sun Mar 8 15:46:24 2015 +0000
----------------------------------------------------------------------
DocFormats/core/src/css/CSS.c | 52 ++++++++++----------
DocFormats/core/src/css/CSSParser.c | 8 +--
DocFormats/core/src/css/CSSProperties.c | 4 +-
DocFormats/core/src/css/CSSSelector.c | 4 +-
DocFormats/core/src/css/CSSSheet.c | 14 +++---
DocFormats/core/src/css/CSSStyle.c | 2 +-
DocFormats/core/src/html/DFHTML.c | 4 +-
DocFormats/core/src/html/DFHTMLNormalization.c | 2 +-
DocFormats/core/src/lib/DFBuffer.c | 2 +-
DocFormats/core/src/lib/DFFilesystem.c | 18 +++----
DocFormats/core/src/lib/DFStorage.c | 12 ++---
DocFormats/core/src/lib/DFString.c | 22 ++++-----
DocFormats/core/src/lib/TextPackage.c | 8 +--
DocFormats/core/src/xml/DFChanges.c | 6 +--
DocFormats/core/src/xml/DFDOM.c | 2 +-
DocFormats/core/src/xml/DFMarkupCompatibility.c | 4 +-
DocFormats/core/src/xml/DFNameMap.c | 10 ++--
DocFormats/core/src/xml/DFXML.c | 2 +-
DocFormats/core/tests/html/HTMLPlain.c | 2 +-
DocFormats/filters/latex/src/HTMLToLaTeX.c | 6 +--
DocFormats/filters/ooxml/src/common/OPC.c | 14 +++---
.../filters/ooxml/src/word/CSSClassNames.c | 6 +--
.../filters/ooxml/src/word/WordConverter.c | 40 +++++++--------
DocFormats/filters/ooxml/src/word/WordLists.c | 10 ++--
.../filters/ooxml/src/word/WordNumbering.c | 10 ++--
DocFormats/filters/ooxml/src/word/WordSheet.c | 14 +++---
DocFormats/filters/ooxml/src/word/WordStyles.c | 18 +++----
DocFormats/filters/ooxml/src/word/WordTheme.c | 4 +-
.../ooxml/src/word/formatting/WordCommonPr.c | 2 +-
.../ooxml/src/word/formatting/WordNumPr.c | 22 ++++-----
.../ooxml/src/word/formatting/WordTblPr.c | 6 +--
.../ooxml/src/word/lenses/WordBookmark.c | 10 ++--
.../filters/ooxml/src/word/lenses/WordDrawing.c | 4 +-
.../filters/ooxml/src/word/lenses/WordField.c | 2 +-
.../ooxml/src/word/lenses/WordParagraph.c | 2 +-
DocFormats/filters/ooxml/tests/word/WordPlain.c | 26 +++++-----
DocFormats/filters/ooxml/tests/word/WordTests.c | 6 +--
DocFormats/headers/DFPlatform.h | 2 +
DocFormats/platform/src/Linux.c | 2 +-
DocFormats/platform/src/Unix.c | 6 +--
DocFormats/platform/src/Win32.c | 6 +--
DocFormats/platform/src/Wrapper.c | 7 +++
DocFormats/unittest/DFUnitTest.c | 7 +--
consumers/dftest/src/main.c | 8 +--
consumers/dfutil/src/Commands.c | 6 +--
45 files changed, 217 insertions(+), 207 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSS.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSS.c b/DocFormats/core/src/css/CSS.c
index 2a249cb..7f2bbf2 100644
--- a/DocFormats/core/src/css/CSS.c
+++ b/DocFormats/core/src/css/CSS.c
@@ -165,7 +165,7 @@ DFHashTable *CSSParseProperties(const char *input)
DFHashTable *properties = CSSParserProperties(parser);
CSSParserFree(parser);
if (properties == NULL)
- return DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ return DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
else
return properties;
}
@@ -190,7 +190,7 @@ char *CSSSerializeProperties(DFHashTable *cssProperties)
count++;
}
free(allKeys);
- char *result = strdup(output->data);
+ char *result = xstrdup(output->data);
DFBufferRelease(output);
return result;
}
@@ -224,31 +224,31 @@ static int splitSides(const char *shorthand, SideValues *sides)
count++;
switch (count) {
case 1:
- sides->top = strdup(tokens[0]);
- sides->bottom = strdup(tokens[0]);
- sides->left = strdup(tokens[0]);
- sides->right = strdup(tokens[0]);
+ sides->top = xstrdup(tokens[0]);
+ sides->bottom = xstrdup(tokens[0]);
+ sides->left = xstrdup(tokens[0]);
+ sides->right = xstrdup(tokens[0]);
ok = 1;
break;
case 2:
- sides->top = strdup(tokens[0]);
- sides->bottom = strdup(tokens[0]);
- sides->left = strdup(tokens[1]);
- sides->right = strdup(tokens[1]);
+ sides->top = xstrdup(tokens[0]);
+ sides->bottom = xstrdup(tokens[0]);
+ sides->left = xstrdup(tokens[1]);
+ sides->right = xstrdup(tokens[1]);
ok = 1;
break;
case 3:
- sides->top = strdup(tokens[0]);
- sides->left = strdup(tokens[1]);
- sides->right = strdup(tokens[1]);
- sides->bottom = strdup(tokens[2]);
+ sides->top = xstrdup(tokens[0]);
+ sides->left = xstrdup(tokens[1]);
+ sides->right = xstrdup(tokens[1]);
+ sides->bottom = xstrdup(tokens[2]);
ok = 1;
break;
case 4:
- sides->top = strdup(tokens[0]);
- sides->right = strdup(tokens[1]);
- sides->bottom = strdup(tokens[2]);
- sides->left = strdup(tokens[3]);
+ sides->top = xstrdup(tokens[0]);
+ sides->right = xstrdup(tokens[1]);
+ sides->bottom = xstrdup(tokens[2]);
+ sides->left = xstrdup(tokens[3]);
ok = 1;
break;
}
@@ -579,7 +579,7 @@ DFArray *CSSParseContent(const char *content)
static DFHashTable *builtTextRules(DFHashTable *input)
{
- DFHashTable *result = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *result = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
const char **allSelectors = DFHashTableCopyKeys(input);
for (int selIndex = 0; allSelectors[selIndex]; selIndex++) {
@@ -624,7 +624,7 @@ static DFHashTable *combineTextRules(DFHashTable *separate)
DFArray *array = DFHashTableLookup(reverse,text);
if (array == NULL) {
- array = DFArrayNew((DFCopyFunction)strdup,free);
+ array = DFArrayNew((DFCopyFunction)xstrdup,free);
DFHashTableAdd(reverse,text,array);
DFArrayRelease(array);
}
@@ -632,7 +632,7 @@ static DFHashTable *combineTextRules(DFHashTable *separate)
}
free(separateKeys);
- DFHashTable *combined = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *combined = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
const char **reverseKeys = DFHashTableCopyKeys(reverse);
for (int keyIndex = 0; reverseKeys[keyIndex]; keyIndex++) {
const char *text = reverseKeys[keyIndex];
@@ -674,7 +674,7 @@ char *CSSCopyStylesheetTextFromRules(DFHashTable *rules)
free(allSelectors);
DFHashTableRelease(separate);
DFHashTableRelease(textRules);
- char *result = strdup(output->data);
+ char *result = xstrdup(output->data);
DFBufferRelease(output);
return result;
}
@@ -785,7 +785,7 @@ char *CSSHexColor(const char *color, int includeHash)
}
if (!includeHash && (result != NULL)) {
- char *nohash = strdup(&result[1]);
+ char *nohash = xstrdup(&result[1]);
free(result);
result = nohash;
}
@@ -800,7 +800,7 @@ char *CSSEncodeFontFamily(const char *input)
if (DFStringContainsWhitespace(input))
return DFQuote(input);
else
- return strdup(input);
+ return xstrdup(input);
}
char *CSSDecodeFontFamily(const char *input)
@@ -1075,12 +1075,12 @@ void CSSParseSelector(const char *cinput, char **result, char **suffix)
free(className);
}
else {
- *result = strdup(elementName);
+ *result = xstrdup(elementName);
}
// Parse suffix
// FIXME: ignore spaces at start?
- *suffix = strdup(&cinput[pos]);
+ *suffix = xstrdup(&cinput[pos]);
free(elementName);
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSSParser.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSSParser.c b/DocFormats/core/src/css/CSSParser.c
index a73fdcc..b6fadfc 100644
--- a/DocFormats/core/src/css/CSSParser.c
+++ b/DocFormats/core/src/css/CSSParser.c
@@ -51,7 +51,7 @@ CSSParser *CSSParserNew(const char *cinput)
if (cinput == NULL)
cinput = "";
- p->chars = strdup(cinput);
+ p->chars = xstrdup(cinput);
p->length = strlen(cinput);
return p;
@@ -210,7 +210,7 @@ static char *trimmedSubstring(CSSParser *p, size_t start, size_t pos)
DFHashTable *CSSParserRules(CSSParser *p)
{
- DFHashTable *result = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *result = DFHashTableNew((DFCopyFunction)xstrdup,free);
while (p->pos < p->length) {
size_t start = p->pos;
int invalid = 0;
@@ -245,7 +245,7 @@ DFHashTable *CSSParserRules(CSSParser *p)
DFArray *CSSParserSelectors(CSSParser *p)
{
- DFArray *result = DFArrayNew((DFCopyFunction)strdup,free);
+ DFArray *result = DFArrayNew((DFCopyFunction)xstrdup,free);
while (p->pos < p->length) {
size_t start = p->pos;
int invalid = 0;
@@ -265,7 +265,7 @@ DFArray *CSSParserSelectors(CSSParser *p)
DFHashTable *CSSParserProperties(CSSParser *p)
{
- DFHashTable *result = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *result = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
while (p->pos < p->length) {
size_t start = p->pos;
int invalid = 0;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSSProperties.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSSProperties.c b/DocFormats/core/src/css/CSSProperties.c
index bbb1161..5d96459 100644
--- a/DocFormats/core/src/css/CSSProperties.c
+++ b/DocFormats/core/src/css/CSSProperties.c
@@ -155,7 +155,7 @@ CSSProperties *CSSPropertiesNewWithExtra(CSSProperties *orig, const char *string
CSSProperties *result = (CSSProperties *)xcalloc(1,sizeof(CSSProperties));
result->retainCount = 1;
- result->hashTable = DFHashTableNew((DFCopyFunction)strdup,free);
+ result->hashTable = DFHashTableNew((DFCopyFunction)xstrdup,free);
const char **names = DFHashTableCopyKeys(orig->hashTable);
for (int i = 0; names[i]; i++) {
const char *value = DFHashTableLookup(orig->hashTable,names[i]);
@@ -180,7 +180,7 @@ CSSProperties *CSSPropertiesNewWithRaw(DFHashTable *raw)
CSSProperties *result = (CSSProperties *)xcalloc(1,sizeof(CSSProperties));
result->retainCount = 1;
- result->hashTable = DFHashTableNew((DFCopyFunction)strdup,free);
+ result->hashTable = DFHashTableNew((DFCopyFunction)xstrdup,free);
if (raw != NULL)
CSSPropertiesUpdateFromRaw(result,raw);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSSSelector.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSSSelector.c b/DocFormats/core/src/css/CSSSelector.c
index 7c2682f..ec17e3e 100644
--- a/DocFormats/core/src/css/CSSSelector.c
+++ b/DocFormats/core/src/css/CSSSelector.c
@@ -65,7 +65,7 @@ char *CSSMakeSelector(const char *elementName, const char *className)
if (className != NULL)
return DFFormatString("%s.%s",elementName,className);
else
- return strdup(elementName);
+ return xstrdup(elementName);
}
char *CSSMakeTagSelector(Tag tag, const char *className)
@@ -114,7 +114,7 @@ char *CSSSelectorCopyElementName(const char *selector)
return NULL;
int dotPos = findDotPos(selector);
if (dotPos < 0)
- return strdup(selector);
+ return xstrdup(selector);
char *result = (char *)xmalloc(dotPos+1);
memcpy(result,selector,dotPos);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSSSheet.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSSSheet.c b/DocFormats/core/src/css/CSSSheet.c
index 41bf968..8f8cdcf 100644
--- a/DocFormats/core/src/css/CSSSheet.c
+++ b/DocFormats/core/src/css/CSSSheet.c
@@ -111,7 +111,7 @@ CSSStyle *CSSSheetFlattenedStyle(CSSSheet *sheet, CSSStyle *orig)
// FIXME: Need tests for parent cycles
CSSStyle *ancestor = orig;
CSSStyle *result = CSSStyleNew("temp");
- DFHashTable *visited = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *visited = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
const char **allSuffixes = NULL;
while (1) {
free(allSuffixes);
@@ -161,7 +161,7 @@ DFHashTable *CSSSheetRules(CSSSheet *sheet)
free(escapedClassName);
}
else {
- baseSelector = strdup(elementName);
+ baseSelector = xstrdup(elementName);
}
CSSStyle *flattenedStyle = CSSSheetFlattenedStyle(sheet,origStyle);
@@ -225,7 +225,7 @@ char *CSSSheetCopyText(CSSSheet *sheet)
free(sortedSuffixes);
}
free(allSelectors);
- char *str = strdup(result->data);
+ char *str = xstrdup(result->data);
DFBufferRelease(result);
return str;
}
@@ -237,7 +237,7 @@ static void breakCycles(CSSSheet *sheet)
for (int i = 0; allSelectors[i]; i++) {
const char *selector = allSelectors[i];
CSSStyle *style = CSSSheetLookupSelector(sheet,selector,0,0);
- DFHashTable *visited = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *visited = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
int depth = 0;
while (style != NULL) {
@@ -268,7 +268,7 @@ static const char **reverseTopologicalSortedSelectors(CSSSheet *sheet)
depth++;
while (DFArrayCount(selectorsByDepth) < depth+1) {
- DFArray *array = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFArray *array = DFArrayNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
DFArrayAppend(selectorsByDepth,array);
DFArrayRelease(array);
}
@@ -278,7 +278,7 @@ static const char **reverseTopologicalSortedSelectors(CSSSheet *sheet)
}
free(allSelectors);
- DFArray *sortedSelectors = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFArray *sortedSelectors = DFArrayNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (size_t i = DFArrayCount(selectorsByDepth); i > 0; i--) {
DFArray *atDepth = DFArrayItemAt(selectorsByDepth,i-1);
for (size_t j = 0; j < DFArrayCount(atDepth); j++)
@@ -353,7 +353,7 @@ static void updateFromRawCSSRules(CSSSheet *sheet, DFHashTable *rules)
if (!strncmp(constSelector,".",1))
selector = DFFormatString("p%s",constSelector); // FIXME: Not covered by tests
else
- selector = strdup(constSelector);
+ selector = xstrdup(constSelector);
DFHashTable *raw = DFHashTableLookup(rules,constSelector);
char *baseId = NULL;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/css/CSSStyle.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/css/CSSStyle.c b/DocFormats/core/src/css/CSSStyle.c
index 083784d..8b9b8a4 100644
--- a/DocFormats/core/src/css/CSSStyle.c
+++ b/DocFormats/core/src/css/CSSStyle.c
@@ -96,7 +96,7 @@ void CSSStyleRelease(CSSStyle *style)
void CSSStyleSetSelector(CSSStyle *style, const char *newSelector)
{
// Take a copy of newSelector first, just in case it's one of the values we're about to free
- char *selector = strdup(newSelector);
+ char *selector = xstrdup(newSelector);
free(style->selector);
free(style->elementName);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/html/DFHTML.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/html/DFHTML.c b/DocFormats/core/src/html/DFHTML.c
index e75c3e9..8716d66 100644
--- a/DocFormats/core/src/html/DFHTML.c
+++ b/DocFormats/core/src/html/DFHTML.c
@@ -71,10 +71,10 @@ char *HTMLCopyCSSText(DFDocument *doc)
{
DFNode *head = DFChildWithTag(doc->root,HTML_HEAD);
if (head == NULL)
- return strdup("");;
+ return xstrdup("");;
DFNode *style = DFChildWithTag(head,HTML_STYLE);
if (style == NULL)
- return strdup("");
+ return xstrdup("");
return DFNodeTextToString(style);
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/html/DFHTMLNormalization.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/html/DFHTMLNormalization.c b/DocFormats/core/src/html/DFHTMLNormalization.c
index dc6d76c..5455611 100644
--- a/DocFormats/core/src/html/DFHTMLNormalization.c
+++ b/DocFormats/core/src/html/DFHTMLNormalization.c
@@ -613,7 +613,7 @@ void HTML_normalizeDocument(DFDocument *doc)
static DFHashTable *extractInlineProperties(DFNode *paragraph)
{
- DFHashTable *inlineProperties = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *inlineProperties = DFHashTableNew((DFCopyFunction)xstrdup,free);
const char *paraCSSText = DFGetAttribute(paragraph,HTML_STYLE);
CSSProperties *paraProperties = CSSPropertiesNewWithString(paraCSSText);
const char **allNames = CSSPropertiesCopyNames(paraProperties);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/lib/DFBuffer.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFBuffer.c b/DocFormats/core/src/lib/DFBuffer.c
index efa50b9..e79929f 100644
--- a/DocFormats/core/src/lib/DFBuffer.c
+++ b/DocFormats/core/src/lib/DFBuffer.c
@@ -194,7 +194,7 @@ char *binaryToString(DFBuffer *input)
}
if ((input->len % 40) != 0)
DFBufferAppendChar(charBuf,'\n');
- char *result = strdup(charBuf->data);
+ char *result = xstrdup(charBuf->data);
DFBufferRelease(charBuf);
return result;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/lib/DFFilesystem.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFFilesystem.c b/DocFormats/core/src/lib/DFFilesystem.c
index a96134a..358b70e 100644
--- a/DocFormats/core/src/lib/DFFilesystem.c
+++ b/DocFormats/core/src/lib/DFFilesystem.c
@@ -177,7 +177,7 @@ static void freeDirEntryList(DFDirEntryList *list)
static DFArray *arrayFromDirEntryList(DFDirEntryList *list)
{
- DFArray *array = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFArray *array = DFArrayNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (DFDirEntryList *l = list; l != NULL; l = l->next)
DFArrayAppend(array,l->name);
return array;
@@ -224,10 +224,10 @@ char *DFPathDirName(const char *path)
size_t pos = len;
while (1) {
if (pos == 0)
- return strdup("");
+ return xstrdup("");
if (path[pos-1] == '/') {
if (pos == 1)
- return strdup("/");
+ return xstrdup("/");
else
return DFSubstring(path,0,pos-1);
}
@@ -264,9 +264,9 @@ char *DFPathExtension(const char *path)
size_t pos = len;
while (1) {
if (pos == 0)
- return strdup("");
+ return xstrdup("");
if (path[pos-1] == '/')
- return strdup("");
+ return xstrdup("");
if (path[pos-1] == '.')
return DFSubstring(path,pos,len);
pos--;
@@ -280,7 +280,7 @@ char *DFPathWithoutExtension(const char *path)
len--;
if (!strcmp(path,"/"))
- return strdup("/");;
+ return xstrdup("/");;
size_t pos = len;
while (1) {
@@ -310,11 +310,11 @@ char *DFPathNormalize(const char *path)
char *DFPathResolveAbsolute(const char *rawBase, const char *relative)
{
if (relative[0] == '/')
- return strdup(relative);
+ return xstrdup(relative);
char *base;
if (rawBase[0] == '/') {
- base = strdup(rawBase);
+ base = xstrdup(rawBase);
}
else {
char cwd[4096];
@@ -322,7 +322,7 @@ char *DFPathResolveAbsolute(const char *rawBase, const char *relative)
base = DFFormatString("%s/%s",cwd,rawBase);
}
- char *baseDirectory = DFStringHasSuffix(base,"/") ? strdup(base) : DFPathDirName(base);
+ char *baseDirectory = DFStringHasSuffix(base,"/") ? xstrdup(base) : DFPathDirName(base);
DFBuffer *path = DFBufferNew();
DFBufferAppendString(path,baseDirectory);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/lib/DFStorage.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFStorage.c b/DocFormats/core/src/lib/DFStorage.c
index 264d269..d6e404f 100644
--- a/DocFormats/core/src/lib/DFStorage.c
+++ b/DocFormats/core/src/lib/DFStorage.c
@@ -145,7 +145,7 @@ const char **fsList(DFStorage *storage, DFError **error)
if (allPaths == NULL)
return NULL;;
- DFArray *filesOnly = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFArray *filesOnly = DFArrayNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (int i = 0; allPaths[i]; i++) {
const char *relPath = allPaths[i];
char *absPath = DFAppendPathComponent(storage->rootPath,relPath);
@@ -315,9 +315,9 @@ static char *fixPath(const char *input)
char *normalized = DFPathNormalize(input);
char *result;
if (normalized[0] == '/')
- result = strdup(&normalized[1]);
+ result = xstrdup(&normalized[1]);
else
- result = strdup(normalized);
+ result = xstrdup(normalized);
free(normalized);
return result;
}
@@ -336,7 +336,7 @@ DFStorage *DFStorageNewFilesystem(const char *rootPath, DFFileFormat format)
if ((rootPath == NULL) || (strlen(rootPath) == 0))
rootPath = ".";;
DFStorage *storage = DFStorageNew(format,&fsOps);
- storage->rootPath = strdup(rootPath);
+ storage->rootPath = xstrdup(rootPath);
return storage;
}
@@ -357,7 +357,7 @@ DFStorage *DFStorageCreateZip(const char *filename, DFError **error)
DFStorage *storage = DFStorageNew(DFFileFormatFromFilename(filename),&zipOps);
storage->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
- storage->zipFilename = strdup(filename);
+ storage->zipFilename = xstrdup(filename);
return storage;
}
@@ -370,7 +370,7 @@ DFStorage *DFStorageOpenZip(const char *filename, DFError **error)
DFStorage *storage = DFStorageNew(DFFileFormatFromFilename(filename),&zipOps);
storage->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
- storage->zipFilename = strdup(filename);
+ storage->zipFilename = xstrdup(filename);
if (!DFUnzip(filename,storage,error)) {
DFStorageRelease(storage);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/lib/DFString.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFString.c b/DocFormats/core/src/lib/DFString.c
index e6295ca..f6a70fe 100644
--- a/DocFormats/core/src/lib/DFString.c
+++ b/DocFormats/core/src/lib/DFString.c
@@ -256,7 +256,7 @@ char *DFStringTrimLeadingWhitespace(const char *str)
ch = DFNextChar(str,&pos);
} while ((ch != 0) && DFCharIsWhitespaceOrNewline(ch));
- return strdup(&str[startpos]);
+ return xstrdup(&str[startpos]);
}
char *DFStringNormalizeWhitespace(const char *input)
@@ -322,7 +322,7 @@ char *DFSubstring(const char *str, size_t start, size_t end)
char *DFStrDup(const char *str)
{
if (str != NULL)
- return strdup(str);
+ return xstrdup(str);
else
return NULL;
}
@@ -334,7 +334,7 @@ char *DFUpperCase(const char *input)
}
size_t len = strlen(input);
- char *result = strdup(input);
+ char *result = xstrdup(input);
for (size_t i = 0; i < len; i++) {
// Avoid calling toupper with chars from UTF-8 multibyte sequences
if ((result[i] >= 'a') && result[i] <= 'z')
@@ -350,7 +350,7 @@ char *DFLowerCase(const char *input)
}
size_t len = strlen(input);
- char *result = strdup(input);
+ char *result = xstrdup(input);
for (size_t i = 0; i < len; i++) {
// Avoid calling tolower with chars from UTF-8 multibyte sequences
if ((result[i] >= 'A') && result[i] <= 'Z')
@@ -489,7 +489,7 @@ char *DFAppendPathComponent(const char *path1, const char *path2)
{
char *unnormalized;
if (strlen(path1) == 0)
- unnormalized = strdup(path2);
+ unnormalized = xstrdup(path2);
else if (path1[strlen(path1)-1] == '/')
unnormalized = DFFormatString("%s%s",path1,path2);
else
@@ -512,7 +512,7 @@ char *DFStringReplace(const char *input, const char *match, const char *replacem
size_t matchLen = strlen(match);
if (matchLen == 0)
- return strdup(input); // protect against infinite loop
+ return xstrdup(input); // protect against infinite loop
struct DFBuffer *output = DFBufferNew();
@@ -528,7 +528,7 @@ char *DFStringReplace(const char *input, const char *match, const char *replacem
}
}
- char *result = strdup(output->data);
+ char *result = xstrdup(output->data);
DFBufferRelease(output);
return result;
}
@@ -598,7 +598,7 @@ char *DFUnquote(const char *in)
return NULL;
if ((in[0] != '"') && (in[0] != '\''))
- return strdup(in);
+ return xstrdup(in);
char quote = in[0];
size_t inlen = strlen(in);
@@ -646,7 +646,7 @@ char *DFUnquote(const char *in)
char *DFSpacesToUnderscores(const char *input)
{
size_t len = strlen(input);
- char *output = strdup(input);
+ char *output = xstrdup(input);
for (size_t i = 0; i < len; i++) {
if (output[i] == ' ')
output[i] = '_';
@@ -657,7 +657,7 @@ char *DFSpacesToUnderscores(const char *input)
char *DFUnderscoresToSpaces(const char *input)
{
size_t len = strlen(input);
- char *output = strdup(input);
+ char *output = xstrdup(input);
for (size_t i = 0; i < len; i++) {
if (output[i] == '_')
output[i] = ' ';
@@ -739,7 +739,7 @@ char *DFStringReadFromFile(const char *filename, DFError **error)
DFBuffer *buffer = DFBufferReadFromFile(filename,error);
if (buffer == NULL)
return NULL;
- char *result = strdup(buffer->data);
+ char *result = xstrdup(buffer->data);
DFBufferRelease(buffer);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/lib/TextPackage.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/TextPackage.c b/DocFormats/core/src/lib/TextPackage.c
index ff14eb0..feff1d6 100644
--- a/DocFormats/core/src/lib/TextPackage.c
+++ b/DocFormats/core/src/lib/TextPackage.c
@@ -34,7 +34,7 @@ static TextPackage *TextPackageNew(void)
{
TextPackage *package = (TextPackage *)xcalloc(1,sizeof(TextPackage));
package->retainCount = 1;
- package->items = DFHashTableNew((DFCopyFunction)strdup,free);
+ package->items = DFHashTableNew((DFCopyFunction)xstrdup,free);
package->keys = (char **)xcalloc(1,sizeof(char *));
return package;
}
@@ -101,7 +101,7 @@ static int parsePackage(TextPackage *package, const char *string, const char *pa
}
- char *currentKey = strdup("");
+ char *currentKey = xstrdup("");
DFBuffer *currentValue = DFBufferNew();
const char **lines = DFStringSplit(replaced->data,"\n",0);
for (int lineno = 0; lines[lineno]; lineno++) {
@@ -112,7 +112,7 @@ static int parsePackage(TextPackage *package, const char *string, const char *pa
}
else if (DFStringHasPrefix(line,"#item ")) {
package->keys = (char **)xrealloc(package->keys,(package->nkeys+2)*sizeof(char *));
- package->keys[package->nkeys++] = strdup(currentKey);
+ package->keys[package->nkeys++] = xstrdup(currentKey);
package->keys[package->nkeys] = NULL;
DFHashTableAdd(package->items,currentKey,currentValue->data);
free(currentKey);
@@ -129,7 +129,7 @@ static int parsePackage(TextPackage *package, const char *string, const char *pa
}
}
package->keys = (char **)xrealloc(package->keys,(package->nkeys+2)*sizeof(char *));
- package->keys[package->nkeys++] = strdup(currentKey);
+ package->keys[package->nkeys++] = xstrdup(currentKey);
package->keys[package->nkeys] = NULL;
DFHashTableAdd(package->items,currentKey,currentValue->data);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/xml/DFChanges.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFChanges.c b/DocFormats/core/src/xml/DFChanges.c
index 5e5e292..c67b0f0 100644
--- a/DocFormats/core/src/xml/DFChanges.c
+++ b/DocFormats/core/src/xml/DFChanges.c
@@ -30,7 +30,7 @@ static char *fullNameForTag(DFDocument *doc, Tag tag)
const TagDecl *tagDecl = DFNameMapNameForTag(doc->map,tag);
const NamespaceDecl *nsDecl = DFNameMapNamespaceForID(doc->map,tagDecl->namespaceID);
if ((nsDecl->prefix == NULL) || (tagDecl->namespaceID == NAMESPACE_HTML))
- return strdup(tagDecl->localName);
+ return xstrdup(tagDecl->localName);
else
return DFFormatString("%s:%s",nsDecl->prefix,tagDecl->localName);
}
@@ -81,7 +81,7 @@ static void nodeDetailToBuffer(DFNode *node, DFBuffer *output)
if (strlen(quoted) >= 2)
sub = DFSubstring(quoted,1,strlen(quoted)-2);
else
- sub = strdup(quoted);
+ sub = xstrdup(quoted);
DFBufferFormat(output,"%s</%s>",quoted,elementName);
free(sub);
free(quoted);
@@ -219,7 +219,7 @@ char *DFChangesToString(DFNode *root)
{
DFBuffer *output = DFBufferNew();
DFChangesToStringRecursive(root,0,output);
- char *result = strdup(output->data);
+ char *result = xstrdup(output->data);
DFBufferRelease(output);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/xml/DFDOM.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFDOM.c b/DocFormats/core/src/xml/DFDOM.c
index 56809c3..a5ef758 100644
--- a/DocFormats/core/src/xml/DFDOM.c
+++ b/DocFormats/core/src/xml/DFDOM.c
@@ -488,7 +488,7 @@ char *DFNodeTextToString(DFNode *node)
{
DFBuffer *buf = DFBufferNew();
DFNodeTextToBuffer(node,buf);
- char *result = strdup(buf->data);
+ char *result = xstrdup(buf->data);
DFBufferRelease(buf);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/xml/DFMarkupCompatibility.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFMarkupCompatibility.c b/DocFormats/core/src/xml/DFMarkupCompatibility.c
index 608fc71..a77a08d 100644
--- a/DocFormats/core/src/xml/DFMarkupCompatibility.c
+++ b/DocFormats/core/src/xml/DFMarkupCompatibility.c
@@ -86,7 +86,7 @@ void DFMarkupCompatibilityPush(DFMarkupCompatibility *mc, int nb_namespaces, con
MCRecord *record = &mc->records[mc->depth-1];
bzero(record,sizeof(MCRecord));
if (nb_namespaces > 0) {
- record->namespaces = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ record->namespaces = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (int i = 0; i < nb_namespaces; i++) {
const char *nsPrefix = namespaces[i*2];
const char *nsURI = namespaces[i*2+1];
@@ -155,7 +155,7 @@ void DFMarkupCompatibilityProcessAttr(DFMarkupCompatibility *mc, Tag attr, const
localName = DFSubstring(component,colonPos+1,strlen(component));
}
else {
- prefix = strdup(component);
+ prefix = xstrdup(component);
localName = NULL;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/xml/DFNameMap.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFNameMap.c b/DocFormats/core/src/xml/DFNameMap.c
index f2f593e..eb5d868 100644
--- a/DocFormats/core/src/xml/DFNameMap.c
+++ b/DocFormats/core/src/xml/DFNameMap.c
@@ -80,8 +80,8 @@ static void DFNameHashTableAdd(DFNameHashTable *table, const char *name, const c
URI = "";;
uint32_t hash = DFNameHashTableHash(name,URI)%HASH_TABLE_SIZE;
DFNameEntry *entry = (DFNameEntry *)xmalloc(sizeof(DFNameEntry));
- entry->name = strdup(name);
- entry->URI = strdup(URI);
+ entry->name = xstrdup(name);
+ entry->URI = xstrdup(URI);
entry->tag = tag;
entry->tagDecl.namespaceID = namespaceID;
entry->tagDecl.localName = (const char *)entry->name;
@@ -127,8 +127,8 @@ DFNamespaceInfo *DFNamespaceInfoNew(NamespaceID nsId, const char *URI, const cha
DFNamespaceInfo *info = (DFNamespaceInfo *)xcalloc(1,sizeof(DFNamespaceInfo));
info->nsId = nsId;
info->decl = (NamespaceDecl *)xmalloc(sizeof(NamespaceDecl));
- info->decl->namespaceURI = strdup(URI);
- info->decl->prefix = strdup(prefix);
+ info->decl->namespaceURI = xstrdup(URI);
+ info->decl->prefix = xstrdup(prefix);
return info;
}
@@ -159,7 +159,7 @@ DFTagInfo *DFTagInfoNew(Tag tag, NamespaceID nsId, const char *localName)
info->tag = tag;
info->decl = (TagDecl *)xmalloc(sizeof(TagDecl));
info->decl->namespaceID = nsId;
- info->decl->localName = strdup(localName);
+ info->decl->localName = xstrdup(localName);
return info;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/src/xml/DFXML.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFXML.c b/DocFormats/core/src/xml/DFXML.c
index 3a335ae..97f2f95 100644
--- a/DocFormats/core/src/xml/DFXML.c
+++ b/DocFormats/core/src/xml/DFXML.c
@@ -611,7 +611,7 @@ char *DFSerializeXMLString(DFDocument *doc, NamespaceID defaultNS, int indent)
{
DFBuffer *buf = DFBufferNew();
DFSerializeXMLBuffer(doc,defaultNS,indent,buf);
- char *result = strdup(buf->data);
+ char *result = xstrdup(buf->data);
DFBufferRelease(buf);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/core/tests/html/HTMLPlain.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/tests/html/HTMLPlain.c b/DocFormats/core/tests/html/HTMLPlain.c
index 75075bd..e131f43 100644
--- a/DocFormats/core/tests/html/HTMLPlain.c
+++ b/DocFormats/core/tests/html/HTMLPlain.c
@@ -77,7 +77,7 @@ char *HTML_toPlain(DFDocument *doc, DFStorage *storage, DFError **error)
}
free(imageSources);
- char *str = strdup(output->data);
+ char *str = xstrdup(output->data);
DFBufferRelease(output);
return str;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/latex/src/HTMLToLaTeX.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/latex/src/HTMLToLaTeX.c b/DocFormats/filters/latex/src/HTMLToLaTeX.c
index 0cd0cc4..20589f8 100644
--- a/DocFormats/filters/latex/src/HTMLToLaTeX.c
+++ b/DocFormats/filters/latex/src/HTMLToLaTeX.c
@@ -45,7 +45,7 @@ LaTeXConverter *LaTeXConverterNew(DFDocument *htmlDoc)
{
LaTeXConverter *conv = (LaTeXConverter *)xcalloc(1,sizeof(LaTeXConverter));
conv->htmlDoc = DFDocumentRetain(htmlDoc);
- conv->packages = DFHashTableNew((DFCopyFunction)strdup,free);
+ conv->packages = DFHashTableNew((DFCopyFunction)xstrdup,free);
return conv;
}
@@ -235,7 +235,7 @@ static void inlineToLaTeX(LaTeXConverter *conv, DFBuffer *output, DFNode *node)
}
if (texWidth == NULL)
- texWidth = strdup("");;
+ texWidth = xstrdup("");;
const char *src = DFGetAttribute(node,HTML_SRC);
if (src != NULL) {
@@ -684,7 +684,7 @@ char *HTMLToLaTeX(DFDocument *htmlDoc)
DFBufferFormat(mainOutput,"\\end{document}\n");
- char *result = strdup(mainOutput->data);
+ char *result = xstrdup(mainOutput->data);
DFBufferRelease(makeTitleOutput);
DFBufferRelease(documentOutput);
DFBufferRelease(mainOutput);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/common/OPC.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/common/OPC.c b/DocFormats/filters/ooxml/src/common/OPC.c
index e64cca4..9c7c1ed 100644
--- a/DocFormats/filters/ooxml/src/common/OPC.c
+++ b/DocFormats/filters/ooxml/src/common/OPC.c
@@ -37,9 +37,9 @@ static OPCRelationship *OPCRelationshipNew(const char *rId, const char *type, co
{
OPCRelationship *rel = (OPCRelationship *)xcalloc(1,sizeof(OPCRelationship));
rel->retainCount = 1;
- rel->rId = (rId != NULL) ? strdup(rId) : NULL;
- rel->type = (type != NULL) ? strdup(type) : NULL;
- rel->target = (target != NULL) ? strdup(target) : NULL;
+ rel->rId = (rId != NULL) ? xstrdup(rId) : NULL;
+ rel->type = (type != NULL) ? xstrdup(type) : NULL;
+ rel->target = (target != NULL) ? xstrdup(target) : NULL;
rel->external = external;
return rel;
}
@@ -192,8 +192,8 @@ OPCPart *OPCPartNew(const char *URI, const char *contentType)
{
OPCPart *part = (OPCPart *)xcalloc(1,sizeof(OPCPart));
part->retainCount = 1;
- part->URI = (URI != NULL) ? strdup(URI) : NULL;
- part->contentType = (contentType != NULL) ? strdup(contentType) : NULL;
+ part->URI = (URI != NULL) ? xstrdup(URI) : NULL;
+ part->contentType = (contentType != NULL) ? xstrdup(contentType) : NULL;
part->relationships = OPCRelationshipSetNew();
return part;
}
@@ -229,8 +229,8 @@ struct OPCContentTypes {
static OPCContentTypes *OPCContentTypesNew(void)
{
OPCContentTypes *ct = (OPCContentTypes *)xcalloc(1,sizeof(OPCContentTypes));
- ct->defaultsByExtension = DFHashTableNew((DFCopyFunction)strdup,free);
- ct->overridesByPartName = DFHashTableNew((DFCopyFunction)strdup,free);
+ ct->defaultsByExtension = DFHashTableNew((DFCopyFunction)xstrdup,free);
+ ct->overridesByPartName = DFHashTableNew((DFCopyFunction)xstrdup,free);
return ct;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/CSSClassNames.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/CSSClassNames.c b/DocFormats/filters/ooxml/src/word/CSSClassNames.c
index e7c0f2f..2c47bc6 100644
--- a/DocFormats/filters/ooxml/src/word/CSSClassNames.c
+++ b/DocFormats/filters/ooxml/src/word/CSSClassNames.c
@@ -269,10 +269,10 @@ static void determineReplacements(CSSSheet *styleSheet, DFHashTable *repls)
const char *selector = allSelectors[i];
char *className = CSSSelectorCopyClassName(selector);
if (className == NULL)
- className = strdup("");;
+ className = xstrdup("");;
SelectorList *item = (SelectorList *)xcalloc(1,sizeof(SelectorList));
- item->selector = strdup(selector);
+ item->selector = xstrdup(selector);
item->next = DFHashTableLookup(selectorsByClassName,className);
DFHashTableAdd(selectorsByClassName,className,item);
free(className);
@@ -399,7 +399,7 @@ static void replaceSelectorsInSheet(DFHashTable *repls, CSSSheet *styleSheet)
void CSSEnsureUnique(CSSSheet *styleSheet, DFDocument *htmlDoc, int creating)
{
- DFHashTable *repls = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *repls = DFHashTableNew((DFCopyFunction)xstrdup,free);
determineReplacements(styleSheet,repls);
replaceSelectorsInSheet(repls,styleSheet);
replaceSelectorsInNode(repls,htmlDoc->root);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordConverter.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordConverter.c b/DocFormats/filters/ooxml/src/word/WordConverter.c
index 0b22f49..e695c96 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.c
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.c
@@ -458,7 +458,7 @@ static char *extractPrefix(DFNode *node, const char *counterName)
int foundSeq = 0;
int foundContent = 0;
extractPrefixRecursive(node,counterName,result,&foundSeq,&foundContent);
- char *str = strdup(result->data);
+ char *str = xstrdup(result->data);
DFBufferRelease(result);
return str;
}
@@ -566,7 +566,7 @@ static WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStor
converter->html = DFDocumentRetain(html);
converter->abstractStorage = DFStorageRetain(abstractStorage);
assert(DFStorageFormat(converter->abstractStorage) == DFFileFormatHTML);
- converter->idPrefix = strdup("word");
+ converter->idPrefix = xstrdup("word");
converter->package = WordPackageRetain(package);
converter->styles = WordSheetNew(converter->package->styles);
converter->numbering = WordNumberingNew(converter->package);
@@ -575,7 +575,7 @@ static WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStor
converter->objects = WordObjectsNew(converter->package);
converter->footnotes = WordNoteGroupNewFootnotes(converter->package->footnotes);
converter->endnotes = WordNoteGroupNewEndnotes(converter->package->endnotes);
- converter->supportedContentTypes = DFHashTableNew((DFCopyFunction)strdup,free);
+ converter->supportedContentTypes = DFHashTableNew((DFCopyFunction)xstrdup,free);
DFHashTableAdd(converter->supportedContentTypes,"jpg","image/jpeg");
DFHashTableAdd(converter->supportedContentTypes,"jpeg","image/jpeg");
DFHashTableAdd(converter->supportedContentTypes,"tif","image/tiff");
@@ -777,7 +777,7 @@ static void updateListTypes(WordPutData *put)
if (!DFStringEquals(wordType,htmlType)) {
// Make a copy of numId, as it may be freed during the first call to DFHashTableRemove
- char *numIdCopy = strdup(numId);
+ char *numIdCopy = xstrdup(numId);
DFHashTableRemove(put->numIdByHtmlId,htmlId);
DFHashTableRemove(put->htmlIdByNumId,numIdCopy);
free(numIdCopy);
@@ -870,8 +870,8 @@ int WordConverterPut(DFDocument *html, DFStorage *abstractStorage, WordPackage *
WordPutData put;
put.conv = converter;
put.contentDoc = converter->package->document;
- put.numIdByHtmlId = DFHashTableNew((DFCopyFunction)strdup,free);
- put.htmlIdByNumId = DFHashTableNew((DFCopyFunction)strdup,free);
+ put.numIdByHtmlId = DFHashTableNew((DFCopyFunction)xstrdup,free);
+ put.htmlIdByNumId = DFHashTableNew((DFCopyFunction)xstrdup,free);
// Make sure we update styles.xml from the CSS stylesheet *before* doing any conversion of the content,
// since the latter requires a full mapping of CSS selectors to styleIds to be in place.
@@ -929,13 +929,13 @@ char *WordStyleIdForStyle(CSSStyle *style)
char *resStyleId = NULL;
if (!strcmp(selector,"table.Normal_Table"))
- return strdup("TableNormal");
+ return xstrdup("TableNormal");
if (!strcmp(selector,"table.Table_Grid"))
- return strdup("TableGrid");
+ return xstrdup("TableGrid");
if (!strcmp(selector,"span.Default_Paragraph_Font"))
- return strdup("DefaultParagraphFont");
+ return xstrdup("DefaultParagraphFont");
if (!strcmp(selector,"p.List_Paragraph"))
- return strdup("ListParagraph");
+ return xstrdup("ListParagraph");
int headingLevel = CSSSelectorHeadingLevel(selector);
if (headingLevel != 0) {
@@ -951,23 +951,23 @@ char *WordStyleIdForStyle(CSSStyle *style)
}
if (!strcmp(selector,"span.Heading1Char"))
- return strdup("Heading1Char");
+ return xstrdup("Heading1Char");
if (!strcmp(selector,"span.Heading2Char"))
- return strdup("Heading2Char");
+ return xstrdup("Heading2Char");
if (!strcmp(selector,"span.Heading3Char"))
- return strdup("Heading3Char");
+ return xstrdup("Heading3Char");
if (!strcmp(selector,"span.Heading4Char"))
- return strdup("Heading4Char");
+ return xstrdup("Heading4Char");
if (!strcmp(selector,"span.Heading5Char"))
- return strdup("Heading5Char");
+ return xstrdup("Heading5Char");
if (!strcmp(selector,"span.Heading6Char"))
- return strdup("Heading6Char");
+ return xstrdup("Heading6Char");
if (!strcmp(selector,"span.Heading7Char"))
- return strdup("Heading7Char");
+ return xstrdup("Heading7Char");
if (!strcmp(selector,"span.Heading8Char"))
- return strdup("Heading8Char");
+ return xstrdup("Heading8Char");
if (!strcmp(selector,"span.Heading9Char"))
- return strdup("Heading9Char");
+ return xstrdup("Heading9Char");
char *className = CSSSelectorCopyClassName(selector);
switch (CSSSelectorGetTag(selector)) {
@@ -1013,7 +1013,7 @@ char *WordStyleIdForStyle(CSSStyle *style)
if (resStyleId == NULL) {
// Note: selector here may start with . (i.e. applies to all elements)
// FIXME: not covered by tests
- resStyleId = strdup(selector);
+ resStyleId = xstrdup(selector);
}
return resStyleId;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordLists.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordLists.c b/DocFormats/filters/ooxml/src/word/WordLists.c
index 018c6a0..e9dee43 100644
--- a/DocFormats/filters/ooxml/src/word/WordLists.c
+++ b/DocFormats/filters/ooxml/src/word/WordLists.c
@@ -546,10 +546,10 @@ static void fixWordLists(DFNode *node, WordConverter *conv)
continue;
if (!createdHashTables) {
- replacementNumIds = DFHashTableNew((DFCopyFunction)strdup,free);
- itemNoByListKey = DFHashTableNew((DFCopyFunction)strdup,free);
- lastNumIdByIlvl = DFHashTableNew((DFCopyFunction)strdup,free);
- itemNoByIlvl = DFHashTableNew((DFCopyFunction)strdup,free);
+ replacementNumIds = DFHashTableNew((DFCopyFunction)xstrdup,free);
+ itemNoByListKey = DFHashTableNew((DFCopyFunction)xstrdup,free);
+ lastNumIdByIlvl = DFHashTableNew((DFCopyFunction)xstrdup,free);
+ itemNoByIlvl = DFHashTableNew((DFCopyFunction)xstrdup,free);
createdHashTables = 1;
}
@@ -575,7 +575,7 @@ static void fixWordLists(DFNode *node, WordConverter *conv)
char *listKey = DFFormatString("%s:%s",numId,ilvl);
char *itemNo = DFStrDup(DFHashTableLookup(itemNoByListKey,listKey));
if (itemNo == NULL) {
- itemNo = strdup("1");
+ itemNo = xstrdup("1");
if ((levelStart != NULL) && (atoi(levelStart) > 1) && (atoi(ilvl) <= maxIlvl)) {
const char *prevNumId = DFHashTableLookup(lastNumIdByIlvl,ilvl);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordNumbering.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordNumbering.c b/DocFormats/filters/ooxml/src/word/WordNumbering.c
index 07fc431..47b85d5 100644
--- a/DocFormats/filters/ooxml/src/word/WordNumbering.c
+++ b/DocFormats/filters/ooxml/src/word/WordNumbering.c
@@ -58,8 +58,8 @@ WordNumLevel *WordNumLevelNew(DFNode *element)
WordNumLevel *level = (WordNumLevel *)xcalloc(1,sizeof(WordNumLevel));
level->ilvl = atoi(ilvl);
- level->numFmt = (numFmt != NULL) ? strdup(numFmt) : NULL;
- level->lvlText = (lvlText != NULL) ? strdup(lvlText) : NULL;
+ level->numFmt = (numFmt != NULL) ? xstrdup(numFmt) : NULL;
+ level->lvlText = (lvlText != NULL) ? xstrdup(lvlText) : NULL;
level->element = element;
return level;
@@ -120,7 +120,7 @@ const char *WordNumLevelToListStyleType(WordNumLevel *level)
static WordAbstractNum *WordAbstractNumNew(const char *abstractNumId1, DFNode *element1)
{
WordAbstractNum *abs = (WordAbstractNum *)xcalloc(1,sizeof(WordAbstractNum));
- abs->abstractNumId = (abstractNumId1 != NULL) ? strdup(abstractNumId1) : NULL;
+ abs->abstractNumId = (abstractNumId1 != NULL) ? xstrdup(abstractNumId1) : NULL;
abs->element = element1;
abs->levels = DFHashTableNew(NULL,(DFFreeFunction)WordNumLevelFree);
return abs;
@@ -152,7 +152,7 @@ WordNumLevel *WordAbstractNumGetLevel(WordAbstractNum *abs, int ilvl)
static WordConcreteNum *WordConcreteNumNew(const char *numId, DFNode *element, WordAbstractNum *abstractNum)
{
WordConcreteNum *con = (WordConcreteNum *)xcalloc(1,sizeof(WordConcreteNum));
- con->numId = (numId != NULL) ? strdup(numId) : NULL;
+ con->numId = (numId != NULL) ? xstrdup(numId) : NULL;
con->element = element;
con->abstractNum = abstractNum;
return con;
@@ -201,7 +201,7 @@ WordNumbering *WordNumberingNew(WordPackage *package)
num->_concreteNums = DFHashTableNew(NULL,(DFFreeFunction)WordConcreteNumFree);
num->_nextAbstractId = 1;
num->_nextConcreteId = 1;
- num->_listStyleTypes = DFHashTableNew((DFCopyFunction)strdup,free);
+ num->_listStyleTypes = DFHashTableNew((DFCopyFunction)xstrdup,free);
WordNumberingRegisterType(num,ListStyleTypeDecimal,"decimal");
WordNumberingRegisterType(num,ListStyleTypeDecimalLeadingZero,"decimal-leading-zero");
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordSheet.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordSheet.c b/DocFormats/filters/ooxml/src/word/WordSheet.c
index 178fde1..8c9231c 100644
--- a/DocFormats/filters/ooxml/src/word/WordSheet.c
+++ b/DocFormats/filters/ooxml/src/word/WordSheet.c
@@ -33,7 +33,7 @@ static char *WordSheetIdentForType(const char *type, const char *styleId)
char *WordStyleNameToClassName(const char *name)
{
- char *className = strdup(name);
+ char *className = xstrdup(name);
for (char *c = className; *c != '\0'; c++) {
if (*c == ' ')
*c = '_';
@@ -43,7 +43,7 @@ char *WordStyleNameToClassName(const char *name)
char *WordStyleNameFromClassName(const char *name)
{
- char *className = strdup(name);
+ char *className = xstrdup(name);
for (char *c = className; *c != '\0'; c++) {
if (*c == '_')
*c = ' ';
@@ -67,13 +67,13 @@ static WordStyle *WordStyleNew(DFNode *element, const char *type, const char *st
WordStyle *style = (WordStyle *)xcalloc(1,sizeof(WordStyle));
style->retainCount = 1;
style->element = element;
- style->type = (type != NULL) ? strdup(type) : NULL;
- style->styleId = (styleId != NULL) ? strdup(styleId) : NULL;
+ style->type = (type != NULL) ? xstrdup(type) : NULL;
+ style->styleId = (styleId != NULL) ? xstrdup(styleId) : NULL;
style->ident = WordSheetIdentForType(style->type,style->styleId);
style->basedOn = DFStrDup(DFGetChildAttribute(style->element,WORD_BASEDON,WORD_VAL));
DFNode *pPr = DFChildWithTag(style->element,WORD_PPR);
style->outlineLvl = DFStrDup(DFGetChildAttribute(pPr,WORD_OUTLINELVL,WORD_VAL));
- style->name = strdup(name);
+ style->name = xstrdup(name);
return style;
}
@@ -211,7 +211,7 @@ WordStyle *WordSheetAddStyle(WordSheet *sheet, const char *type, const char *sty
DFSetAttribute(nameNode,WORD_VAL,name);
WordStyle *style = WordStyleNew(element,type,styleId,name);
- style->selector = strdup(selector);
+ style->selector = xstrdup(selector);
DFHashTableAdd(sheet->stylesByIdent,style->ident,style);
DFHashTableAdd(sheet->stylesByName,style->name,style);
DFHashTableAdd(sheet->stylesBySelector,style->selector,style);
@@ -270,7 +270,7 @@ static void determineSelectors(WordSheet *sheet)
// Compute inherited properties
WordStyle *ancestor = style;
- DFHashTable *visited = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *visited = DFHashTableNew((DFCopyFunction)xstrdup,free);
while ((ancestor != NULL) && (DFHashTableLookup(visited,ancestor->ident) == NULL)) {
DFHashTableAdd(visited,ancestor->ident,"");
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordStyles.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordStyles.c b/DocFormats/filters/ooxml/src/word/WordStyles.c
index 6f73508..6006564 100644
--- a/DocFormats/filters/ooxml/src/word/WordStyles.c
+++ b/DocFormats/filters/ooxml/src/word/WordStyles.c
@@ -235,7 +235,7 @@ static void WordPutStyle(DFNode *concrete, CSSStyle *style, WordConverter *conve
if ((style->tag != HTML_P) && (style->tag != HTML_SPAN) && (style->tag != HTML_TABLE)) {
CSSStyle *parentStyle = CSSSheetLookupElement(converter->styleSheet,style->elementName,NULL,0,0);
if ((parentStyle != NULL) && !parentStyle->latent)
- parentSelector = strdup(style->elementName);
+ parentSelector = xstrdup(style->elementName);
}
}
}
@@ -723,13 +723,13 @@ static char *WordStyleNameForStyle(CSSStyle *style)
return WordStyleNameFromClassName(style->className);
switch (style->tag) {
- case HTML_H1: return strdup("heading 1");
- case HTML_H2: return strdup("heading 2");
- case HTML_H3: return strdup("heading 3");
- case HTML_H4: return strdup("heading 4");
- case HTML_H5: return strdup("heading 5");
- case HTML_H6: return strdup("heading 6");
- case HTML_FIGURE: return strdup("Figure");
+ case HTML_H1: return xstrdup("heading 1");
+ case HTML_H2: return xstrdup("heading 2");
+ case HTML_H3: return xstrdup("heading 3");
+ case HTML_H4: return xstrdup("heading 4");
+ case HTML_H5: return xstrdup("heading 5");
+ case HTML_H6: return xstrdup("heading 6");
+ case HTML_FIGURE: return xstrdup("Figure");
}
return NULL;
@@ -817,7 +817,7 @@ void WordUpdateStyles(WordConverter *converter, CSSSheet *styleSheet)
char *styleId = WordStyleIdForStyle(style);
char *name = WordStyleNameForStyle(style);
if (name == NULL)
- name = strdup(styleId);;
+ name = xstrdup(styleId);;
WordStyle *wordStyle = WordSheetAddStyle(sheet,familyStr,styleId,name,selector);
DFCreateChildElement(wordStyle->element,WORD_QFORMAT);
free(styleId);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/WordTheme.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordTheme.c b/DocFormats/filters/ooxml/src/word/WordTheme.c
index 1366b7a..d64fc8e 100644
--- a/DocFormats/filters/ooxml/src/word/WordTheme.c
+++ b/DocFormats/filters/ooxml/src/word/WordTheme.c
@@ -49,8 +49,8 @@ WordTheme *WordThemeNew(WordPackage *package)
const char *majorFont = DFGetChildAttribute(majorFontElem,DML_MAIN_LATIN,NULL_TYPEFACE);
const char *minorFont = DFGetChildAttribute(minorFontElem,DML_MAIN_LATIN,NULL_TYPEFACE);
- theme->majorFont = (majorFont != NULL) ? strdup(majorFont) : NULL;
- theme->minorFont = (minorFont != NULL) ? strdup(minorFont) : NULL;
+ theme->majorFont = (majorFont != NULL) ? xstrdup(majorFont) : NULL;
+ theme->minorFont = (minorFont != NULL) ? xstrdup(minorFont) : NULL;
return theme;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c b/DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c
index 7a88308..dd50fd5 100644
--- a/DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c
+++ b/DocFormats/filters/ooxml/src/word/formatting/WordCommonPr.c
@@ -129,7 +129,7 @@ void WordGetBorder(DFNode *concrete, const char *side, CSSProperties *properties
if ((color != NULL) && isRRGGBB(color))
value = DFFormatString("#%s",color);
else
- value = strdup("black");
+ value = xstrdup("black");
CSSPut(properties,colorName,value);
free(value);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c b/DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c
index c9ff069..b8e431d 100644
--- a/DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c
+++ b/DocFormats/filters/ooxml/src/word/formatting/WordNumPr.c
@@ -78,7 +78,7 @@ static char *parseLvlText(const char *input, WordConcreteNum *num)
if ((result->len > 0) && !endsWithWhitespace)
DFBufferFormat(result," \" \"");
- char *str = strdup(result->data);
+ char *str = xstrdup(result->data);
DFBufferRelease(result);
return str;
}
@@ -185,9 +185,9 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
if (DFStringEquals(part->value,elementName)) {
free(info->cssType);
if (part->arg != NULL)
- info->cssType = strdup(part->arg);
+ info->cssType = xstrdup(part->arg);
else
- info->cssType = strdup("decimal");
+ info->cssType = xstrdup("decimal");
}
if ((strlen(part->value) == 2) && (part->value[0] == 'h'))
DFBufferFormat(format,"%%%c",part->value[1]);
@@ -206,7 +206,7 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
format->len--;
}
- info->cssLvlText = strdup(format->data);
+ info->cssLvlText = xstrdup(format->data);
free(elementName);
DFBufferRelease(format);
}
@@ -224,8 +224,8 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
if (concreteNum != NULL) {
WordNumLevel *level = WordConcreteNumGetLevel(concreteNum,atoi(ilvl));
if (level != NULL) {
- info->wordNumId = strdup(numId);
- info->wordIlvl = strdup(ilvl);
+ info->wordNumId = xstrdup(numId);
+ info->wordIlvl = xstrdup(ilvl);
info->wordLevel = level;
int ilvlValue = atoi(ilvl);
@@ -279,7 +279,7 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
if ((style->headingLevel >= 1) && (style->headingLevel <= 6)) {
int level = style->headingLevel - 1;
SelectorList *item = (SelectorList *)xcalloc(1,sizeof(SelectorList));
- item->selector = strdup(style->selector);
+ item->selector = xstrdup(style->selector);
item->next = DFHashTableLookupInt(selectorsByLevel,level);
DFHashTableAddInt(selectorsByLevel,level,item);
}
@@ -318,13 +318,13 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
info = WordNumInfoNew();
DFHashTableAdd(infoByStyleId,style->selector,info);
}
- curType = strdup(info->cssType);
- curLvlText = strdup(info->cssLvlText);
+ curType = xstrdup(info->cssType);
+ curLvlText = xstrdup(info->cssLvlText);
}
if (curType == NULL)
- curType = (prevType != NULL) ? strdup(prevType) : strdup("decimal");
+ curType = (prevType != NULL) ? xstrdup(prevType) : xstrdup("decimal");
if ((curLvlText == NULL) || (strlen(curLvlText) == 0)) {
free(curLvlText);
@@ -343,7 +343,7 @@ void updateNumbering(WordConverter *converter, CSSSheet *cssSheet)
assert(info->wordLevel != NULL);
free(info->wordNumId);
free(info->wordIlvl);
- info->wordNumId = strdup(concreteNum->numId);
+ info->wordNumId = xstrdup(concreteNum->numId);
info->wordIlvl = DFFormatString("%d",i);
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c b/DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c
index d173ec0..5ce603f 100644
--- a/DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c
+++ b/DocFormats/filters/ooxml/src/word/formatting/WordTblPr.c
@@ -107,13 +107,13 @@ static char *cssPctWidth(const char *type, const char *width, WordSection *secti
// Units: 1/50ths of a percent
double pct = atoi(width)/50.0;
char buf[100];
- return strdup(DFFormatDoublePct(buf,100,pct));
+ return xstrdup(DFFormatDoublePct(buf,100,pct));
}
else if (!strcmp(type,"dxa") && (WordSectionContentWidth(section) > 0)) {
// Units: 1/20ths of a point
double pct = 100.0*atoi(width)/(double)WordSectionContentWidth(section);
char buf[100];
- return strdup(DFFormatDoublePct(buf,100,pct));
+ return xstrdup(DFFormatDoublePct(buf,100,pct));
}
return NULL;
}
@@ -208,7 +208,7 @@ static void WordGetTblCellMarSide(DFNode *concrete, CSSProperties *properties, c
double pts = atoi(w)/20.0;
char *name = DFFormatString("padding-%s",side);
char buf[100];
- char *value = strdup(DFFormatDoublePt(buf,100,pts));
+ char *value = xstrdup(DFFormatDoublePt(buf,100,pts));
CSSPut(properties,name,value);
free(name);
free(value);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c b/DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c
index 5289a7c..56d8a02 100644
--- a/DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c
+++ b/DocFormats/filters/ooxml/src/word/lenses/WordBookmark.c
@@ -74,8 +74,8 @@ WordBookmark *WordBookmarkNew(const char *bookmarkId1, const char *bookmarkName1
{
WordBookmark *bookmark = (WordBookmark *)xcalloc(1,sizeof(WordBookmark));
bookmark->retainCount = 1;
- bookmark->bookmarkId = (bookmarkId1 != NULL) ? strdup(bookmarkId1) : NULL;
- bookmark->bookmarkName = (bookmarkName1 != NULL) ? strdup(bookmarkName1) : NULL;
+ bookmark->bookmarkId = (bookmarkId1 != NULL) ? xstrdup(bookmarkId1) : NULL;
+ bookmark->bookmarkName = (bookmarkName1 != NULL) ? xstrdup(bookmarkName1) : NULL;
bookmark->type = WordBookmarkUnknown;
return bookmark;
}
@@ -164,7 +164,7 @@ void findLabel(WordBookmark *bookmark)
DFNodeTextToBuffer(child,buffer);
}
free(bookmark->label);
- bookmark->label = strdup(buffer->data);
+ bookmark->label = xstrdup(buffer->data);
DFBufferRelease(buffer);
}
@@ -536,8 +536,8 @@ static void collapseRecursive(DFNode *node, DFHashTable *bookmarksById)
case WORD_BOOKMARKEND: {
DFArray *startElements = DFArrayNew(NULL,NULL);
DFArray *endElements = DFArrayNew(NULL,NULL);
- DFHashTable *startIds = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- DFHashTable *endIds = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *startIds = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ DFHashTable *endIds = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
DFNode *n;
for (n = child;
(n != NULL) && ((n->tag == WORD_BOOKMARKSTART) || (n->tag == WORD_BOOKMARKEND));
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c b/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
index 2f60e54..77ef362 100644
--- a/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
+++ b/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
@@ -149,7 +149,7 @@ WordDrawing *WordDrawingNew(const char *drawingId)
{
WordDrawing *drawing = (WordDrawing *)xcalloc(1,sizeof(WordDrawing));
drawing->retainCount = 1;
- drawing->drawingId = strdup(drawingId);
+ drawing->drawingId = xstrdup(drawingId);
return drawing;
}
@@ -338,7 +338,7 @@ static char *genImageFilename(DFStorage *storage, const char *mediaRelDir, const
if (paths == NULL)
return NULL;;
- DFHashTable *existingPaths = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *existingPaths = DFHashTableNew((DFCopyFunction)xstrdup,free);
for (int i = 0; paths[i]; i++) {
const char *path = paths[i];
char *lowerPath = DFLowerCase(path);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/lenses/WordField.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/lenses/WordField.c b/DocFormats/filters/ooxml/src/word/lenses/WordField.c
index 1f356a6..5ba51ac 100644
--- a/DocFormats/filters/ooxml/src/word/lenses/WordField.c
+++ b/DocFormats/filters/ooxml/src/word/lenses/WordField.c
@@ -37,7 +37,7 @@ static void WordFieldPut(WordPutData *put, DFNode *abstract, DFNode *concrete);
const char **Word_parseField(const char *str)
{
size_t len = strlen(str);
- DFArray *components = DFArrayNew((DFCopyFunction)strdup,free);
+ DFArray *components = DFArrayNew((DFCopyFunction)xstrdup,free);
size_t start = 0;
int inString = 0;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c b/DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c
index 8c02fc5..5801221 100644
--- a/DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c
+++ b/DocFormats/filters/ooxml/src/word/lenses/WordParagraph.c
@@ -195,7 +195,7 @@ static void WordParagraphPut(WordPutData *put, DFNode *abstract, DFNode *concret
// FIXME: Won't work with Word documents created in non-English languages
if ((selector != NULL) && (abstract->tag == HTML_P) && DFStringEquals(className,"Caption")) {
free(selector);
- selector = strdup("caption");
+ selector = xstrdup("caption");
}
if (selector != NULL) {
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/tests/word/WordPlain.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/tests/word/WordPlain.c b/DocFormats/filters/ooxml/tests/word/WordPlain.c
index 2498418..dfb13a4 100644
--- a/DocFormats/filters/ooxml/tests/word/WordPlain.c
+++ b/DocFormats/filters/ooxml/tests/word/WordPlain.c
@@ -87,7 +87,7 @@ static char *findDocumentPath(DFStorage *storage, DFError **error)
if (strcmp(type,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"))
continue;
- result = strdup(target);
+ result = xstrdup(target);
ok = 1;
break;
}
@@ -158,7 +158,7 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
DFBuffer *output, DFStorage *storage, DFError **error)
{
int ok = 0;
- DFHashTable *includeTypes = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *includeTypes = DFHashTableNew((DFCopyFunction)xstrdup,free);
DFHashTableAdd(includeTypes,WORDREL_HYPERLINK,"");
DFHashTableAdd(includeTypes,WORDREL_IMAGE,"");
@@ -225,7 +225,7 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
if (!DFStringHasSuffix(filename,"/"))
absFilename = DFFormatString("/%s",filename);
else
- absFilename = strdup(filename);
+ absFilename = xstrdup(filename);
DFBuffer *data = DFBufferReadFromStorage(storage,absFilename,NULL);
addSerializedBinary(output,data,absFilename);
DFBufferRelease(data);
@@ -246,7 +246,7 @@ end:
static char *Word_toPlainFromDir(DFStorage *storage, DFHashTable *parts, DFError **error)
{
char *documentPath = NULL;
- DFHashTable *rels = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *rels = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
DFBuffer *output = DFBufferNew();
char *relsPathRel = NULL;
DFDocument *relsDoc = NULL;
@@ -282,7 +282,7 @@ end:
return NULL;
}
else {
- char *result = strdup(output->data);
+ char *result = xstrdup(output->data);
DFBufferRelease(output);
return result;
}
@@ -424,11 +424,11 @@ static int Word_fromStorage(TextPackage *tp, DFStorage *storage, DFError **error
const char *documentStr = DFHashTableLookup(tp->items,"document.xml");
const char **allFilenames = NULL;
- DFHashTable *ctDefaults = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- DFHashTable *ctOverrides = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- DFHashTable *docRelURIs = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- DFHashTable *docRelTypes = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- DFHashTable *docRelModes = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFHashTable *ctDefaults = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ DFHashTable *ctOverrides = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ DFHashTable *docRelURIs = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ DFHashTable *docRelTypes = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ DFHashTable *docRelModes = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
if (documentStr == NULL) {
@@ -519,9 +519,9 @@ static int Word_fromStorage(TextPackage *tp, DFStorage *storage, DFError **error
DFHashTableRelease(docRelURIs);
DFHashTableRelease(docRelTypes);
DFHashTableRelease(docRelModes);
- docRelURIs = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- docRelTypes = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- docRelModes = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ docRelURIs = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ docRelTypes = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
+ docRelModes = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (DFNode *child = doc->root->first; child != NULL; child = child->next) {
if (child->tag == REL_RELATIONSHIP) {
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/filters/ooxml/tests/word/WordTests.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/tests/word/WordTests.c b/DocFormats/filters/ooxml/tests/word/WordTests.c
index 5c157b3..9c6bb7b 100644
--- a/DocFormats/filters/ooxml/tests/word/WordTests.c
+++ b/DocFormats/filters/ooxml/tests/word/WordTests.c
@@ -44,7 +44,7 @@ static void test_collapseBookmarks(void)
return;
}
- DFHashTable *parts = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *parts = DFHashTableNew((DFCopyFunction)xstrdup,free);
DFHashTableAdd(parts,"document","");
// Output the docx file
@@ -72,7 +72,7 @@ static void test_expandBookmarks(void)
return;
}
- DFHashTable *parts = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *parts = DFHashTableNew((DFCopyFunction)xstrdup,free);
DFHashTableAdd(parts,"document","");
// Output the docx file
@@ -129,7 +129,7 @@ static DFHashTable *getFlags(void)
{
if (utgetargc() == 0)
return NULL;;
- DFHashTable *set = DFHashTableNew((DFCopyFunction)strdup,free);
+ DFHashTable *set = DFHashTableNew((DFCopyFunction)xstrdup,free);
for (int i = 0; i < utgetargc(); i++) {
const char *colon = strchr(utgetargv()[i],':');
if (colon == NULL)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index d3d2dba..e181966 100755
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -105,4 +105,6 @@ void *xcalloc(size_t nmemb, size_t size);
void *xrealloc(void *ptr, size_t size);
+char *xstrdup(const char *s);
+
#endif // DocFormats_DFPlatform_h
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/platform/src/Linux.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Linux.c b/DocFormats/platform/src/Linux.c
index 8f01264..a324504 100644
--- a/DocFormats/platform/src/Linux.c
+++ b/DocFormats/platform/src/Linux.c
@@ -30,7 +30,7 @@ int DFGetImageDimensions(const void *data, size_t len, const char *ext,
SDL_Surface *image = IMG_Load_RW(SDL_RWFromMem((void *)data,len),1);
if (image == NULL) {
if (errmsg != NULL)
- *errmsg = strdup(IMG_GetError());
+ *errmsg = xstrdup(IMG_GetError());
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/platform/src/Unix.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Unix.c b/DocFormats/platform/src/Unix.c
index 5e78953..7c854f3 100644
--- a/DocFormats/platform/src/Unix.c
+++ b/DocFormats/platform/src/Unix.c
@@ -50,7 +50,7 @@ int DFMkdirIfAbsent(const char *path, char **errmsg)
if ((mkdir(path,0777) != 0) && (errno != EEXIST)) {
printf("DFMkdirIfAbsent: errno = %d (%s)\n",errno,strerror(errno));
if (errmsg != NULL)
- *errmsg = strdup(strerror(errno));
+ *errmsg = xstrdup(strerror(errno));
return 0;
}
return 1;
@@ -65,7 +65,7 @@ int DFAddDirContents(const char *absPath, const char *relPath, int recursive, DF
if (errmsg != NULL) {
char temp[1024];
snprintf(temp,1024,"%s: %s",relPath,strerror(errno));
- *errmsg = strdup(temp);
+ *errmsg = xstrdup(temp);
}
return 0;
}
@@ -93,7 +93,7 @@ int DFAddDirContents(const char *absPath, const char *relPath, int recursive, DF
entryName = relSubPath;
*listptr = (DFDirEntryList *)xcalloc(1,sizeof(DFDirEntryList));
- (*listptr)->name = strdup(entryName);
+ (*listptr)->name = xstrdup(entryName);
listptr = &(*listptr)->next;
struct stat statbuf;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/platform/src/Win32.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Win32.c b/DocFormats/platform/src/Win32.c
index 0dd6533..43cdbb2 100755
--- a/DocFormats/platform/src/Win32.c
+++ b/DocFormats/platform/src/Win32.c
@@ -47,7 +47,7 @@ static void DFErrorMsgSetWin32(char **errmsg, DWORD code)
(lpMsgBuf[len - 1] == '.')))
len--;
lpMsgBuf[len] = '\0';
- *errmsg = strdup(lpMsgBuf);
+ *errmsg = xstrdup(lpMsgBuf);
LocalFree(lpMsgBuf);
}
@@ -122,7 +122,7 @@ int DFAddDirContents(const char *absPath, const char *relPath, int recursive, DF
entryName = relSubPath;
*listptr = (DFDirEntryList *)xcalloc(1,sizeof(DFDirEntryList));
- (*listptr)->name = strdup(entryName);
+ (*listptr)->name = xstrdup(entryName);
listptr = &(*listptr)->next;
if (recursive && (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
@@ -144,7 +144,7 @@ int DFGetImageDimensions(const void *data, size_t len, const char *ext,
SDL_Surface *image = IMG_Load_RW(SDL_RWFromMem((void *)data,len),1);
if (image == NULL) {
if (errmsg != NULL)
- *errmsg = strdup(IMG_GetError());
+ *errmsg = xstrdup(IMG_GetError());
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index 500d85c..1e8e506 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -194,3 +194,10 @@ void *xrealloc(void *in_ptr, size_t size)
return ptr;
}
+
+
+char *xstrdup(const char *s)
+{
+ size_t l = strlen(s)+1;
+ return (char*) memcpy (xmalloc (l), s, l);
+}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/DocFormats/unittest/DFUnitTest.c
----------------------------------------------------------------------
diff --git a/DocFormats/unittest/DFUnitTest.c b/DocFormats/unittest/DFUnitTest.c
index 37c2100..17e8ae1 100644
--- a/DocFormats/unittest/DFUnitTest.c
+++ b/DocFormats/unittest/DFUnitTest.c
@@ -16,6 +16,7 @@
// under the License.
#include "DFUnitTest.h"
+#include "DFPlatform.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -62,7 +63,7 @@ void utassert(int condition, const char *description)
{
if (!condition) {
curtest.failed = 1;
- curtest.reason = strdup(description);
+ curtest.reason = xstrdup(description);
}
}
@@ -70,14 +71,14 @@ void utexpect(const char *actual, const char *expected)
{
if (strcmp(actual,expected)) {
curtest.failed = 1;
- curtest.reason = strdup("Output mismatch");
+ curtest.reason = xstrdup("Output mismatch");
}
}
void utfail(const char *reason)
{
curtest.failed = 1;
- curtest.reason = strdup(reason);
+ curtest.reason = xstrdup(reason);
}
TestCase *utlookup(TestGroup **groups, const char *name)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/consumers/dftest/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dftest/src/main.c b/consumers/dftest/src/main.c
index 6324f02..2621b89 100644
--- a/consumers/dftest/src/main.c
+++ b/consumers/dftest/src/main.c
@@ -93,7 +93,7 @@ static char *getCommandFromCode(const char *code, DFError **error)
for (int i = 0; lines[i]; i++) {
if (!DFStringIsWhitespace(lines[i]) && strncmp(lines[i],"//",2)) {
if (command == NULL)
- command = strdup(lines[i]);
+ command = xstrdup(lines[i]);
count++;
}
}
@@ -115,7 +115,7 @@ static const char **parseCommand(const char *command, DFError **error)
const char *closebr = strrchr(command,')');
if ((openbr == NULL) && (closebr == NULL)) {
- DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
+ DFArray *array = DFArrayNew((DFCopyFunction)xstrdup,free);
DFArrayAppend(array,(void *)command);
const char **result = DFStringArrayFlatten(array);
DFArrayRelease(array);
@@ -140,7 +140,7 @@ static const char **parseCommand(const char *command, DFError **error)
char *arguments = DFSubstring(command,openpos+1,closepos);
const char **components = DFStringSplit(arguments,",",0);
- DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
+ DFArray *array = DFArrayNew((DFCopyFunction)xstrdup,free);
DFArrayAppend(array,name);
for (int i = 0; components[i]; i++) {
char *trimmed = DFStringTrimWhitespace(components[i]);
@@ -278,7 +278,7 @@ static void TestGetFilenamesRecursive(const char *path, DFArray *result)
void runTests(int argc, const char **argv, int diff)
{
- DFArray *tests = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ DFArray *tests = DFArrayNew((DFCopyFunction)xstrdup,(DFFreeFunction)free);
for (int i = 0; i < argc; i++) {
const char *path = argv[i];
if (!DFFileExists(path)) {
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e3820933/consumers/dfutil/src/Commands.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Commands.c b/consumers/dfutil/src/Commands.c
index 5e633c5..7f90e56 100644
--- a/consumers/dfutil/src/Commands.c
+++ b/consumers/dfutil/src/Commands.c
@@ -56,7 +56,7 @@ static char *readString(const char *filename, DFError **error)
DFBuffer *buffer = readData(filename,error);
if (buffer == NULL)
return NULL;
- char *result = strdup(buffer->data);
+ char *result = xstrdup(buffer->data);
DFBufferRelease(buffer);
return result;
}
@@ -177,7 +177,7 @@ int fromPlain(const char *inFilename, const char *outFilename, DFError **error)
if (inStr == NULL)
return 0;
- char *inPath = fromStdin ? strdup(".") : DFPathDirName(inFilename);
+ char *inPath = fromStdin ? xstrdup(".") : DFPathDirName(inFilename);
int ok = fromPlain2(inStr,inPath,outFilename,error);
free(inPath);
free(inStr);
@@ -299,7 +299,7 @@ int textPackageGet(const char *filename, const char *itemPath, DFError **error)
return 0;
}
free(value);
- value = strdup(DFHashTableLookup(package->items,name));
+ value = xstrdup(DFHashTableLookup(package->items,name));
if (value == NULL) {
DFErrorFormat(error,"%s: Item %s not found",filename,itemPath);
TextPackageRelease(package);