Ignore:
Timestamp:
Mar 22, 2011, 3:19:54 PM (10 years ago)
Author:
jordan
Message:

(trunk) #4138 "use stdbool.h instead of tr_bool" -- done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/wildmat.c

    r11599 r12204  
    2121**  The precondition that must be fulfilled is that DoMatch will consume
    2222**  at least one character in text. This is true if *p is neither '*' nor
    23 **  '\0'.)  The last return has ABORT instead of FALSE to avoid quadratic
     23**  '\0'.)  The last return has ABORT instead of false to avoid quadratic
    2424**  behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With
    25 **  FALSE, each star-loop has to run to the end of the text; with ABORT
     25**  false, each star-loop has to run to the end of the text; with ABORT
    2626**  only the last one does.
    2727**
    2828**  Once the control of one instance of DoMatch enters the star-loop, that
    29 **  instance will return either TRUE or ABORT, and any calling instance
     29**  instance will return either true or ABORT, and any calling instance
    3030**  will therefore return immediately after (without calling recursively
    3131**  again). In effect, only one star-loop is ever active. It would be
     
    5252
    5353/*
    54 **  Match text and p, return TRUE, FALSE, or ABORT.
     54**  Match text and p, return true, false, or ABORT.
    5555*/
    5656static int
     
    7171        default:
    7272            if (*text != *p)
    73                 return FALSE;
     73                return false;
    7474            continue;
    7575        case '?':
     
    8282            if (*p == '\0')
    8383                /* Trailing star matches everything. */
    84                 return TRUE;
     84                return true;
    8585            while (*text)
    86                 if ((matched = DoMatch(text++, p)) != FALSE)
     86                if ((matched = DoMatch(text++, p)) != false)
    8787                    return matched;
    8888            return ABORT;
    8989        case '[':
    90             reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;
     90            reverse = p[1] == NEGATE_CLASS ? true : false;
    9191            if (reverse)
    9292                /* Inverted character class. */
    9393                p++;
    94             for (last = 0400, matched = FALSE; *++p && *p != ']'; last = *p)
     94            for (last = 0400, matched = false; *++p && *p != ']'; last = *p)
    9595                /* This next line requires a good C compiler. */
    9696                if (*p == '-' ? *text <= *++p && *text >= last : *text == *p)
    97                     matched = TRUE;
     97                    matched = true;
    9898            if (matched == reverse)
    99                 return FALSE;
     99                return false;
    100100            continue;
    101101        }
     
    104104#ifdef  MATCH_TAR_PATTERN
    105105    if (*text == '/')
    106         return TRUE;
     106        return true;
    107107#endif  /* MATCH_TAR_ATTERN */
    108108    return *text == '\0';
     
    110110
    111111
    112 /*
    113 **  User-level routine. Returns TRUE or FALSE.
    114 */
    115 int
     112/* User-level routine. returns whether or not 'text' and 'p' matched */
     113bool
    116114tr_wildmat(const char * text, const char * p )
    117115{
    118116    if (p[0] == '*' && p[1] == '\0')
    119         return TRUE;
     117        return true;
    120118
    121     return DoMatch(text, p) == TRUE;
     119    return DoMatch(text, p) == true;
    122120}
Note: See TracChangeset for help on using the changeset viewer.