
read_point_(FILE *input)
{
  int lookahead, items_read;
  char directive, c;
  bool two_newlines;
  double x, y;

 
  cosas=fscanf(input,"%a[a-zA-Z0-9] = %a[^;\n\r\v\f\t];",&variable,&valor);
      
  if (cosas==2) procese_punto(); 
 
           else {
             fprintf(stderr,"error en la lectura de n punto\n"); 
             return -1;}

            /*
             if (cosas<1) {  
                   fprintf(stderr,"%i menos que uno\n",cosas); exit(0);}
	     if (cosas>2) {fprintf(stderr,"error"); exit(0);}*/
   

 
  
 head:
  
  /* skip whitespace, up to but not including 2nd newline */
  two_newlines = skip_some_whitespace (input);
  if (two_newlines)
    /* end of dataset */
    {
      skip_all_whitespace (input);
      if (feof (input))
	return ENDED_BY_EOF;	/* no dataset follows */
      else
	return ENDED_BY_DATASET_TERMINATOR; /* dataset presumably follows */
    }

  lookahead = getc (input);
  ungetc (lookahead, input);
  switch (lookahead)
    {
    case 'C':			/* old-style `Curve' line, discard it */
    case '#':			/* modern-style comment line, discard it */
      do 
	{
	  items_read = fread (&c, sizeof (c), 1, input);
	  if (items_read <= 0)
	    return ENDED_BY_EOF; /* effectively */
	}
      while (c != '\n');
      ungetc ((int)'\n', input); /* push back \n at the end of line */
      goto head;

    case 'i':		    /* old-style directive-first line (in-range) */
    case 'o':		    /* old-style directive-first line (out-of-range) */
      /* read coordinates */
      items_read = fscanf (input, 
			   "%c x=%lf y=%lf", 
			   &directive, &x, &y);
      if (items_read == 3)	/* must match all */
	{
	  point->x = x;
	  point->y = y;
	  return IN_PROGRESS; /* got a pair of floats */
	}
      else
	{
	  fprintf (stderr, 
		   "%s: cannot parse gnuplot-format input file\n", 
		   progname);
	  return ENDED_BY_EOF; /* effectively */
	}

    case 'u':			/* old-style directive-first line */
      /* `undefined', next point begins new polyline (same line mode) */
      do 
	{
	  items_read = fread (&c, sizeof (c), 1, input);
	  if (items_read <= 0)
	    {
	      fprintf (stderr, 
		       "%s: cannot parse gnuplot-format input file\n", 
		       progname);
	    return ENDED_BY_EOF; /* effectively */
	    }
	}
      while (c != '\n');
      /* break the polyline here in a soft way (i.e. don't bump line mode) */
      reader->need_break = true;	
      goto head;

    default:			/* parse as a new-style directive-last line */
      items_read = fscanf (input, 
			   "%lf %lf %c", 
			   &x, &y, &directive);
      if (items_read == 3 
	  && (directive == 'i' || directive == 'o' || directive == 'u'))
	{
	  if (directive == 'u')
	    {
	      /* drop point; break the polyline here in a soft way
                 (i.e. don't bump line mode) */
	      reader->need_break = true;	
	      goto head;
	    }
	  else
	    {
	      point->x = x;
	      point->y = y;
	      return IN_PROGRESS;
	    }
	}
      else
	{
	  fprintf (stderr, 
		   "%s: cannot parse gnuplot-format input file\n", 
		   progname);
	  return ENDED_BY_EOF; /* effectively */
	}
    }
}


read_dataset (int *no_of_points)   

{
  for ( ; ; )
    {

   paso=skip_space (input);
  if (paso==-1) eof;
  if (paso==2) nuevo conjunto;
 
 if (paso==1) nuevo punto;
     
   status = read_point (input);
      if (status != IN_PROGRESS)
	/* we didn't get a point, i.e. dataset ended */
	break;

      (*no_of_points)++;
    }

  return status;
}

