Changeset 4273


Ignore:
Timestamp:
01/15/10 22:14:39 (3 years ago)
Author:
sam
Message:

Fix zzcat's -s flag. It must propagate to the next file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/zzcat.c

    r4271 r4273  
    6262static void usage(void); 
    6363 
    64 /* Output parameters */ 
    65 static int escape_tabs = 0; 
    66 static int escape_ends = 0; 
    67 static int escape_other = 0; 
    68 static int number_lines = 0; 
    69 static int number_nonblank = 0; 
    70 static int squeeze_lines = 0; 
     64/* Global parameters */ 
     65static char escape_tabs = 0; 
     66static char escape_ends = 0; 
     67static char escape_other = 0; 
     68static char number_lines = 0; 
     69static char number_nonblank = 0; 
     70static char squeeze_lines = 0; 
     71 
     72/* Global output state */ 
     73static int ncrs = 0; 
     74static int line = 1; 
     75static char newline = 1; 
    7176 
    7277/* 
     
    177182{ 
    178183    size_t i; 
    179     int line = 1, newline = 1; 
    180  
     184 
     185    /* If no special features are requested, output directly */ 
    181186    if (!(escape_tabs || escape_ends || escape_other 
    182187           || number_lines || number_nonblank || squeeze_lines)) 
     
    186191    } 
    187192 
     193    /* If any special feature is active, go through every possibility */ 
    188194    for (i = 0; i < len; i++) 
    189195    { 
    190196        int ch = (unsigned int)(unsigned char)buf[i]; 
    191197 
    192         if (squeeze_lines && i > 1 
    193              && ch == '\n' && buf[i - 1] == '\n' && buf[i - 2] == '\n') 
    194             continue; 
     198        if (squeeze_lines) 
     199        { 
     200            if (ch == '\n') 
     201            { 
     202                if (++ncrs > 2) 
     203                    continue; 
     204            } 
     205            else 
     206                ncrs = 0; 
     207        } 
    195208 
    196209        if (number_lines || number_nonblank) 
     
    352365    size_t retlen = 0, retoff = 0; 
    353366    int nloops = 0, fd = -1, feofs = 0, finish = 0; 
     367 
     368    /* Initialise per-file state */ 
     369    /* TODO */ 
    354370 
    355371    /* Allocate 32MB for our temporary buffer. Any larger value will crash. */ 
Note: See TracChangeset for help on using the changeset viewer.