Skip to content

Commit 7dd1248

Browse files
author
Andi Gutmans
committed
- Clean up mess made by netware guys. There's no reason not to abstract
- the macro a tiny bit more allowing the code to look cleaner. The more - #ifdef's code has the more unreadable it becomes.
1 parent e66a760 commit 7dd1248

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

TSRM/tsrm_virtual_cwd.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
360360
fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
361361
#endif
362362
if (IS_ABSOLUTE_PATH(path_copy, path_length)) {
363-
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
364-
#ifndef NETWARE
365-
copy_amount = COPY_WHEN_ABSOLUTE;
366-
#else
367363
copy_amount = COPY_WHEN_ABSOLUTE(path_copy);
368-
#endif
369364
is_absolute = 1;
370365
#ifdef TSRM_WIN32
371366
} else if (IS_UNC_PATH(path_copy, path_length)) {
@@ -438,12 +433,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
438433
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
439434
}
440435

441-
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
442-
#ifndef NETWARE
443-
if (state->cwd_length == COPY_WHEN_ABSOLUTE) {
444-
#else
445436
if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
446-
#endif
447437
state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
448438
state->cwd[state->cwd_length] = DEFAULT_SLASH;
449439
state->cwd[state->cwd_length+1] = '\0';
@@ -493,12 +483,7 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
493483
return -1;
494484
}
495485

496-
/* COPY_WHEN_ABSOLUTE needs to account for volume name that is unique to NetWare absolute paths */
497-
#ifndef NETWARE
498-
if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
499-
#else
500486
if (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
501-
#endif
502487
length++;
503488
}
504489
temp = (char *) tsrm_do_alloca(length+1);

TSRM/tsrm_virtual_cwd.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ typedef unsigned short mode_t;
5252
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
5353
#define IS_SLASH_P(c) (*(c) == '/' || \
5454
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
55-
#define COPY_WHEN_ABSOLUTE 2
55+
56+
/* COPY_WHEN_ABSOLUTE also takes path as argument because netware needs it
57+
/* to account for volume name that is unique to NetWare absolute paths
58+
*/
59+
#define COPY_WHEN_ABSOLUTE(path) 2
5660
#define IS_ABSOLUTE_PATH(path, len) \
5761
(len >= 2 && isalpha(path[0]) && path[1] == ':')
5862
#define IS_UNC_PATH(path, len) \
@@ -91,7 +95,7 @@ typedef unsigned short mode_t;
9195

9296

9397
#ifndef COPY_WHEN_ABSOLUTE
94-
#define COPY_WHEN_ABSOLUTE 0
98+
#define COPY_WHEN_ABSOLUTE(path) 0
9599
#endif
96100

97101
#ifndef IS_ABSOLUTE_PATH

0 commit comments

Comments
 (0)