1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add strCatZ().

strCat() did not follow our convention of appending Z to functions that accept zero-terminated strings rather than String objects.

Add strCatZ() to accept zero-terminated strings and update strCat() to accept String objects.

Use LF_STR where appropriate but don't use other String constants because they do not improve readability.
This commit is contained in:
David Steele 2020-06-24 12:09:24 -04:00 committed by GitHub
parent dab00e2010
commit 45d9b03136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 161 additions and 145 deletions

View File

@ -1176,7 +1176,7 @@ backupJobResult(
// Add a comma if this is not the first item
if (errorIdx != 0)
strCat(error, ", ");
strCatZ(error, ", ");
// If an error range
if (varType(errorItem) == varTypeVariantList)

View File

@ -44,21 +44,21 @@ backupRegExp(BackupRegExpParam param)
// If full requested then diff/incr is optional
if (param.full)
{
strCat(result, "(\\_");
strCatZ(result, "(\\_");
}
// Else diff/incr is required
else
{
strCat(result, "\\_");
strCatZ(result, "\\_");
}
// Append date/time regexp for diff/incr
strCat(result, DATE_TIME_REGEX);
strCatZ(result, DATE_TIME_REGEX);
// Filter on both diff/incr
if (param.differential && param.incremental)
{
strCat(result, "(D|I)");
strCatZ(result, "(D|I)");
}
// Else just diff
else if (param.differential)
@ -74,13 +74,13 @@ backupRegExp(BackupRegExpParam param)
// If full requested then diff/incr is optional
if (param.full)
{
strCat(result, "){0,1}");
strCatZ(result, "){0,1}");
}
}
// Append the end anchor
if (!param.noAnchorEnd)
strCat(result, "$");
strCatZ(result, "$");
FUNCTION_LOG_RETURN(STRING, result);
}

View File

@ -73,7 +73,7 @@ cmdBegin(bool logOption)
if (strchr(strPtr(commandParam), ' ') != NULL)
commandParam = strNewFmt("\"%s\"", strPtr(commandParam));
strCat(info, strPtr(commandParam));
strCat(info, commandParam);
}
strCatFmt(info, "]");
@ -203,13 +203,13 @@ cmdEnd(int code, const String *errorMessage)
if (errorMessage == NULL)
{
strCat(info, "completed successfully");
strCatZ(info, "completed successfully");
if (cfgOptionValid(cfgOptLogTimestamp) && cfgOptionBool(cfgOptLogTimestamp))
strCatFmt(info, " (%" PRIu64 "ms)", timeMSec() - timeBegin);
}
else
strCat(info, strPtr(errorMessage));
strCat(info, errorMessage);
LOG(cfgLogLevelDefault(), 0, strPtr(info));
}

View File

@ -45,7 +45,7 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
{
// Add LF if there is already content
if (strSize(result) != 0)
strCat(result, "\n");
strCat(result, LF_STR);
// Split the paragraph into lines that don't exceed the line length
StringList *partList = strLstNewSplitSizeZ(strLstGet(lineList, lineIdx), " ", length - indent);
@ -56,14 +56,14 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
if (partIdx != 0 || indentFirst)
{
if (partIdx != 0)
strCat(result, "\n");
strCat(result, LF_STR);
if (strSize(strLstGet(partList, partIdx)))
strCatFmt(result, "%*s", (int)indent, "");
}
// Add the line
strCat(result, strPtr(strLstGet(partList, partIdx)));
strCat(result, strLstGet(partList, partIdx));
}
}
@ -101,7 +101,7 @@ helpRenderValue(const Variant *value)
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
{
if (keyIdx != 0)
strCat(resultTemp, ", ");
strCatZ(resultTemp, ", ");
strCatFmt(
resultTemp, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
@ -119,7 +119,7 @@ helpRenderValue(const Variant *value)
for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++)
{
if (listIdx != 0)
strCat(resultTemp, ", ");
strCatZ(resultTemp, ", ");
strCatFmt(resultTemp, "%s", strPtr(varStr(varLstGet(list, listIdx))));
}
@ -151,7 +151,7 @@ helpRender(void)
// Display general help
if (cfgCommand() == cfgCmdHelp || cfgCommand() == cfgCmdNone)
{
strCat(
strCatZ(
result,
" - General help\n"
"\n"
@ -271,7 +271,7 @@ helpRender(void)
if (value != NULL || defaultValue != NULL)
{
strCat(summary, " [");
strCatZ(summary, " [");
if (value != NULL)
strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));
@ -279,12 +279,12 @@ helpRender(void)
if (defaultValue != NULL)
{
if (value != NULL)
strCat(summary, ", ");
strCatZ(summary, ", ");
strCatFmt(summary, "default=%s", strPtr(defaultValue));
}
strCat(summary, "]");
strCatZ(summary, "]");
}
// Output option help
@ -341,7 +341,7 @@ helpRender(void)
if (value != NULL || defaultValue != NULL)
{
strCat(result, "\n");
strCat(result, LF_STR);
if (value != NULL)
strCatFmt(result, "current: %s\n", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));

View File

@ -549,7 +549,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
// List is ordered so 0 is always the current DB index
if (dbIdx == varLstSize(dbSection) - 1)
strCat(resultStr, "\n db (current)");
strCatZ(resultStr, "\n db (current)");
// Get the min/max archive information for the database
String *archiveResult = strNew("");
@ -574,7 +574,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strPtr(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MAX_VAR))));
}
else
strCat(archiveResult, "none present\n");
strCatZ(archiveResult, "none present\n");
}
}
@ -610,7 +610,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strCatFmt(
backupResult, " timestamp start/stop: %s / %s\n", timeBufferStart, timeBufferStop);
strCat(backupResult, " wal start/stop: ");
strCatZ(backupResult, " wal start/stop: ");
KeyValue *archiveBackupInfo = varKv(kvGet(backupInfo, KEY_ARCHIVE_VAR));
@ -621,7 +621,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strPtr(varStr(kvGet(archiveBackupInfo, KEY_STOP_VAR))));
}
else
strCat(backupResult, "n/a\n");
strCatZ(backupResult, "n/a\n");
KeyValue *info = varKv(kvGet(backupInfo, BACKUP_KEY_INFO_VAR));
@ -646,10 +646,10 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
if (kvGet(backupInfo, BACKUP_KEY_DATABASE_REF_VAR) != NULL)
{
VariantList *dbSection = kvGetList(backupInfo, BACKUP_KEY_DATABASE_REF_VAR);
strCat(backupResult, " database list:");
strCatZ(backupResult, " database list:");
if (varLstSize(dbSection) == 0)
strCat(backupResult, " none\n");
strCatZ(backupResult, " none\n");
else
{
for (unsigned int dbIdx = 0; dbIdx < varLstSize(dbSection); dbIdx++)
@ -660,16 +660,17 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strPtr(varStrForce(kvGet(db, KEY_OID_VAR))));
if (dbIdx != varLstSize(dbSection) - 1)
strCat(backupResult, ",");
strCatZ(backupResult, ",");
}
strCat(backupResult, "\n");
strCat(backupResult, LF_STR);
}
}
if (kvGet(backupInfo, BACKUP_KEY_LINK_VAR) != NULL)
{
VariantList *linkSection = kvGetList(backupInfo, BACKUP_KEY_LINK_VAR);
strCat(backupResult, " symlinks:\n");
strCatZ(backupResult, " symlinks:\n");
for (unsigned int linkIdx = 0; linkIdx < varLstSize(linkSection); linkIdx++)
{
@ -680,16 +681,16 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strPtr(varStr(kvGet(link, KEY_DESTINATION_VAR))));
if (linkIdx != varLstSize(linkSection) - 1)
strCat(backupResult, "\n");
strCat(backupResult, LF_STR);
}
strCat(backupResult, "\n");
strCat(backupResult, LF_STR);
}
if (kvGet(backupInfo, BACKUP_KEY_TABLESPACE_VAR) != NULL)
{
VariantList *tablespaceSection = kvGetList(backupInfo, BACKUP_KEY_TABLESPACE_VAR);
strCat(backupResult, " tablespaces:\n");
strCatZ(backupResult, " tablespaces:\n");
for (unsigned int tblIdx = 0; tblIdx < varLstSize(tablespaceSection); tblIdx++)
{
@ -701,10 +702,10 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strPtr(varStr(kvGet(tablespace, KEY_DESTINATION_VAR))));
if (tblIdx != varLstSize(tablespaceSection) - 1)
strCat(backupResult, "\n");
strCat(backupResult, LF_STR);
}
strCat(backupResult, "\n");
strCat(backupResult, LF_STR);
}
}
}
@ -713,13 +714,13 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
if (strSize(archiveResult) > 0 || strSize(backupResult) > 0)
{
if (dbIdx != varLstSize(dbSection) - 1)
strCat(resultStr, "\n db (prior)");
strCatZ(resultStr, "\n db (prior)");
if (strSize(archiveResult) > 0)
strCat(resultStr, strPtr(archiveResult));
strCat(resultStr, archiveResult);
if (strSize(backupResult) > 0)
strCat(resultStr, strPtr(backupResult));
strCat(resultStr, backupResult);
}
}
FUNCTION_TEST_RETURN_VOID();

View File

@ -1249,7 +1249,7 @@ restoreSelectiveExpression(Manifest *manifest)
if (expression == NULL)
expression = strNew("");
else
strCat(expression, "|");
strCatZ(expression, "|");
// Filter files in base directory
strCatFmt(expression, "(^" MANIFEST_TARGET_PGDATA "/" PG_PATH_BASE "/%s/)", strPtr(db));
@ -1535,21 +1535,21 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel)
for (unsigned int contentIdx = 0; contentIdx < strLstSize(contentList); contentIdx++)
{
if (contentIdx != 0)
strCat(content, "\n");
strCat(content, LF_STR);
const String *line = strLstGet(contentList, contentIdx);
if (regExpMatch(recoveryExp, line))
strCatFmt(content, "# Removed by " PROJECT_NAME " restore on %s # ", strPtr(restoreLabel));
strCat(content, strPtr(line));
strCat(content, line);
}
// If settings will be appended then format the file so a blank line will be between old and new settings
if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR))
{
strTrim(content);
strCat(content, "\n\n");
strCatZ(content, "\n\n");
}
}
@ -1837,7 +1837,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
// Note if file was zeroed (i.e. selective restore)
if (zeroed)
strCat(log, " zeroed");
strCatZ(log, " zeroed");
// Add filename
strCatFmt(log, " file %s", strPtr(restoreFilePgPath(manifest, file->name)));
@ -1845,7 +1845,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
// If not copied and not zeroed add details to explain why it was not copied
if (!copy && !zeroed)
{
strCat(log, " - ");
strCatZ(log, " - ");
// On force we match on size and modification time
if (cfgOptionBool(cfgOptForce))
@ -1857,16 +1857,16 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
// Else a checksum delta or file is zero-length
else
{
strCat(log, "exists and ");
strCatZ(log, "exists and ");
// No need to copy zero-length files
if (file->size == 0)
{
strCat(log, "is zero size");
strCatZ(log, "is zero size");
}
// The file matched the manifest checksum so did not need to be copied
else
strCat(log, "matches backup");
strCatZ(log, "matches backup");
}
}

View File

@ -281,7 +281,7 @@ compressExtCat(String *file, CompressType type)
ASSERT(file != NULL);
strCat(file, strPtr(compressExtStr(type)));
strCat(file, compressExtStr(type));
FUNCTION_TEST_RETURN_VOID();
}

View File

@ -142,7 +142,7 @@ exitSafe(int result, bool error, SignalType signalType)
// Terminate from a child
if (signalType == signalTypeNone)
strCat(errorMessage, "from child process");
strCatZ(errorMessage, "from child process");
// Else terminated directly
else
strCatFmt(errorMessage, "[SIG%s]", exitSignalName(signalType));

View File

@ -104,8 +104,8 @@ httpHeaderAdd(HttpHeader *this, const String *key, const String *value)
MEM_CONTEXT_TEMP_BEGIN()
{
String *valueAppend = strDup(varStr(valueVar));
strCat(valueAppend, ", ");
strCat(valueAppend, strPtr(value));
strCatZ(valueAppend, ", ");
strCatZ(valueAppend, strPtr(value));
kvPut(this->kv, keyVar, VARSTR(valueAppend));
}
@ -193,7 +193,7 @@ httpHeaderToLog(const HttpHeader *this)
const String *key = strLstGet(keyList, keyIdx);
if (strSize(result) != 1)
strCat(result, ", ");
strCatZ(result, ", ");
if (httpHeaderRedact(this, key))
strCatFmt(result, "%s: <redacted>", strPtr(key));
@ -201,7 +201,7 @@ httpHeaderToLog(const HttpHeader *this)
strCatFmt(result, "%s: '%s'", strPtr(key), strPtr(httpHeaderGet(this, key)));
}
strCat(result, "}");
strCatZ(result, "}");
return result;
}

View File

@ -143,7 +143,7 @@ httpQueryRender(const HttpQuery *this)
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
{
if (strSize(result) != 0)
strCat(result, "&");
strCatZ(result, "&");
strCatFmt(
result, "%s=%s", strPtr(strLstGet(keyList, keyIdx)),
@ -167,14 +167,14 @@ httpQueryToLog(const HttpQuery *this)
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
{
if (strSize(result) != 1)
strCat(result, ", ");
strCatZ(result, ", ");
strCatFmt(
result, "%s: '%s'", strPtr(strLstGet(keyList, keyIdx)),
strPtr(httpQueryGet(this, strLstGet(keyList, keyIdx))));
}
strCat(result, "}");
strCatZ(result, "}");
return result;
}

View File

@ -466,7 +466,7 @@ bufToLog(const Buffer *this)
if (this->limitSet)
strCatFmt(result, "%zu}", this->limit);
else
strCat(result, "<off>}");
strCatZ(result, "<off>}");
return result;
}

View File

@ -665,7 +665,7 @@ jsonFromStrInternal(String *json, const String *string)
// If string is null
if (string == NULL)
{
strCat(json, NULL_Z);
strCat(json, NULL_STR);
}
// Else escape and output string
else
@ -701,43 +701,43 @@ jsonFromStrInternal(String *json, const String *string)
{
case '"':
{
strCat(json, "\\\"");
strCatZ(json, "\\\"");
break;
}
case '\\':
{
strCat(json, "\\\\");
strCatZ(json, "\\\\");
break;
}
case '\n':
{
strCat(json, "\\n");
strCatZ(json, "\\n");
break;
}
case '\r':
{
strCat(json, "\\r");
strCatZ(json, "\\r");
break;
}
case '\t':
{
strCat(json, "\\t");
strCatZ(json, "\\t");
break;
}
case '\b':
{
strCat(json, "\\b");
strCatZ(json, "\\b");
break;
}
case '\f':
{
strCat(json, "\\f");
strCatZ(json, "\\f");
break;
}
}
@ -805,21 +805,21 @@ jsonFromKvInternal(const KeyValue *kv)
// If going to add another key, prepend a comma
if (keyIdx > 0)
strCat(result, ",");
strCatZ(result, ",");
// Keys are always strings in the output, so add starting quote and colon.
strCatFmt(result, "\"%s\":", strPtr(key));
// NULL value
if (value == NULL)
strCat(result, NULL_Z);
strCat(result, NULL_STR);
else
{
switch (varType(value))
{
case varTypeKeyValue:
{
strCat(result, strPtr(jsonFromKvInternal(kvDup(varKv(value)))));
strCat(result, jsonFromKvInternal(kvDup(varKv(value))));
break;
}
@ -827,12 +827,12 @@ jsonFromKvInternal(const KeyValue *kv)
{
// If the array is empty, then do not add formatting, else process the array.
if (varVarLst(value) == NULL)
strCat(result, NULL_Z);
strCat(result, NULL_STR);
else if (varLstSize(varVarLst(value)) == 0)
strCat(result, "[]");
strCatZ(result, "[]");
else
{
strCat(result, "[");
strCatZ(result, "[");
for (unsigned int arrayIdx = 0; arrayIdx < varLstSize(varVarLst(value)); arrayIdx++)
{
@ -840,12 +840,12 @@ jsonFromKvInternal(const KeyValue *kv)
// If going to add another element, add a comma
if (arrayIdx > 0)
strCat(result, ",");
strCatZ(result, ",");
// If array value is null
if (arrayValue == NULL)
{
strCat(result, NULL_Z);
strCat(result, NULL_STR);
}
// If the type is a string, add leading and trailing double quotes
else if (varType(arrayValue) == varTypeString)
@ -854,18 +854,18 @@ jsonFromKvInternal(const KeyValue *kv)
}
else if (varType(arrayValue) == varTypeKeyValue)
{
strCat(result, strPtr(jsonFromKvInternal(kvDup(varKv(arrayValue)))));
strCat(result, jsonFromKvInternal(kvDup(varKv(arrayValue))));
}
else if (varType(arrayValue) == varTypeVariantList)
{
strCat(result, strPtr(jsonFromVar(arrayValue)));
strCat(result, jsonFromVar(arrayValue));
}
// Numeric, Boolean or other type
else
strCat(result, strPtr(varStrForce(arrayValue)));
strCat(result, varStrForce(arrayValue));
}
strCat(result, "]");
strCatZ(result, "]");
}
break;
@ -880,14 +880,14 @@ jsonFromKvInternal(const KeyValue *kv)
default:
{
strCat(result, strPtr(varStrForce(value)));
strCat(result, varStrForce(value));
break;
}
}
}
}
result = strCat(result, "}");
result = strCatZ(result, "}");
}
MEM_CONTEXT_TEMP_END();
@ -946,19 +946,19 @@ jsonFromVar(const Variant *var)
// If VariantList then process each item in the array. Currently the list must be KeyValue types.
if (var == NULL)
{
strCat(jsonStr, strPtr(NULL_STR));
strCat(jsonStr, NULL_STR);
}
else if (varType(var) == varTypeBool)
{
strCat(jsonStr, strPtr(jsonFromBool(varBool(var))));
strCat(jsonStr, jsonFromBool(varBool(var)));
}
else if (varType(var) == varTypeUInt)
{
strCat(jsonStr, strPtr(jsonFromUInt(varUInt(var))));
strCat(jsonStr, jsonFromUInt(varUInt(var)));
}
else if (varType(var) == varTypeUInt64)
{
strCat(jsonStr, strPtr(jsonFromUInt64(varUInt64(var))));
strCat(jsonStr, jsonFromUInt64(varUInt64(var)));
}
else if (varType(var) == varTypeString)
{
@ -971,63 +971,63 @@ jsonFromVar(const Variant *var)
// If not an empty array
if (varLstSize(vl) > 0)
{
strCat(jsonStr, "[");
strCatZ(jsonStr, "[");
// Currently only KeyValue and String lists are supported
for (unsigned int vlIdx = 0; vlIdx < varLstSize(vl); vlIdx++)
{
// If going to add another key, append a comma
if (vlIdx > 0)
strCat(jsonStr, ",");
strCatZ(jsonStr, ",");
Variant *varSub = varLstGet(vl, vlIdx);
if (varSub == NULL)
{
strCat(jsonStr, NULL_Z);
strCat(jsonStr, NULL_STR);
}
else if (varType(varSub) == varTypeBool)
{
strCat(jsonStr, strPtr(jsonFromBool(varBool(varSub))));
strCat(jsonStr, jsonFromBool(varBool(varSub)));
}
else if (varType(varSub) == varTypeKeyValue)
{
strCat(jsonStr, strPtr(jsonFromKvInternal(varKv(varSub))));
strCat(jsonStr, jsonFromKvInternal(varKv(varSub)));
}
else if (varType(varSub) == varTypeVariantList)
{
strCat(jsonStr, strPtr(jsonFromVar(varSub)));
strCat(jsonStr, jsonFromVar(varSub));
}
else if (varType(varSub) == varTypeInt)
{
strCat(jsonStr, strPtr(jsonFromInt(varInt(varSub))));
strCat(jsonStr, jsonFromInt(varInt(varSub)));
}
else if (varType(varSub) == varTypeInt64)
{
strCat(jsonStr, strPtr(jsonFromInt64(varInt64(varSub))));
strCat(jsonStr, jsonFromInt64(varInt64(varSub)));
}
else if (varType(varSub) == varTypeUInt)
{
strCat(jsonStr, strPtr(jsonFromUInt(varUInt(varSub))));
strCat(jsonStr, jsonFromUInt(varUInt(varSub)));
}
else if (varType(varSub) == varTypeUInt64)
{
strCat(jsonStr, strPtr(jsonFromUInt64(varUInt64(varSub))));
strCat(jsonStr, jsonFromUInt64(varUInt64(varSub)));
}
else
jsonFromStrInternal(jsonStr, varStr(varSub));
}
// Close the array
strCat(jsonStr, "]");
strCatZ(jsonStr, "]");
}
// Else empty array
else
strCat(jsonStr, "[]");
strCatZ(jsonStr, "[]");
}
else if (varType(var) == varTypeKeyValue)
{
strCat(jsonStr, strPtr(jsonFromKvInternal(varKv(var))));
strCat(jsonStr, jsonFromKvInternal(varKv(var)));
}
else
THROW(JsonFormatError, "variant type is invalid");

View File

@ -280,7 +280,21 @@ strResize(String *this, size_t requested)
/**********************************************************************************************************************************/
String *
strCat(String *this, const char *cat)
strCat(String *this, const String *cat)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, this);
FUNCTION_TEST_PARAM(STRING, cat);
FUNCTION_TEST_END();
ASSERT(this != NULL);
ASSERT(cat != NULL);
FUNCTION_TEST_RETURN(strCatZN(this, strPtr(cat), strSize(cat)));
}
String *
strCatZ(String *this, const char *cat)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, this);

View File

@ -84,8 +84,9 @@ String *strBase(const String *this);
bool strBeginsWith(const String *this, const String *beginsWith);
bool strBeginsWithZ(const String *this, const char *beginsWith);
// Append a string
String *strCat(String *this, const char *cat);
// Append a string or zero-terminated string
String *strCat(String *this, const String *cat);
String *strCatZ(String *this, const char *cat);
// Append a character
String *strCatChr(String *this, char cat);

View File

@ -440,10 +440,10 @@ strLstJoinQuote(const StringList *this, const char *separator, const char *quote
for (unsigned int listIdx = 0; listIdx < strLstSize(this); listIdx++)
{
if (listIdx != 0)
strCat(join, separator);
strCatZ(join, separator);
if (strLstGet(this, listIdx) == NULL)
strCat(join, "[NULL]");
strCatZ(join, "[NULL]");
else
strCatFmt(join, "%s%s%s", quote, strPtr(strLstGet(this, listIdx)), quote);
}

View File

@ -302,7 +302,7 @@ cfgLoadLogFile(void)
strCatFmt(logFile, "-%03u", cfgOptionUInt(cfgOptProcess));
// Add extension
strCat(logFile, ".log");
strCatZ(logFile, ".log");
// Attempt to open log file
if (!logFileSet(strPtr(logFile)))

View File

@ -273,8 +273,8 @@ cfgFileLoadPart(String **config, const Buffer *configPart)
else
// Add the config part to the result config file
strCat(*config, "\n");
strCat(*config, strPtr(configPartStr));
strCat(*config, LF_STR);
strCat(*config, configPartStr);
}
}

View File

@ -360,7 +360,7 @@ dbBackupStopQuery(unsigned int pgVersion)
// For PostgreSQL >= 9.6 the backup label and tablespace map are returned from pg_stop_backup
if (pgVersion >= PG_VERSION_96)
{
strCat(
strCatZ(
result,
",\n"
" labelfile::text as backuplabel_file,\n"
@ -368,7 +368,7 @@ dbBackupStopQuery(unsigned int pgVersion)
}
// Build stop backup function
strCat(
strCatZ(
result,
"\n"
" from pg_catalog.pg_stop_backup(");

View File

@ -2866,9 +2866,9 @@ manifestTargetPath(const Manifest *this, const ManifestTarget *target)
String *pgPath = strPath(manifestPathPg(target->name));
if (strSize(pgPath) != 0)
strCat(pgPath, "/");
strCatZ(pgPath, "/");
strCat(pgPath, strPtr(target->path));
strCat(pgPath, target->path);
MEM_CONTEXT_PRIOR_BEGIN()
{

View File

@ -168,8 +168,8 @@ protocolClientProcessError(ProtocolClient *this, KeyValue *errorKv)
{
const String *stack = varStr(kvGet(errorKv, VARSTR(PROTOCOL_ERROR_STACK_STR)));
strCat(throwMessage, "\n");
strCat(throwMessage, stack == NULL ? "no stack trace available" : strPtr(stack));
strCat(throwMessage, LF_STR);
strCat(throwMessage, stack == NULL ? STRDEF("no stack trace available") : stack);
}
THROWP(type, strPtr(throwMessage));

View File

@ -333,7 +333,7 @@ storageS3Request(
strPtr(httpClientResponseMessage(httpClient)));
// Output uri/query
strCat(error, "\n*** URI/Query ***:");
strCatZ(error, "\n*** URI/Query ***:");
strCatFmt(error, "\n%s", strPtr(httpUriEncode(uri, true)));
@ -343,7 +343,7 @@ storageS3Request(
// Output request headers
const StringList *requestHeaderList = httpHeaderList(requestHeader);
strCat(error, "\n*** Request Headers ***:");
strCatZ(error, "\n*** Request Headers ***:");
for (unsigned int requestHeaderIdx = 0; requestHeaderIdx < strLstSize(requestHeaderList); requestHeaderIdx++)
{
@ -361,7 +361,7 @@ storageS3Request(
if (strLstSize(responseHeaderList) > 0)
{
strCat(error, "\n*** Response Headers ***:");
strCatZ(error, "\n*** Response Headers ***:");
for (unsigned int responseHeaderIdx = 0; responseHeaderIdx < strLstSize(responseHeaderList);
responseHeaderIdx++)

View File

@ -321,7 +321,7 @@ hrnLogReplace(void)
strCatFmt(replace, "-%u", index + 1);
}
strCat(replace, "]");
strCatZ(replace, "]");
// Find end of match and calculate size difference from replacement
char *end = begin + strSize(match);

View File

@ -27,7 +27,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
{
case storageTypeFile:
{
strCat(data->content, "file");
strCatZ(data->content, "file");
if (info->level >= storageInfoLevelBasic && !data->sizeOmit)
{
@ -60,13 +60,13 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
case storageTypePath:
{
strCat(data->content, "path");
strCatZ(data->content, "path");
break;
}
case storageTypeSpecial:
{
strCat(data->content, "special");
strCatZ(data->content, "special");
break;
}
}
@ -115,5 +115,5 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
}
}
strCat(data->content, "}\n");
strCatZ(data->content, "}\n");
}

View File

@ -51,7 +51,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
{
case storageTypeFile:
{
strCat(data->content, "file");
strCatZ(data->content, "file");
// Calculate checksum/size and decompress if needed
// ---------------------------------------------------------------------------------------------------------------------
@ -129,7 +129,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
case storageTypePath:
{
strCat(data->content, "path");
strCatZ(data->content, "path");
// Check against the manifest
// ---------------------------------------------------------------------------------------------------------------------
@ -156,7 +156,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
}
}
strCat(data->content, "}\n");
strCatZ(data->content, "}\n");
}
static String *

View File

@ -55,7 +55,7 @@ archiveExpectList(const unsigned int start, unsigned int end, const char *majorW
wal = strNewFmt("%s000000%u-9baedd24b61aa15305732ac678c4e2c102435a09", majorWal, i);
if (strSize(result) == 0)
strCat(result, strPtr(wal));
strCat(result, wal);
else
strCatFmt(result, ", %s", strPtr(wal));
}

View File

@ -99,7 +99,7 @@ testRun(void)
String *string = strNew("XXXX");
String *string2 = strNew("ZZZZ");
TEST_RESULT_STR_Z(strCat(string, "YYYY"), "XXXXYYYY", "cat string");
TEST_RESULT_STR_Z(strCat(string, STRDEF("YYYY")), "XXXXYYYY", "cat string");
TEST_RESULT_UINT(string->extra, 60, "check extra");
TEST_RESULT_STR_Z(strCatFmt(string, "%05d", 777), "XXXXYYYY00777", "cat formatted string");
TEST_RESULT_UINT(string->extra, 55, "check extra");
@ -239,7 +239,7 @@ testRun(void)
TEST_ERROR(strTrunc(val, -1), AssertError, "assertion 'idx >= 0 && (size_t)idx <= this->size' failed");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'd')), "abc", "simple string truncated");
strCat(val, "\r\n to end");
strCatZ(val, "\r\n to end");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'n')), "abc\r\n to e", "complex string truncated");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'a')), "", "complete string truncated - empty string");

View File

@ -513,76 +513,76 @@ testRun(void)
TEST_ERROR(sizeQualifierToMultiplier('w'), AssertError, "'w' is not a valid size qualifier");
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10.0' is not valid");
strTrunc(value, strChr(value, '.'));
strCat(value, "K2");
strCatZ(value, "K2");
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10K2' is not valid");
strTrunc(value, strChr(value, '1'));
strCat(value, "ab");
strCatZ(value, "ab");
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value 'ab' is not valid");
strTrunc(value, strChr(value, 'a'));
strCat(value, "10");
strCatZ(value, "10");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl no character identifier - straight to bytes");
TEST_RESULT_STR_Z(value, "10", "value no character identifier - straight to bytes");
strCat(value, "B");
strCatZ(value, "B");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl B to bytes");
TEST_RESULT_STR_Z(value, "10", "value B to bytes");
strCat(value, "Kb");
strCatZ(value, "Kb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl KB to bytes");
TEST_RESULT_STR_Z(value, "10240", "value KB to bytes");
strTrunc(value, strChr(value, '2'));
strCat(value, "k");
strCatZ(value, "k");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl k to bytes");
TEST_RESULT_STR_Z(value, "10240", "value k to bytes");
strCat(value, "pB");
strCatZ(value, "pB");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11529215046068469760U, "valueDbl Pb to bytes");
TEST_RESULT_STR_Z(value, "11529215046068469760", "value Pb to bytes");
strTrunc(value, strChr(value, '5'));
strCat(value, "GB");
strCatZ(value, "GB");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl GB to bytes");
TEST_RESULT_STR_Z(value, "11811160064", "value GB to bytes");
strTrunc(value, strChr(value, '8'));
strCat(value, "g");
strCatZ(value, "g");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl g to bytes");
TEST_RESULT_STR_Z(value, "11811160064", "value g to bytes");
strTrunc(value, strChr(value, '8'));
strCat(value, "T");
strCatZ(value, "T");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 12094627905536U, "valueDbl T to bytes");
TEST_RESULT_STR_Z(value, "12094627905536", "value T to bytes");
strTrunc(value, strChr(value, '0'));
strCat(value, "tb");
strCatZ(value, "tb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 13194139533312U, "valueDbl tb to bytes");
TEST_RESULT_STR_Z(value, "13194139533312", "value tb to bytes");
strTrunc(value, strChr(value, '3'));
strCat(value, "0m");
strCatZ(value, "0m");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10485760, "valueDbl m to bytes");
TEST_RESULT_STR_Z(value, "10485760", "value m to bytes");
strCat(value, "mb");
strCatZ(value, "mb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10995116277760U, "valueDbl mb to bytes");
TEST_RESULT_STR_Z(value, "10995116277760", "value mb to bytes");
strTrunc(value, strChr(value, '0'));
strCat(value, "99999999999999999999p");
strCatZ(value, "99999999999999999999p");
convertToByte(&value, &valueDbl);
TEST_RESULT_STR_Z(value, "225179981368524800000000000000000000", "value really large to bytes");
}

View File

@ -161,7 +161,7 @@ testRun(void)
for (unsigned int linkIdx = 0; linkIdx < 1; linkIdx++)
strCatFmt(manifestStr, "pg_data/pg_stat%u={\"path\":\"../pg_stat\",\"type\":\"link\"}\n", linkIdx);
strCat(
strCatZ(
manifestStr,
"\n"
"[target:file]\n");
@ -180,7 +180,7 @@ testRun(void)
16384 + fileIdx);
}
strCat(
strCatZ(
manifestStr,
"\n"
"[target:file:default]\n"

View File

@ -39,7 +39,7 @@ testRequest(Storage *s3, const char *verb, const char *uri, TestRequestParam par
verb, uri);
if (param.content != NULL)
strCat(request, "content-md5;");
strCatZ(request, "content-md5;");
strCatFmt(
request,
@ -72,7 +72,7 @@ testRequest(Storage *s3, const char *verb, const char *uri, TestRequestParam par
// Add content
if (param.content != NULL)
strCat(request, param.content);
strCatZ(request, param.content);
hrnTlsServerExpect(request);
}
@ -105,19 +105,19 @@ testResponse(TestResponseParam param)
{
case 200:
{
strCat(response, "OK");
strCatZ(response, "OK");
break;
}
case 403:
{
strCat(response, "Forbidden");
strCatZ(response, "Forbidden");
break;
}
}
// End header
strCat(response, "\r\n");
strCatZ(response, "\r\n");
// Headers
if (param.header != NULL)
@ -134,7 +134,7 @@ testResponse(TestResponseParam param)
strlen(param.content), param.content);
}
else
strCat(response, "\r\n");
strCatZ(response, "\r\n");
hrnTlsServerReply(response);
}