ref: a3f5b4baef15ae47df172c143b5b0ec82c9af365
parent: e1a653d823f133ad775443fccbc321eadef1334f
author: uriel <uriel@engel.se.cat-v.org>
date: Tue Nov 25 23:50:03 EST 2008
New helper function: crop_text
--- a/bin/cgilib.rc
+++ b/bin/cgilib.rc
@@ -94,6 +94,20 @@
'
}
+fn crop_text {
+ max_chars = $0
+ awk -v max'='^$max_chars^' ' '
+ {
+ nc += 1 + length;
+ if(nc > max) {
+ print substr($0, 1, nc - max) "..."
+ exit
+ }
+ }'
+}
+
+
# Cookies
fn set_cookie {
# TODO: should check input values more carefully