Mercurial > hg > nnchat
comparison main.c @ 551:89fafb218396
Fix situations where the log path is unset.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 12 Nov 2012 18:32:08 +0200 |
parents | 504a8b9297a3 |
children | dfe46cd1b81b |
comparison
equal
deleted
inserted
replaced
550:504a8b9297a3 | 551:89fafb218396 |
---|---|
1509 char *path = NULL; | 1509 char *path = NULL; |
1510 | 1510 |
1511 if (!optLogEnable) | 1511 if (!optLogEnable) |
1512 return FALSE; | 1512 return FALSE; |
1513 | 1513 |
1514 th_free(win->logFilename); | |
1515 win->logFilename = NULL; | |
1516 | |
1517 if (optLogPath != NULL) | 1514 if (optLogPath != NULL) |
1518 { | 1515 { |
1519 char *lt = strrchr(optLogPath, SET_DIR_SEPARATOR); | 1516 char *lt = strrchr(optLogPath, SET_DIR_SEPARATOR); |
1520 if (lt == NULL || lt[1] != 0) | 1517 if (lt == NULL || lt[1] != 0) |
1521 path = th_strdup_printf("%s%c", optLogPath, SET_DIR_SEPARATOR); | 1518 path = th_strdup_printf("%s%c", optLogPath, SET_DIR_SEPARATOR); |
1524 } | 1521 } |
1525 | 1522 |
1526 if (win->id == NULL) | 1523 if (win->id == NULL) |
1527 { | 1524 { |
1528 win->logFilename = th_strdup_printf("%sroom_%d%s", | 1525 win->logFilename = th_strdup_printf("%sroom_%d%s", |
1529 path, optPort, optLogExtension); | 1526 path != NULL ? path : "", optPort, optLogExtension); |
1530 } | 1527 } |
1531 else | 1528 else |
1532 { | 1529 { |
1533 size_t pos; | 1530 size_t pos; |
1534 char *cleaned; | 1531 char *cleaned; |
1540 { | 1537 { |
1541 if (!isalnum(cleaned[pos])) | 1538 if (!isalnum(cleaned[pos])) |
1542 cleaned[pos] = '_'; | 1539 cleaned[pos] = '_'; |
1543 } | 1540 } |
1544 | 1541 |
1545 win->logFilename = th_strdup_printf("%s%s%s", path, cleaned, optLogExtension); | 1542 win->logFilename = th_strdup_printf("%s%s%s", |
1543 path != NULL ? path : "", cleaned, optLogExtension); | |
1544 | |
1546 th_free(cleaned); | 1545 th_free(cleaned); |
1547 } | 1546 } |
1548 | 1547 |
1549 if (win->logFilename == NULL) | 1548 if (win->logFilename == NULL) |
1550 goto error; | 1549 goto error; |