| @@ -34,6 +34,8 @@ typedef void (*TTL_Generator_Function)(const char* basename); | |||||
| static int isPathSeparator(char c); | static int isPathSeparator(char c); | ||||
| static char* makeNormalPath(const char* path); | static char* makeNormalPath(const char* path); | ||||
| // TODO support Unicode paths on the Windows platform | |||||
| int main(int argc, char* argv[]) | int main(int argc, char* argv[]) | ||||
| { | { | ||||
| if (argc != 2) | if (argc != 2) | ||||
| @@ -68,18 +70,23 @@ int main(int argc, char* argv[]) | |||||
| if (ttlFn != NULL) | if (ttlFn != NULL) | ||||
| { | { | ||||
| // convert the paths to a normalized form, such that path separators are | |||||
| // replaced with '/', and duplicate separators are removed | |||||
| char* normalPath = makeNormalPath(path); | char* normalPath = makeNormalPath(path); | ||||
| // get rid of any "./" prefixes | |||||
| path = normalPath; | path = normalPath; | ||||
| while (path[0] == '.' && path[1] == '/') | while (path[0] == '.' && path[1] == '/') | ||||
| path += 2; | path += 2; | ||||
| // extract the file name part | |||||
| char* basename = strrchr(path, '/'); | char* basename = strrchr(path, '/'); | ||||
| if (basename != NULL) | if (basename != NULL) | ||||
| basename += 1; | basename += 1; | ||||
| else | else | ||||
| basename = (char*)path; | basename = (char*)path; | ||||
| // remove the file extension | |||||
| char* dotPos = strrchr(basename, '.'); | char* dotPos = strrchr(basename, '.'); | ||||
| if (dotPos) | if (dotPos) | ||||
| *dotPos = '\0'; | *dotPos = '\0'; | ||||