Commits (5)
(in-package :fare-utils)
(exporting-definitions
(defun ascii-char-p (x)
(and (characterp x) (<= 0 (char-code x) 127)))
(defun ascii-uppercase-letter-p (x)
(char<= #\A x #\Z))
(defun ascii-lowercase-letter-p (x)
(char<= #\a x #\z))
(defun ascii-letter-p (x)
(or (ascii-uppercase-letter-p x) (ascii-lowercase-letter-p x)))
(defun ascii-digit-p (x)
(char<= #\0 x #\9))
(defun ascii-alphanumeric-p (x)
(or (ascii-letter-p x) (ascii-digit-p x)))
(defun ascii-non-alphanumeric-p (x)
(and (ascii-char-p x) (not (ascii-alphanumeric-p x))))
(defun ascii-alphanumeric-or-underscore-p (x)
(or (ascii-alphanumeric-p x)
(eql x #\_)))
); exporting-definitions
......@@ -238,11 +238,18 @@ outputs a tag plus a list of variable and their values, returns the last value"
(,f "~{~S~^ ~}~%" (setf ,res (multiple-value-list ,x)))))
exprs)
(apply 'values ,res)))))
(defun package-function (package name)
(let* ((p (find-package package))
(s (find-symbol* name p nil)))
(and s
(eq (symbol-package s) p)
(fboundp s)
(not (macro-function s))
(fdefinition s))))
(defun package-functions (package-designator)
(loop :with p = (find-package package-designator)
:for s :being :each :present-symbol :of p
:when (and (eq p (symbol-package s))
(fboundp s) (not (macro-function s)))
:when (package-function p s)
:collect s))
(defun trace-package-functions (package-designator)
(eval `(trace ,@(package-functions package-designator))))
......@@ -302,7 +309,7 @@ outputs a tag plus a list of variable and their values, returns the last value"
;;; Streams
(defun n-stream-has-char-p (c s)
(and (eql (peek-char nil s) c) (read-char s)))
(and (eql (peek-char nil s nil) c) (read-char s)))
(defun n-stream-eol-p (s)
(let* ((cr (n-stream-has-char-p #\return s))
......
......@@ -72,9 +72,9 @@
(*print-level* nil)
(*print-length* nil))
(when xnd
(style-warn "Current defpackage for ~A doesn't include declared exports~% ~S" (package-name p) xnd))
(warn "Current defpackage for ~A doesn't include declared exports~% ~S" (package-name p) xnd))
(when dnx
(style-warn "Current defpackage for ~A includes undeclared exports~% ~S" (package-name p) dnx)))
(warn "Current defpackage for ~A includes undeclared exports~% ~S" (package-name p) dnx)))
`(defpackage
,(s name)
,@(w* :nicknames nicknames)
......
......@@ -32,20 +32,11 @@
(defmacro declare-type (&rest specs) (declare (ignore specs)))
(defmacro the* (type form) (declare (ignore type)) form))
; -----------------------------------------------------------------------------
;;; Warnings
(eval-now
(defun style-warn (string &rest args)
#-sbcl
(apply #'warn string args)
#+sbcl
(apply #'sb-int:style-warn string args)))
; -----------------------------------------------------------------------------
;;; Helper functions for package management
(eval-now
(defparameter *package-misdefinition-warning-hook* #'style-warn)
(defparameter *package-misdefinition-warning-hook* #'warn)
(defun package-exported-symbols-symbol (p)
(find-symbol "%%EXPORTED-SYMBOLS" p))
......@@ -129,7 +120,6 @@
(ensure-symbols-exported
eval-now
declaim-type declare-type the*
style-warn
*package-misdefinition-warning-hook*
ensure-symbols-exported* ensure-symbols-exported ensure-symbol-exported
exporting-definitions define-exporter)
......
;;; -*- Mode: Lisp ; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
(defsystem "fare-utils"
:version "1.0.0.2"
:version "1.0.0.5"
:description "Basic functions and macros, interfaces, pure and stateful datastructures"
:long-description "fare-utils is a small collection of utilities.
It contains a lot of basic everyday functions and macros"
......@@ -15,6 +15,7 @@ It contains a lot of basic everyday functions and macros"
:depends-on ("package")
:components
((:file "utils")
(:file "character-classes" :depends-on ("utils"))
(:file "strings" :depends-on ("utils"))
(:file "symbols" :depends-on ("strings"))
(:file "macros" :depends-on ("symbols"))
......
......@@ -16,7 +16,11 @@
#:*safe-package* #:*standard-readtable*
#:+all-chars-base-feature+ ;; #:absolute-pathname-p
#:accessors-equal-p #:acond #:acond2 #:adjust-size #:aif
#:aif2 #:alist->hash-table #:association
#:aif2 #:alist->hash-table
#:ascii-char-p #:ascii-uppercase-letter-p #:ascii-lowercase-letter-p
#:ascii-letter-p #:ascii-digit-p #:ascii-alphanumeric-p #:ascii-non-alphanumeric-p
#:ascii-alphanumeric-or-underscore-p
#:association
#:base-char-p #:binary-heap #:binomial-heap #:boolean
#:cached-size-mixin
#:check-not-empty
......@@ -62,6 +66,7 @@
#:maybe-adjust-size-down #:maybe-adjust-size-up
#:msg #:multiple-value-quote #:mvbind
#:mvcall #:mvlist #:mvprog1 #:mvquote #:mvsetq
#:n-stream-has-char-p #:n-stream-eol-p
#:ndolist-with-rest #:ndolist-with-rest-fun #:nilf #:niy
#:node-item #:node-mixin #:nop
#:null-string-p #:plist->alist #:pop-last-item
......@@ -72,7 +77,7 @@
#:set-container-contents-from-list! #:simplify-string
#:single-arg #:single-arg-form-p #:sized-container-mixin
#:string-all-base-char-p #:string-basic-p ;; #:strcat
#:->string #:style-warn #:test-form #:test-forms
#:->string #:test-form #:test-forms
#:test-only #:the* #:ttest #:ttest* #:unfeaturify
#:vector->list #:vector-container-mixin
#:vector-container-ref #:with-buffered-file-contents
......@@ -118,6 +123,7 @@
;; #:parse-body
#:parse-defsetf-lambda-list
#:identifierp
#:package-function
#:package-functions
#:trace-package-functions
#:untrace-package-functions
......
......@@ -16,9 +16,16 @@
(deftest test-eol-p ()
(with-input-from-string (s (format nil "x~cy~cz~at" #\return #\newline +crlf+))
(is (equal (n-stream-eol-p s) nil))
(is (equal (n-stream-has-char-p #\a s) nil))
(is (equal (n-stream-has-char-p #\x s) #\x))
(is (equal (n-stream-eol-p s) #\return))
(is (equal (n-stream-eol-p s) nil))
(is (equal (n-stream-has-char-p #\y s) #\y))
(is (equal (n-stream-eol-p s) #\newline))
(is (equal (n-stream-eol-p s) nil))
(is (equal (n-stream-has-char-p #\z s) #\z))
(is (equal (n-stream-eol-p s) +crlf+))
(is (equal (n-stream-eol-p s) nil))))
(is (equal (n-stream-eol-p s) nil))
(is (equal (n-stream-has-char-p #\t s) #\t))
(is (equal (n-stream-eol-p s) nil))
(is (equal (n-stream-has-char-p #\a s) nil))))