Merge: Activate C warnings in FFI code and revert `NativeString` to `char *`
authorJean Privat <jean@pryen.org>
Wed, 10 Jun 2015 01:47:19 +0000 (21:47 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 Jun 2015 01:47:19 +0000 (21:47 -0400)
The revert commit is partial, it affects only NativeString and does not touch Char.

Pull-Request: #1451
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

1  2 
lib/standard/file.nit

diff --combined lib/standard/file.nit
@@@ -767,12 -767,11 +767,12 @@@ redef class Strin
                return res
        end
  
 -      # Simplify a file path by remove useless ".", removing "//", and resolving ".."
 +      # Simplify a file path by remove useless `.`, removing `//`, and resolving `..`
        #
 -      # * ".." are not resolved if they start the path
 -      # * starting "/" is not removed
 -      # * trailing "/" is removed
 +      # * `..` are not resolved if they start the path
 +      # * starting `.` is simplified unless the path is empty
 +      # * starting `/` is not removed
 +      # * trailing `/` is removed
        #
        # Note that the method only work on the string:
        #
        # assert "dir/..".simplify_path            ==  "."
        # assert "//absolute//path/".simplify_path ==  "/absolute/path"
        # assert "//absolute//../".simplify_path   ==  "/"
 +      # assert "/".simplify_path                 == "/"
 +      # assert "../".simplify_path               == ".."
 +      # assert "./".simplify_path                == "."
 +      # assert "././././././".simplify_path      == "."
 +      # assert "./../dir".simplify_path                  == "../dir"
 +      # assert "./dir".simplify_path                     == "dir"
        # ~~~
        fun simplify_path: String
        do
                var a = self.split_with("/")
                var a2 = new Array[String]
                for x in a do
 -                      if x == "." then continue
 -                      if x == "" and not a2.is_empty then continue
 +                      if x == "." and not a2.is_empty then continue # skip `././`
 +                      if x == "" and not a2.is_empty then continue # skip `//`
                        if x == ".." and not a2.is_empty and a2.last != ".." then
 -                              a2.pop
 -                              continue
 +                              if a2.last == "." then # do not skip `./../`
 +                                      a2.pop # reduce `./../` in `../`
 +                              else # reduce `dir/../` in `/`
 +                                      a2.pop
 +                                      continue
 +                              end
 +                      else if not a2.is_empty and a2.last == "." then
 +                              a2.pop # reduce `./dir` in `dir`
                        end
                        a2.push(x)
                end
@@@ -1195,7 -1182,6 +1195,6 @@@ redef class Sy
        private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]) : nullable Int is extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{
                int in_len, out_len, total_len;
                struct pollfd *c_fds;
-               sigset_t sigmask;
                int i;
                int first_polled_fd = -1;
                int result;