From e60f6df68b27b49b6c2408ba70e8a2fcdcef652b Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 28 Nov 2000 04:03:45 +0000 Subject: [PATCH] * Hahaha. Added a rasterman filter. (Not just "raster" as I worry about namespace pollution.) --- Makefile | 2 +- debian/changelog | 7 ++++ debian/copyright | 4 ++ filters.6 | 4 +- rasterman | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100755 rasterman diff --git a/Makefile b/Makefile index 88a38bb..1649d4b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ LEX = flex ALL = jethro kraut cockney jive nyc -OTHER = eleet b1ff chef jibberish upside-down +OTHER = eleet b1ff chef jibberish upside-down rasterman all: $(OTHER) $(ALL) diff --git a/debian/changelog b/debian/changelog index 07823de..e17d623 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +filters (2.14) unstable; urgency=low + + * Hahaha. Added a rasterman filter. (Not just "raster" as I worry about + namespace pollution.) + + -- Joey Hess Mon, 27 Nov 2000 20:00:28 -0800 + filters (2.13) unstable; urgency=low * cockney, jive, and nyc filters are now GPL'd, moved from -nonfree diff --git a/debian/copyright b/debian/copyright index ed43db7..4535b17 100644 --- a/debian/copyright +++ b/debian/copyright @@ -33,4 +33,8 @@ Klein. He confirmed the new copyright in this email: > and nyc filters to the GPL? Is that correct? I'd love to move them into > Debian proper. +The rasterman filter was pulled out of +http://www.xach.com/xachbot/xachbot-2000-07-15.tar.gz, which is as a whole +copyright (C) 1997 Zachary Beane and is GPL'd. + Everything else is copyright 1999 by Joey Hess, under the terms of GPL. diff --git a/filters.6 b/filters.6 index fcb8211..0a124fa 100644 --- a/filters.6 +++ b/filters.6 @@ -1,6 +1,6 @@ .TH FILTERS 6 .SH NAME -b1ff, chef, cockney, eleet, jethro, jibberish, jive, kraut, nyc, upside-down \- assorted text filters +b1ff, chef, cockney, eleet, jethro, jibberish, jive, kraut, nyc, rasterman, upside-down \- assorted text filters .SH SYNOPSIS $SHELL | chef .SH "DESCRIPTION" @@ -27,6 +27,8 @@ K3wl hacker slang Generates text with a German accent. .IP nyc Brooklyn English +.IP rasterman +Makes text look like it came from the keyboard of Carsten Haitzler. .IP upside-down Flips text upside down. Stand on your head and squint to read the output. .SH "SEE ALSO" diff --git a/rasterman b/rasterman new file mode 100755 index 0000000..492061c --- /dev/null +++ b/rasterman @@ -0,0 +1,100 @@ +#!/usr/bin/perl + +$row = "!qwertyuiop!asdfghjkl!zxcvbnm!"; +@row_array = split(//, $row); + +while (<>) { + chomp; + y/A-Z/a-z/; + s/\byou\b/u/gi; + s/\bpeople\b/ppl/gi; + s/\bthrough\b/thru/gi; + s/\bthough\b/tho/gi; + s/\bnope\b/nup/gi; + s/\baustralia\b/oz/gi; + s/\bsucks\b/sux/gi; + s/\benough\b/enuff/gi; + s/\ba lot\b/a shitload/gi; + s/\bstuff\b/shit/gi; + s/, /.. /g; + s/\.$/.../g; + + @lets = split(//); + + $strlen = $#lets; + + for ($x = 0; $x < $strlen; $x++) { + if (rand() < 0.01) { + swap(\@lets, $x, $x + 1); + next; + } + + if (rand() < 0.10 && $lets[$x] eq " ") { + swap(\@lets, $x - 1, $x - 2); + next; + } + + if(rand() < 0.01) { + $i = insert_adjacent(\@lets, $x, $lets[$x]); + $strlen += $i; + next; + } + + if(rand() < 0.01) { + splice(@lets, $x, 1); + $strlen--; + next; + } + } + + print join("", @lets) . "\n"; +} + +sub insert_adjacent { + my($aref, $pos, $let) = @_; + + + $newlet = get_adjacent($let); + + if( !$newlet ) { + return 0; + } + + splice(@$aref, $pos + 1, 0, $newlet); + return 1; +} + + +sub get_adjacent { + my($let) = @_; + + return 0 if $let !~ /[a-zA-Z]/; + + $i = index($row, $let); + $before = $row_array[$i - 1]; + $after = $row_array[$i + 1]; + + + + if( $before eq "!" || (rand() < rand() && $after ne "!")) { + return $after; + } else { + return $before; + } +} + +sub swap { + my($aref, $n, $m) = @_; + my($tmp); + + if(defined($$aref[$n]) && defined($$aref[$m])) { + if(! (($$aref[$n] =~ /[A-Z ]/ && $$aref[$m] =~ /[A-Z ]/) || + ($$aref[$n] =~ /[a-z ]/ && $$aref[$m] =~ /[a-z ]/) )) { + return; + } + $tmp = $$aref[$n]; + $$aref[$n] = $$aref[$m]; + $$aref[$m] = $tmp; + } +} + -- 2.30.2