Commit 61bba1de authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Tweaking some comments.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4718 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 7a254dd1
Showing with 17 additions and 22 deletions
+17 -22
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
to override --enable-tiny. to override --enable-tiny.
* src/rcfile.c (check_vitals_mapped): Do not allow 'set quiet' * src/rcfile.c (check_vitals_mapped): Do not allow 'set quiet'
to suppress a fatal-error message, make sure the user sees it. to suppress a fatal-error message, make sure the user sees it.
* src/color.c: Comment tweaks.
2014-04-03 Benno Schulenberg <bensberg@justemail.net> 2014-04-03 Benno Schulenberg <bensberg@justemail.net>
* configure.ac: Remove unused '*_support' variables. * configure.ac: Remove unused '*_support' variables.
......
...@@ -107,7 +107,7 @@ void color_init(void) ...@@ -107,7 +107,7 @@ void color_init(void)
} }
} }
/* Cleanup a regex we previously compiled */ /* Clean up a regex we previously compiled. */
void nfreeregex(regex_t **r) void nfreeregex(regex_t **r)
{ {
assert(r != NULL); assert(r != NULL);
...@@ -125,8 +125,7 @@ void color_update(void) ...@@ -125,8 +125,7 @@ void color_update(void)
colortype *tmpcolor, *defcolor = NULL; colortype *tmpcolor, *defcolor = NULL;
exttype *e; exttype *e;
/* libmagic structures */ /* Var magicstring will stay NULL if we fail to get a magic result. */
/* magicstring will be NULL if we fail to get magic result */
#ifdef HAVE_LIBMAGIC #ifdef HAVE_LIBMAGIC
const char *magicstring = NULL; const char *magicstring = NULL;
const char *magicerr = NULL; const char *magicerr = NULL;
...@@ -134,7 +133,6 @@ void color_update(void) ...@@ -134,7 +133,6 @@ void color_update(void)
struct stat fileinfo; struct stat fileinfo;
#endif /* HAVE_LIBMAGIC */ #endif /* HAVE_LIBMAGIC */
assert(openfile != NULL); assert(openfile != NULL);
openfile->syntax = NULL; openfile->syntax = NULL;
...@@ -208,8 +206,7 @@ void color_update(void) ...@@ -208,8 +206,7 @@ void color_update(void)
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED); regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
} }
/* Set colorstrings if we matched the extension /* Set colorstrings if we matched the extension regex. */
* regex. */
if (regexec(e->ext, openfile->filename, 0, NULL, 0) == 0) { if (regexec(e->ext, openfile->filename, 0, NULL, 0) == 0) {
openfile->syntax = tmpsyntax; openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color; openfile->colorstrings = tmpsyntax->color;
...@@ -223,14 +220,12 @@ void color_update(void) ...@@ -223,14 +220,12 @@ void color_update(void)
} }
} }
/* Check magic if we don't yet have an answer */
#ifdef HAVE_LIBMAGIC #ifdef HAVE_LIBMAGIC
/* Check magic if we don't have an answer yet. */
if (openfile->colorstrings == NULL) { if (openfile->colorstrings == NULL) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "No match using extension, trying libmagic...\n"); fprintf(stderr, "No match using extension, trying libmagic...\n");
#endif #endif
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) { tmpsyntax = tmpsyntax->next) {
for (e = tmpsyntax->magics; e != NULL; e = e->next) { for (e = tmpsyntax->magics; e != NULL; e = e->next) {
...@@ -256,7 +251,7 @@ void color_update(void) ...@@ -256,7 +251,7 @@ void color_update(void)
} }
#endif /* HAVE_LIBMAGIC */ #endif /* HAVE_LIBMAGIC */
/* If we haven't matched anything yet, try the headers */ /* If we haven't matched anything yet, try the headers. */
if (openfile->colorstrings == NULL) { if (openfile->colorstrings == NULL) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "No match for file extensions, looking at headers...\n"); fprintf(stderr, "No match for file extensions, looking at headers...\n");
...@@ -275,11 +270,10 @@ void color_update(void) ...@@ -275,11 +270,10 @@ void color_update(void)
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED); regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
} }
/* Set colorstrings if we matched the extension
* regex. */
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Comparing header regex \"%s\" to fileage \"%s\"...\n", e->ext_regex, openfile->fileage->data); fprintf(stderr, "Comparing header regex \"%s\" to fileage \"%s\"...\n", e->ext_regex, openfile->fileage->data);
#endif #endif
/* Set colorstrings if we matched the extension regex. */
if (regexec(e->ext, openfile->fileage->data, 0, NULL, 0) == 0) { if (regexec(e->ext, openfile->fileage->data, 0, NULL, 0) == 0) {
openfile->syntax = tmpsyntax; openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color; openfile->colorstrings = tmpsyntax->color;
...@@ -298,8 +292,8 @@ void color_update(void) ...@@ -298,8 +292,8 @@ void color_update(void)
} }
/* If we didn't get a syntax based on the file extension, and we /* If we didn't find any syntax yet, and we do have a default one,
* have a default syntax, use it. */ * use it. */
if (openfile->colorstrings == NULL && defcolor != NULL) { if (openfile->colorstrings == NULL && defcolor != NULL) {
openfile->syntax = defsyntax; openfile->syntax = defsyntax;
openfile->colorstrings = defcolor; openfile->colorstrings = defcolor;
...@@ -325,7 +319,7 @@ void color_update(void) ...@@ -325,7 +319,7 @@ void color_update(void)
} }
/* Reset the multicolor info cache for records for any lines which need /* Reset the multicolor info cache for records for any lines which need
to be recalculated */ * to be recalculated. */
void reset_multis_after(filestruct *fileptr, int mindex) void reset_multis_after(filestruct *fileptr, int mindex)
{ {
filestruct *oof; filestruct *oof;
...@@ -375,7 +369,7 @@ void reset_multis_before(filestruct *fileptr, int mindex) ...@@ -375,7 +369,7 @@ void reset_multis_before(filestruct *fileptr, int mindex)
edit_refresh_needed = TRUE; edit_refresh_needed = TRUE;
} }
/* Reset one multiline regex info */ /* Reset one multiline regex info. */
void reset_multis_for_id(filestruct *fileptr, int num) void reset_multis_for_id(filestruct *fileptr, int num)
{ {
reset_multis_before(fileptr, num); reset_multis_before(fileptr, num);
...@@ -383,9 +377,9 @@ void reset_multis_for_id(filestruct *fileptr, int num) ...@@ -383,9 +377,9 @@ void reset_multis_for_id(filestruct *fileptr, int num)
fileptr->multidata[num] = -1; fileptr->multidata[num] = -1;
} }
/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping /* Reset multi-line strings around a filestruct ptr, trying to be smart
force = reset everything regardless, useful when we don't know how much screen state * about stopping. Bool force means: reset everything regardless, useful
has changed */ * when we don't know how much screen state has changed. */
void reset_multis(filestruct *fileptr, bool force) void reset_multis(filestruct *fileptr, bool force)
{ {
int nobegin, noend; int nobegin, noend;
...@@ -397,7 +391,7 @@ void reset_multis(filestruct *fileptr, bool force) ...@@ -397,7 +391,7 @@ void reset_multis(filestruct *fileptr, bool force)
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
/* If it's not a multi-line regex, amscray */ /* If it's not a multi-line regex, amscray. */
if (tmpcolor->end == NULL) if (tmpcolor->end == NULL)
continue; continue;
...@@ -408,7 +402,7 @@ void reset_multis(filestruct *fileptr, bool force) ...@@ -408,7 +402,7 @@ void reset_multis(filestruct *fileptr, bool force)
} }
/* Figure out where the first begin and end are to determine if /* Figure out where the first begin and end are to determine if
things changed drastically for the precalculated multi values */ * things changed drastically for the precalculated multi values. */
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0); nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0); noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) { if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
...@@ -423,7 +417,7 @@ void reset_multis(filestruct *fileptr, bool force) ...@@ -423,7 +417,7 @@ void reset_multis(filestruct *fileptr, bool force)
continue; continue;
} }
/* If we got here assume the worst */ /* If we got here, assume the worst. */
reset_multis_for_id(fileptr, tmpcolor->id); reset_multis_for_id(fileptr, tmpcolor->id);
} }
} }
......
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