Show
Ignore:
Timestamp:
09/09/06 16:30:10 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/pgg-gpg.el

    r4058 r4161  
    7575         (orig-mode (default-file-modes)) 
    7676         (process-connection-type nil) 
    77          exit-status) 
     77         (inhibit-redisplay t) 
     78         process status exit-status 
     79         passphrase-with-newline 
     80         encoded-passphrase-with-new-line) 
    7881    (with-current-buffer (get-buffer-create errors-buffer) 
    7982      (buffer-disable-undo) 
     
    8285        (progn 
    8386          (set-default-file-modes 448) 
    84           (let ((coding-system-for-write 'binary) 
    85                 (input (buffer-substring-no-properties start end)) 
    86                 (default-enable-multibyte-characters nil)) 
    87             (with-temp-buffer 
    88               (when passphrase 
    89                 (insert passphrase "\n")) 
    90               (insert input) 
    91               (setq exit-status 
    92                     (apply #'call-process-region (point-min) (point-max) program 
    93                            nil errors-buffer nil args)))) 
     87          (let ((coding-system-for-write 'binary)) 
     88            (setq process 
     89                  (apply #'start-process "*GnuPG*" errors-buffer 
     90                         program args))) 
     91          (set-process-sentinel process #'ignore) 
     92          (when passphrase 
     93            (setq passphrase-with-newline (concat passphrase "\n")) 
     94            (if pgg-passphrase-coding-system 
     95                (progn 
     96                  (setq encoded-passphrase-with-new-line 
     97                        (encode-coding-string passphrase-with-newline 
     98                                              pgg-passphrase-coding-system)) 
     99                  (pgg-clear-string passphrase-with-newline)) 
     100              (setq encoded-passphrase-with-new-line passphrase-with-newline 
     101                    passphrase-with-newline nil)) 
     102            (process-send-string process encoded-passphrase-with-new-line)) 
     103          (process-send-region process start end) 
     104          (process-send-eof process) 
     105          (while (eq 'run (process-status process)) 
     106            (accept-process-output process 5)) 
     107          (setq status (process-status process) 
     108                exit-status (process-exit-status process)) 
     109          (delete-process process) 
    94110          (with-current-buffer (get-buffer-create output-buffer) 
    95111            (buffer-disable-undo) 
     
    101117                  (insert-file-contents output-file-name))) 
    102118            (set-buffer errors-buffer) 
    103             (if (not (equal exit-status 0)) 
    104                 (insert (format "\n%s exited abnormally: '%s'\n" 
    105                                 program exit-status))))) 
     119            (if (memq status '(stop signal)) 
     120                (error "%s exited abnormally: '%s'" program exit-status)) 
     121            (if (= 127 exit-status) 
     122                (error "%s could not be found" program)))) 
     123      (if passphrase-with-newline 
     124          (pgg-clear-string passphrase-with-newline)) 
     125      (if encoded-passphrase-with-new-line 
     126          (pgg-clear-string encoded-passphrase-with-new-line)) 
     127      (if (and process (eq 'run (process-status process))) 
     128          (interrupt-process process)) 
    106129      (if (file-exists-p output-file-name) 
    107130          (delete-file output-file-name))