swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit ab7ea620953fc99eadf3cd07490604258677f2da
parent 228066e3857247b1cb7f74c567d4d050b0548f3d
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Fri, 12 Dec 2008 02:25:10 +0100

Fix bug in crop_text, and allow to set the 'ellipsis' text ('...' by default)
Diffstat:
Mbin/cgilib.rc | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/bin/cgilib.rc b/bin/cgilib.rc @@ -95,12 +95,17 @@ BEGIN { } fn crop_text { - max_chars = $0 - awk -v max'='^$max_chars^' ' ' + max_chars = $1 + + ellipsis = '...' + if(~ $#* 2) + ellipsis = $2 + + awk -v max'='^$"max_chars^' ' -v 'ellipsis='$ellipsis ' { nc += 1 + length; if(nc > max) { - print substr($0, 1, nc - max) "..." + print substr($0, 1, nc - max) ellipsis exit } print