27 |
|
}; |
28 |
|
|
29 |
|
|
30 |
+ |
/// \brief Test if the char is a directory separator |
31 |
+ |
static bool |
32 |
+ |
is_dir_sep(char c) |
33 |
+ |
{ |
34 |
+ |
#ifdef TUKLIB_DOSLIKE |
35 |
+ |
return c == '/' || c == '\\' || c == ':'; |
36 |
+ |
#else |
37 |
+ |
return c == '/'; |
38 |
+ |
#endif |
39 |
+ |
} |
40 |
+ |
|
41 |
+ |
|
42 |
+ |
/// \brief Test if the string contains a directory separator |
43 |
+ |
static bool |
44 |
+ |
has_dir_sep(const char *str) |
45 |
+ |
{ |
46 |
+ |
#ifdef TUKLIB_DOSLIKE |
47 |
+ |
return strpbrk(str, "/\\:") != NULL; |
48 |
+ |
#else |
49 |
+ |
return strchr(str, '/') != NULL; |
50 |
+ |
#endif |
51 |
+ |
} |
52 |
+ |
|
53 |
+ |
|
54 |
|
/// \brief Checks if src_name has given compressed_suffix |
55 |
|
/// |
56 |
|
/// \param suffix Filename suffix to look for |
68 |
|
// The filename must have at least one character in addition to |
69 |
|
// the suffix. src_name may contain path to the filename, so we |
70 |
|
// need to check for directory separator too. |
71 |
< |
if (src_len <= suffix_len || src_name[src_len - suffix_len - 1] == '/') |
71 |
> |
if (src_len <= suffix_len |
72 |
> |
|| is_dir_sep(src_name[src_len - suffix_len - 1])) |
73 |
|
return 0; |
74 |
|
|
75 |
|
if (strcmp(suffix, src_name + src_len - suffix_len) == 0) |
224 |
|
extern void |
225 |
|
suffix_set(const char *suffix) |
226 |
|
{ |
227 |
< |
// Empty suffix and suffixes having a slash are rejected. Such |
228 |
< |
// suffixes would break things later. |
229 |
< |
if (suffix[0] == '\0' || strchr(suffix, '/') != NULL) |
227 |
> |
// Empty suffix and suffixes having a directory separator are |
228 |
> |
// rejected. Such suffixes would break things later. |
229 |
> |
if (suffix[0] == '\0' || has_dir_sep(suffix)) |
230 |
|
message_fatal(_("%s: Invalid filename suffix"), optarg); |
231 |
|
|
232 |
|
// Replace the old custom_suffix (if any) with the new suffix. |