File src/menus/menus.c changed (mode: 100644) (index 71c04713d..5fa0586fe) |
... |
... |
parse_spec(const char spec[], int *line_num) |
493 |
493 |
{ |
{ |
494 |
494 |
char *path_buf; |
char *path_buf; |
495 |
495 |
const char *colon; |
const char *colon; |
|
496 |
|
int colon_lookup_offset = 0; |
496 |
497 |
const size_t bufs_len = 2 + strlen(spec) + 1 + 1; |
const size_t bufs_len = 2 + strlen(spec) + 1 + 1; |
497 |
498 |
|
|
498 |
499 |
path_buf = malloc(bufs_len); |
path_buf = malloc(bufs_len); |
|
... |
... |
parse_spec(const char spec[], int *line_num) |
510 |
511 |
copy_str(path_buf, bufs_len, "./"); |
copy_str(path_buf, bufs_len, "./"); |
511 |
512 |
} |
} |
512 |
513 |
|
|
513 |
|
colon = strchr(spec, ':'); |
|
|
514 |
|
#ifdef _WIN32 |
|
515 |
|
if(is_path_absolute(spec)) |
|
516 |
|
{ |
|
517 |
|
colon_lookup_offset = 2; |
|
518 |
|
} |
|
519 |
|
#endif |
|
520 |
|
|
|
521 |
|
colon = strchr(spec + colon_lookup_offset, ':'); |
514 |
522 |
if(colon != NULL) |
if(colon != NULL) |
515 |
523 |
{ |
{ |
516 |
524 |
strncat(path_buf, spec, colon - spec); |
strncat(path_buf, spec, colon - spec); |
File tests/misc/parse_spec.c changed (mode: 100644) (index a05ef5163..d7752864e) |
... |
... |
test_relative_path_with_linenum(void) |
80 |
80 |
|
|
81 |
81 |
#ifdef _WIN32 |
#ifdef _WIN32 |
82 |
82 |
|
|
|
83 |
|
static void |
|
84 |
|
test_win_absolute_path_without_linenum(void) |
|
85 |
|
{ |
|
86 |
|
int line_num; |
|
87 |
|
char *const path = parse_spec("c:/home/user", &line_num); |
|
88 |
|
|
|
89 |
|
assert_string_equal("c:/home/user", path); |
|
90 |
|
assert_int_equal(DEFAULT_LINENUM, line_num); |
|
91 |
|
|
|
92 |
|
free(path); |
|
93 |
|
} |
|
94 |
|
|
|
95 |
|
static void |
|
96 |
|
test_win_absolute_path_with_linenum(void) |
|
97 |
|
{ |
|
98 |
|
int line_num; |
|
99 |
|
char *const path = parse_spec("c:/home/user:1234", &line_num); |
|
100 |
|
|
|
101 |
|
assert_string_equal("c:/home/user", path); |
|
102 |
|
assert_int_equal(1234, line_num); |
|
103 |
|
|
|
104 |
|
free(path); |
|
105 |
|
} |
|
106 |
|
|
83 |
107 |
static void |
static void |
84 |
108 |
test_win_relative_path_without_linenum(void) |
test_win_relative_path_without_linenum(void) |
85 |
109 |
{ |
{ |
|
... |
... |
parse_spec_tests(void) |
118 |
142 |
run_test(test_relative_path_without_linenum); |
run_test(test_relative_path_without_linenum); |
119 |
143 |
run_test(test_relative_path_with_linenum); |
run_test(test_relative_path_with_linenum); |
120 |
144 |
#ifdef _WIN32 |
#ifdef _WIN32 |
|
145 |
|
run_test(test_win_absolute_path_without_linenum); |
|
146 |
|
run_test(test_win_absolute_path_with_linenum); |
121 |
147 |
run_test(test_win_relative_path_without_linenum); |
run_test(test_win_relative_path_without_linenum); |
122 |
148 |
run_test(test_win_relative_path_with_linenum); |
run_test(test_win_relative_path_with_linenum); |
123 |
149 |
#endif |
#endif |