procmail
[Top] [All Lists]

Re: non-INCLUDERC-ing string-splitter

2005-01-09 21:54:10
Toen wij Ruud H.G. van Tol kietelden, kwam er dit uit:
Bart Schaefer:

it does not work when $leftpart contains an embedded newline.  It
appeared (at the time) that what happens is that $\leftpart causes
the newline to be prefixed with a backslash, which when parsed again
by the regex engine is then recognized as a line continuation,
causing the newline itself and any whitespace that follows it to be
ignored. 

Just change two lines in the script that I just published
(the non-INCLUDERC-ing string-splitter)

New version:

  s    = '0000-0001-0002-00
03-0004-0005-0006-0007-0008-0009-'  # 51

  Str  = "$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"            # 1020

  Count = 25


# Non-INCLUDERC-ing string-splitter.
# Very fast. Uses little memory.
#
# It works as-is up to 255, which can easily be enhanced
# to 511, 1023, 2047, etc. (see out-commented code).


  d0 = '(.|^)'   d1 = '$d0$d0'  d2 = '$d1$d1'  d3 = '$d2$d2'  # 15
  d4 = '$d3$d3'  d5 = '$d4$d4'  d6 = '$d5$d5'  d7 = '$d6$d6'  # 255
# d8 = '$d7$d7'  d9 = '$d8$d8'  dA = '$d9$d9'  dB = '$dA$dA'  # 4095
# dC = '$dB$dB'  dD = '$dC$dC'  dE = '$dD$dD'  dF = '$dE$dE'  # 65535
# dG = '$dF$dF'  # etc.

  s = '${:+:256=8:128=7:64=6:32=5:16=4:8=3:4=2:2=1:1=0:}'

  :0
  *       1^0
  *$ $Count^0
  { } sc = "$="

# :0
# *$  $sc^0
# *  -256^0  s ?? :256=\/[^:]+
# { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *  -128^0  s ?? :128=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *   -64^0  s ??  :64=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *   -32^0  s ??  :32=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *   -16^0  s ??  :16=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *    -8^0  s ??   :8=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *    -4^0  s ??   :4=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *    -2^0  s ??   :2=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$  $sc^0
  *    -1^0  s ??   :1=\/[^:]+
  { sc = "$="  s = "$s\$d$MATCH" }

  :0
  *$ $ $ $ $ $ $  Str ?? ^^\/$s
  { Str_Left = "$MATCH" }

  :0
  *$ $ $ $ $ $ $  Str ?? ^^$s\/(.|^)*
  { Str_Right = "$MATCH" }

-- 
Grtz, Ruud

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>