From 7a42510cc0b2a2863c27f242d0dc3a568c003998 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 1 Nov 2016 11:30:08 +0100 Subject: [PATCH] const'ify some 'skip'ing functions --- src/include/ngspice/ngspice.h | 2 +- src/include/ngspice/stringskip.h | 8 ++++---- src/misc/string.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/ngspice/ngspice.h b/src/include/ngspice/ngspice.h index 3c3070a9a..c9f0ba291 100644 --- a/src/include/ngspice/ngspice.h +++ b/src/include/ngspice/ngspice.h @@ -241,7 +241,7 @@ extern double x_atanh(double); extern char *gettok_noparens(char **s); extern char *gettok_node(char **s); extern char *gettok_iv(char **s); -extern char *nexttok(char *s); +extern char *nexttok(const char *s); extern int get_l_paren(char **s); extern int get_r_paren(char **s); diff --git a/src/include/ngspice/stringskip.h b/src/include/ngspice/stringskip.h index ee553d043..7e3de7b4f 100644 --- a/src/include/ngspice/stringskip.h +++ b/src/include/ngspice/stringskip.h @@ -1,13 +1,13 @@ #ifndef ngspice_STRINGSKIP_H #define ngspice_STRINGSKIP_H -static inline char *skip_non_ws(char *s) { while (*s && !isspace_c(*s)) s++; return s; } -static inline char *skip_ws(char *s) { while ( isspace_c(*s)) s++; return s; } +static inline char *skip_non_ws(const char *s) { while (*s && !isspace_c(*s)) s++; return (char *) s; } +static inline char *skip_ws(const char *s) { while ( isspace_c(*s)) s++; return (char *) s; } static inline char *depreciated_skip_back_non_ws(char *s) { while (s[-1] && !isspace_c(s[-1])) s--; return s; } static inline char *depreciated_skip_back_ws(char *s) { while (isspace_c(s[-1])) s--; return s; } -static inline char *skip_back_non_ws(char *s, char *start) { while (s > start && !isspace_c(s[-1])) s--; return s; } -static inline char *skip_back_ws(char *s, char *start) { while (s > start && isspace_c(s[-1])) s--; return s; } +static inline char *skip_back_non_ws(const char *s, const char *start) { while (s > start && !isspace_c(s[-1])) s--; return (char *) s; } +static inline char *skip_back_ws(const char *s, const char *start) { while (s > start && isspace_c(s[-1])) s--; return (char *) s; } #endif diff --git a/src/misc/string.c b/src/misc/string.c index 4148a7d47..95dae1a8e 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -316,7 +316,7 @@ gettok(char **s) * you have parens or commas anywhere in the nodelist. *-------------------------------------------------------------------------*/ char * -nexttok(char *s) +nexttok(const char *s) { int paren = 0; @@ -335,7 +335,7 @@ nexttok(char *s) while (isspace_c(*s) || *s == ',') s++; - return s; + return (char *) s; }