New helper function: crop_text

This commit is contained in:
Uriel 2008-11-26 04:50:03 +01:00
parent 1a0da5a633
commit d381768c8f

View file

@ -94,6 +94,20 @@ BEGIN {
'
}
fn crop_text {
max_chars = $0
awk -v max'='^$max_chars^' ' '
{
nc += 1 + length;
if(nc > max) {
print substr($0, 1, nc - max) "..."
exit
}
print
}'
}
# Cookies
fn set_cookie {
# TODO: should check input values more carefully