From 6095d57ab8041da1047061bee6a33879341559d1 Mon Sep 17 00:00:00 2001 From: uriel Date: Sat, 20 Dec 2008 05:46:41 +0100 Subject: [PATCH] A couple of minor code simplifications and add a comment about some code that probably should be killed. --- bin/werc.rc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/werc.rc b/bin/werc.rc index 6b9b896..1b0af3e 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -36,12 +36,14 @@ fn gensidebar { dirs = ( $sitedir^$dd $dirs ) } # Ignore stderr, last item in path might be a file that doesn't exist (eg., foo for foo.md) - ls -F $dirs >[2]/dev/null | sed 's/\*$//; s,^'$sitedir',,; '^$dirfilter^' s,^/,,'|sort -u | awk -F/ ' + ls -F $dirs >[2]/dev/null | sed 's/\*$//; s,^'$sitedir',,; '^$dirfilter | sort -u | awk -F/ ' function p(x, y, s) { for( i=0; i < x-y; i+=1) print s } - /^([a-zA-Z0-9+_\-]+[*\/]?)+$/ { + + # XXX Regexp to hide non-document/non-dir stuff, there must be a better way, if we really want this. + /^\/([a-zA-Z0-9+_\-]+[*\/]?)+$/ { d = "" if(match($0, "/$")) @@ -53,7 +55,7 @@ fn gensidebar { lNF = NF bname = $NF d - path = "/" $0 d + path = $0 d gsub("_", " ", bname) if(index(ENVIRON["REQUEST_URI"] "/", path) == 1) @@ -69,8 +71,7 @@ fn gensidebar { # Handlers fn set_handler { handler = $1 - shift - handler_args = $* + handler_args = $*(2-) } fn md_handler { cat $* | $formatter }