Skip to content

Instantly share code, notes, and snippets.

@gbataille
Created April 26, 2013 09:28
Show Gist options
  • Save gbataille/5466047 to your computer and use it in GitHub Desktop.
Save gbataille/5466047 to your computer and use it in GitHub Desktop.
[11:25] gregou LandOfLisp$ clisp -c webserver.lisp
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8
Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>
Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010
Type :h and hit Enter for context help.
;; Compiling file /Users/gregou/Documents/Prog/GregsSandbox/CommonLisp/LandOfLisp/webserver.lisp ...
*** - READ: input stream #<INPUT BUFFERED FILE-STREAM CHARACTER #P"/Users/gregou/Documents/Prog/GregsSandbox/CommonLisp/LandOfLisp/webserver.lisp" @74> ends within an object. Last opening
parenthesis probably in line 10.
0 errors, 0 warnings
Bye.
(defun http-char (c1 c2 &optional (default #\Space))
(let ((code (parse-integer
(coerce (list c1 c2) 'string)
:radix 16
:junk-allowed t)))
(if code
(code-char code)
default)))
(defun decode-param (s)
(labels ((f (lst)
(when lst
(case (car lst)
(#\% (cons (http-char (cadr lst) (caddr lst))
(f (cdddr lst))))
(#\+ (cons #\space (f (cdr lst))))
(otherwise (cons (car lst) (f (cdr lst))))))))
(coerce (f (coerce s 'list)) 'string))
; The last line is missing a parenthesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment