use strchr() instead of strstr()

This commit is contained in:
rlar 2016-11-18 18:39:42 +01:00
parent bd50814677
commit dc6e1cb064
12 changed files with 20 additions and 20 deletions

View File

@ -73,7 +73,7 @@ com_stop(wordlist *wl)
} else if (eq(wl->wl_word, "when") && wl->wl_next) {
/* cp_lexer(string) will not discriminate '=', so we have
to do it here */
if (strstr(wl->wl_next->wl_word, "=") &&
if (strchr(wl->wl_next->wl_word, '=') &&
(!(wl->wl_next->wl_next) ||
strstr(wl->wl_next->wl_next->wl_word, "when") ||
strstr(wl->wl_next->wl_next->wl_word, "after")))
@ -82,7 +82,7 @@ com_stop(wordlist *wl)
wordlist *wln;
char **charr = TMALLOC(char*, 4);
char *tok = copy(wl->wl_next->wl_word);
char *tokeq = strstr(tok, "=");
char *tokeq = strchr(tok, '=');
char *tokafter = copy(tokeq + 1);
*tokeq = '\0';
charr[0] = tok;

View File

@ -89,12 +89,12 @@ correct_vec(MEASUREPTR meas)
char *vec = meas->m_vec;
/* return if not of type VM() etc */
if ((*vec != 'v') || (!strstr(vec, "(")))
if ((*vec != 'v') || (!strchr(vec, '(')))
return;
if (vec[1] != '(') {
meas->m_vectype = vec[1];
meas->m_vec = tprintf("%c%s", vec[0], strstr(vec, "("));
meas->m_vec = tprintf("%c%s", vec[0], strchr(vec, '('));
tfree(vec);
}
@ -102,7 +102,7 @@ correct_vec(MEASUREPTR meas)
if (vec && (vec[1] != '(')) {
meas->m_vectype2 = vec[1];
meas->m_vec2 = tprintf("%c%s", vec[0], strstr(vec, "("));
meas->m_vec2 = tprintf("%c%s", vec[0], strchr(vec, '('));
tfree(vec);
}
}

View File

@ -1415,7 +1415,7 @@ com_alter_mod(wordlist *wl)
}
input = wl_flatten(wl);
/* get the file name */
eqword = strstr(input, "=");
eqword = strchr(input, '=');
if (eqword) {
eqword++;
while (*eqword == ' ')

View File

@ -573,7 +573,7 @@ gettoks(char *s)
/* stripWhite.... uses copy() to return a malloc'ed s, so we have to free it,
using s0 as its starting address */
if (strstr(s, "("))
if (strchr(s, '('))
s0 = s = stripWhiteSpacesInsideParens(s);
else
s0 = s = copy(s);

View File

@ -86,7 +86,7 @@ com_meas(wordlist *wl)
}
}
/* may be inside the same wl_word */
else if ((equal_ptr = strstr(token, "=")) != NULL) {
else if ((equal_ptr = strchr(token, '=')) != NULL) {
vec_found = equal_ptr + 1;
if (!cieq(vec_found, "LAST")) {
INPevaluate(&vec_found, &err, 1);
@ -174,7 +174,7 @@ get_double_value(
*value = INPevaluate(&junk, &err, 1);
} else {
if ((equal_ptr = strstr(token, "=")) != NULL) {
if ((equal_ptr = strchr(token, '=')) != NULL) {
equal_ptr += 1;
*value = INPevaluate(&equal_ptr, &err, 1);
} else {

View File

@ -909,12 +909,12 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
if (ciprefix(".ic", c->li_line) || ciprefix(".nodeset", c->li_line)) {
paren_ptr = s = c->li_line;
while ((paren_ptr = strstr(paren_ptr, "(")) != NULL) {
while ((paren_ptr = strchr(paren_ptr, '(')) != NULL) {
*paren_ptr = '\0';
paren_ptr++;
name = paren_ptr;
if ((paren_ptr = strstr(paren_ptr, ")")) == NULL) {
if ((paren_ptr = strchr(paren_ptr, ')')) == NULL) {
*(name-1) = '(';
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->li_line);
goto quit;

View File

@ -666,7 +666,7 @@ get_comma_separated_values( char *values[], char *str ) {
int count = 0;
char *ptr, *comma_ptr, keep;
while ( ( comma_ptr = strstr( str, "," ) ) != NULL ) {
while ( ( comma_ptr = strchr( str, ',' ) ) != NULL ) {
ptr = comma_ptr - 1;
while ( isspace_c(*ptr) ) ptr--;
ptr++; keep = *ptr; *ptr = '\0';

View File

@ -21,7 +21,7 @@ CKTncDump(
fprintf(stdout,"%-30s %20s %20s\n", "Node", "Last Voltage", "Previous Iter");
fprintf(stdout,"%-30s %20s %20s\n", "----", "------------", "-------------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#")) {
if (strstr(node->name, "#branch") || !strchr(node->name, '#')) {
new = ckt->CKTrhsOld [i] ;
old = ckt->CKTrhs [i] ;
fprintf(stdout,"%-30s %20g %20g", node->name, new, old);

View File

@ -99,7 +99,7 @@ DCop(CKTcircuit *ckt, int notused)
fprintf(stdout,"%-30s %20s %20s\n", "----", "------------",
"-------------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#")) {
if (strstr(node->name, "#branch") || !strchr(node->name, '#')) {
new = ckt->CKTrhsOld [i] ;
old = ckt->CKTrhs [i] ;
fprintf(stdout,"%-30s %20g %20g", node->name, new, old);

View File

@ -300,7 +300,7 @@ DCpss(CKTcircuit *ckt,
fprintf(stdout,"%-30s %20s %20s\n", "----", "------------",
"-------------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#")) {
if (strstr(node->name, "#branch") || !strchr(node->name, '#')) {
new = ckt->CKTrhsOld [i] ;
old = ckt->CKTrhs [i] ;
fprintf(stdout,"%-30s %20g %20g", node->name, new, old);
@ -326,7 +326,7 @@ DCpss(CKTcircuit *ckt,
fprintf(stdout,"%-30s %15s\n", "Node", "Voltage");
fprintf(stdout,"%-30s %15s\n", "----", "-------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#"))
if (strstr(node->name, "#branch") || !strchr(node->name, '#'))
fprintf(stdout,"%-30s %15g\n", node->name,
ckt->CKTrhsOld[node->number]);
}
@ -793,7 +793,7 @@ DCpss(CKTcircuit *ckt,
for (i = 0, node = ckt->CKTnodes->next ; node ; i++, node = node->next)
{
/* Voltage Node */
if (!strstr (node->name, "#"))
if (!strchr (node->name, '#'))
{
if (fabs (err_conv [i]) > (fabs (RHS_max [i] - RHS_min [i]) * ckt->CKTreltol + ckt->CKTvoltTol) *
ckt->CKTtrtol * ckt->CKTsteady_coeff)

View File

@ -241,7 +241,7 @@ DCtran(CKTcircuit *ckt,
fprintf(stdout,"%-30s %20s %20s\n", "----", "------------",
"-------------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#")) {
if (strstr(node->name, "#branch") || !strchr(node->name, '#')) {
new = ckt->CKTrhsOld [i] ;
old = ckt->CKTrhs [i] ;
fprintf(stdout,"%-30s %20g %20g", node->name, new, old);
@ -267,7 +267,7 @@ DCtran(CKTcircuit *ckt,
fprintf(stdout,"%-30s %15s\n", "Node", "Voltage");
fprintf(stdout,"%-30s %15s\n", "----", "-------");
for(node=ckt->CKTnodes->next;node;node=node->next) {
if (strstr(node->name, "#branch") || !strstr(node->name, "#"))
if (strstr(node->name, "#branch") || !strchr(node->name, '#'))
fprintf(stdout,"%-30s %15g\n", node->name,
ckt->CKTrhsOld[node->number]);
}

View File

@ -113,7 +113,7 @@ char *MIFgetMod(
/* maschmann : remove : from name
* char *pos;
* if((pos=strstr(name,":"))!=NULL) *pos=0;
* if((pos=strchr(name,':'))!=NULL) *pos=0;
*/
/*------------------------------------