Ticket #1921: lslR.diff

File lslR.diff, 1.2 KB (added by storchaka, 14 years ago)
  • lslR.in

    ../  
    2424$MYCAT "$1" | $AWK ' 
    2525BEGIN { 
    2626  dir=""; 
    27   # Pattern to match 8 first fields. 
     27  empty=1; 
    2828  rx = "[^      ]+[     ]+"; 
    29   rx = "^" rx rx rx rx rx rx rx rx; 
     29  # Pattern to match 7 first fields. 
     30  rx7 = "^" rx rx rx rx rx rx "[^       ]+[     ]"; 
     31  # Pattern to match 8 first fields. 
     32  rx8 = "^" rx rx rx rx rx rx rx "[^    ]+[     ]"; 
    3033} 
    3134/^total\ [0-9]*$/ { next } 
    32 /^$/ { next } 
    33 /^[^    ].*:$/ { 
     35/^$/ { empty=1; next } 
     36empty==1 && /:$/ { 
     37  empty=0 
    3438  if ($0 ~ /^\//) dir=substr($0, 2); 
    3539  else dir=$0; 
    3640  if (dir ~ /\/:$/) sub(/:$/, "", dir); 
    3741  else sub(/:$/, "/", dir); 
     42  if (dir ~ /^[         ]/) dir="./"dir; 
    3843  next; 
    3944} 
    40 ( $9 != "" ) { 
     45( NF > 7 ) { 
     46  empty=0 
    4147  # gensub() is not portable. 
    4248  name=$0 
    43   sub(rx, "", name) 
    44   # Cannot assign to $9, or spaces in the filename would be reduced. 
    45   attr=substr($0, 1, length($0)-length(name)) 
    46   printf "%s%s%s\n", attr, dir, name 
     49  i=index($6, "-") 
     50  if (i) { 
     51    sub(rx7, "", name) 
     52    NF = 7 
     53    $6=substr($6,i+1)"-"substr($6,1,i-1) 
     54  } 
     55  else { 
     56    sub(rx8, "", name) 
     57    NF = 8 
     58  } 
     59  printf "%s %s%s\n", $0, dir, name 
     60} 
     61 { 
     62  empty=0 
    4763}'  
    4864} 
    4965