ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/src/vendor/xz/5.0.7/src/xz/suffix.c
(Generate patch)

Comparing branches/TUKAANI/contrib/xz/src/xz/suffix.c (file contents):
Revision 3411 by laffer1, Wed Jun 16 12:26:20 2010 UTC vs.
Revision 3837 by laffer1, Tue Mar 8 03:55:29 2011 UTC

# Line 27 | Line 27 | struct suffix_pair {
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
# Line 44 | Line 68 | test_suffix(const char *suffix, const char *src_name,
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)
# Line 199 | Line 224 | suffix_get_dest_name(const char *src_name)
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.

Comparing branches/TUKAANI/contrib/xz/src/xz/suffix.c (property cvs2svn:cvs-rev):
Revision 3411 by laffer1, Wed Jun 16 12:26:20 2010 UTC vs.
Revision 3837 by laffer1, Tue Mar 8 03:55:29 2011 UTC

# Line 1 | Line 1
1 < 1.1.1.1
1 > 1.1.1.2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines