+2014-04-08 David Lawrence Ramsey <pooka109@gmail.com>
+ * src/*.c: More editing of comment blocks and trimming of blank lines.
+
2014-04-08 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c: Correct two comments, and tweak two others.
* src/color.c (color_update): Correct one comment, tweak some others,
_("Too many backup files?"));
free(backuptemp);
free(backupname);
- /* If we can't write to the backup, DONT go on, since
- whatever caused the backup file to fail (e.g. disk
- full may well cause the real file write to fail, which
- means we could lose both the backup and the original! */
+ /* If we can't write to the backup, DON'T go on, since
+ * whatever caused the backup file to fail (e.g. disk
+ * full may well cause the real file write to fail,
+ * which means we could lose both the backup and the
+ * original! */
goto cleanup_and_exit;
} else {
free(backupname);
}
/* First, unlink any existing backups. Next, open the backup
- file with O_CREAT and O_EXCL. If it succeeds, we
- have a file descriptor to a new backup file. */
+ * file with O_CREAT and O_EXCL. If it succeeds, we have a file
+ * descriptor to a new backup file. */
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
backup_fd = open(backupname, backup_cflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
/* Now we've got a safe file stream. If the previous open()
- call failed, this will return NULL. */
+ * call failed, this will return NULL. */
backup_file = fdopen(backup_fd, "wb");
if (backup_fd < 0 || backup_file == NULL) {
goto skip_backup;
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
- /* If we can't write to the backup, DONT go on, since
- whatever caused the backup file to fail (e.g. disk
- full may well cause the real file write to fail, which
- means we could lose both the backup and the original! */
+ /* If we can't write to the backup, DON'T go on, since
+ * whatever caused the backup file to fail (e.g. disk full
+ * may well cause the real file write to fail, which means
+ * we could lose both the backup and the original! */
goto cleanup_and_exit;
}
}
}
#ifndef NANO_TINY
- /* Complain if the file exists, the name hasn't changed, and the
- stat information we had before does not match what we have now */
+ /* Complain if the file exists, the name hasn't changed,
+ * and the stat information we had before does not match
+ * what we have now. */
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
i = do_yesno_prompt(FALSE,
return construct_filename("/.nano/filepos_history");
}
-
-
void history_error(const char *msg, ...)
{
va_list ap;
legacyhist, nanohist);
}
-
-
/* Assume do_rcfile() has reported a missing home directory. */
if (nanohist != NULL) {
FILE *hist = fopen(nanohist, "rb");
}
/* Didn't find it, make a new node yo! */
-
posptr = (poshiststruct *) nmalloc(sizeof(poshiststruct));
posptr->filename = mallocstrcpy(NULL, fullpath);
posptr->lineno = lineno;
return 0;
}
-
/* Load histories from ~/.nano_history. */
void load_poshistory(void)
{
}
#ifndef NANO_TINY
-/* Now let's come up with a single (hopefully)
- * function to get a string for each flag. */
+/* Now let's come up with a single (hopefully) function to get a string
+ * for each flag. */
const char *flagtostr(int flag)
{
switch (flag) {
}
#endif /* !NANO_TINY */
-/* Interpret the string given by the rc file and return a
- * shortcut struct, complete with proper value for execute. */
+/* Interpret the string given by the rc file and return a shortcut
+ * struct, complete with proper value for execute. */
sc *strtosc(int menu, char *input)
{
sc *s;
display_main_list();
}
-/* Another placeholder for function mapping */
+/* Another placeholder for function mapping. */
void do_cancel(void)
{
;
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
}
-/* Bleh */
+/* Bleh. */
void do_toggle_void(void)
{
-;
+ ;
}
#endif /* !NANO_TINY */
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
-
#ifdef DEBUG
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
#endif
/* We should never get here. */
assert(FALSE);
}
-
'\0' || currmenu != MWRITEFILE)
do_statusbar_backspace();
} else {
- /* Handle the normal statusbar prompt shortcuts, setting
- * ran_func to TRUE if we try to run their associated
- * functions and setting finished to TRUE to indicate
- * that we're done after running or trying to run their
- * associated functions. */
-
+ /* Handle the normal statusbar prompt shortcuts, setting
+ * ran_func to TRUE if we try to run their associated
+ * functions and setting finished to TRUE to indicate
+ * that we're done after running or trying to run their
+ * associated functions. */
f = sctofunc((sc *) s);
if (s->scfunc != 0 && s->execute == TRUE) {
*ran_func = TRUE;
void do_credits(void);
#endif
-/* May as just throw these here since they are just placeholders */
+/* May as well throw these here, since they are just placeholders. */
void do_cancel(void);
void do_page_up(void);
void do_page_down(void);
void no_replace_void(void);
void ext_cmd_void(void);
-
#endif /* !PROTO_H */
ptr = parse_next_word(ptr);
if (!strcmp(menuptr, "")) {
- /* TRANSLATORS: do not translate the word "all". */
+ /* TRANSLATORS: Do not translate the word "all". */
rcfile_error(N_("Must specify menu in which to bind/unbind key (or \"all\")"));
return;
}
struct stat rcinfo;
FILE *rcstream;
- /* Can't get the specified file's full path cause it may screw up
- our cwd depending on the parent dirs' permissions, (see Savannah bug 25297) */
+ /* Can't get the specified file's full path because it may screw up
+ * our cwd depending on the parent directories' permissions (see
+ * Savannah bug #25297). */
/* Don't open directories, character files, or block files. */
if (stat(file, &rcinfo) != -1) {
#ifdef DEBUG
fprintf(stderr, "Adding new entry for fg %hd, bg %hd\n", fg, bg);
#endif
- /* Need to recompute endcolor now so we can extend colors to syntaxes */
+ /* Need to recompute endcolor now so we can extend
+ * colors to syntaxes. */
for (endcolor = endsyntax->color; endcolor->next != NULL; endcolor = endcolor->next)
- ;
+ ;
endcolor->next = newcolor;
}
if (ptr == NULL)
break;
- /* If the start regex was invalid, skip past the end regex to
- * stay in sync. */
+ /* If the start regex was invalid, skip past the end regex
+ * to stay in sync. */
if (cancelled)
continue;
}
}
-
/* Parse the linter requested for this syntax. Simple? */
void parse_linter(char *ptr)
{
}
#endif /* !DISABLE_COLOR */
-
/* Check whether the user has unmapped every shortcut for a
* sequence we consider 'vital', like the exit function. */
static void check_vitals_mapped(void)
keyword = ptr;
ptr = parse_next_word(ptr);
-
#ifndef DISABLE_COLOR
/* Handle extending first... */
if (strcasecmp(keyword, "extendsyntax") == 0) {
return (*h)->data;
}
-/* More placeholders */
+/* More placeholders. */
void get_history_newer_void(void)
{
;
do_indent(-tabsize);
}
-
/* Undo a cut, or redo an uncut. */
void undo_cut(undo *u)
{
}
/* Redo a cut, or undo an uncut. */
-void redo_cut(undo *u) {
+void redo_cut(undo *u)
+{
int i;
filestruct *t, *c;
free(cutbuffer);
cutbuffer = NULL;
- /* Move ahead the same # lines we had if a marked cut. */
+ /* Move ahead the same number of lines we had if a marked cut. */
if (u->mark_set) {
for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++)
t = t->next;
* We'll need to trick nano into thinking it's a marked cut,
* to cut more than one line again. */
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
-
#ifdef DEBUG
- fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
+ fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
#endif
c = c->next;
t = t->next;
- }
+ }
openfile->mark_begin = t;
openfile->mark_begin_x = 0;
openfile->mark_set = TRUE;
#endif
openfile->current_x = u->begin;
- switch(u->type) {
+ switch (u->type) {
case ADD:
undidmsg = _("text add");
len = strlen(f->data) - strlen(u->strdata) + 1;
fprintf(stderr, "Redo running for type %d\n", u->type);
#endif
- switch(u->type) {
+ switch (u->type) {
case ADD:
undidmsg = _("text add");
len = strlen(f->data) + strlen(u->strdata) + 1;
if (!undoing)
add_undo(ENTER);
-
/* Do auto-indenting, like the neolithic Turbo Pascal editor. */
if (ISSET(AUTOINDENT)) {
/* If we are breaking the line in the indentation, the new
}
/* Need this again... */
-void do_enter_void(void) {
+void do_enter_void(void)
+{
do_enter(FALSE);
}
undo *u;
char *data;
openfilestruct *fs = openfile;
- static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut. */
- ssize_t wrap_loc; /* For calculating split beginning. */
+ static undo *last_cutu = NULL;
+ /* Last thing we cut to set up the undo for uncut. */
+ ssize_t wrap_loc;
+ /* For calculating split beginning. */
if (!ISSET(UNDOABLE))
return;
}
#ifdef DEBUG
- fprintf(stderr, "Done in udpate_undo (type was %d)\n", action);
+ fprintf(stderr, "Done in update_undo (type was %d)\n", action);
#endif
if (fs->last_action != action) {
#ifdef DEBUG
char *message = mallocstrcpy(NULL, read_buff_word);
/* At the moment we're assuming the following formats:
- filenameorcategory:line:column:message (e.g. splint)
- filenameorcategory:line:message (e.g. pyflakes)
- filenameorcategory:line,col:message (e.g. pylint)
- This could be turnes into some scanf() based parser but ugh.
- */
+ *
+ * filenameorcategory:line:column:message (e.g. splint)
+ * filenameorcategory:line:message (e.g. pyflakes)
+ * filenameorcategory:line,col:message (e.g. pylint)
+ *
+ * This could be turned into some scanf() based parser,
+ * but ugh. */
if ((filename = strtok(read_buff_word, ":")) != NULL) {
if ((linestr = strtok(NULL, ":")) != NULL) {
if ((maybecol = strtok(NULL, ":")) != NULL) {
tmpcolno = strtol(maybecol, &convendptr, 10);
if (*convendptr != '\0') {
-
- /* Prev field might still be line,col format */
+ /* Previous field might still be
+ * line,col format. */
strtok(linestr, ",");
if ((tmplinecol = strtok(NULL, ",")) != NULL)
tmpcolno = strtol(tmplinecol, NULL, 10);
#ifdef DEBUG
fprintf(stderr, "text.c:do_lint:Successful parse! %d:%d:%s\n", tmplineno, tmpcolno, message);
#endif
- /* Nice we have a lint message we can use */
+ /* Nice. We have a lint message we can use. */
parsesuccess++;
tmplint = curlint;
curlint = nmalloc(sizeof(lintstruct));
free(output);
}
-
f = f->next;
}
-
/* And put back the equivalent key. */
if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->scfunc);
return NULL;
}
-
-/* Try to get a function back from a window. Just a wrapper so
- functions to need to create function_key meta_key blah blah
- mmenu - what menu name to look through for valid funcs */
+/* Try to get a function back from a window. Just a wrapper
+ * functions need to create a function_key meta_key blah blah
+ * menu - what menu name to look through for valid funcs. */
const subnfunc *getfuncfromkey(WINDOW *win)
{
int kbinput;
}
-
-
/* Move to (x, y) in win, and display a line of n spaces with the
* current attributes. */
void blank_line(WINDOW *win, int y, int x, int n)
nodelay(edit, FALSE);
}
-
/* Highlight the current word being replaced or spell checked. We
* expect word to have tabs and control characters expanded. */
void do_replace_highlight(bool highlight, const char *word)