Changeset 3402 for src/pge

Show
Ignore:
Timestamp:
05/18/05 20:35:47 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
4977
Message:

* Fix a bug in run_pge in external single-process parrot mode:

Previously, rules cannot contain newlines due to line buffering.
putter++ for catching this.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/pge/run_pge.pir

    r3357 r3402  
    4141    chopn arg2, 1 # skip \n 
    4242 
     43    arg1 = unescape(arg1) 
     44    arg2 = unescape(arg2) 
     45 
    4346    if cmd == "add_rule" goto do_add_rule 
    4447    if cmd == "match" goto do_match 
     
    6265    arg1 = args[1] 
    6366    arg2 = args[2] 
     67    arg1 = unescape(arg1) 
     68    arg2 = unescape(arg2) 
    6469    result = match(arg1, arg2) 
    6570    print result 
     
    6772  end: 
    6873.end 
     74 
     75.sub unescape 
     76    .param string str 
     77    .local string ret, tmp 
     78    .local int i, j 
     79 
     80    ret = "" 
     81    j = length str 
     82    if j == 0 goto END 
     83    i = 0 
     84 
     85LOOP: 
     86    tmp = str[i] 
     87    inc i 
     88    if i >= j goto FIN 
     89 
     90    eq tmp, "\\", ESC 
     91    concat ret, tmp 
     92    goto LOOP 
     93 
     94ESC: 
     95    tmp = str[i] 
     96    inc i 
     97    eq tmp, "n", LF 
     98    concat ret, tmp 
     99    goto UNESC 
     100LF: 
     101    concat ret, "\n" 
     102UNESC: 
     103    inc i 
     104    if i >= j goto END 
     105    goto LOOP 
     106 
     107FIN: 
     108    concat ret, tmp 
     109END: 
     110    .return(ret) 
     111.end