emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master ecf1577 1/5: Avoid reading a binary as a source file


From: Rocky Bernstein
Subject: [elpa] master ecf1577 1/5: Avoid reading a binary as a source file
Date: Thu, 4 Aug 2016 03:03:26 +0000 (UTC)

branch: master
commit ecf1577499f7f331625b24b1da948c68f171fd3d
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Avoid reading a binary as a source file
    
    * follow symlinks before running "file"
    * don't find-file-noselect if file is large
---
 realgud/common/core.el       |   16 ++++++++++++----
 realgud/debugger/gdb/core.el |    7 ++++---
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/realgud/common/core.el b/realgud/common/core.el
index c051e26..ad5dd6a 100644
--- a/realgud/common/core.el
+++ b/realgud/common/core.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2010-2015 Free Software Foundation, Inc
+;; Copyright (C) 2010-2016 Free Software Foundation, Inc
 
 ;; Author: Rocky Bernstein <address@hidden>
 
@@ -12,7 +12,9 @@
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
-; (require 'term)
+;; (require 'term)
+(require 'files)
+
 (if (< emacs-major-version 24)
     (error
      "You need at least Emacs 24 or greater to run this - you have version %d"
@@ -195,10 +197,16 @@ the buffer and data associated with it are already gone."
   (message "That's all folks.... %s" string))
 
 (defun realgud:binary (file-name)
-"Return a priority for whether file-name is likely we can run gdb on"
-  (let ((output (shell-command-to-string (format "file %s" file-name))))
+  "Return a whether FILE-NAME is executable or not or very large"
+  (let* ((truename (file-chase-links file-name))
+        (output (shell-command-to-string
+                 (format "file %s" truename)))
+        (filesize (nth 7 (file-attributes truename)))
+        )
     (cond
      ((string-match "ELF" output) t)
+     ((and large-file-warning-threshold filesize
+          (> filesize large-file-warning-threshold)) t)
      ('t nil))))
 
 
diff --git a/realgud/debugger/gdb/core.el b/realgud/debugger/gdb/core.el
index 22fbed3..5a36a23 100644
--- a/realgud/debugger/gdb/core.el
+++ b/realgud/debugger/gdb/core.el
@@ -17,6 +17,7 @@
 
 (eval-when-compile (require 'cl))
 
+(require 'files)
 (require 'load-relative)
 (require-relative-list '("../../common/track"
                         "../../common/core"
@@ -147,15 +148,15 @@ Note that path elements have been expanded via 
`expand-file-name'.
 (defvar realgud:gdb-command-name)
 
 (defun realgud:gdb-executable (file-name)
-"Return a priority for whether file-name is likely we can run gdb on"
-  (let ((output (shell-command-to-string (format "file %s" file-name))))
+  "Return a priority for whether FILE-NAME is likely we can run gdb on"
+  (let ((output (shell-command-to-string
+                (format "file %s" (file-chase-links file-name)))))
     (cond
      ((string-match "ASCII" output) 2)
      ((string-match "ELF" output) 7)
      ((string-match "executable" output) 6)
      ('t 5))))
 
-
 (defun realgud:gdb-suggest-invocation (&optional debugger-name)
   "Suggest a gdb command invocation. Here is the priority we use:
 * an executable file with the name of the current buffer stripped of its 
extension



reply via email to

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