Changeset 4002 for zzuf


Ignore:
Timestamp:
Nov 22, 2009, 7:54:17 PM (10 years ago)
Author:
Sam Hocevar
Message:

Add a getc_unlocked method to zzcat.

Location:
zzuf/trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/test/check-utils

    r3734 r4002  
    2121            check "$ZZOPTS" "< $file" "zzuf"
    2222        fi
    23         for n in 0 20 21 22 23 30 31 40 41 42; do
     23        for n in 0 20 21 22 23 24 25 30 31 40 41 42; do
    2424            check "$ZZOPTS" "$ZZCAT $n $file" "zzcat $n"
    2525        done
  • zzuf/trunk/test/zzcat.c

    r3742 r4002  
    5454    char const *name;
    5555    FILE *stream;
    56     int i, j, fd;
     56    int cmd, i, j, fd;
    5757    char c;
    5858
     
    7575
    7676    /* Read shit here and there, using different methods */
    77     switch(atoi(argv[1]))
     77    switch((cmd = atoi(argv[1])))
    7878    {
    7979    /* 0x: simple fd calls
     
    9898        break;
    9999    case 21: /* only getc() calls */
    100         stream = fopen(name, "r");
    101         if(!stream)
    102             return EXIT_FAILURE;
    103         for(i = 0; i < len; i++)
     100#if defined HAVE_GETC_UNLOCKED
     101    case 22: /* only getc_unlocked() calls */
     102#endif
     103        stream = fopen(name, "r");
     104        if(!stream)
     105            return EXIT_FAILURE;
     106        for(i = 0; i < len; i++)
     107#if defined HAVE_GETC_UNLOCKED
     108            data[i] = cmd == 21 ? getc(stream)
     109                                : getc_unlocked(stream);
     110#else
    104111            data[i] = getc(stream);
    105         fclose(stream);
    106         break;
    107     case 22: /* only fgetc() calls */
     112#endif
     113        fclose(stream);
     114        break;
     115    case 23: /* only fgetc() calls */
    108116        stream = fopen(name, "r");
    109117        if(!stream)
     
    114122        break;
    115123#if defined HAVE_GETLINE
    116     case 23: /* getline() and getc() calls */
    117 #if defined HAVE_GETC_UNLOCKED
    118     case 24: /* getline() and getc_unlocked() calls */
     124    case 24: /* getline() and getc() calls */
     125#if defined HAVE_GETC_UNLOCKED
     126    case 25: /* getline() and getc_unlocked() calls */
    119127#endif
    120128        stream = fopen(name, "r");
     
    123131        i = 0;
    124132#if defined HAVE_GETC_UNLOCKED
    125         while ((c = (atoi(argv[1]) == 23) ? getc(stream)
    126                                           : getc_unlocked(stream)) != EOF)
     133        while ((c = (cmd == 24 ? getc(stream)
     134                               : getc_unlocked(stream))) != EOF)
    127135#else
    128136        while ((c = getc(stream)) != EOF)
Note: See TracChangeset for help on using the changeset viewer.