refactor(find.c): Replace magic num 8 with const
This commit is contained in:
parent
642e766b72
commit
e3297cdad2
@ -705,6 +705,7 @@ int findinit(const char *pattern_) {
|
|||||||
int i;
|
int i;
|
||||||
char *s;
|
char *s;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
const unsigned int truncation_len = 8;
|
||||||
|
|
||||||
/* HBB: be nice: free regexp before allocating a new one */
|
/* HBB: be nice: free regexp before allocating a new one */
|
||||||
if(isregexp_valid == true) regfree(®exp);
|
if(isregexp_valid == true) regfree(®exp);
|
||||||
@ -759,8 +760,8 @@ int findinit(const char *pattern_) {
|
|||||||
/* look for use of the -T option (truncate symbol to 8
|
/* look for use of the -T option (truncate symbol to 8
|
||||||
characters) on a database not built with -T */
|
characters) on a database not built with -T */
|
||||||
if(trun_syms == true && preserve_database == true && dbtruncated == false &&
|
if(trun_syms == true && preserve_database == true && dbtruncated == false &&
|
||||||
s - pattern >= 8) {
|
s - pattern >= truncation_len) {
|
||||||
strcpy(pattern + 8, ".*");
|
strcpy(pattern + truncation_len, ".*");
|
||||||
isregexp = true;
|
isregexp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -780,7 +781,7 @@ int findinit(const char *pattern_) {
|
|||||||
s[i] = '\0';
|
s[i] = '\0';
|
||||||
}
|
}
|
||||||
/* if requested, try to truncate a C symbol pattern */
|
/* if requested, try to truncate a C symbol pattern */
|
||||||
if(trun_syms == true && strpbrk(s, "[{*+") == NULL) { s[8] = '\0'; }
|
if(trun_syms == true && strpbrk(s, "[{*+") == NULL) { s[truncation_len] = '\0'; }
|
||||||
/* must be an exact match */
|
/* must be an exact match */
|
||||||
/* note: regcomp doesn't recognize ^*keypad$ as a syntax error
|
/* note: regcomp doesn't recognize ^*keypad$ as a syntax error
|
||||||
unless it is given as a single arg */
|
unless it is given as a single arg */
|
||||||
@ -793,7 +794,7 @@ int findinit(const char *pattern_) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if requested, truncate a C symbol pattern */
|
/* if requested, truncate a C symbol pattern */
|
||||||
if(trun_syms == true && field <= CALLING) { pattern[8] = '\0'; }
|
if(trun_syms == true && field <= CALLING) { pattern[truncation_len] = '\0'; }
|
||||||
/* compress the string pattern for matching */
|
/* compress the string pattern for matching */
|
||||||
s = cpattern;
|
s = cpattern;
|
||||||
for(i = 0; (c = pattern[i]) != '\0'; ++i) {
|
for(i = 0; (c = pattern[i]) != '\0'; ++i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user