third_party/closure/goog/labs/format/csv.js
function readField() {
    var start = index;
    var didSeeComma = sawComma;
    sawComma = false;
    var token = nextToken();
    if (token == EMPTY) {
      return EOR;
    }
    if (token == EOF || token == NEWLINE) {
      if (didSeeComma) {
        pushBack(EMPTY);
        return '';
      }
      return EOR;
    }

    // This is the beginning of a quoted field.
    if (token == '"') {
      return readQuotedField();
    }

    while (true) {
      // This is the end of line or file.
      if (token == EOF || token == NEWLINE) {
        pushBack(token);
        break;
      }

      // This is the end of record.
      if (token == delimiter) {
        sawComma = true;
        break;
      }

      if (token == '"' && !opt_ignoreErrors) {
        throw new goog.labs.format.csv.ParseError(
            text, index - 1, 'Unexpected quote mark');
      }

      token = nextToken();
    }


    var returnString = (token == EOF) ?
        text.substring(start) :  // Return to end of file.
        text.substring(start, index - 1);

    return returnString.replace(/[\r\n]+/g, '');  // Squash any CRLFs.
  }
function readField() {
    var start = index;
    var didSeeComma = sawComma;
    sawComma = false;
    var token = nextToken();
    if (token == EMPTY) {
      return EOR;
    }
    if (token == EOF || token == NEWLINE) {
      if (didSeeComma) {
        pushBack(EMPTY);
        return '';
      }
      return EOR;
    }

    // This is the beginning of a quoted field.
    if (token == '"') {
      return readQuotedField();
    }

    while (true) {
      // This is the end of line or file.
      if (token == EOF || token == NEWLINE) {
        pushBack(token);
        break;
      }

      // This is the end of record.
      if (token == delimiter) {
        sawComma = true;
        break;
      }

      if (token == '"' && !opt_ignoreErrors) {
        throw new goog.labs.format.csv.ParseError(
            text, index - 1, 'Unexpected quote mark');
      }

      token = nextToken();
    }


    var returnString = (token == EOF) ?
        text.substring(start) :  // Return to end of file.
        text.substring(start, index - 1);

    return returnString.replace(/[\r\n]+/g, '');  // Squash any CRLFs.
  }
function readField ( ) { var start = index ; var didSeeComma = sawComma ; sawComma = false ; var token = nextToken ( ) ; if ( token == EMPTY ) { return EOR ; } if ( token == EOF || token == NEWLINE ) { if ( didSeeComma ) { pushBack ( EMPTY ) ; return '' ; } return EOR ; } // This is the beginning of a quoted field. if ( token == '"' ) { return readQuotedField ( ) ; } while ( true ) { // This is the end of line or file. if ( token == EOF || token == NEWLINE ) { pushBack ( token ) ; break ; } // This is the end of record. if ( token == delimiter ) { sawComma = true ; break ; } if ( token == '"' && ! opt_ignoreErrors ) { throw new goog . labs . format . csv . ParseError ( text , index - 1 , 'Unexpected quote mark' ) ; } token = nextToken ( ) ; } var returnString = ( token == EOF ) ? text . substring ( start ) : // Return to end of file. text . substring ( start , index - 1 ) ; return returnString . replace ( / [\r\n]+ / g , '' ) ; // Squash any CRLFs. }
Read a field from input.
@return {string|!goog.labs.format.csv.Sentinels_} The field, as a string,
or a sentinel (if applicable).
Read a field from input .