Renaming another struct element, because it refers not just

to file extensions, but also to header lines and magic strings.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5690 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-02-26 20:19:13 +00:00
parent 3522751c6b
commit 07441adb14
5 changed files with 18 additions and 16 deletions

View File

@ -9,6 +9,8 @@
* src/color.c (color_update): Rename a variable for conciseness.
* src/color.c (nfreeregex): Elide this function, now used just once.
* src/nano.h: Rename a struct element for aptness and contrast.
* src/nano.h: Rename another element, because it refers not just
to file extensions, but also to header lines and magic strings.
GNU nano 2.5.3 - 2016.02.25

View File

@ -147,20 +147,20 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
bool not_compiled;
for (item = head; item != NULL; item = item->next) {
not_compiled = (item->ext == NULL);
not_compiled = (item->rgx == NULL);
if (not_compiled) {
item->ext = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(item->ext, fixbounds(item->full_regex), REG_EXTENDED);
item->rgx = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(item->rgx, fixbounds(item->full_regex), REG_EXTENDED);
}
if (regexec(item->ext, shibboleth, 0, NULL, 0) == 0)
if (regexec(item->rgx, shibboleth, 0, NULL, 0) == 0)
return TRUE;
if (not_compiled) {
regfree(item->ext);
free(item->ext);
item->ext = NULL;
regfree(item->rgx);
free(item->rgx);
item->rgx = NULL;
}
}

View File

@ -1627,9 +1627,9 @@ int strtomenu(const char *input)
void free_list_item(regexlisttype *dropit)
{
free(dropit->full_regex);
if (dropit->ext != NULL)
regfree(dropit->ext);
free(dropit->ext);
if (dropit->rgx != NULL)
regfree(dropit->rgx);
free(dropit->rgx);
free(dropit);
}
#endif

View File

@ -231,10 +231,10 @@ typedef struct colortype {
typedef struct regexlisttype {
char *full_regex;
/* A regex string to match things that imply a certain syntax. */
regex_t *ext;
/* The compiled regexes. */
regex_t *rgx;
/* The compiled regex. */
struct regexlisttype *next;
/* Next set of regexes. */
/* The next regex. */
} regexlisttype;
typedef struct syntaxtype {

View File

@ -375,7 +375,7 @@ void parse_syntax(char *ptr)
/* Save the extension regex if it's valid. */
if (nregcomp(fileregptr, REG_NOSUB)) {
newext->full_regex = mallocstrcpy(NULL, fileregptr);
newext->ext = NULL;
newext->rgx = NULL;
if (endext == NULL)
endsyntax->extensions = newext;
@ -896,7 +896,7 @@ void parse_header_exp(char *ptr)
/* Save the regex string if it's valid. */
if (nregcomp(regexstring, 0)) {
newheader->full_regex = mallocstrcpy(NULL, regexstring);
newheader->ext = NULL;
newheader->rgx = NULL;
if (endheader == NULL)
endsyntax->headers = newheader;
@ -961,7 +961,7 @@ void parse_magic_exp(char *ptr)
/* Save the regex string if it's valid. */
if (nregcomp(regexstring, REG_NOSUB)) {
newmagic->full_regex = mallocstrcpy(NULL, regexstring);
newmagic->ext = NULL;
newmagic->rgx = NULL;
if (endmagic == NULL)
endsyntax->magics = newmagic;