Change strtok() to strsep(), strtok() usage is depricated

in libraries.
This commit is contained in:
Andrey A. Chernov 1995-03-24 17:27:22 +00:00
parent bee5b8efe8
commit c8448f10eb
3 changed files with 39 additions and 14 deletions

View File

@ -2106,7 +2106,7 @@ etob(out, e)
char *out;
char *e;
{
char *word;
char *word, *cp;
int i, p, v,l, low,high;
char b[9];
char input[36];
@ -2115,10 +2115,13 @@ char *e;
return -1;
strncpy(input,e,sizeof(input));
cp = input;
memset(b, 0, sizeof(b));
memset(out, 0, 8);
for(i=0,p=0;i<6;i++,p+=11){
if((word = strtok(i == 0 ? input : NULL," ")) == NULL)
while ((word = strsep(&cp, " ")) != NULL && *word == '\0')
;
if (word == NULL)
return -1;
l = strlen(word);
if(l > 4 || l < 1){

View File

@ -44,6 +44,7 @@
* Token input with one-deep pushback.
*/
static char *prev_token = 0; /* push-back buffer */
static char *line_pointer = NULL;
static char *first_token();
static int line_number;
static void unget_token();
@ -286,7 +287,10 @@ FILE *fp;
if (buf[0])
printf("rule: %s\n", buf);
#endif
if (cp = strtok(buf, " \t"))
line_pointer = buf;
while ((cp = strsep(&line_pointer, " \t")) != NULL && *cp == '\0')
;
if (cp != NULL)
return (cp);
}
}
@ -308,7 +312,8 @@ static char *get_token()
if (cp = prev_token) {
prev_token = 0;
} else {
cp = strtok((char *) 0, " \t");
while ((cp = strsep(&line_pointer, " \t")) != NULL && *cp == '\0')
;
}
return (cp);
}

View File

@ -100,7 +100,7 @@ char *name;
int found;
int len;
long recstart;
char *cp;
char *cp, *p;
struct stat statbuf;
/* See if the _PATH_SKEYFILE exists, and create it if not */
@ -127,14 +127,23 @@ char *name;
rip(mp->buf);
if(mp->buf[0] == '#')
continue; /* Comment */
if((mp->logname = strtok(mp->buf," \t")) == NULL)
p = mp->buf;
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
if((mp->logname = cp) == NULL)
continue;
if((cp = strtok(NULL," \t")) == NULL)
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
if(cp == NULL)
continue;
mp->n = atoi(cp);
if((mp->seed = strtok(NULL," \t")) == NULL)
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
if((mp->seed = cp) == NULL)
continue;
if((mp->val = strtok(NULL," \t")) == NULL)
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
if((mp->val = cp) == NULL)
continue;
if(strlen(mp->logname) == len
&& strncmp(mp->logname,name,len) == 0){
@ -173,7 +182,7 @@ long microsec;
char tbuf[27],buf[60];
char me[80];
int rval;
char *cp;
char *cp, *p;
time(&now);
tm = localtime(&now);
@ -215,10 +224,18 @@ long microsec;
return -1;
}
rip(mp->buf);
mp->logname = strtok(mp->buf," \t");
cp = strtok(NULL," \t") ;
mp->seed = strtok(NULL," \t");
mp->val = strtok(NULL," \t");
p = mp->buf;
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
mp->logname = cp;
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
mp->seed = cp;
while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0')
;
mp->val = cp;
/* And convert file value to hex for comparison */
atob8(filekey,mp->val);