- if ((TraceFP == 0) && tracelevel) {
- const char *mode = _nc_globals.init_trace ? "ab" : "wb";
-
- if (TracePath[0] == '\0') {
- size_t size = sizeof(TracePath) - 12;
- if (getcwd(TracePath, size) == 0) {
- perror("curses: Can't get working directory");
- exit(EXIT_FAILURE);
+ if ((MyFP == 0) && tracelevel) {
+ MyInit = TRUE;
+ if (MyFD >= 0) {
+ MyFP = fdopen(MyFD, "wb");
+ } else {
+ if (MyPath[0] == '\0') {
+ size_t size = sizeof(MyPath) - 12;
+ if (getcwd(MyPath, size) == 0) {
+ perror("curses: Can't get working directory");
+ exit(EXIT_FAILURE);
+ }
+ MyPath[size] = '\0';
+ assert(strlen(MyPath) <= size);
+ _nc_STRCAT(MyPath, "/trace", sizeof(MyPath));
+ if (_nc_is_dir_path(MyPath)) {
+ _nc_STRCAT(MyPath, ".log", sizeof(MyPath));
+ }