ref: 04da70c705020e3e842588f53fb2aa59be9e5a00
parent: 159d4eb8e145e679d6a67a69cef2448f9f85869b
author: uriel <uriel@engel.se.cat-v.org>
date: Thu Dec 11 21:25:10 EST 2008
Fix bug in crop_text, and allow to set the 'ellipsis' text ('...' by default)
--- a/bin/cgilib.rc
+++ b/bin/cgilib.rc
@@ -95,12 +95,17 @@
}
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
}