- if (c == '"') {
- while ((c = getc(cfile)) != EOF && c != '"') {
- if (c == '\\')
- c = getc(cfile);
- *cp++ = c;
- if (cp - tokval > MAX_TOKVAL_SIZE-1) {
- adios(NULL, "credential tokens restricted to length %d",
- MAX_TOKVAL_SIZE - 1);
- }
- }
- } else {
- *cp++ = c;
- while ((c = getc(cfile)) != EOF
- && c != '\n' && c != '\t' && c != ' ' && c != ',') {
- if (c == '\\')
- c = getc(cfile);
- *cp++ = c;
- if (cp - tokval > MAX_TOKVAL_SIZE-1) {
- adios(NULL, "credential tokens restricted to length %d",
- MAX_TOKVAL_SIZE - 1);
- }
- }
+ if (c == '"')
+ /* FIXME: Where is the quoted-string syntax of netrc documented?
+ * This code treats «"foo""bar"» as two tokens without further
+ * separators. */
+ stop = "\"";
+ else
+ /* Might be backslash. Get it again later. It's handled then. */
+ if (ungetc(c, cfile) == EOF)
+ return TOK_EOF;
+
+ while ((c = getc(cfile)) != EOF && c && !strchr(stop, c)) {
+ if (c == '\\' && (c = getc(cfile)) == EOF)
+ return TOK_EOF; /* Discard whole token. */
+
+ *cp++ = c;
+ if (cp - tokval > MAX_TOKVAL_SIZE-1) {
+ adios(NULL, "credential tokens restricted to length %d",
+ MAX_TOKVAL_SIZE - 1);
+ }