From: David Lawrence Ramsey Date: Tue, 19 Jul 2005 04:53:45 +0000 (+0000) Subject: in find_history() and get_history_completion(), make parameters const X-Git-Tag: v1.3.9~150 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=96e6d56571ff7d0df71997ec91a9e2dff7e3ff24;p=nano.git in find_history() and get_history_completion(), make parameters const where possible git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2896 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index db19121b..1fbba091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -161,6 +161,8 @@ CVS code - - Only include this function when DISABLE_SPELLER isn't defined, as the alternate spell checking code is now the only place where it's used. (DLR) + find_history(), get_history_completion() + - Make parameters const where possible. (DLR) - winio.c: edit_redraw(), edit_refresh() - Clean up and simplify. (DLR) diff --git a/src/proto.h b/src/proto.h index a2d7e516..dd643a94 100644 --- a/src/proto.h +++ b/src/proto.h @@ -518,13 +518,13 @@ bool history_has_changed(void); #endif void history_init(void); void history_reset(const filestruct *h); -filestruct *find_history(filestruct *h_start, filestruct *h_end, const - char *s, size_t len); +filestruct *find_history(const filestruct *h_start, const filestruct + *h_end, const char *s, size_t len); void update_history(filestruct **h, const char *s); char *get_history_older(filestruct **h); char *get_history_newer(filestruct **h); #ifndef DISABLE_TABCOMP -char *get_history_completion(filestruct **h, char *s, size_t len); +char *get_history_completion(filestruct **h, const char *s, size_t len); #endif #endif /* !NANO_SMALL */ diff --git a/src/search.c b/src/search.c index ff4480c2..a30efe38 100644 --- a/src/search.c +++ b/src/search.c @@ -1180,14 +1180,14 @@ void history_reset(const filestruct *h) /* Return the first node containing the first len characters of the * string s in the history list, starting at h_start and ending at * h_end, or NULL if there isn't one. */ -filestruct *find_history(filestruct *h_start, filestruct *h_end, const - char *s, size_t len) +filestruct *find_history(const filestruct *h_start, const filestruct + *h_end, const char *s, size_t len) { - filestruct *p; + const filestruct *p; for (p = h_start; p != h_end->next && p != NULL; p = p->next) { if (strncmp(s, p->data, len) == 0) - return p; + return (filestruct *)p; } return NULL; @@ -1289,7 +1289,7 @@ char *get_history_newer(filestruct **h) * looking at only the first len characters of s, and return that * string. If there isn't one, or if len is 0, don't move h and return * s. */ -char *get_history_completion(filestruct **h, char *s, size_t len) +char *get_history_completion(filestruct **h, const char *s, size_t len) { assert(s != NULL); @@ -1336,7 +1336,7 @@ char *get_history_completion(filestruct **h, char *s, size_t len) /* If we're here, we didn't find a match, we didn't find an inexact * match, or len is 0. Return s. */ - return s; + return (char *)s; } #endif #endif /* !NANO_SMALL */