emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113031: lisp/gnus/auth-source.el: When a data token


From: Katsumi Yamaoka
Subject: [Emacs-diffs] trunk r113031: lisp/gnus/auth-source.el: When a data token is "machine", abort parsing the current line
Date: Mon, 17 Jun 2013 23:35:51 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113031
revision-id: address@hidden
parent: address@hidden
author: Teodor Zlatanov <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Mon 2013-06-17 23:35:46 +0000
message:
  lisp/gnus/auth-source.el: When a data token is "machine", abort parsing the 
current line
modified:
  lisp/gnus/ChangeLog            changelog-20091113204419-o5vbwnq5f7feedwu-1433
  lisp/gnus/auth-source.el       
authsource.el-20091113204419-o5vbwnq5f7feedwu-8608
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2013-06-17 23:11:40 +0000
+++ b/lisp/gnus/ChangeLog       2013-06-17 23:35:46 +0000
@@ -1,3 +1,9 @@
+2013-06-17  Teodor Zlatanov  <address@hidden>
+
+       * auth-source.el (auth-source-current-line): New function.
+       (auth-source-netrc-parse-entries): When a data token is "machine",
+       assume we're in the wrong place and abort parsing the current line.
+
 2013-06-17  Lars Magne Ingebrigtsen  <address@hidden>
 
        * eww.el (eww-tag-select): Don't render totally empty <select> forms.

=== modified file 'lisp/gnus/auth-source.el'
--- a/lisp/gnus/auth-source.el  2013-06-15 21:59:59 +0000
+++ b/lisp/gnus/auth-source.el  2013-06-17 23:35:46 +0000
@@ -1055,6 +1055,13 @@
     (auth-source-netrc-parse-next-interesting)
     (match-string-no-properties 1)))
 
+;; with thanks to org-mode
+(defsubst auth-source-current-line (&optional pos)
+  (save-excursion
+    (and pos (goto-char pos))
+    ;; works also in narrowed buffer, because we start at 1, not point-min
+    (+ (if (bolp) 1 0) (count-lines 1 (point)))))
+
 (defun auth-source-netrc-parse-entries(check max)
   "Parse up to MAX netrc entries, passed by CHECK, from the current buffer."
   (let ((adder (lambda(check alist all)
@@ -1071,6 +1078,8 @@
       (when (and alist
                  (or default
                      (equal item "machine")))
+        (auth-source-do-trivia
+         "auth-source-netrc-parse-entries: got entry %S" alist)
         (setq all (funcall adder check alist all)
               alist nil))
       ;; In default entries, we don't have a next token.
@@ -1079,11 +1088,21 @@
           (push (cons "machine" t) alist)
         ;; Not a default entry.  Grab the next item.
         (when (setq item2 (auth-source-netrc-parse-one))
-          (push (cons item item2) alist))))
+          ;; Did we get a "machine" value?
+          (if (equal item2 "machine")
+              (progn
+                (gnus-error 1
+                 "%s: Unexpected 'machine' token at line %d"
+                 "auth-source-netrc-parse-entries"
+                 (auth-source-current-line))
+                (forward-line 1))
+            (push (cons item item2) alist)))))
 
     ;; Clean up: if there's an entry left over, use it.
     (when alist
-      (setq all (funcall adder check alist all)))
+      (setq all (funcall adder check alist all))
+      (auth-source-do-trivia
+       "auth-source-netrc-parse-entries: got2 entry %S" alist))
     (nreverse all)))
 
 (defvar auth-source-passphrase-alist nil)


reply via email to

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