mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-29 05:39:55 +03:00
Renaming and symmetrifying two functions, and improving some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4861 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
8e01293b34
commit
cf4f80da9a
@ -7,6 +7,9 @@
|
||||
* src/rcfile.c (parse_magictype, parse_headers): Handle the libmagic
|
||||
and headerline regexes in the same manner, eliding a static variable
|
||||
while renaming some others.
|
||||
* src/*.h, src/rcfile.c (parse_magictype, parse_headers): Rename them
|
||||
to parse_magic_exp() and parse_header_exp() to be more fitting, further
|
||||
symmetrify them, and improve some comments.
|
||||
|
||||
2014-05-10 Chris Allegretta <chrisa@asty.org>
|
||||
* src/rcfile.c (parse_color_names): Redefine false and true to
|
||||
|
12
src/nano.h
12
src/nano.h
@ -228,11 +228,11 @@ typedef struct colortype {
|
||||
|
||||
typedef struct exttype {
|
||||
char *ext_regex;
|
||||
/* The extensions that match this syntax. */
|
||||
/* The regexstrings for the things that match this syntax. */
|
||||
regex_t *ext;
|
||||
/* The compiled extensions that match this syntax. */
|
||||
/* The compiled regexes. */
|
||||
struct exttype *next;
|
||||
/* Next set of extensions. */
|
||||
/* Next set of regexes. */
|
||||
} exttype;
|
||||
|
||||
typedef struct syntaxtype {
|
||||
@ -241,13 +241,13 @@ typedef struct syntaxtype {
|
||||
exttype *extensions;
|
||||
/* The list of extensions that this syntax applies to. */
|
||||
exttype *headers;
|
||||
/* Regexes to match on the 'header' (1st line) of the file. */
|
||||
/* The list of headerlines that this syntax applies to. */
|
||||
exttype *magics;
|
||||
/* Regexes to match libmagic results. */
|
||||
/* The list of libmagic results that this syntax applies to. */
|
||||
colortype *color;
|
||||
/* The colors used in this syntax. */
|
||||
char *linter;
|
||||
/* Command to lint this type of file. */
|
||||
/* The command to lint this type of file. */
|
||||
int nmultis;
|
||||
/* How many multi-line strings this syntax has. */
|
||||
struct syntaxtype *next;
|
||||
|
@ -542,7 +542,7 @@ int do_prompt(bool allow_tabs,
|
||||
void do_prompt_abort(void);
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
|
||||
/* All functions in rcfile.c. */
|
||||
/* Most functions in rcfile.c. */
|
||||
#ifndef DISABLE_NANORC
|
||||
void rcfile_error(const char *msg, ...);
|
||||
char *parse_next_word(char *ptr);
|
||||
@ -551,7 +551,6 @@ char *parse_argument(char *ptr);
|
||||
char *parse_next_regex(char *ptr);
|
||||
bool nregcomp(const char *regex, int eflags);
|
||||
void parse_syntax(char *ptr);
|
||||
void parse_magic_syntax(char *ptr);
|
||||
void parse_include(char *ptr);
|
||||
short color_to_short(const char *colorname, bool *bright);
|
||||
void parse_colors(char *ptr, bool icase);
|
||||
|
26
src/rcfile.c
26
src/rcfile.c
@ -380,10 +380,9 @@ void parse_syntax(char *ptr)
|
||||
}
|
||||
|
||||
/* Parse the magic regexes that may influence the choice of syntax. */
|
||||
void parse_magictype(char *ptr)
|
||||
void parse_magic_exp(char *ptr)
|
||||
{
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
const char *fileregptr = NULL;
|
||||
exttype *endmagic = NULL;
|
||||
|
||||
assert(ptr != NULL);
|
||||
@ -411,6 +410,7 @@ void parse_magictype(char *ptr)
|
||||
|
||||
/* Now load the magic regexes into their part of the struct. */
|
||||
while (*ptr != '\0') {
|
||||
const char *regexstring;
|
||||
exttype *newmagic;
|
||||
|
||||
while (*ptr != '"' && *ptr != '\0')
|
||||
@ -421,7 +421,7 @@ void parse_magictype(char *ptr)
|
||||
|
||||
ptr++;
|
||||
|
||||
fileregptr = ptr;
|
||||
regexstring = ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
@ -429,8 +429,8 @@ void parse_magictype(char *ptr)
|
||||
newmagic = (exttype *)nmalloc(sizeof(exttype));
|
||||
|
||||
/* Save the regex string if it's valid. */
|
||||
if (nregcomp(fileregptr, REG_NOSUB)) {
|
||||
newmagic->ext_regex = mallocstrcpy(NULL, fileregptr);
|
||||
if (nregcomp(regexstring, REG_NOSUB)) {
|
||||
newmagic->ext_regex = mallocstrcpy(NULL, regexstring);
|
||||
newmagic->ext = NULL;
|
||||
|
||||
if (endmagic == NULL)
|
||||
@ -874,9 +874,8 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
|
||||
}
|
||||
|
||||
/* Parse the header-line regexes that may influence the choice of syntax. */
|
||||
void parse_headers(char *ptr)
|
||||
void parse_header_exp(char *ptr)
|
||||
{
|
||||
char *regstr;
|
||||
exttype *endheader = NULL;
|
||||
|
||||
assert(ptr != NULL);
|
||||
@ -892,7 +891,8 @@ void parse_headers(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
while (ptr != NULL && *ptr != '\0') {
|
||||
while (*ptr != '\0') {
|
||||
const char *regexstring;
|
||||
exttype *newheader;
|
||||
|
||||
if (*ptr != '"') {
|
||||
@ -904,7 +904,7 @@ void parse_headers(char *ptr)
|
||||
|
||||
ptr++;
|
||||
|
||||
regstr = ptr;
|
||||
regexstring = ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
@ -912,8 +912,8 @@ void parse_headers(char *ptr)
|
||||
newheader = (exttype *)nmalloc(sizeof(exttype));
|
||||
|
||||
/* Save the regex string if it's valid */
|
||||
if (nregcomp(regstr, 0)) {
|
||||
newheader->ext_regex = mallocstrcpy(NULL, regstr);
|
||||
if (nregcomp(regexstring, 0)) {
|
||||
newheader->ext_regex = mallocstrcpy(NULL, regexstring);
|
||||
newheader->ext = NULL;
|
||||
|
||||
if (endheader == NULL)
|
||||
@ -1078,9 +1078,9 @@ void parse_rcfile(FILE *rcstream
|
||||
parse_syntax(ptr);
|
||||
}
|
||||
else if (strcasecmp(keyword, "magic") == 0)
|
||||
parse_magictype(ptr);
|
||||
parse_magic_exp(ptr);
|
||||
else if (strcasecmp(keyword, "header") == 0)
|
||||
parse_headers(ptr);
|
||||
parse_header_exp(ptr);
|
||||
else if (strcasecmp(keyword, "color") == 0)
|
||||
parse_colors(ptr, FALSE);
|
||||
else if (strcasecmp(keyword, "icolor") == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user