r11859: Canonicalize whitespace
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 31 Aug 2007 18:04:31 +0000 (18:04 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 31 Aug 2007 18:04:31 +0000 (18:04 +0000)
cl-readline.c
cl-termios.c
packages.lisp
readline.lisp

index 63874f6b7bc4f09cbe3fcd37a673e765ad19696a..3697a7702036cdfbc5e15589853dd026e4c49632 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   Copyright (c) 2003 Nikodemus Siivola
- *   
+ *
  *   Permission is hereby granted, free of charge, to any person obtaining
  *   a copy of this software and associated documentation files (the
  *   "Software"), to deal in the Software without restriction, including
@@ -8,10 +8,10 @@
  *   distribute, sublicense, and/or sell copies of the Software, and to
  *   permit persons to whom the Software is furnished to do so, subject to
  *   the following conditions:
- *   
+ *
  *   The above copyright notice and this permission notice shall be included
  *   in all copies or substantial portions of the Software.
- *   
+ *
  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -43,10 +43,10 @@ add_completion (char * str)
     {
       int cmp = strcmp (str, tmp->str);
       if (0 == cmp)
-       return 1;
-      
+        return 1;
+
       if (0 < cmp)
-       break;
+        break;
 
       /* printf ("-skip- (%s)\n", tmp->str);*/
 
@@ -57,13 +57,13 @@ add_completion (char * str)
   node = malloc (sizeof (node_t));
   if (!node)
     return 0;
-  
+
   node->next = tmp;
   node->str = strdup (str);
 
   if (! pre)
     collection = node;
-  else 
+  else
     pre->next = node;
 
   return 1;
@@ -80,15 +80,15 @@ custom_completer (const char * str, int target)
       root = NULL;
       node_t * tmp = collection;
       while (len && tmp)
-       {
-         if (0 == strncmp (str, tmp->str, len))
-           {         
-             root = tmp;
-             return strdup (root->str);
-           }
-         else
-           tmp = tmp->next;
-       }
+        {
+          if (0 == strncmp (str, tmp->str, len))
+            {
+              root = tmp;
+              return strdup (root->str);
+            }
+          else
+            tmp = tmp->next;
+        }
       return (char *)NULL;
     }
   else if (root && (0 == strncmp (str, root->str, len)))
index cfc9a8b67eb42e5717697b8d21802df16db342f3..221dc63e9ef66ff80d579ef7e1d48e3f251fbefb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   Copyright (c) 2003 Nikodemus Siivola
- *   
+ *
  *   Permission is hereby granted, free of charge, to any person obtaining
  *   a copy of this software and associated documentation files (the
  *   "Software"), to deal in the Software without restriction, including
@@ -8,10 +8,10 @@
  *   distribute, sublicense, and/or sell copies of the Software, and to
  *   permit persons to whom the Software is furnished to do so, subject to
  *   the following conditions:
- *   
+ *
  *   The above copyright notice and this permission notice shall be included
  *   in all copies or substantial portions of the Software.
- *   
+ *
  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -49,13 +49,13 @@ save_term (void)
 
   return 1;
 }
-  
+
 void
 restore_term (void)
 {
   state_t * tmp = stack;
   if (!stack) return;
-  
+
   tcsetattr (STDIN_FILENO, TCSANOW, stack->attr);
   stack = stack->next;
 
@@ -66,8 +66,8 @@ restore_term (void)
 int
 no_echo (void)
 {
-  struct termios attr;  
-  if (! (isatty (STDIN_FILENO) && save_term ())) 
+  struct termios attr;
+  if (! (isatty (STDIN_FILENO) && save_term ()))
     return 0;
 
   tcgetattr (STDIN_FILENO, &attr);
index 51c0b1ae4e3d3dc7d89f3c6102cc083da09ae5e4..cd3ecf1070120e53caa56a783139eca18e18d713 100644 (file)
@@ -1,5 +1,5 @@
 ;; Copyright (c) 2003 Nikodemus Siivola
-;; 
+;;
 ;; Permission is hereby granted, free of charge, to any person obtaining
 ;; a copy of this software and associated documentation files (the
 ;; "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
 ;; distribute, sublicense, and/or sell copies of the Software, and to
 ;; permit persons to whom the Software is furnished to do so, subject to
 ;; the following conditions:
-;; 
+;;
 ;; The above copyright notice and this permission notice shall be included
 ;; in all copies or substantial portions of the Software.
-;; 
+;;
 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -21,7 +21,7 @@
 
 (defpackage readline
   (:nicknames rl)
-  (:use cl uffi)  
+  (:use cl uffi)
   (:export
    add-completion
    add-history
    ))
 
 (uffi:load-foreign-library "/lib/libreadline.so.4"
-                          :module "readline")
+                           :module "readline")
 
 (uffi:load-foreign-library "cl-readline.o"
-                          :module "cl-readline")
+                           :module "cl-readline")
 
 (uffi:load-foreign-library "cl-termios.o"
-                          :module "cl-termios")
+                           :module "cl-termios")
 
index ea2dedef0de5c5794710d9691403208eba6608ce..18b48c08e1a9240ba576cace714238999c1b5ed2 100644 (file)
@@ -1,5 +1,5 @@
 ;; Copyright (c) 2003 Nikodemus Siivola
-;; 
+;;
 ;; Permission is hereby granted, free of charge, to any person obtaining
 ;; a copy of this software and associated documentation files (the
 ;; "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
 ;; distribute, sublicense, and/or sell copies of the Software, and to
 ;; permit persons to whom the Software is furnished to do so, subject to
 ;; the following conditions:
-;; 
+;;
 ;; The above copyright notice and this permission notice shall be included
 ;; in all copies or substantial portions of the Software.
-;; 
+;;
 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -18,7 +18,7 @@
 ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 (in-package readline)
 
 (defvar *whitespace* (list #\Space #\Tab))
@@ -31,8 +31,8 @@
 (defmacro ignore-end-of-file (&body forms)
   `(catch 'end-of-file
     (handler-bind ((end-of-file (lambda (e)
-                                 (declare (ignore e))
-                                 (throw 'end-of-file nil))))
+                                  (declare (ignore e))
+                                  (throw 'end-of-file nil))))
       ,@forms)))
 
 (def-function ("readline" c-readline)
@@ -66,7 +66,7 @@
   :returning :void)
 
 (let (pkg)
-  
+
   (defun add-completion (string)
     "Add STRING as a custom-completion."
     (setq pkg nil)
     "Clear all custom-completions."
     (setq pkg nil)
     (c-clear-completions))
-  
+
   (defun use-package-complete (package)
     "Load symbols in package CL-USER as custom-completions."
     (unless (eql pkg package)
       (setq pkg package)
       (clear-completions)
       (do-symbols (sym (find-package package))
-       (add-completion (string-downcase (string sym)))))
+        (add-completion (string-downcase (string sym)))))
     (use-custom-complete)
     nil))
 
   (with-cstring (c-string string)
     (c-add-history c-string))
   string)
-  
+
 (defun readline (&key (prompt "") (history t))
   "Read a line from current TTY with line-editing."
   (with-cstring (c-prompt prompt)
     (let* ((str (convert-and-free-foreign-string (c-readline c-prompt)))
-          (str2 (string-trim *whitespace* str)))
+           (str2 (string-trim *whitespace* str)))
       (when (and history (not (string= "" str2)))
-       (add-history str2))
+        (add-history str2))
       str)))
 
 (defun readexpr (&key
-                (primary-prompt "=> ")
-                (secondary-prompt "|     ")
-                (history t))
+                 (primary-prompt "=> ")
+                 (secondary-prompt "|     ")
+                 (history t))
   "Read an expression from current TTY with line-editing."
   (let (expr)
     (do* ((str (readline :prompt primary-prompt :history history)
-              (readline :prompt secondary-prompt :history history))
-         (input str (concatenate 'string input " " str)))
-        ((ignore-end-of-file
-          (setq expr (with-input-from-string (in input)
-                       (read in nil nil))))
-         expr))))
+               (readline :prompt secondary-prompt :history history))
+          (input str (concatenate 'string input " " str)))
+         ((ignore-end-of-file
+           (setq expr (with-input-from-string (in input)
+                        (read in nil nil))))
+          expr))))
 
 ;;
 ;; Termios