]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
Fix ipcalc.
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 22 Jan 2019 14:48:21 +0000 (15:48 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 22 Jan 2019 14:48:21 +0000 (15:48 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
lisp/ipcalc.el

index 59fdec76e01ef2d49c0b571f55537c2b93fc5e75..a095e9d6c77cd0b6af4e66f484ade1254cfee9be 100644 (file)
@@ -31,7 +31,7 @@
 ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 ;; COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 ;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
@@ -41,9 +41,9 @@
 ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 ;; OF THE POSSIBILITY OF SUCH DAMAGE.
 
-;;; Code
+;;; Code:
 
-(defconst cidr-default 32 "CIDR value")
+(defconst cidr-default 32 "CIDR value.")
 
 (defun int-to-bin-string (n &optional length)
   ;; 08 Jun 1997 Jamie Zawinski <jwzNOSPAMnetscape.com> comp.emacs
@@ -59,7 +59,7 @@
     s))
 
 (defun octets-as-binary (list-of-octets)
-  "return LST of octets as a single binary string"
+  "return LST of octets as a single binary string."
   (let ((binary ""))
   (while list-of-octets
     (setq binary
   binary))
 
 (defun ip-to-octets (ip)
-  "split IP address and return the octets"
+  "split IP address and return the octets."
   (let ((octets (split-string ip "\\.")))
     (if (= 4 (length octets))
         octets
       (message "not correct IP format"))))
 
 (defun ones-and-pad (num)
-  "return 1's equal to NUM and pad the rest up to 32"
+  "return 1's equal to NUM and pad the rest up to 32."
   (unless (and (<= num cidr-default) (> num 0))
-    (error "wrong value provided"))
+    (error "Wrong value provided"))
   (concat (make-string num ?1)
           (make-string (- cidr-default num) ?0)))
 
@@ -93,7 +93,7 @@
        (remove-if-not (lambda (ch) (position ch "01")) num)))
 
 (defun network (ip cidr)
-  "Takes IP & CIDR and produces network"
+  "Takes IP & CIDR and produces network."
   (let ((cidr-as-int (string-to-int cidr)))
     (concat
      (substring (octets-as-binary
      (make-string (- cidr-default cidr-as-int) ?0))))
 
 (defun host+1 (binary-ip)
-  "increment the given BINARY-IP by 1"
+  "increment the given BINARY-IP by 1."
   (let ((tmp binary-ip))
   (aset tmp (- cidr-default 1) ?1)
   tmp))
     ip))
 
 (defun hosts/net (num)
-  "Calculate Hosts/Net for the NUM given"
+  "Calculate Hosts/Net for the NUM given."
   (- (expt 2 (- cidr-default num)) 2))
 
 (defmacro list-to-string (lst)
-  "convert LST to string"
+  "convert LST to string."
   `(mapconcat
-    '(lambda (val)
+    #'(lambda (val)
        (identity (if (integerp val)
                      (int-to-string val)
                    val)))
     ,lst ""))
 
 (defun insert-values (lst)
-  "insert given LST"
+  "insert given LST."
   (insert
    (list-to-string lst)))
 
 (defun bin-to-int (bin)
-  "Convert binary to integer"
+  "Convert binary to integer."
   (int-to-string (read (concat "#b" bin))))
 
 (defun binary-to-ip (binary)
-  "convert binary to IP address"
+  "convert binary to IP address."
   (let* (full-ip
         (count 0)
         (1st-octet (substring binary 0 8))
     (concat full-ip (car (last octets)))))
 
 (defun ipcalc (ip/cidr)
-  "IP calculator"
+  "IP calculator."
   (let* ((ip (car (split-string ip/cidr "/")))
          (ip-in-binary (octets-as-binary (ip-to-octets ip)))
          (cidr (car (cdr (split-string ip/cidr "/"))))