]> git.saurik.com Git - cycript.git/blobdiff - Console.cpp
Identifiers that contain $ should tab-complete :(.
[cycript.git] / Console.cpp
index f9637573b35c4a35a1fdba48d210df3b405f0b44..883f03f0977cbf5b13e150f2b3765e7de73fe297 100644 (file)
@@ -1,5 +1,5 @@
 /* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2014  Jay Freeman (saurik)
+ * Copyright (C) 2009-2015  Jay Freeman (saurik)
 */
 
 /* GNU Affero General Public License, Version 3 {{{ */
@@ -85,7 +85,8 @@ static void sigint(int) {
         case Parsing:
             longjmp(ctrlc_, 1);
         case Running:
-            throw "*** Ctrl-C";
+            CYCancel();
+            return;
         case Sending:
             return;
         case Waiting:
@@ -386,7 +387,7 @@ static char **Complete(const char *word, int start, int end) {
 
 // need char *, not const char *
 static char name_[] = "cycript";
-static char break_[] = " \t\n\"\\'`@$><=;|&{(" ")}" ".:[]";
+static char break_[] = " \t\n\"\\'`@><=;|&{(" ")}" ".:[]";
 
 class History {
   private:
@@ -553,9 +554,9 @@ static void Console(CYOptions &options) {
 
             if (parser.parse() != 0 || !driver.errors_.empty()) {
                 for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) {
-                    cy::position begin(error->location_.begin);
+                    CYPosition begin(error->location_.begin);
                     if (begin.line != lines.size() || begin.column < lines.back().size() || error->warning_) {
-                        cy::position end(error->location_.end);
+                        CYPosition end(error->location_.end);
 
                         if (begin.line != lines.size()) {
                             std::cerr << "  | ";
@@ -608,7 +609,7 @@ static void Console(CYOptions &options) {
     }
 }
 
-void InjectLibrary(pid_t pid);
+void InjectLibrary(pid_t, int, const char *[]);
 
 int Main(int argc, char * const argv[], char const * const envp[]) {
     bool tty(isatty(STDIN_FILENO));
@@ -836,7 +837,14 @@ int Main(int argc, char * const argv[], char const * const envp[]) {
         memset(&address, 0, sizeof(address));
         address.sun_family = AF_UNIX;
 
-        sprintf(address.sun_path, "/tmp/.s.cy.%u", getpid());
+        const char *tmp;
+#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
+        tmp = "/Library/Caches";
+#else
+        tmp = "/tmp";
+#endif
+
+        sprintf(address.sun_path, "%s/.s.cy.%u", tmp, getpid());
         unlink(address.sun_path);
 
         struct File {
@@ -856,7 +864,7 @@ int Main(int argc, char * const argv[], char const * const envp[]) {
         _syscall(chmod(address.sun_path, 0777));
 
         _syscall(listen(server, 1));
-        InjectLibrary(pid);
+        InjectLibrary(pid, 1, (const char *[]) {address.sun_path, NULL});
         client_ = _syscall(accept(server, NULL, NULL));
     }
 #else