emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/play/gamegrid.el


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/play/gamegrid.el
Date: Fri, 04 Apr 2003 01:22:46 -0500

Index: emacs/lisp/play/gamegrid.el
diff -c emacs/lisp/play/gamegrid.el:1.14 emacs/lisp/play/gamegrid.el:1.15
*** emacs/lisp/play/gamegrid.el:1.14    Tue Feb  4 08:20:41 2003
--- emacs/lisp/play/gamegrid.el Wed Feb 26 05:18:43 2003
***************
*** 427,433 ****
  ;; ;;;;;;;;;;;;;;; high score functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (defun gamegrid-add-score (file score)
!   "Add the current score to the high score file."
    (case system-type
      ((ms-dos windows-nt)
       (gamegrid-add-score-insecure file score))
--- 427,449 ----
  ;; ;;;;;;;;;;;;;;; high score functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (defun gamegrid-add-score (file score)
!   "Add the current score to the high score file.
! 
! On POSIX systems there may be a shared game directory for all users in
! which the scorefiles are kept. On such systems Emacs doesn't create
! the score file FILE in this directory, if it doesn't already exist. In
! this case Emacs searches for FILE in the directory specified by
! `gamegrid-user-score-file-directory' and creates it there, if
! necessary.
! 
! To add the score file for a game to the system wide shared game
! directory, create the file with the shell command \"touch\" in this
! directory and make sure that it is owned by the correct user and
! group. You probably need special user privileges to do this.
! 
! On non-POSIX systems Emacs searches for FILE in the directory
! specified by the variable `temporary-file-directory'. If necessary,
! FILE is created there."
    (case system-type
      ((ms-dos windows-nt)
       (gamegrid-add-score-insecure file score))
***************
*** 435,482 ****
       (gamegrid-add-score-with-update-game-score file score))))
  
  (defun gamegrid-add-score-with-update-game-score (file score)
!   (let* ((result nil)
!        (errbuf (generate-new-buffer " *update-game-score loss*"))
         (have-shared-game-dir
          (not (zerop (logand (file-modes
                               (expand-file-name "update-game-score"
                                                 exec-directory))
!                             #o4000))))
!        (target (if have-shared-game-dir
!                    (expand-file-name file shared-game-score-directory)
!                  (let ((f (expand-file-name
!                            gamegrid-user-score-file-directory)))
!                    (when (file-writable-p f)
!                      (unless (eq (car-safe (file-attributes f))
!                                  t)
!                        (make-directory f))
!                      (setq f (expand-file-name file f))
!                      (unless (file-exists-p f)
!                        (write-region "" nil f nil 'silent nil 'excl)))
!                    f))))
!     (let ((default-directory "/"))
!       (apply
!        'call-process
!        (append
!       (list
!        (expand-file-name "update-game-score" exec-directory)
!        nil errbuf nil
!        "-m" (int-to-string gamegrid-score-file-length)
!        "-d" (if have-shared-game-dir
!                 (expand-file-name shared-game-score-directory)
!               (file-name-directory target))
!        file
!        (int-to-string score)
!        (concat
!         (user-full-name)
!         " <"
!         (cond ((fboundp 'user-mail-address)
!                (user-mail-address))
!               ((boundp 'user-mail-address)
!                user-mail-address)
!               (t ""))
!         ">  "
!         (current-time-string))))))
      (if (buffer-modified-p errbuf)
        (progn
          (display-buffer errbuf)
--- 451,510 ----
       (gamegrid-add-score-with-update-game-score file score))))
  
  (defun gamegrid-add-score-with-update-game-score (file score)
!   (let* ((result nil) ;; What is this good for? -- os
         (have-shared-game-dir
          (not (zerop (logand (file-modes
                               (expand-file-name "update-game-score"
                                                 exec-directory))
!                             #o4000)))))
!     (if (and have-shared-game-dir
!            (file-exists-p (expand-file-name file 
shared-game-score-directory)))
!       ;; Use the setuid update-gamescore program to update a
!       ;; system-wide score file.
!       (gamegrid-add-score-with-update-game-score-1
!        (expand-file-name file shared-game-score-directory) score)
!       ;; Else: Add the score to a score file in the user's home
!       ;; directory. If `have-shared-game-dir' is non-nil, the
!       ;; "update-gamescore" program is setuid, so don't use it.
!       (if have-shared-game-dir
!         (gamegrid-add-score-insecure file score
!                                      gamegrid-user-score-file-directory)
!       (let ((f (expand-file-name
!                 gamegrid-user-score-file-directory)))
!         (when (file-writable-p f)
!           (unless (eq (car-safe (file-attributes f))
!                       t)
!             (make-directory f))
!           (setq f (expand-file-name file f))
!           (unless (file-exists-p f)
!             (write-region "" nil f nil 'silent nil 'excl)))
!         (gamegrid-add-score-with-update-game-score-1 f score))))))
! 
! (defun gamegrid-add-score-with-update-game-score-1 (target score)
!   (let ((default-directory "/")
!       (errbuf (generate-new-buffer " *update-game-score loss*")))
!     (apply
!      'call-process
!      (append
!       (list
!        (expand-file-name "update-game-score" exec-directory)
!        nil errbuf nil
!        "-m" (int-to-string gamegrid-score-file-length)
!        "-d" (if have-shared-game-dir
!               (expand-file-name shared-game-score-directory)
!             (file-name-directory target))
!        file
!        (int-to-string score)
!        (concat
!       (user-full-name)
!       " <"
!       (cond ((fboundp 'user-mail-address)
!              (user-mail-address))
!             ((boundp 'user-mail-address)
!              user-mail-address)
!             (t ""))
!       ">  "
!       (current-time-string)))))
      (if (buffer-modified-p errbuf)
        (progn
          (display-buffer errbuf)
***************
*** 491,499 ****
              (display-buffer buf))
          (find-file-read-only-other-window target))))))
  
! (defun gamegrid-add-score-insecure (file score)
    (save-excursion
!     (setq file (expand-file-name file temporary-file-directory))
      (find-file-other-window file)
      (setq buffer-read-only nil)
      (goto-char (point-max))
--- 519,528 ----
              (display-buffer buf))
          (find-file-read-only-other-window target))))))
  
! (defun gamegrid-add-score-insecure (file score &optional directory)
    (save-excursion
!     (setq file (expand-file-name file (or directory
!                                         temporary-file-directory)))
      (find-file-other-window file)
      (setq buffer-read-only nil)
      (goto-char (point-max))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]