adb/base: minor compiler portability improvements

I've been using these changes to compile with Visual Studio.

- GetFileBasename(): __FILE__ uses \ with Visual Studio.

- adb_trace.cpp: Apparently VS needs an ampersand before the function name.

- "expr1 ? : expr2" is a GCC extension.

- <algorithm> contains std::min().

- seekdir can't always be #define'd because some headers have members
  named seekdir.

- adb_utils.cpp: Not really a compiler issue, just a random fix:
  0x7F/DEL is not printable.

Change-Id: I0dfb634f1ba4ccbc0d1b9f71b00e838fbebb3b41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/adb/adb_trace.cpp b/adb/adb_trace.cpp
index 9586f7c..cf99df7 100644
--- a/adb/adb_trace.cpp
+++ b/adb/adb_trace.cpp
@@ -163,7 +163,7 @@
     }
 #endif
 
-    android::base::InitLogging(argv, AdbLogger);
+    android::base::InitLogging(argv, &AdbLogger);
     setup_trace_mask();
 
     VLOG(ADB) << adb_version();
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index fd61bda..42f1c7d 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -182,11 +182,8 @@
     line.push_back(' ');
 
     for (size_t i = 0; i < byte_count; ++i) {
-        int c = p[i];
-        if (c < 32 || c > 127) {
-            c = '.';
-        }
-        line.push_back(c);
+        int ch = p[i];
+        line.push_back(isprint(ch) ? ch : '.');
     }
 
     return line;
diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp
index 7f34ade..268a11f 100644
--- a/adb/file_sync_client.cpp
+++ b/adb/file_sync_client.cpp
@@ -753,7 +753,7 @@
     umask(mask);
     int r2 = chmod(lpath, mode & ~mask);
 
-    return r1 ? : r2;
+    return r1 ? r1 : r2;
 }
 
 static bool copy_remote_dir_local(SyncConnection& sc, std::string rpath,
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index f8c2f64..eb0ce85 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <algorithm>
+
 #if !ADB_HOST
 #include "cutils/properties.h"
 #endif
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 1735627..9f4012a 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -309,7 +309,12 @@
 #define closedir adb_closedir
 #define rewinddir rewinddir_utf8_not_yet_implemented
 #define telldir telldir_utf8_not_yet_implemented
-#define seekdir seekdir_utf8_not_yet_implemented
+// Some compiler's C++ headers have members named seekdir, so we can't do the
+// macro technique and instead cause a link error if seekdir is called.
+inline void seekdir(DIR*, long) {
+    extern int seekdir_utf8_not_yet_implemented;
+    seekdir_utf8_not_yet_implemented = 1;
+}
 
 #define utime adb_utime
 #define chmod adb_chmod
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 9d50854..4066889 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <algorithm>
 #include <list>
 
 #include <base/logging.h>