| version 1.19, 1998/03/18 20:29:27 |
version 1.20, 1998/07/21 13:36:54 |
| Line 298 getent(cap, len, db_array, fd, name, dep |
|
| Line 298 getent(cap, len, db_array, fd, name, dep |
|
| */ |
*/ |
| { |
{ |
| char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
| char *b_end, *bp; |
char *b_end, *bp, *cp; |
| int c; |
int c, slash; |
| |
|
| /* |
/* |
| * Loop invariants: |
* Loop invariants: |
| Line 308 getent(cap, len, db_array, fd, name, dep |
|
| Line 308 getent(cap, len, db_array, fd, name, dep |
|
| * Rp always points just past last character in record. |
* Rp always points just past last character in record. |
| * B_end always points just past last character in buf. |
* B_end always points just past last character in buf. |
| * Bp always points at next character in buf. |
* Bp always points at next character in buf. |
| |
* Cp remembers where the last colon was. |
| */ |
*/ |
| b_end = buf; |
b_end = buf; |
| bp = buf; |
bp = buf; |
| |
cp = 0; |
| |
slash = 0; |
| for (;;) { |
for (;;) { |
| |
|
| /* |
/* |
| Line 341 getent(cap, len, db_array, fd, name, dep |
|
| Line 344 getent(cap, len, db_array, fd, name, dep |
|
| |
|
| c = *bp++; |
c = *bp++; |
| if (c == '\n') { |
if (c == '\n') { |
| if (rp > record && *(rp-1) == '\\') { |
if (slash) { |
| |
slash = 0; |
| rp--; |
rp--; |
| continue; |
continue; |
| } else |
} else |
| break; |
break; |
| } |
} |
| |
if (slash) { |
| |
slash = 0; |
| |
cp = 0; |
| |
} |
| |
if (c == ':') { |
| |
/* |
| |
* If the field was `empty' (i.e. |
| |
* contained only white space), back up |
| |
* to the colon (eliminating the |
| |
* field). |
| |
*/ |
| |
if (cp) |
| |
rp = cp; |
| |
else |
| |
cp = rp; |
| |
} else if (c == '\\') { |
| |
slash = 1; |
| |
} else if (c != ' ' && c != '\t') { |
| |
/* |
| |
* Forget where the colon was, as this |
| |
* is not an empty field. |
| |
*/ |
| |
cp = 0; |
| |
} |
| *rp++ = c; |
*rp++ = c; |
| |
|
| /* |
/* |
| Line 371 getent(cap, len, db_array, fd, name, dep |
|
| Line 399 getent(cap, len, db_array, fd, name, dep |
|
| rp = record + pos; |
rp = record + pos; |
| } |
} |
| } |
} |
| /* loop invariant let's us do this */ |
/* Eliminate any white space after the last colon. */ |
| |
if (cp) |
| |
rp = cp + 1; |
| |
/* Loop invariant lets us do this. */ |
| *rp++ = '\0'; |
*rp++ = '\0'; |
| |
|
| /* |
/* |