From f03d3810925b256290ffc139104b3c02c7655f76 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 28 Jan 2013 11:51:36 -0500 Subject: [PATCH] Fix indentation in unix command-line tool and also make sure to not use strcat for our logfile since it messes up the compressed image output. --- CLTool/src/clunix.cpp | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/CLTool/src/clunix.cpp b/CLTool/src/clunix.cpp index 18d0da2..508a160 100644 --- a/CLTool/src/clunix.cpp +++ b/CLTool/src/clunix.cpp @@ -55,18 +55,18 @@ void PrintUsage() { } void ExtractBasename(const char *filename, char *buf, int bufSz) { - int len = strlen(filename); - const char *end = filename + len; - while(--end != filename) { - if(*end == '.') - { - int numChars = end - filename + 1; - int toCopy = (numChars > bufSz)? bufSz : numChars; - memcpy(buf, filename, toCopy); - buf[toCopy - 1] = '\0'; - return; - } - } + int len = strlen(filename); + const char *end = filename + len; + while(--end != filename) { + if(*end == '.') + { + int numChars = end - filename + 1; + int toCopy = (numChars > bufSz)? bufSz : numChars; + memcpy(buf, filename, toCopy); + buf[toCopy - 1] = '\0'; + return; + } + } } int main(int argc, char **argv) { @@ -161,16 +161,16 @@ int main(int argc, char **argv) { exit(1); } - char basename[256]; - ExtractBasename(argv[fileArg], basename, 256); + char basename[256]; + ExtractBasename(argv[fileArg], basename, 256); ImageFile file (argv[fileArg]); - if(!file.Load()) { + if(!file.Load()) { fprintf(stderr, "Error loading file: %s\n", argv[fileArg]); return 1; - } + } - const Image *img = file.GetImage(); + const Image *img = file.GetImage(); int numBlocks = (img->GetWidth() * img->GetHeight())/16; BlockStatManager *statManager = NULL; @@ -201,12 +201,14 @@ int main(int argc, char **argv) { } if(bSaveLog) { - statManager->ToFile(strcat(basename, ".log")); + char logname[256]; + sprintf(logname, "%s.log", basename); + statManager->ToFile(logname); } - Image cImg (*ci); - ImageFile cImgFile (strcat(basename, "-bc7.png"), eFileFormat_PNG, cImg); - cImgFile.Write(); + Image cImg (*ci); + ImageFile cImgFile (strcat(basename, "-bc7.png"), eFileFormat_PNG, cImg); + cImgFile.Write(); // Cleanup delete ci;