Commit 07441adb authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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
No related merge requests found
Showing with 18 additions and 16 deletions
+18 -16
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* src/color.c (color_update): Rename a variable for conciseness. * src/color.c (color_update): Rename a variable for conciseness.
* src/color.c (nfreeregex): Elide this function, now used just once. * 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 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 GNU nano 2.5.3 - 2016.02.25
......
...@@ -147,20 +147,20 @@ bool found_in_list(regexlisttype *head, const char *shibboleth) ...@@ -147,20 +147,20 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
bool not_compiled; bool not_compiled;
for (item = head; item != NULL; item = item->next) { for (item = head; item != NULL; item = item->next) {
not_compiled = (item->ext == NULL); not_compiled = (item->rgx == NULL);
if (not_compiled) { if (not_compiled) {
item->ext = (regex_t *)nmalloc(sizeof(regex_t)); item->rgx = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(item->ext, fixbounds(item->full_regex), REG_EXTENDED); 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; return TRUE;
if (not_compiled) { if (not_compiled) {
regfree(item->ext); regfree(item->rgx);
free(item->ext); free(item->rgx);
item->ext = NULL; item->rgx = NULL;
} }
} }
......
...@@ -1627,9 +1627,9 @@ int strtomenu(const char *input) ...@@ -1627,9 +1627,9 @@ int strtomenu(const char *input)
void free_list_item(regexlisttype *dropit) void free_list_item(regexlisttype *dropit)
{ {
free(dropit->full_regex); free(dropit->full_regex);
if (dropit->ext != NULL) if (dropit->rgx != NULL)
regfree(dropit->ext); regfree(dropit->rgx);
free(dropit->ext); free(dropit->rgx);
free(dropit); free(dropit);
} }
#endif #endif
......
...@@ -231,10 +231,10 @@ typedef struct colortype { ...@@ -231,10 +231,10 @@ typedef struct colortype {
typedef struct regexlisttype { typedef struct regexlisttype {
char *full_regex; char *full_regex;
/* A regex string to match things that imply a certain syntax. */ /* A regex string to match things that imply a certain syntax. */
regex_t *ext; regex_t *rgx;
/* The compiled regexes. */ /* The compiled regex. */
struct regexlisttype *next; struct regexlisttype *next;
/* Next set of regexes. */ /* The next regex. */
} regexlisttype; } regexlisttype;
typedef struct syntaxtype { typedef struct syntaxtype {
......
...@@ -375,7 +375,7 @@ void parse_syntax(char *ptr) ...@@ -375,7 +375,7 @@ void parse_syntax(char *ptr)
/* Save the extension regex if it's valid. */ /* Save the extension regex if it's valid. */
if (nregcomp(fileregptr, REG_NOSUB)) { if (nregcomp(fileregptr, REG_NOSUB)) {
newext->full_regex = mallocstrcpy(NULL, fileregptr); newext->full_regex = mallocstrcpy(NULL, fileregptr);
newext->ext = NULL; newext->rgx = NULL;
if (endext == NULL) if (endext == NULL)
endsyntax->extensions = newext; endsyntax->extensions = newext;
...@@ -896,7 +896,7 @@ void parse_header_exp(char *ptr) ...@@ -896,7 +896,7 @@ void parse_header_exp(char *ptr)
/* Save the regex string if it's valid. */ /* Save the regex string if it's valid. */
if (nregcomp(regexstring, 0)) { if (nregcomp(regexstring, 0)) {
newheader->full_regex = mallocstrcpy(NULL, regexstring); newheader->full_regex = mallocstrcpy(NULL, regexstring);
newheader->ext = NULL; newheader->rgx = NULL;
if (endheader == NULL) if (endheader == NULL)
endsyntax->headers = newheader; endsyntax->headers = newheader;
...@@ -961,7 +961,7 @@ void parse_magic_exp(char *ptr) ...@@ -961,7 +961,7 @@ void parse_magic_exp(char *ptr)
/* Save the regex string if it's valid. */ /* Save the regex string if it's valid. */
if (nregcomp(regexstring, REG_NOSUB)) { if (nregcomp(regexstring, REG_NOSUB)) {
newmagic->full_regex = mallocstrcpy(NULL, regexstring); newmagic->full_regex = mallocstrcpy(NULL, regexstring);
newmagic->ext = NULL; newmagic->rgx = NULL;
if (endmagic == NULL) if (endmagic == NULL)
endsyntax->magics = newmagic; endsyntax->magics = newmagic;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment