Browse Source

use strchr() instead of index()

rlar 14 years ago
parent
commit
f285dd0aa8
  1. 15
      ChangeLog
  2. 2
      src/frontend/com_compose.c
  3. 2
      src/frontend/define.c
  4. 2
      src/frontend/device.c
  5. 6
      src/frontend/inpcom.c
  6. 2
      src/frontend/parse.c
  7. 2
      src/frontend/parser/complete.c
  8. 2
      src/frontend/parser/unixcom.c
  9. 4
      src/frontend/vectors.c
  10. 2
      src/frontend/wdisp/windisp.c
  11. 7
      src/include/ngspice/ngspice.h
  12. 2
      src/spicelib/parser/inpptree.c

15
ChangeLog

@ -1,3 +1,18 @@
2012-02-06 Robert Larice
* src/frontend/com_compose.c ,
* src/frontend/define.c ,
* src/frontend/device.c ,
* src/frontend/inpcom.c ,
* src/frontend/parse.c ,
* src/frontend/vectors.c ,
* src/frontend/parser/complete.c ,
* src/frontend/parser/unixcom.c ,
* src/frontend/wdisp/windisp.c ,
* src/include/ngspice/ngspice.h ,
* src/spicelib/parser/inpptree.c :
use strchr() instead of index()
which is depreciated
============================ ngspice-24 ================================== ============================ ngspice-24 ==================================
2012-01-30 Dietmar Warning 2012-01-30 Dietmar Warning
* src/spicelib/devices/dio/diotemp.c: Add temperature dependent * src/spicelib/devices/dio/diotemp.c: Add temperature dependent

2
src/frontend/com_compose.c

@ -218,7 +218,7 @@ com_compose(wordlist *wl)
var = wl->wl_word; var = wl->wl_word;
val = s + 1; val = s + 1;
wl = wl->wl_next; wl = wl->wl_next;
} else if (index(wl->wl_word, '=')) {
} else if (strchr(wl->wl_word, '=')) {
/* This is var= val. */ /* This is var= val. */
*s = '\0'; *s = '\0';
var = wl->wl_word; var = wl->wl_word;

2
src/frontend/define.c

@ -57,7 +57,7 @@ com_define(wordlist *wlist)
* to try really hard to break this here. * to try really hard to break this here.
*/ */
buf[0] = '\0'; buf[0] = '\0';
for (wl = wlist; wl && (index(wl->wl_word, /* ( */ ')') == NULL);
for (wl = wlist; wl && (strchr(wl->wl_word, /* ( */ ')') == NULL);
wl = wl->wl_next) wl = wl->wl_next)
(void) strcat(buf, wl->wl_word); (void) strcat(buf, wl->wl_word);
if (wl) { if (wl) {

2
src/frontend/device.c

@ -1353,7 +1353,7 @@ devexpand(char *name)
{ {
wordlist *wl, *devices, *tw; wordlist *wl, *devices, *tw;
if (index(name, '*') ||strchr(name, '[') ||strchr(name, '?')) {
if (strchr(name, '*') || strchr(name, '[') || strchr(name, '?')) {
devices = cp_cctowl(ft_curckt->ci_devices); devices = cp_cctowl(ft_curckt->ci_devices);
for (wl = NULL; devices; devices = devices->wl_next) for (wl = NULL; devices; devices = devices->wl_next)
if (cp_globmatch(name, devices->wl_word)) { if (cp_globmatch(name, devices->wl_word)) {

6
src/frontend/inpcom.c

@ -801,7 +801,7 @@ inp_pathopen(char *name, char *mode)
char buf2[BSIZE_SP]; char buf2[BSIZE_SP];
/* search in the path where the source (input) file has been found, /* search in the path where the source (input) file has been found,
but only if "name" is just a file name */ but only if "name" is just a file name */
if (!(index(name, DIR_TERM)) && !(index(name, DIR_TERM_LINUX)) && cp_getvar("sourcefile", CP_STRING, buf2)) {
if (!strchr(name, DIR_TERM) && !strchr(name, DIR_TERM_LINUX) && cp_getvar("sourcefile", CP_STRING, buf2)) {
/* If pathname is found, get path. /* If pathname is found, get path.
(char *dirname(const char *name) might have been used here) */ (char *dirname(const char *name) might have been used here) */
if (substring(DIR_PATHSEP, buf2) || substring(DIR_PATHSEP_LINUX, buf2)) { if (substring(DIR_PATHSEP, buf2) || substring(DIR_PATHSEP_LINUX, buf2)) {
@ -821,7 +821,7 @@ inp_pathopen(char *name, char *mode)
/* If this is an abs pathname, or there is no sourcepath var, just /* If this is an abs pathname, or there is no sourcepath var, just
* do an fopen. * do an fopen.
*/ */
if (index(name, DIR_TERM) || index(name, DIR_TERM_LINUX)
if (strchr(name, DIR_TERM) || strchr(name, DIR_TERM_LINUX)
|| !cp_getvar("sourcepath", CP_LIST, &v)) || !cp_getvar("sourcepath", CP_LIST, &v))
return (fopen(name, mode)); return (fopen(name, mode));
#else #else
@ -830,7 +830,7 @@ inp_pathopen(char *name, char *mode)
/* If this is an abs pathname, or there is no sourcepath var, just /* If this is an abs pathname, or there is no sourcepath var, just
* do an fopen. * do an fopen.
*/ */
if (index(name, DIR_TERM)
if (strchr(name, DIR_TERM)
|| !cp_getvar("sourcepath", CP_LIST, &v)) || !cp_getvar("sourcepath", CP_LIST, &v))
return (fopen(name, mode)); return (fopen(name, mode));
#endif #endif

2
src/frontend/parse.c

@ -672,7 +672,7 @@ PPlex(YYSTYPE *lvalp, struct PPltype *llocp, char **line)
* name, and otherwise it isn't. * name, and otherwise it isn't.
* va, ']' too * va, ']' too
*/ */
for (; *sbuf && !index(specials, *sbuf); sbuf++)
for (; *sbuf && !strchr(specials, *sbuf); sbuf++)
if (*sbuf == '@') if (*sbuf == '@')
atsign = 1; atsign = 1;
else if (!atsign && ( *sbuf == '[' || *sbuf == ']' )) else if (!atsign && ( *sbuf == '[' || *sbuf == ']' ))

2
src/frontend/parser/complete.c

@ -106,7 +106,7 @@ cp_ccom(wordlist *wlist, char *buf, bool esc)
pmatches = ccfilec(buf); pmatches = ccfilec(buf);
s =strrchr(buf, '/'); s =strrchr(buf, '/');
i = (int) strlen(s ? s + 1 : buf); i = (int) strlen(s ? s + 1 : buf);
if ((*buf == '~') && !index(buf, '/'))
if ((*buf == '~') && !strchr(buf, '/'))
i--; i--;
} }

2
src/frontend/parser/unixcom.c

@ -162,7 +162,7 @@ cp_unixcom(wordlist *wl)
wl_print(wl, stdout); wl_print(wl, stdout);
printf(".\n"); printf(".\n");
} }
if (index(name, '/'))
if (strchr(name, '/'))
return (tryexec(name, argv)); return (tryexec(name, argv));
i = hash(name); i = hash(name);
for (hh = hashtab[i]; hh; hh = hh->h_next) { for (hh = hashtab[i]; hh; hh = hh->h_next) {

4
src/frontend/vectors.c

@ -365,7 +365,7 @@ vec_get(const char *vec_name)
wd = word = copy(vec_name); /* Gets mangled below... */ wd = word = copy(vec_name); /* Gets mangled below... */
if (index(word, '.')) {
if (strchr(word, '.')) {
/* Snag the plot... */ /* Snag the plot... */
for (i = 0, s = word; *s != '.'; i++, s++) for (i = 0, s = word; *s != '.'; i++, s++)
buf[i] = *s; buf[i] = *s;
@ -854,7 +854,7 @@ vec_basename(struct dvec *v)
char buf[BSIZE_SP], *t, *s; char buf[BSIZE_SP], *t, *s;
int i; int i;
if (index(v->v_name, '.')) {
if (strchr(v->v_name, '.')) {
for (t = v->v_name, i = 0; *t; t++) for (t = v->v_name, i = 0; *t; t++)
buf[i++] = *t; buf[i++] = *t;
buf[i] = '\0'; buf[i] = '\0';

2
src/frontend/wdisp/windisp.c

@ -481,7 +481,7 @@ LRESULT CALLBACK PlotWindowProc( HWND hwnd,
WIN_ScreentoData(gr, xe, ye, &fxe, &fye); WIN_ScreentoData(gr, xe, ye, &fxe, &fye);
strncpy(buf2, gr->plotname, sizeof(buf2)); strncpy(buf2, gr->plotname, sizeof(buf2));
if ((t = index(buf2, ':')) != NULL) /* strchr */
if ((t = strchr(buf2, ':')) != NULL)
*t = 0; *t = 0;
if (!eq(plot_cur->pl_typename, buf2)) { if (!eq(plot_cur->pl_typename, buf2)) {

7
src/include/ngspice/ngspice.h

@ -192,14 +192,9 @@
#define WaGauss #define WaGauss
#define RR_MAX RAND_MAX #define RR_MAX RAND_MAX
#ifdef HAVE_INDEX
#if !defined(HAVE_STRCHR) && defined(HAVE_INDEX)
# define strchr index # define strchr index
# define strrchr rindex # define strrchr rindex
#else /* va: no index, but strchr */
# ifdef HAVE_STRCHR
# define index strchr
# define rindex strrchr
# endif /* va: no index, but strchr */
#endif #endif
/* added for CYGWIN */ /* added for CYGWIN */

2
src/spicelib/parser/inpptree.c

@ -1194,7 +1194,7 @@ int PTlex (YYSTYPE *lvalp, char **line)
char *tmp; char *tmp;
token = TOK_STR; token = TOK_STR;
for (s = sbuf; *s; s++) for (s = sbuf; *s; s++)
if (index(specials, *s))
if (strchr(specials, *s))
break; break;
tmp = TMALLOC(char, s - sbuf + 1); tmp = TMALLOC(char, s - sbuf + 1);
strncpy(tmp, sbuf, (size_t) (s - sbuf)); strncpy(tmp, sbuf, (size_t) (s - sbuf));

Loading…
Cancel
Save