Skip to content

Commit

Permalink
Added path delimiter argument to Con_PrintPathList
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 11, 2011
1 parent 7f844c0 commit 67c1da9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
18 changes: 10 additions & 8 deletions doomsday/engine/portable/include/con_main.h
Expand Up @@ -338,27 +338,29 @@ 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);

/**
* 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);

Expand Down
38 changes: 28 additions & 10 deletions doomsday/engine/portable/src/con_main.c
Expand Up @@ -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");
Expand All @@ -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, ...)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/resourcerecord.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit 67c1da9

Please sign in to comment.