Minor splint fixes
This commit is contained in:
parent
55e57050c4
commit
315aedc7cb
6
bp.c
6
bp.c
@ -202,9 +202,9 @@ static void cleanup(void)
|
|||||||
if (modifying_file && backup_file) {
|
if (modifying_file && backup_file) {
|
||||||
rewind(modifying_file);
|
rewind(modifying_file);
|
||||||
ftruncate(fileno(modifying_file), 0);
|
ftruncate(fileno(modifying_file), 0);
|
||||||
fwrite(backup_file->start, 1,
|
(void)fwrite(backup_file->start, 1,
|
||||||
(size_t)(backup_file->end - backup_file->start),
|
(size_t)(backup_file->end - backup_file->start),
|
||||||
modifying_file);
|
modifying_file);
|
||||||
fclose(modifying_file);
|
fclose(modifying_file);
|
||||||
modifying_file = NULL;
|
modifying_file = NULL;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ pat_t *new_pat(file_t *f, const char *start, const char *end, size_t minlen, ssi
|
|||||||
static pat_t *new_range(file_t *f, const char *start, const char *end, size_t min, ssize_t max, pat_t *repeating, pat_t *sep)
|
static pat_t *new_range(file_t *f, const char *start, const char *end, size_t min, ssize_t max, pat_t *repeating, pat_t *sep)
|
||||||
{
|
{
|
||||||
size_t minlen = min*repeating->min_matchlen + (min > 0 ? min-1 : 0)*(sep ? sep->min_matchlen : 0);
|
size_t minlen = min*repeating->min_matchlen + (min > 0 ? min-1 : 0)*(sep ? sep->min_matchlen : 0);
|
||||||
ssize_t maxlen = (max == -1 || UNBOUNDED(repeating) || (max != 0 && max != 1 && sep && UNBOUNDED(sep))) ? -1
|
ssize_t maxlen = (max == -1 || UNBOUNDED(repeating) || (max != 0 && max != 1 && sep && UNBOUNDED(sep))) ? (ssize_t)-1
|
||||||
: max*repeating->max_matchlen + (ssize_t)(max > 0 ? min-1 : 0)*(ssize_t)(sep ? sep->min_matchlen : 0);
|
: max*repeating->max_matchlen + (ssize_t)(max > 0 ? min-1 : 0)*(ssize_t)(sep ? sep->min_matchlen : 0);
|
||||||
pat_t *range = new_pat(f, start, end, minlen, maxlen, BP_REPEAT);
|
pat_t *range = new_pat(f, start, end, minlen, maxlen, BP_REPEAT);
|
||||||
range->args.repetitions.min = min;
|
range->args.repetitions.min = min;
|
||||||
@ -141,7 +141,7 @@ pat_t *chain_together(file_t *f, pat_t *first, pat_t *second)
|
|||||||
if (first == NULL) return second;
|
if (first == NULL) return second;
|
||||||
if (second == NULL) return first;
|
if (second == NULL) return first;
|
||||||
size_t minlen = first->min_matchlen + second->min_matchlen;
|
size_t minlen = first->min_matchlen + second->min_matchlen;
|
||||||
ssize_t maxlen = (UNBOUNDED(first) || UNBOUNDED(second)) ? -1 : first->max_matchlen + second->max_matchlen;
|
ssize_t maxlen = (UNBOUNDED(first) || UNBOUNDED(second)) ? (ssize_t)-1 : first->max_matchlen + second->max_matchlen;
|
||||||
pat_t *chain = new_pat(f, first->start, second->end, minlen, maxlen, BP_CHAIN);
|
pat_t *chain = new_pat(f, first->start, second->end, minlen, maxlen, BP_CHAIN);
|
||||||
chain->args.multiple.first = first;
|
chain->args.multiple.first = first;
|
||||||
chain->args.multiple.second = second;
|
chain->args.multiple.second = second;
|
||||||
@ -174,7 +174,7 @@ pat_t *either_pat(file_t *f, pat_t *first, pat_t *second)
|
|||||||
if (first == NULL) return second;
|
if (first == NULL) return second;
|
||||||
if (second == NULL) return first;
|
if (second == NULL) return first;
|
||||||
size_t minlen = first->min_matchlen < second->min_matchlen ? first->min_matchlen : second->min_matchlen;
|
size_t minlen = first->min_matchlen < second->min_matchlen ? first->min_matchlen : second->min_matchlen;
|
||||||
ssize_t maxlen = (UNBOUNDED(first) || UNBOUNDED(second)) ? -1 :
|
ssize_t maxlen = (UNBOUNDED(first) || UNBOUNDED(second)) ? (ssize_t)-1 :
|
||||||
(first->max_matchlen > second->max_matchlen ? first->max_matchlen : second->max_matchlen);
|
(first->max_matchlen > second->max_matchlen ? first->max_matchlen : second->max_matchlen);
|
||||||
pat_t *either = new_pat(f, first->start, second->end, minlen, maxlen, BP_OTHERWISE);
|
pat_t *either = new_pat(f, first->start, second->end, minlen, maxlen, BP_OTHERWISE);
|
||||||
either->args.multiple.first = first;
|
either->args.multiple.first = first;
|
||||||
|
4
utf8.h
4
utf8.h
@ -12,7 +12,7 @@
|
|||||||
// (i.e. skip forward one codepoint at a time, not one byte at a time)
|
// (i.e. skip forward one codepoint at a time, not one byte at a time)
|
||||||
//
|
//
|
||||||
__attribute__((nonnull, pure))
|
__attribute__((nonnull, pure))
|
||||||
static inline const char *next_char(file_t *f, const char *str)
|
inline const char *next_char(file_t *f, const char *str)
|
||||||
{
|
{
|
||||||
if (__builtin_expect(str+1 <= f->end && (str[0] & 0x80) == 0x0, 1))
|
if (__builtin_expect(str+1 <= f->end && (str[0] & 0x80) == 0x0, 1))
|
||||||
return str+1;
|
return str+1;
|
||||||
@ -30,7 +30,7 @@ static inline const char *next_char(file_t *f, const char *str)
|
|||||||
// (i.e. skip backwards one codepoint at a time, not one byte at a time)
|
// (i.e. skip backwards one codepoint at a time, not one byte at a time)
|
||||||
//
|
//
|
||||||
__attribute__((nonnull, pure))
|
__attribute__((nonnull, pure))
|
||||||
static inline const char *prev_char(file_t *f, const char *str)
|
inline const char *prev_char(file_t *f, const char *str)
|
||||||
{
|
{
|
||||||
if (__builtin_expect(str-1 >= f->start && (str[-1] & 0x80) == 0x0, 1))
|
if (__builtin_expect(str-1 >= f->start && (str[-1] & 0x80) == 0x0, 1))
|
||||||
return str-1;
|
return str-1;
|
||||||
|
Loading…
Reference in New Issue
Block a user