From 67c1da9ab7e96cf76ab0d5d2c2b92d00ea819901 Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 11 Sep 2011 03:34:41 +0100 Subject: [PATCH] Added path delimiter argument to Con_PrintPathList --- doomsday/engine/portable/include/con_main.h | 18 +++++---- doomsday/engine/portable/src/con_main.c | 38 ++++++++++++++----- doomsday/engine/portable/src/resourcerecord.c | 2 +- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/doomsday/engine/portable/include/con_main.h b/doomsday/engine/portable/include/con_main.h index 1320d04a2d..235cfa3a2b 100644 --- a/doomsday/engine/portable/include/con_main.h +++ b/doomsday/engine/portable/include/con_main.h @@ -338,18 +338,20 @@ void Con_PrintRuler(void); #define PPF_TRANSFORM_PATH_PRINTINDEX 0x4 // Print an index for each path. /*}@*/ +#define DEFAULT_PRINTPATHFLAGS (PPF_MULTILINE|PPF_TRANSFORM_PATH_MAKEPRETTY|PPF_TRANSFORM_PATH_PRINTINDEX) + /** * Prints the passed path list to the console. * * \todo treat paths as URIs (i.e., resolve symbols). * - * @param pathList A series of textual file/resource names/paths separated - * by semicolons. - * @param flags @see printPathFlags. + * @param pathList A series of file/resource names/paths separated by @a delimiter. + * @param flags @see printPathFlags. */ -void Con_PrintPathList3(const char* pathList, const char* seperator, int flags); -void Con_PrintPathList2(const char* pathList, const char* seperator); -void Con_PrintPathList(const char* pathList); +void Con_PrintPathList4(const char* pathList, char delimiter, const char* seperator, int flags); +void Con_PrintPathList3(const char* pathList, char delimiter, const char* seperator); /* flags = DEFAULT_PRINTPATHFLAGS */ +void Con_PrintPathList2(const char* pathList, char delimiter); /* seperator = " " */ +void Con_PrintPathList(const char* pathList); /* delimiter = ';' */ void Con_PrintCVar(cvar_t* cvar, char* prefix); @@ -357,8 +359,8 @@ void Con_PrintCVar(cvar_t* cvar, char* prefix); * Outputs the usage information for the given ccmd to the console if the * ccmd's usage is validated by Doomsday. * - * @param ccmd Ptr to the ccmd to print the usage info for. - * @param printInfo If @c true, print any additional info we have. + * @param ccmd Ptr to the ccmd to print the usage info for. + * @param printInfo If @c true, print any additional info we have. */ void Con_PrintCCmdUsage(ccmd_t* ccmd, boolean printInfo); diff --git a/doomsday/engine/portable/src/con_main.c b/doomsday/engine/portable/src/con_main.c index 68c9844e96..f364bb054f 100644 --- a/doomsday/engine/portable/src/con_main.c +++ b/doomsday/engine/portable/src/con_main.c @@ -1822,21 +1822,34 @@ void Con_FPrintf(int flags, const char* format, ...) va_end(args);} } -void Con_PrintPathList3(const char* pathList, const char* seperator, int flags) +static void printListPath(const ddstring_t* path, int flags, int index) +{ + assert(path); + if(flags & PPF_TRANSFORM_PATH_PRINTINDEX) + Con_Printf("%i: ", index); + Con_Printf("%s", (flags & PPF_TRANSFORM_PATH_MAKEPRETTY)? F_PrettyPath(Str_Text(path)) : Str_Text(path)); +} + +void Con_PrintPathList4(const char* pathList, char delimiter, const char* seperator, int flags) { assert(pathList && pathList[0]); { const char* p = pathList; ddstring_t path; int n = 0; - Str_Init(&path); - while((p = Str_CopyDelim2(&path, p, ';', CDF_OMIT_DELIMITER))) + while((p = Str_CopyDelim2(&path, p, delimiter, CDF_OMIT_DELIMITER))) + { + printListPath(&path, flags, n++); + if(seperator && !(flags & PPF_MULTILINE) && strchr(p, delimiter) != 0) + Con_Printf("%s", seperator); + if(flags & PPF_MULTILINE) + Con_Printf("\n"); + } + if(Str_Length(&path) != 0) { - if(flags & PPF_TRANSFORM_PATH_PRINTINDEX) - Con_Printf("%i: ", n++); - Con_Printf("%s", (flags & PPF_TRANSFORM_PATH_MAKEPRETTY)? F_PrettyPath(Str_Text(&path)) : Str_Text(&path)); - if(seperator && !(flags & PPF_MULTILINE) && strchr(p, ';') != 0) + printListPath(&path, flags, n++); + if(seperator && !(flags & PPF_MULTILINE) && strchr(p, delimiter) != 0) Con_Printf("%s", seperator); if(flags & PPF_MULTILINE) Con_Printf("\n"); @@ -1845,14 +1858,19 @@ void Con_PrintPathList3(const char* pathList, const char* seperator, int flags) } } -void Con_PrintPathList2(const char* pathList, const char* seperator) +void Con_PrintPathList3(const char* pathList, char delimiter, const char* seperator) +{ + Con_PrintPathList4(pathList, delimiter, seperator, DEFAULT_PRINTPATHFLAGS); +} + +void Con_PrintPathList2(const char* pathList, char delimiter) { - Con_PrintPathList3(pathList, seperator, PPF_MULTILINE|PPF_TRANSFORM_PATH_MAKEPRETTY|PPF_TRANSFORM_PATH_PRINTINDEX); + Con_PrintPathList3(pathList, delimiter, " "); } void Con_PrintPathList(const char* pathList) { - Con_PrintPathList2(pathList, " "); + Con_PrintPathList2(pathList, ';'); } void Con_Message(const char *message, ...) diff --git a/doomsday/engine/portable/src/resourcerecord.c b/doomsday/engine/portable/src/resourcerecord.c index 143e043998..12fa2fd1e2 100644 --- a/doomsday/engine/portable/src/resourcerecord.c +++ b/doomsday/engine/portable/src/resourcerecord.c @@ -203,7 +203,7 @@ void ResourceRecord_Print(resourcerecord_t* rec, boolean printStatus) if(printStatus) Con_Printf("%s", rec->_searchPathUsed == 0? " ! ":" "); - Con_PrintPathList3(Str_Text(searchPaths), " or ", PPF_TRANSFORM_PATH_MAKEPRETTY); + Con_PrintPathList4(Str_Text(searchPaths), ';', " or ", PPF_TRANSFORM_PATH_MAKEPRETTY); if(printStatus) {