diff options
Diffstat (limited to 'usr/src/cmd/ttymon/tmparse.c')
-rw-r--r-- | usr/src/cmd/ttymon/tmparse.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/usr/src/cmd/ttymon/tmparse.c b/usr/src/cmd/ttymon/tmparse.c index ccc2065832..8413ca81f0 100644 --- a/usr/src/cmd/ttymon/tmparse.c +++ b/usr/src/cmd/ttymon/tmparse.c @@ -20,27 +20,25 @@ * CDDL HEADER END */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ +#include <stdio.h> +#include <ctype.h> -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ - -#include <stdio.h> -#include <ctype.h> +char quoted(char *, int *); /* * getword - extract one token from the string + * char *ptr; pointer to the string to be scanned + * int *size; *size = number of characters scanned + * int getall; if TRUE, get all char until ':' or '\0' * - token delimiter is white space if getall is FALSE * - token delimiter is ':' or '\0' if getall is TRUE */ char * -getword(ptr, size, getall) -register char *ptr; /* pointer to the string to be scanned */ -int *size; /* *size = number of characters scanned */ -int getall; /* if TRUE, get all char until ':' or '\0' */ +getword(char *ptr, int *size, int getall) { - register char *optr,c; - char quoted(); + char *optr, c; static char word[BUFSIZ]; int qsize; @@ -55,8 +53,8 @@ int getall; /* if TRUE, get all char until ':' or '\0' */ /* Put all characters from here to next white space or ':' or '\0' */ /* into the word, up to the size of the word. */ - for (optr= word,*optr='\0'; - *ptr != '\0' && *ptr != ':'; ptr++,(*size)++) { + for (optr = word, *optr = '\0'; + *ptr != '\0' && *ptr != ':'; ptr++, (*size)++) { if (!getall) { if (isspace(*ptr)) break; @@ -64,16 +62,17 @@ int getall; /* if TRUE, get all char until ':' or '\0' */ /* If the character is quoted, analyze it. */ if (*ptr == '\\') { - c = quoted(ptr,&qsize); + c = quoted(ptr, &qsize); (*size) += qsize; ptr += qsize; } else c = *ptr; /* If there is room, add this character to the word. */ - if (optr < &word[BUFSIZ] ) *optr++ = c; + if (optr < &word[BUFSIZ]) + *optr++ = c; } - /* skip trailing blanks if any*/ + /* skip trailing blanks if any */ while (isspace(*ptr)) { (*size)++; ptr++; @@ -81,23 +80,21 @@ int getall; /* if TRUE, get all char until ':' or '\0' */ /* Make sure the line is null terminated. */ *optr++ = '\0'; - return(word); + return (word); } /* "quoted" takes a quoted character, starting at the quote */ /* character, and returns a single character plus the size of */ /* the quote string. "quoted" recognizes the following as */ /* special, \n,\r,\v,\t,\b,\f as well as the \nnn notation. */ -char -quoted(ptr,qsize) -char *ptr; -int *qsize; +char +quoted(char *ptr, int *qsize) { - register char c,*rptr; - register int i; + char c, *rptr; + int i; rptr = ptr; - switch(*++rptr) { + switch (*++rptr) { case 'n': c = '\n'; break; @@ -124,9 +121,10 @@ int *qsize; /* If this is a numeric string, take up to three characters of */ /* it as the value of the quoted character. */ if (*rptr >= '0' && *rptr <= '7') { - for (i=0,c=0; i < 3;i++) { - c = c*8 + (*rptr - '0'); - if (*++rptr < '0' || *rptr > '7') break; + for (i = 0, c = 0; i < 3; i++) { + c = c * 8 + (*rptr - '0'); + if (*++rptr < '0' || *rptr > '7') + break; } rptr--; @@ -138,12 +136,13 @@ int *qsize; rptr--; /* In all other cases the quoting does nothing. */ - } else c = *rptr; + } else { + c = *rptr; + } break; } /* Compute the size of the quoted character. */ - (*qsize) = rptr - ptr; - return(c); + (*qsize) = rptr - ptr; + return (c); } - |