Commit d0dec317 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Reformat some comment blocks, fix a few typos, and remove a few unneeded

blank lines.  Patch by David Lawrence Ramsey was lightly tweaked.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4750 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 79 additions and 99 deletions
+79 -99
2014-04-08 David Lawrence Ramsey <pooka109@gmail.com> 2014-04-08 David Lawrence Ramsey <pooka109@gmail.com>
* src/nano.c (main): Convert the literal UTF-8 whitespace string into * src/nano.c (main): Convert the literal UTF-8 whitespace string into
its corresponding byte sequence, and add a comment for it. its corresponding byte sequence, and add a comment for it.
* src/{files.c,global.c,help.c,winio.c}: Reformat some comment blocks,
fix a few typos, and remove a few unneeded blank lines.
2014-04-08 Benno Schulenberg <bensberg@justemail.net> 2014-04-08 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_binding): Melt the binding and unbinding code, * src/rcfile.c (parse_binding): Melt the binding and unbinding code,
...@@ -92,7 +94,7 @@ ...@@ -92,7 +94,7 @@
* doc/syntax/go.nanorc: basic go syntax highlighting * doc/syntax/go.nanorc: basic go syntax highlighting
2014-03-30 Benno Schulenberg <bensberg@justemail.net> 2014-03-30 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/changelog.nanorc: New file, first attemp at colouring * doc/syntax/changelog.nanorc: New file, first attempt at colouring
Changelog files. Changelog files.
* ChangeLog: Consistently use a colon after names of changed files. * ChangeLog: Consistently use a colon after names of changed files.
......
...@@ -105,19 +105,18 @@ void initialize_buffer_text(void) ...@@ -105,19 +105,18 @@ void initialize_buffer_text(void)
openfile->totsize = 0; openfile->totsize = 0;
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* Actyally write the lock file. This function will /* Actually write the lockfile. This function will ALWAYS annihilate
ALWAYS annihilate any previous version of the file. * any previous version of the file. We'll borrow INSECURE_BACKUP here
We'll borrow INSECURE_BACKUP here to decide about lock file * to decide about lockfile paranoia here as well...
paranoia here as well... *
Args: * Args:
lockfilename: file name for lock * lockfilename: file name for lock
origfilename: name of the file the lock is for * origfilename: name of the file the lock is for
modified: whether to set the modified bit in the file * modified: whether to set the modified bit in the file
*
Returns: 1 on success, 0 on failure (but continue loading), -1 on failure and abort * Returns: 1 on success, 0 on failure (but continue loading), -1 on
*/ * failure and abort. */
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified) int write_lockfile(const char *lockfilename, const char *origfilename, bool modified)
{ {
int cflags, fd; int cflags, fd;
...@@ -130,8 +129,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi ...@@ -130,8 +129,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
ssize_t lockdatalen = 1024; ssize_t lockdatalen = 1024;
ssize_t wroteamt; ssize_t wroteamt;
/* Run things which might fail first before we try and blow away /* Run things which might fail first before we try and blow away the
the old state */ * old state. */
myuid = geteuid(); myuid = geteuid();
if ((mypwuid = getpwuid(myuid)) == NULL) { if ((mypwuid = getpwuid(myuid)) == NULL) {
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)")); statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
...@@ -155,14 +154,14 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi ...@@ -155,14 +154,14 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
fd = open(lockfilename, cflags, fd = open(lockfilename, cflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
/* Maybe we just don't have write access, don't stop us from /* Maybe we just don't have write access. Don't stop us from
opening the file at all, just don't set the lock_filename * opening the file at all, just don't set the lock_filename and
and return success */ * return success. */
if (fd < 0 && errno == EACCES) if (fd < 0 && errno == EACCES)
return 1; return 1;
/* Now we've got a safe file stream. If the previous open() /* Now we've got a safe file stream. If the previous open() call
call failed, this will return NULL. */ * failed, this will return NULL. */
filestream = fdopen(fd, "wb"); filestream = fdopen(fd, "wb");
if (fd < 0 || filestream == NULL) { if (fd < 0 || filestream == NULL) {
...@@ -171,25 +170,24 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi ...@@ -171,25 +170,24 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
return -1; return -1;
} }
/* Okay, so at the moment we're following this state for how to
/* Okay. so at the moment we're following this state for how * store the lock data:
to store the lock data: *
byte 0 - 0x62 * byte 0 - 0x62
byte 1 - 0x30 * byte 1 - 0x30
bytes 2-12 - program name which created the lock * bytes 2-12 - program name which created the lock
bytes 24,25 - little endian store of creator program's PID * bytes 24,25 - little endian store of creator program's PID
(b24 = 256^0 column, b25 = 256^1 column) * (b24 = 256^0 column, b25 = 256^1 column)
bytes 28-44 - username of who created the lock * bytes 28-44 - username of who created the lock
bytes 68-100 - hostname of where the lock was created * bytes 68-100 - hostname of where the lock was created
bytes 108-876 - filename the lock is for * bytes 108-876 - filename the lock is for
byte 1007 - 0x55 if file is modified * byte 1007 - 0x55 if file is modified
*
Looks like VIM also stores undo state in this file so we're * Looks like VIM also stores undo state in this file, so we're
gonna have to figure out how to slap a 'OMG don't use recover * gonna have to figure out how to slap a 'OMG don't use recover on
on our lockfile' message in here... * our lockfile' message in here...
*
This is likely very wrong, so this is a WIP * This is likely very wrong, so this is a WIP. */
*/
null_at(&lockdata, lockdatalen); null_at(&lockdata, lockdatalen);
lockdata[0] = 0x62; lockdata[0] = 0x62;
lockdata[1] = 0x30; lockdata[1] = 0x30;
...@@ -224,10 +222,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi ...@@ -224,10 +222,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
return 1; return 1;
} }
/* Less exciting, delete the lockfile. Return -1 if unsuccessful and
/* Less exciting, delete the lock file. * complain on the statusbar, 1 otherwise. */
Return -1 if successful and complain on the statusbar, 1 otherwite
*/
int delete_lockfile(const char *lockfilename) int delete_lockfile(const char *lockfilename)
{ {
if (unlink(lockfilename) < 0 && errno != ENOENT) { if (unlink(lockfilename) < 0 && errno != ENOENT) {
...@@ -238,12 +234,10 @@ int delete_lockfile(const char *lockfilename) ...@@ -238,12 +234,10 @@ int delete_lockfile(const char *lockfilename)
return 1; return 1;
} }
/* Deal with lockfiles. Return -1 on refusing to override the lockfile,
/* Deal with lockfiles. Return -1 on refusing to override * and 1 on successfully creating it; 0 means we were not successful in
the lock file, and 1 on successfully created the lockfile, 0 means * creating the lockfile but we should continue to load the file and
we were not successful on creating the lockfile but we should * complain to the user. */
continue to load the file and complain to the user.
*/
int do_lockfile(const char *filename) int do_lockfile(const char *filename)
{ {
char *lockdir = dirname((char *) mallocstrcpy(NULL, filename)); char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
...@@ -255,7 +249,6 @@ int do_lockfile(const char *filename) ...@@ -255,7 +249,6 @@ int do_lockfile(const char *filename)
struct stat fileinfo; struct stat fileinfo;
int lockfd, lockpid; int lockfd, lockpid;
snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir, snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir,
locking_prefix, lockbase, locking_suffix); locking_prefix, lockbase, locking_suffix);
#ifdef DEBUG #ifdef DEBUG
...@@ -305,7 +298,6 @@ int do_lockfile(const char *filename) ...@@ -305,7 +298,6 @@ int do_lockfile(const char *filename)
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
/* If it's not "", filename is a file to open. We make a new buffer, if /* If it's not "", filename is a file to open. We make a new buffer, if
* necessary, and then open and read the file, if applicable. */ * necessary, and then open and read the file, if applicable. */
void open_buffer(const char *filename, bool undoable) void open_buffer(const char *filename, bool undoable)
...@@ -499,12 +491,11 @@ bool close_buffer(void) ...@@ -499,12 +491,11 @@ bool close_buffer(void)
} }
#endif /* !DISABLE_MULTIBUFFER */ #endif /* !DISABLE_MULTIBUFFER */
/* A bit of a copy and paste from open_file(), is_file_writable() /* A bit of a copy and paste from open_file(), is_file_writable() just
* just checks whether the file is appendable as a quick * checks whether the file is appendable as a quick permissions check,
* permissions check, and we tend to err on the side of permissiveness * and we tend to err on the side of permissiveness (reporting TRUE when
* (reporting TRUE when it might be wrong) to not fluster users * it might be wrong) to not fluster users editing on odd filesystems by
* editing on odd filesystems by printing incorrect warnings. * printing incorrect warnings. */
*/
int is_file_writable(const char *filename) int is_file_writable(const char *filename)
{ {
struct stat fileinfo, fileinfo2; struct stat fileinfo, fileinfo2;
...@@ -597,9 +588,9 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool ...@@ -597,9 +588,9 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
/* Read an open file into the current buffer. f should be set to the /* Read an open file into the current buffer. f should be set to the
* open file, and filename should be set to the name of the file. * open file, and filename should be set to the name of the file.
* undoable means do we want to create undo records to try and undo this. * undoable means do we want to create undo records to try and undo
* Will also attempt to check file writability if fd > 0 and checkwritable == TRUE * this. Will also attempt to check file writability if fd > 0 and
*/ * checkwritable == TRUE. */
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable) void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable)
{ {
size_t num_lines = 0; size_t num_lines = 0;
...@@ -909,8 +900,8 @@ int open_file(const char *filename, bool newfie, FILE **f) ...@@ -909,8 +900,8 @@ int open_file(const char *filename, bool newfie, FILE **f)
#endif #endif
if (stat(full_filename, &fileinfo) == -1) { if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS /* Well, maybe we can open the file even if the OS says it's
says its not there */ * not there. */
if ((fd = open(filename, O_RDONLY)) != -1) { if ((fd = open(filename, O_RDONLY)) != -1) {
statusbar(_("Reading File")); statusbar(_("Reading File"));
free(full_filename); free(full_filename);
...@@ -1585,15 +1576,14 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp) ...@@ -1585,15 +1576,14 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp)
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
/* Although this sucks, it sucks less than having a single 'my system is messed up /* Although this sucks, it sucks less than having a single 'my system is
* and I'm blanket allowing insecure file writing operations. * messed up and I'm blanket allowing insecure file writing operations'. */
*/
int prompt_failed_backupwrite(const char *filename) int prompt_failed_backupwrite(const char *filename)
{ {
static int i; static int i;
static char *prevfile = NULL; /* What was the laast file we were paased so we don't keep asking this? static char *prevfile = NULL; /* What was the last file we were
though maybe we should.... */ * passed so we don't keep asking
* this? Though maybe we should... */
if (prevfile == NULL || strcmp(filename, prevfile)) { if (prevfile == NULL || strcmp(filename, prevfile)) {
i = do_yesno_prompt(FALSE, i = do_yesno_prompt(FALSE,
_("Failed to write backup file, continue saving? (Say N if unsure) ")); _("Failed to write backup file, continue saving? (Say N if unsure) "));
...@@ -2924,9 +2914,8 @@ char *histfilename(void) ...@@ -2924,9 +2914,8 @@ char *histfilename(void)
return construct_filename("/.nano/search_history"); return construct_filename("/.nano/search_history");
} }
/* Construct the legacy history filename /* Construct the legacy history filename.
* (Deprecate in 2.5, delete later * (Deprecate in 2.5, delete later.) */
*/
char *legacyhistfilename(void) char *legacyhistfilename(void)
{ {
return construct_filename("/.nano_history"); return construct_filename("/.nano_history");
...@@ -2953,10 +2942,9 @@ void history_error(const char *msg, ...) ...@@ -2953,10 +2942,9 @@ void history_error(const char *msg, ...)
} }
/* Now that we have more than one history file, let's just rely /* Now that we have more than one history file, let's just rely on a
on a .nano dir for this stuff. Return 1 if the dir exists * .nano dir for this stuff. Return 1 if the dir exists or was
or was successfully created, and return 0 otherwise. * successfully created, and return 0 otherwise. */
*/
int check_dotnano(void) int check_dotnano(void)
{ {
struct stat dirstat; struct stat dirstat;
...@@ -3093,8 +3081,7 @@ void save_history(void) ...@@ -3093,8 +3081,7 @@ void save_history(void)
} }
} }
/* Analogs for the POS history. */
/* Analogs for the POS history */
void save_poshistory(void) void save_poshistory(void)
{ {
char *poshist; char *poshist;
...@@ -3129,9 +3116,8 @@ void save_poshistory(void) ...@@ -3129,9 +3116,8 @@ void save_poshistory(void)
} }
} }
/* Update the POS history, given a filename line and column. /* Update the POS history, given a filename line and column. If no
* If no entry is found, add a new entry on the end * entry is found, add a new entry on the end. */
*/
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos) void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
{ {
poshiststruct *posptr, *posprev = NULL; poshiststruct *posptr, *posprev = NULL;
...@@ -3166,10 +3152,9 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos) ...@@ -3166,10 +3152,9 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
} }
/* Check the POS history to see if file matches /* Check the POS history to see if file matches an existing entry. If
* an existing entry. If so return 1 and set line and column * so, return 1 and set line and column to the right values. Otherwise,
* to the right values Otherwise return 0 * return 0. */
*/
int check_poshistory(const char *file, ssize_t *line, ssize_t *column) int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
{ {
poshiststruct *posptr; poshiststruct *posptr;
......
...@@ -401,7 +401,6 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl ...@@ -401,7 +401,6 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl
#endif #endif
} }
/* Assign one menu's shortcuts to another function. */ /* Assign one menu's shortcuts to another function. */
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void)) void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{ {
...@@ -416,7 +415,6 @@ void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void)) ...@@ -416,7 +415,6 @@ void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
} }
} }
/* Return the given menu's first shortcut sequence, or the default value /* Return the given menu's first shortcut sequence, or the default value
* (2nd arg). Assumes currmenu for the menu to check. */ * (2nd arg). Assumes currmenu for the menu to check. */
int sc_seq_or (void (*func)(void), int defaultval) int sc_seq_or (void (*func)(void), int defaultval)
...@@ -491,12 +489,11 @@ void print_sclist(void) ...@@ -491,12 +489,11 @@ void print_sclist(void)
if (f) if (f)
fprintf(stderr, "Shortcut \"%s\", function: %s, menus %x\n", s->keystr, f->desc, f->menus); fprintf(stderr, "Shortcut \"%s\", function: %s, menus %x\n", s->keystr, f->desc, f->menus);
else else
fprintf(stderr, "Hmm, didnt find a func for \"%s\"\n", s->keystr); fprintf(stderr, "Hmm, didn't find a func for \"%s\"\n", s->keystr);
} }
} }
#endif #endif
/* Stuff we need to make at least static here so we can access it below. */ /* Stuff we need to make at least static here so we can access it below. */
/* TRANSLATORS: Try to keep the next six strings at most 10 characters. */ /* TRANSLATORS: Try to keep the next six strings at most 10 characters. */
const char *cancel_msg = N_("Cancel"); const char *cancel_msg = N_("Cancel");
...@@ -543,7 +540,6 @@ const char *ext_cmd_msg = N_("Execute Command"); ...@@ -543,7 +540,6 @@ const char *ext_cmd_msg = N_("Execute Command");
const char *new_buffer_msg = N_("New Buffer"); const char *new_buffer_msg = N_("New Buffer");
#endif #endif
/* Initialize the list of functions and the list of shortcuts. */ /* Initialize the list of functions and the list of shortcuts. */
void shortcut_init(void) void shortcut_init(void)
{ {
...@@ -1288,7 +1284,6 @@ void set_spell_shortcuts(void) ...@@ -1288,7 +1284,6 @@ void set_spell_shortcuts(void)
} }
#endif #endif
const subnfunc *sctofunc(sc *s) const subnfunc *sctofunc(sc *s)
{ {
subnfunc *f; subnfunc *f;
......
...@@ -431,8 +431,8 @@ void help_init(void) ...@@ -431,8 +431,8 @@ void help_init(void)
if (!f->desc || !strcmp(f->desc, "")) if (!f->desc || !strcmp(f->desc, ""))
continue; continue;
/* Lets just try and use the first 3 shortcuts /* Let's just try and use the first 3 shortcuts from the new
from the new struct... */ * struct... */
for (s = sclist, scsfound = 0; s != NULL; s = s->next) { for (s = sclist, scsfound = 0; s != NULL; s = s->next) {
if (scsfound == 3) if (scsfound == 3)
...@@ -454,7 +454,7 @@ void help_init(void) ...@@ -454,7 +454,7 @@ void help_init(void)
*(ptr++) = '\t'; *(ptr++) = '\t';
} }
} }
/* Pad with tabs if we didnt find 3 */ /* Pad with tabs if we didn't find 3. */
for (; scsfound < 3; scsfound++) { for (; scsfound < 3; scsfound++) {
*(ptr++) = '\t'; *(ptr++) = '\t';
} }
......
...@@ -2840,8 +2840,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int ...@@ -2840,8 +2840,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
/* Just update one line in the edit buffer. This is basically a wrapper /* Just update one line in the edit buffer. This is basically a wrapper
* for edit_draw(). The line will be displayed starting with * for edit_draw(). The line will be displayed starting with
* fileptr->data[index]. Likely arguments are current_x or zero. * fileptr->data[index]. Likely arguments are current_x or zero.
* Returns: Number of additiona lines consumed (needed for SOFTWRAP) * Returns: Number of additional lines consumed (needed for SOFTWRAP). */
*/
int update_line(filestruct *fileptr, size_t index) int update_line(filestruct *fileptr, size_t index)
{ {
int line = 0; int line = 0;
...@@ -2948,8 +2947,7 @@ bool need_vertical_update(size_t pww_save) ...@@ -2948,8 +2947,7 @@ bool need_vertical_update(size_t pww_save)
} }
/* When edittop changes, try and figure out how many lines /* When edittop changes, try and figure out how many lines
* we really have to work with (i.e. set maxrows) * we really have to work with (i.e. set maxrows). */
*/
void compute_maxrows(void) void compute_maxrows(void)
{ {
int n; int n;
...@@ -2962,7 +2960,7 @@ void compute_maxrows(void) ...@@ -2962,7 +2960,7 @@ void compute_maxrows(void)
maxrows = 0; maxrows = 0;
for (n = 0; n < editwinrows && foo; n++) { for (n = 0; n < editwinrows && foo; n++) {
maxrows ++; maxrows++;
n += strlenpt(foo->data) / COLS; n += strlenpt(foo->data) / COLS;
foo = foo->next; foo = foo->next;
} }
...@@ -3491,7 +3489,7 @@ void do_credits(void) ...@@ -3491,7 +3489,7 @@ void do_credits(void)
N_("Thank you for using nano!") N_("Thank you for using nano!")
}; };
/* credits[15]: Make sure this name is displayed properly, since we /* credits[16]: Make sure this name is displayed properly, since we
* can't dynamically assign it above, using Unicode 00F6 (Latin * can't dynamically assign it above, using Unicode 00F6 (Latin
* Small Letter O with Diaresis) if applicable. */ * Small Letter O with Diaresis) if applicable. */
credits[16] = credits[16] =
......
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