* doc/syntax/nanorc.nanorc: Show key names like M-6 and M-/ as valid.
* src/global.c (thanks_for_all_the_fish): Upon exit also free the
lists with functions and shortcuts.
+ * src/*.c: Several random whitespace and comment tweaks.
2014-05-12 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_spell): Provide startup feedback, as for the linter.
char *full_filename;
bool ans = TRUE;
-
if (ISSET(VIEW_MODE))
return TRUE;
full_filename = get_full_path(filename);
/* Okay, if we can't stat the path due to a component's
- permissions, just try the relative one */
+ permissions, just try the relative one. */
if (full_filename == NULL
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
full_filename = get_full_path(filename);
/* Okay, if we can't stat the path due to a component's
- permissions, just try the relative one */
+ permissions, just try the relative one. */
if (full_filename == NULL
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
* allow inserting a file into a new buffer. */
void do_insertfile_void(void)
{
-
if (ISSET(RESTRICTED)) {
nano_disabled_msg();
return;
bool path_only;
if (origpath == NULL)
- return NULL;
+ return NULL;
/* Get the current directory. If it doesn't exist, back up and try
* again until we get a directory that does, and use that as the
goto cleanup_and_exit;
}
- /* Save the state of the file at the end of the symlink (if there is
- * one). */
+ /* Check whether the file (at the end of the symlink) exists. */
realexists = (stat(realname, &st) != -1);
#ifndef NANO_TINY
- /* if we have not stat()d this file before (say, the user just
- * specified it interactively), stat and save the value
- * or else we will chase null pointers when we do
- * modtime checks, preserve file times, etc. during backup */
+ /* If we haven't stat()d this file before (say, the user just
+ * specified it interactively), stat and save the value now,
+ * or else we will chase null pointers when we do modtime checks,
+ * preserve file times, and so on, during backup. */
if (openfile->current_stat == NULL && !tmp && realexists) {
openfile->current_stat = (struct stat *)nmalloc(sizeof(struct stat));
stat(realname, openfile->current_stat);
}
return newstr;
-
}
char *histfilename(void)
ssize_t read, lineno, xno;
poshiststruct *posptr;
- /* See if we can find the file we're currently editing */
+ /* See if we can find the file we're currently editing. */
while ((read = getline(&line, &buf_len, hist)) >= 0) {
if (read > 0 && line[read - 1] == '\n') {
read--;
#endif
bool nodelay_mode = FALSE;
- /* Are we in nodelay mode (checking for a cancel wile doing something */
+ /* Are we checking for a cancel wile doing something? */
char *answer = NULL;
/* The answer string used by the statusbar prompt. */
/* The directory where we store backup files. */
const char *locking_prefix = ".";
- /* Prefix of how to store the vim-style lock file */
+ /* Prefix of how to store the vim-style lock file. */
const char *locking_suffix = ".swp";
- /* Suffix of the vim-style lock file */
+ /* Suffix of the vim-style lock file. */
#endif
#ifndef DISABLE_OPERATINGDIR
char *operating_dir = NULL;
if (htx[2] != NULL)
allocsize += strlen(htx[2]);
- /* Count the shortcut help text. Each entry has up to three keys,
- * which fill 24 columns, plus translated text, plus one or two
- * \n's. */
+ /* Calculate the length of the shortcut help text. Each entry has
+ * one or two keys, which fill 16 columns, plus translated text,
+ * plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
- allocsize += (24 * mb_cur_max()) + strlen(f->help) + 2;
+ allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
- * Each entry has "M-%c\t\t\t", which fills 24 columns, plus a
- * space, plus translated text, plus one or two '\n's. */
+ * Each entry has "M-%c\t\t", five chars which fill 16 columns,
+ * plus a space, plus translated text, plus one or two '\n's. */
if (currmenu == MMAIN) {
size_t endis_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void)
- allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 9;
+ allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
}
#endif
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
-#endif
+#endif /* !NANO_TINY */
/* If all went well, we didn't overwrite the allocated space for
* help_text. */
interface_color_pair[TITLE_BAR].bright = FALSE;
interface_color_pair[STATUS_BAR].bright = FALSE;
interface_color_pair[KEY_COMBO].bright = FALSE;
- interface_color_pair[FUNCTION_TAG].bright = FALSE;
+ interface_color_pair[FUNCTION_TAG].bright = FALSE;
#endif
#ifdef DEBUG
newheader = (regexlisttype *)nmalloc(sizeof(regexlisttype));
- /* Save the regex string if it's valid */
+ /* Save the regex string if it's valid. */
if (nregcomp(regexstring, 0)) {
newheader->ext_regex = mallocstrcpy(NULL, regexstring);
newheader->ext = NULL;
copy_from_filestruct(cutbuffer);
free_filestruct(cutbuffer);
cutbuffer = NULL;
-
}
/* Redo a cut, or undo an uncut. */
#endif /* !DISABLE_SPELLER */
#ifndef DISABLE_COLOR
-/* Cleanup things to do after leaving the linter */
+/* Cleanup things to do after leaving the linter. */
void lint_cleanup(void)
{
currmenu = MMAIN;
return totsize;
}
-/* Get back a pointer given a line number in the current openfilestruct */
+/* Get back a pointer given a line number in the current openfilestruct. */
filestruct *fsfromline(ssize_t lineno)
{
filestruct *f = openfile->current;
/* Read in a character and interpret it. Continue doing this until
* we get a recognized value or sequence. */
- while ((kbinput = parse_kbinput(win, meta_key, func_key)) == ERR);
+ while ((kbinput = parse_kbinput(win, meta_key, func_key)) == ERR)
+ ;
/* If we read from the edit window, blank the statusbar if we need
* to. */
if (kbinput == 0)
return 0;
} else
- while ((kbinput = get_input(win, 1)) == NULL);
+ while ((kbinput = get_input(win, 1)) == NULL)
+ ;
switch (*kbinput) {
case ERR:
int *kbinput, *retval;
/* Read in the first keystroke. */
- while ((kbinput = get_input(win, 1)) == NULL);
+ while ((kbinput = get_input(win, 1)) == NULL)
+ ;
#ifdef ENABLE_UTF8
if (using_utf8()) {
statusbar(_("Unicode Input"));
while (uni == ERR) {
- while ((kbinput = get_input(win, 1)) == NULL);
-
+ while ((kbinput = get_input(win, 1)) == NULL)
+ ;
uni = get_unicode_kbinput(*kbinput);
}
#ifdef DEBUG
fprintf(stderr, "update_line(): Softwrap code, moving to %d index %lu\n", line, (unsigned long) index);
#endif
- blank_line(edit, line, 0, COLS);
+ blank_line(edit, line, 0, COLS);
/* Expand the line, replacing tabs with spaces, and control
- * characters with their displayed forms. */
+ * characters with their displayed forms. */
converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
#ifdef DEBUG
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
/* Paint the line. */
edit_draw(fileptr, converted, line, index);
- free(converted);
+ free(converted);
extralinesused++;
}
}
maxrows || openfile->current->lineno <
openfile->edittop->lineno || openfile->current->lineno >=
openfile->edittop->lineno + maxrows) {
-
#ifdef DEBUG
- fprintf(stderr, "edit_redraw(): line %d was offscreen, oldcurrent = %d edittop = %d",
- openfile->current->lineno, old_current->lineno, openfile->edittop->lineno);
+ fprintf(stderr, "edit_redraw(): line %d was offscreen, oldcurrent = %d edittop = %d",
+ openfile->current->lineno, old_current->lineno, openfile->edittop->lineno);
#endif
#ifndef NANO_TINY