Logo Search packages:      
Sourcecode: octave3.0 version File versions

__gnuplot_raw__.cc

#line 3 "<stdout>"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define yy_create_buffer gpt_create_buffer
#define yy_delete_buffer gpt_delete_buffer
#define yy_flex_debug gpt_flex_debug
#define yy_init_buffer gpt_init_buffer
#define yy_flush_buffer gpt_flush_buffer
#define yy_load_buffer_state gpt_load_buffer_state
#define yy_switch_to_buffer gpt_switch_to_buffer
#define yyin gptin
#define yyleng gptleng
#define yylex gptlex
#define yylineno gptlineno
#define yyout gptout
#define yyrestart gptrestart
#define yytext gpttext
#define yywrap gptwrap
#define yyalloc gptalloc
#define yyrealloc gptrealloc
#define yyfree gptfree

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

/* First, we deal with  platform-specific or compiler-specific issues. */

/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

/* end standard C headers. */

/* flex integer type definitions */

#ifndef FLEXINT_H
#define FLEXINT_H

/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */

#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L

/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
 * if you want the limit (max/min) macros for int types. 
 */
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif

#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; 
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */

/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN               (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN              (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN              (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX               (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX              (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX              (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX              (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX             (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX             (4294967295U)
#endif

#endif /* ! FLEXINT_H */

#ifdef __cplusplus

/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST

#else /* ! __cplusplus */

/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)

#define YY_USE_CONST

#endif      /* defined (__STDC__) */
#endif      /* ! __cplusplus */

#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif

/* Returned upon end-of-file. */
#define YY_NULL 0

/* Promotes a possibly negative, possibly signed char to an unsigned
 * integer for use as an array index.  If the signed char is negative,
 * we want to instead treat it as an 8-bit unsigned char, hence the
 * double cast.
 */
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)

/* Enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN.
 */
#define BEGIN (yy_start) = 1 + 2 *

/* Translate the current start state into a value that can be later handed
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
 * compatibility.
 */
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START

/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)

/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE gptrestart(gptin  )

#define YY_END_OF_BUFFER_CHAR 0

/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif

/* The state buf must be large enough to hold one state per character in the main buffer.
 */
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))

#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif

extern int gptleng;

extern FILE *gptin, *gptout;

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

    #define YY_LESS_LINENO(n)
    
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
      do \
            { \
            /* Undo effects of setting up gpttext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
            *yy_cp = (yy_hold_char); \
            YY_RESTORE_YY_MORE_OFFSET \
            (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
            YY_DO_BEFORE_ACTION; /* set up gpttext again */ \
            } \
      while ( 0 )

#define unput(c) yyunput( c, (yytext_ptr)  )

#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif

#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
      {
      FILE *yy_input_file;

      char *yy_ch_buf;        /* input buffer */
      char *yy_buf_pos;       /* current position in input buffer */

      /* Size of input buffer in bytes, not including room for EOB
       * characters.
       */
      yy_size_t yy_buf_size;

      /* Number of characters read into yy_ch_buf, not including EOB
       * characters.
       */
      int yy_n_chars;

      /* Whether we "own" the buffer - i.e., we know we created it,
       * and can realloc() it to grow it, and should free() it to
       * delete it.
       */
      int yy_is_our_buffer;

      /* Whether this is an "interactive" input source; if so, and
       * if we're using stdio for input, then we want to use getc()
       * instead of fread(), to make sure we stop fetching input after
       * each newline.
       */
      int yy_is_interactive;

      /* Whether we're considered to be at the beginning of a line.
       * If so, '^' rules will be active on the next match, otherwise
       * not.
       */
      int yy_at_bol;

    int yy_bs_lineno; /**< The line count. */
    int yy_bs_column; /**< The column count. */
    
      /* Whether to try to fill the input buffer when we reach the
       * end of it.
       */
      int yy_fill_buffer;

      int yy_buffer_status;

#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
      /* When an EOF's been seen but there's still some text to process
       * then we mark the buffer as YY_EOF_PENDING, to indicate that we
       * shouldn't try reading from the input source any more.  We might
       * still have a bunch of tokens to match, though, because of
       * possible backing-up.
       *
       * When we actually see the EOF, we change the status to "new"
       * (via gptrestart()), so that the user can continue scanning by
       * just pointing gptin at a new input file.
       */
#define YY_BUFFER_EOF_PENDING 2

      };
#endif /* !YY_STRUCT_YY_BUFFER_STATE */

/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */

/* We provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state".
 *
 * Returns the top of the stack, or NULL.
 */
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
                          : NULL)

/* Same as previous macro, but useful when we know that the buffer stack is not
 * NULL or when we need an lvalue. For internal use only.
 */
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]

/* yy_hold_char holds the character lost when gpttext is formed. */
static char yy_hold_char;
static int yy_n_chars;        /* number of characters read into yy_ch_buf */
int gptleng;

/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 0;       /* whether we need to initialize */
static int yy_start = 0;      /* start state number */

/* Flag which is used to allow gptwrap()'s to do buffer switches
 * instead of setting up a fresh gptin.  A bit of a hack ...
 */
static int yy_did_buffer_switch_on_eof;

void gptrestart (FILE *input_file  );
void gpt_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
YY_BUFFER_STATE gpt_create_buffer (FILE *file,int size  );
void gpt_delete_buffer (YY_BUFFER_STATE b  );
void gpt_flush_buffer (YY_BUFFER_STATE b  );
void gptpush_buffer_state (YY_BUFFER_STATE new_buffer  );
void gptpop_buffer_state (void );

static void gptensure_buffer_stack (void );
static void gpt_load_buffer_state (void );
static void gpt_init_buffer (YY_BUFFER_STATE b,FILE *file  );

#define YY_FLUSH_BUFFER gpt_flush_buffer(YY_CURRENT_BUFFER )

YY_BUFFER_STATE gpt_scan_buffer (char *base,yy_size_t size  );
YY_BUFFER_STATE gpt_scan_string (yyconst char *yy_str  );
YY_BUFFER_STATE gpt_scan_bytes (yyconst char *bytes,int len  );

void *gptalloc (yy_size_t  );
void *gptrealloc (void *,yy_size_t  );
void gptfree (void *  );

#define yy_new_buffer gpt_create_buffer

#define yy_set_interactive(is_interactive) \
      { \
      if ( ! YY_CURRENT_BUFFER ){ \
        gptensure_buffer_stack (); \
            YY_CURRENT_BUFFER_LVALUE =    \
            gpt_create_buffer(gptin,YY_BUF_SIZE ); \
      } \
      YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
      }

#define yy_set_bol(at_bol) \
      { \
      if ( ! YY_CURRENT_BUFFER ){\
        gptensure_buffer_stack (); \
            YY_CURRENT_BUFFER_LVALUE =    \
            gpt_create_buffer(gptin,YY_BUF_SIZE ); \
      } \
      YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
      }

#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

#define gptwrap(n) 1
#define YY_SKIP_YYWRAP

typedef unsigned char YY_CHAR;

FILE *gptin = (FILE *) 0, *gptout = (FILE *) 0;

typedef int yy_state_type;

extern int gptlineno;

int gptlineno = 1;

extern char *gpttext;
#define yytext_ptr gpttext

static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
static int yy_get_next_buffer (void );
static void yy_fatal_error (yyconst char msg[]  );

/* Done after the current pattern has been matched and before the
 * corresponding action - sets up gpttext.
 */
#define YY_DO_BEFORE_ACTION \
      (yytext_ptr) = yy_bp; \
      gptleng = (size_t) (yy_cp - yy_bp); \
      (yy_hold_char) = *yy_cp; \
      *yy_cp = '\0'; \
      (yy_c_buf_p) = yy_cp;

#define YY_NUM_RULES 20
#define YY_END_OF_BUFFER 21
/* This struct is not used in this scanner,
   but its presence is necessary. */
struct yy_trans_info
      {
      flex_int32_t yy_verify;
      flex_int32_t yy_nxt;
      };
static yyconst flex_int16_t yy_accept[54] =
    {   0,
        0,    0,   21,   19,   18,   20,   16,   12,   11,   16,
       10,    1,    2,   16,   16,    9,   16,   16,   16,   15,
       15,    7,    8,   16,   16,   13,    5,    6,    3,    4,
       16,   16,   16,   16,   17,   16,   15,   15,   15,    0,
        0,   16,   16,   13,    0,   14,   15,    0,   15,   15,
        0,   15,    0
    } ;

static yyconst flex_int32_t yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    2,    4,    5,    1,    6,    1,    7,    8,    9,
       10,   11,   12,   13,   14,   15,   16,   17,   18,   18,
       18,   18,   18,   18,   18,   18,   18,   19,   20,   21,
       22,   23,    1,   24,   25,   25,   25,   26,   26,   25,
       27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
       27,   27,   27,   27,   27,   27,   27,   28,   27,   27,
       29,   16,   30,   16,   27,    1,   25,   25,   25,   26,

       26,   25,   27,   27,   27,   27,   27,   27,   27,   27,
       27,   27,   27,   27,   27,   27,   27,   27,   27,   28,
       27,   27,   31,    7,   32,   33,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1
    } ;

static yyconst flex_int32_t yy_meta[34] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    2,    2,    1,    1,
        1,    1,    1,    1,    2,    2,    2,    2,    1,    1,
        1,    1,    1
    } ;

static yyconst flex_int16_t yy_base[55] =
    {   0,
        0,    0,   76,  131,  131,  131,   52,  131,  131,   27,
      131,  131,  131,   24,   25,  131,   22,   43,   41,   47,
       51,  131,  131,   49,   60,    0,  131,  131,  131,  131,
      131,  131,   36,  131,  131,   30,   61,   80,   75,   90,
       92,   31,   23,    0,  102,  131,   68,   21,   25,  104,
       82,   94,  131,   38
    } ;

static yyconst flex_int16_t yy_def[55] =
    {   0,
       53,    1,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   54,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   54,   53,   53,   53,   53,   53,   53,
       53,   53,    0,   53
    } ;

static yyconst flex_int16_t yy_nxt[165] =
    {   0,
        4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
       14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
       24,   10,   25,   26,   26,   26,   26,   26,   27,   28,
       29,   30,    7,   32,   33,   35,   35,   49,   49,   44,
       33,   49,   49,   34,   31,   34,   34,   32,   32,   32,
       35,   34,   31,   36,   33,   32,   33,   34,   33,   37,
       37,   38,   34,   39,   39,   38,   32,   39,   39,   42,
       32,   32,   40,   31,   41,   53,   40,   37,   37,   53,
       32,   32,   43,   53,   47,   47,   45,   46,   53,   38,
       46,   39,   39,   40,   53,   46,   47,   47,   52,   52,

       40,   48,   53,   48,   53,   40,   49,   49,   50,   50,
       52,   52,   53,   51,   53,   51,   50,   50,   52,   52,
       50,   50,   53,   53,   53,   53,   53,   53,   50,   50,
        3,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53
    } ;

static yyconst flex_int16_t yy_chk[165] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,   10,   14,   17,   15,   48,   48,   54,
       36,   49,   49,   17,   43,   14,   15,   10,   10,   10,
       18,   36,   42,   18,   18,   24,   18,   33,   18,   18,
       18,   20,   19,   20,   20,   21,   25,   21,   21,   24,
       24,   24,   20,    7,   20,    3,   21,   37,   37,    0,
       25,   25,   25,    0,   47,   47,   37,   38,    0,   39,
       38,   39,   39,   47,    0,   38,   38,   38,   51,   51,

       39,   40,    0,   40,    0,   38,   40,   40,   41,   41,
       52,   52,    0,   45,    0,   45,   41,   41,   45,   45,
       50,   50,    0,    0,    0,    0,    0,    0,   50,   50,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
       53,   53,   53,   53
    } ;

static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;

extern int gpt_flex_debug;
int gpt_flex_debug = 0;

/* The intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed.
 */
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *gpttext;
#line 1 "DLD-FUNCTIONS/__gnuplot_raw__.l"
/*

Copyright (C) 2004, 2005, 2006, 2007 John W. Eaton and Teemu Ikonen

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

Octave is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/
#line 27 "DLD-FUNCTIONS/__gnuplot_raw__.l"
// PKG_ADD: mark_as_rawcommand ("__gnuplot_plot__");
// PKG_ADD: mark_as_rawcommand ("__gnuplot_splot__");
// PKG_ADD: mark_as_rawcommand ("__gnuplot_replot__");

// PKG_ADD: mark_as_command ("__gnuplot_set__");
// PKG_ADD: mark_as_command ("__gnuplot_show__");

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <map>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>

#ifdef HAVE_UNISTD_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <unistd.h>
#endif

#include "file-ops.h"
#include "oct-env.h"

#include "defun-dld.h"
#include "file-io.h"
#include "gripes.h"
#include "ls-oct-ascii.h"
#include "parse.h"
#include "procstream.h"
#include "sighandlers.h"
#include "utils.h"
#include "variables.h"

enum _toktype
  {
    START_PAREN = 1,
    END_PAREN,
    START_BRACE,
    END_BRACE,
    START_BRACKET,
    END_BRACKET,
    COLON,
    SEMICOLON,
    COMMA,
    QUOTE,
    DOLLAR,
    IDENT,
    NUMBER,
    BINOP,
    UNOP,
    STRING,
    OTHER,
    TITLE,
    USING,
    WITH,
    AXES,
    CLEAR
  };

typedef bool (*pred) (const int);

class
gpt_parse_error
{
public:
  gpt_parse_error (void) : msg () { }
  gpt_parse_error (std::string errmsg) : msg (errmsg) { }

  std::string msg;
};

static bool gpt_quote_is_transpose;
static bool gpt_allow_plotkw;
static int gpt_parens;
static int gpt_brackets;
static int gpt_braces;

static bool can_be_plotkw (void);

static int is_plot_keyword (const std::string& s);

static int handle_string (char delim);
static std::string strbuf;

/* NOT is not strictly a binary operator, but is close enough for us. */
/* single quote (') transpose operator is handled separately. */
#line 635 "<stdout>"

#define INITIAL 0

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
 * down here because we want the user's section 1 to have been scanned first.
 * The user has a chance to override it with an option.
 */
#include <unistd.h>
#endif

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif

static int yy_init_globals (void );

/* Accessor methods to globals.
   These are made visible to non-reentrant scanners for convenience. */

int gptlex_destroy (void );

int gptget_debug (void );

void gptset_debug (int debug_flag  );

YY_EXTRA_TYPE gptget_extra (void );

void gptset_extra (YY_EXTRA_TYPE user_defined  );

FILE *gptget_in (void );

void gptset_in  (FILE * in_str  );

FILE *gptget_out (void );

void gptset_out  (FILE * out_str  );

int gptget_leng (void );

char *gptget_text (void );

int gptget_lineno (void );

void gptset_lineno (int line_number  );

/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int gptwrap (void );
#else
extern int gptwrap (void );
#endif
#endif

    static void yyunput (int c,char *buf_ptr  );
    
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * );
#endif

#ifndef YY_NO_INPUT

#ifdef __cplusplus
static int yyinput (void );
#else
static int input (void );
#endif

#endif

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif

/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite().
 */
#define ECHO fwrite( gpttext, gptleng, 1, gptout )
#endif

/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
      if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
            { \
            int c = '*'; \
            int n; \
            for ( n = 0; n < max_size && \
                       (c = getc( gptin )) != EOF && c != '\n'; ++n ) \
                  buf[n] = (char) c; \
            if ( c == '\n' ) \
                  buf[n++] = (char) c; \
            if ( c == EOF && ferror( gptin ) ) \
                  YY_FATAL_ERROR( "input in flex scanner failed" ); \
            result = n; \
            } \
      else \
            { \
            errno=0; \
            while ( (result = fread(buf, 1, max_size, gptin))==0 && ferror(gptin)) \
                  { \
                  if( errno != EINTR) \
                        { \
                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
                        break; \
                        } \
                  errno=0; \
                  clearerr(gptin); \
                  } \
            }\
\

#endif

/* No semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif

/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif

/* end tables serialization structures and prototypes */

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1

extern int gptlex (void);

#define YY_DECL int gptlex (void)
#endif /* !YY_DECL */

/* Code executed at the beginning of each rule, after gpttext and gptleng
 * have been set up.
 */
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif

#define YY_RULE_SETUP \
      YY_USER_ACTION

/** The main scanner function which does all the work.
 */
YY_DECL
{
      register yy_state_type yy_current_state;
      register char *yy_cp, *yy_bp;
      register int yy_act;
    
#line 128 "DLD-FUNCTIONS/__gnuplot_raw__.l"


#line 820 "<stdout>"

      if ( !(yy_init) )
            {
            (yy_init) = 1;

#ifdef YY_USER_INIT
            YY_USER_INIT;
#endif

            if ( ! (yy_start) )
                  (yy_start) = 1;   /* first start state */

            if ( ! gptin )
                  gptin = stdin;

            if ( ! gptout )
                  gptout = stdout;

            if ( ! YY_CURRENT_BUFFER ) {
                  gptensure_buffer_stack ();
                  YY_CURRENT_BUFFER_LVALUE =
                        gpt_create_buffer(gptin,YY_BUF_SIZE );
            }

            gpt_load_buffer_state( );
            }

      while ( 1 )       /* loops until end-of-file is reached */
            {
            yy_cp = (yy_c_buf_p);

            /* Support of gpttext. */
            *yy_cp = (yy_hold_char);

            /* yy_bp points to the position in yy_ch_buf of the start of
             * the current run.
             */
            yy_bp = yy_cp;

            yy_current_state = (yy_start);
yy_match:
            do
                  {
                  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
                  if ( yy_accept[yy_current_state] )
                        {
                        (yy_last_accepting_state) = yy_current_state;
                        (yy_last_accepting_cpos) = yy_cp;
                        }
                  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                        {
                        yy_current_state = (int) yy_def[yy_current_state];
                        if ( yy_current_state >= 54 )
                              yy_c = yy_meta[(unsigned int) yy_c];
                        }
                  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                  ++yy_cp;
                  }
            while ( yy_base[yy_current_state] != 131 );

yy_find_action:
            yy_act = yy_accept[yy_current_state];
            if ( yy_act == 0 )
                  { /* have to back up */
                  yy_cp = (yy_last_accepting_cpos);
                  yy_current_state = (yy_last_accepting_state);
                  yy_act = yy_accept[yy_current_state];
                  }

            YY_DO_BEFORE_ACTION;

do_action:  /* This label is used only to access EOF actions. */

            switch ( yy_act )
      { /* beginning of action switch */
                  case 0: /* must back up */
                  /* undo the effects of YY_DO_BEFORE_ACTION */
                  *yy_cp = (yy_hold_char);
                  yy_cp = (yy_last_accepting_cpos);
                  yy_current_state = (yy_last_accepting_state);
                  goto yy_find_action;

case 1:
YY_RULE_SETUP
#line 130 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_parens++;
    return START_PAREN;
    }
      YY_BREAK
case 2:
YY_RULE_SETUP
#line 136 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = true;
    gpt_parens--;
    return END_PAREN;
    }
      YY_BREAK
case 3:
YY_RULE_SETUP
#line 142 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_braces++;
    return START_BRACE;
    }
      YY_BREAK
case 4:
YY_RULE_SETUP
#line 148 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = true;
    gpt_braces--;
    return END_BRACE;
    }
      YY_BREAK
case 5:
YY_RULE_SETUP
#line 154 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_brackets++;
    return START_BRACKET;
    }
      YY_BREAK
case 6:
YY_RULE_SETUP
#line 160 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = true;
    gpt_brackets--;
    return END_BRACKET;
    }
      YY_BREAK
case 7:
YY_RULE_SETUP
#line 166 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    return COLON;
    }
      YY_BREAK
case 8:
YY_RULE_SETUP
#line 171 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    return SEMICOLON;
    }
      YY_BREAK
case 9:
YY_RULE_SETUP
#line 176 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    return COMMA;
    }
      YY_BREAK
case 10:
YY_RULE_SETUP
#line 181 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    if (gpt_quote_is_transpose)
      {
        gpt_allow_plotkw = true;
        return QUOTE;
      }
    else
      {
        gpt_quote_is_transpose = true;
        gpt_allow_plotkw = true;
        return handle_string ('\'');
      }
    }
      YY_BREAK
case 11:
YY_RULE_SETUP
#line 195 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    return DOLLAR;
    }
      YY_BREAK
case 12:
YY_RULE_SETUP
#line 200 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    return handle_string ('"');
    }
      YY_BREAK
case 13:
YY_RULE_SETUP
#line 204 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    int itok = 0;
    if (can_be_plotkw () && (itok = is_plot_keyword (gpttext)))
      {
        gpt_quote_is_transpose = false;
        gpt_allow_plotkw = true;
        return itok;
      }
    else if (std::string (gpttext) == "function")
      throw gpt_parse_error ("function keyword not allowed in plot commands");
    else
      {
        gpt_quote_is_transpose = true;
        gpt_allow_plotkw = true;
        return IDENT;
      }
    }
      YY_BREAK
case 14:
*yy_cp = (yy_hold_char); /* undo effects of setting up gpttext */
(yy_c_buf_p) = yy_cp -= 2;
YY_DO_BEFORE_ACTION; /* set up gpttext again */
#line 223 "DLD-FUNCTIONS/__gnuplot_raw__.l"
case 15:
YY_RULE_SETUP
#line 223 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = true;
    gpt_allow_plotkw = true;
    return NUMBER;
    }
      YY_BREAK
case 16:
YY_RULE_SETUP
#line 229 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_allow_plotkw = false;
    return BINOP;
    }
      YY_BREAK
case 17:
YY_RULE_SETUP
#line 235 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_allow_plotkw = true;
    return UNOP;
    }
      YY_BREAK
case 18:
YY_RULE_SETUP
#line 241 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{ /* Ignore spaces and tabs outside of character strings. */ }
      YY_BREAK
case 19:
YY_RULE_SETUP
#line 243 "DLD-FUNCTIONS/__gnuplot_raw__.l"
{
    gpt_quote_is_transpose = false;
    gpt_allow_plotkw = true;
    warning ("unknown token = \"%s\" in plot command", gpttext);
    return OTHER;
    }
      YY_BREAK
case 20:
YY_RULE_SETUP
#line 250 "DLD-FUNCTIONS/__gnuplot_raw__.l"
ECHO;
      YY_BREAK
#line 1086 "<stdout>"
case YY_STATE_EOF(INITIAL):
      yyterminate();

      case YY_END_OF_BUFFER:
            {
            /* Amount of text matched not including the EOB char. */
            int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;

            /* Undo the effects of YY_DO_BEFORE_ACTION. */
            *yy_cp = (yy_hold_char);
            YY_RESTORE_YY_MORE_OFFSET

            if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
                  {
                  /* We're scanning a new file or input source.  It's
                   * possible that this happened because the user
                   * just pointed gptin at a new source and called
                   * gptlex().  If so, then we have to assure
                   * consistency between YY_CURRENT_BUFFER and our
                   * globals.  Here is the right place to do so, because
                   * this is the first action (other than possibly a
                   * back-up) that will match for the new input source.
                   */
                  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
                  YY_CURRENT_BUFFER_LVALUE->yy_input_file = gptin;
                  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
                  }

            /* Note that here we test for yy_c_buf_p "<=" to the position
             * of the first EOB in the buffer, since yy_c_buf_p will
             * already have been incremented past the NUL character
             * (since all states make transitions on EOB to the
             * end-of-buffer state).  Contrast this with the test
             * in input().
             */
            if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
                  { /* This was really a NUL. */
                  yy_state_type yy_next_state;

                  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;

                  yy_current_state = yy_get_previous_state(  );

                  /* Okay, we're now positioned to make the NUL
                   * transition.  We couldn't have
                   * yy_get_previous_state() go ahead and do it
                   * for us because it doesn't know how to deal
                   * with the possibility of jamming (and we don't
                   * want to build jamming into it because then it
                   * will run more slowly).
                   */

                  yy_next_state = yy_try_NUL_trans( yy_current_state );

                  yy_bp = (yytext_ptr) + YY_MORE_ADJ;

                  if ( yy_next_state )
                        {
                        /* Consume the NUL. */
                        yy_cp = ++(yy_c_buf_p);
                        yy_current_state = yy_next_state;
                        goto yy_match;
                        }

                  else
                        {
                        yy_cp = (yy_c_buf_p);
                        goto yy_find_action;
                        }
                  }

            else switch ( yy_get_next_buffer(  ) )
                  {
                  case EOB_ACT_END_OF_FILE:
                        {
                        (yy_did_buffer_switch_on_eof) = 0;

                        if ( gptwrap( ) )
                              {
                              /* Note: because we've taken care in
                               * yy_get_next_buffer() to have set up
                               * gpttext, we can now set up
                               * yy_c_buf_p so that if some total
                               * hoser (like flex itself) wants to
                               * call the scanner after we return the
                               * YY_NULL, it'll still work - another
                               * YY_NULL will get returned.
                               */
                              (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;

                              yy_act = YY_STATE_EOF(YY_START);
                              goto do_action;
                              }

                        else
                              {
                              if ( ! (yy_did_buffer_switch_on_eof) )
                                    YY_NEW_FILE;
                              }
                        break;
                        }

                  case EOB_ACT_CONTINUE_SCAN:
                        (yy_c_buf_p) =
                              (yytext_ptr) + yy_amount_of_matched_text;

                        yy_current_state = yy_get_previous_state(  );

                        yy_cp = (yy_c_buf_p);
                        yy_bp = (yytext_ptr) + YY_MORE_ADJ;
                        goto yy_match;

                  case EOB_ACT_LAST_MATCH:
                        (yy_c_buf_p) =
                        &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];

                        yy_current_state = yy_get_previous_state(  );

                        yy_cp = (yy_c_buf_p);
                        yy_bp = (yytext_ptr) + YY_MORE_ADJ;
                        goto yy_find_action;
                  }
            break;
            }

      default:
            YY_FATAL_ERROR(
                  "fatal flex scanner internal error--no action found" );
      } /* end of action switch */
            } /* end of scanning one token */
} /* end of gptlex */

/* yy_get_next_buffer - try to read in a new buffer
 *
 * Returns a code representing an action:
 *    EOB_ACT_LAST_MATCH -
 *    EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 *    EOB_ACT_END_OF_FILE - end of file
 */
static int yy_get_next_buffer (void)
{
      register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
      register char *source = (yytext_ptr);
      register int number_to_move, i;
      int ret_val;

      if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
            YY_FATAL_ERROR(
            "fatal flex scanner internal error--end of buffer missed" );

      if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
            { /* Don't try to fill the buffer, so this is an EOF. */
            if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
                  {
                  /* We matched a single character, the EOB, so
                   * treat this as a final EOF.
                   */
                  return EOB_ACT_END_OF_FILE;
                  }

            else
                  {
                  /* We matched some text prior to the EOB, first
                   * process it.
                   */
                  return EOB_ACT_LAST_MATCH;
                  }
            }

      /* Try to read more data. */

      /* First move last chars to start of buffer. */
      number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;

      for ( i = 0; i < number_to_move; ++i )
            *(dest++) = *(source++);

      if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
            /* don't do the read, it's not guaranteed to return an EOF,
             * just force an EOF
             */
            YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;

      else
            {
                  int num_to_read =
                  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

            while ( num_to_read <= 0 )
                  { /* Not enough room in the buffer - grow it. */

                  /* just a shorter name for the current buffer */
                  YY_BUFFER_STATE b = YY_CURRENT_BUFFER;

                  int yy_c_buf_p_offset =
                        (int) ((yy_c_buf_p) - b->yy_ch_buf);

                  if ( b->yy_is_our_buffer )
                        {
                        int new_size = b->yy_buf_size * 2;

                        if ( new_size <= 0 )
                              b->yy_buf_size += b->yy_buf_size / 8;
                        else
                              b->yy_buf_size *= 2;

                        b->yy_ch_buf = (char *)
                              /* Include room in for 2 EOB chars. */
                              gptrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
                        }
                  else
                        /* Can't grow it, we don't own it. */
                        b->yy_ch_buf = 0;

                  if ( ! b->yy_ch_buf )
                        YY_FATAL_ERROR(
                        "fatal error - scanner input buffer overflow" );

                  (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];

                  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
                                    number_to_move - 1;

                  }

            if ( num_to_read > YY_READ_BUF_SIZE )
                  num_to_read = YY_READ_BUF_SIZE;

            /* Read in more data. */
            YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
                  (yy_n_chars), (size_t) num_to_read );

            YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
            }

      if ( (yy_n_chars) == 0 )
            {
            if ( number_to_move == YY_MORE_ADJ )
                  {
                  ret_val = EOB_ACT_END_OF_FILE;
                  gptrestart(gptin  );
                  }

            else
                  {
                  ret_val = EOB_ACT_LAST_MATCH;
                  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
                        YY_BUFFER_EOF_PENDING;
                  }
            }

      else
            ret_val = EOB_ACT_CONTINUE_SCAN;

      if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
            /* Extend the array by 50%, plus the number we really need. */
            yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
            YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) gptrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
            if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
                  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
      }

      (yy_n_chars) += number_to_move;
      YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
      YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;

      (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];

      return ret_val;
}

/* yy_get_previous_state - get the state just before the EOB char was reached */

    static yy_state_type yy_get_previous_state (void)
{
      register yy_state_type yy_current_state;
      register char *yy_cp;
    
      yy_current_state = (yy_start);

      for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
            {
            register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
            if ( yy_accept[yy_current_state] )
                  {
                  (yy_last_accepting_state) = yy_current_state;
                  (yy_last_accepting_cpos) = yy_cp;
                  }
            while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                  {
                  yy_current_state = (int) yy_def[yy_current_state];
                  if ( yy_current_state >= 54 )
                        yy_c = yy_meta[(unsigned int) yy_c];
                  }
            yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
            }

      return yy_current_state;
}

/* yy_try_NUL_trans - try to make a transition on the NUL character
 *
 * synopsis
 *    next_state = yy_try_NUL_trans( current_state );
 */
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
{
      register int yy_is_jam;
      register char *yy_cp = (yy_c_buf_p);

      register YY_CHAR yy_c = 1;
      if ( yy_accept[yy_current_state] )
            {
            (yy_last_accepting_state) = yy_current_state;
            (yy_last_accepting_cpos) = yy_cp;
            }
      while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
            {
            yy_current_state = (int) yy_def[yy_current_state];
            if ( yy_current_state >= 54 )
                  yy_c = yy_meta[(unsigned int) yy_c];
            }
      yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
      yy_is_jam = (yy_current_state == 53);

      return yy_is_jam ? 0 : yy_current_state;
}

    static void yyunput (int c, register char * yy_bp )
{
      register char *yy_cp;
    
    yy_cp = (yy_c_buf_p);

      /* undo effects of setting up gpttext */
      *yy_cp = (yy_hold_char);

      if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
            { /* need to shift things up to make room */
            /* +2 for EOB chars. */
            register int number_to_move = (yy_n_chars) + 2;
            register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
                              YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
            register char *source =
                        &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];

            while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
                  *--dest = *--source;

            yy_cp += (int) (dest - source);
            yy_bp += (int) (dest - source);
            YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
                  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;

            if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
                  YY_FATAL_ERROR( "flex scanner push-back overflow" );
            }

      *--yy_cp = (char) c;

      (yytext_ptr) = yy_bp;
      (yy_hold_char) = *yy_cp;
      (yy_c_buf_p) = yy_cp;
}

#ifndef YY_NO_INPUT
#ifdef __cplusplus
    static int yyinput (void)
#else
    static int input  (void)
#endif

{
      int c;
    
      *(yy_c_buf_p) = (yy_hold_char);

      if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
            {
            /* yy_c_buf_p now points to the character we want to return.
             * If this occurs *before* the EOB characters, then it's a
             * valid NUL; if not, then we've hit the end of the buffer.
             */
            if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
                  /* This was really a NUL. */
                  *(yy_c_buf_p) = '\0';

            else
                  { /* need more input */
                  int offset = (yy_c_buf_p) - (yytext_ptr);
                  ++(yy_c_buf_p);

                  switch ( yy_get_next_buffer(  ) )
                        {
                        case EOB_ACT_LAST_MATCH:
                              /* This happens because yy_g_n_b()
                               * sees that we've accumulated a
                               * token and flags that we need to
                               * try matching the token before
                               * proceeding.  But for input(),
                               * there's no matching to consider.
                               * So convert the EOB_ACT_LAST_MATCH
                               * to EOB_ACT_END_OF_FILE.
                               */

                              /* Reset buffer status. */
                              gptrestart(gptin );

                              /*FALLTHROUGH*/

                        case EOB_ACT_END_OF_FILE:
                              {
                              if ( gptwrap( ) )
                                    return EOF;

                              if ( ! (yy_did_buffer_switch_on_eof) )
                                    YY_NEW_FILE;
#ifdef __cplusplus
                              return yyinput();
#else
                              return input();
#endif
                              }

                        case EOB_ACT_CONTINUE_SCAN:
                              (yy_c_buf_p) = (yytext_ptr) + offset;
                              break;
                        }
                  }
            }

      c = *(unsigned char *) (yy_c_buf_p);      /* cast for 8-bit char's */
      *(yy_c_buf_p) = '\0';   /* preserve gpttext */
      (yy_hold_char) = *++(yy_c_buf_p);

      return c;
}
#endif      /* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * 
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void gptrestart  (FILE * input_file )
{
    
      if ( ! YY_CURRENT_BUFFER ){
        gptensure_buffer_stack ();
            YY_CURRENT_BUFFER_LVALUE =
            gpt_create_buffer(gptin,YY_BUF_SIZE );
      }

      gpt_init_buffer(YY_CURRENT_BUFFER,input_file );
      gpt_load_buffer_state( );
}

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * 
 */
    void gpt_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
{
    
      /* TODO. We should be able to replace this entire function body
       * with
       *          gptpop_buffer_state();
       *          gptpush_buffer_state(new_buffer);
     */
      gptensure_buffer_stack ();
      if ( YY_CURRENT_BUFFER == new_buffer )
            return;

      if ( YY_CURRENT_BUFFER )
            {
            /* Flush out information for old buffer. */
            *(yy_c_buf_p) = (yy_hold_char);
            YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
            YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
            }

      YY_CURRENT_BUFFER_LVALUE = new_buffer;
      gpt_load_buffer_state( );

      /* We don't actually know whether we did this switch during
       * EOF (gptwrap()) processing, but the only time this flag
       * is looked at is after gptwrap() is called, so it's safe
       * to go ahead and always set it.
       */
      (yy_did_buffer_switch_on_eof) = 1;
}

static void gpt_load_buffer_state  (void)
{
      (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
      (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
      gptin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
      (yy_hold_char) = *(yy_c_buf_p);
}

/** Allocate and initialize an input buffer state.
 * @param file A readable stream.
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
 * 
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE gpt_create_buffer  (FILE * file, int  size )
{
      YY_BUFFER_STATE b;
    
      b = (YY_BUFFER_STATE) gptalloc(sizeof( struct yy_buffer_state )  );
      if ( ! b )
            YY_FATAL_ERROR( "out of dynamic memory in gpt_create_buffer()" );

      b->yy_buf_size = size;

      /* yy_ch_buf has to be 2 characters longer than the size given because
       * we need to put in 2 end-of-buffer characters.
       */
      b->yy_ch_buf = (char *) gptalloc(b->yy_buf_size + 2  );
      if ( ! b->yy_ch_buf )
            YY_FATAL_ERROR( "out of dynamic memory in gpt_create_buffer()" );

      b->yy_is_our_buffer = 1;

      gpt_init_buffer(b,file );

      return b;
}

/** Destroy the buffer.
 * @param b a buffer created with gpt_create_buffer()
 * 
 */
    void gpt_delete_buffer (YY_BUFFER_STATE  b )
{
    
      if ( ! b )
            return;

      if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
            YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;

      if ( b->yy_is_our_buffer )
            gptfree((void *) b->yy_ch_buf  );

      gptfree((void *) b  );
}

#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
    
/* Initializes or reinitializes a buffer.
 * This function is sometimes called more than once on the same buffer,
 * such as during a gptrestart() or at EOF.
 */
    static void gpt_init_buffer  (YY_BUFFER_STATE  b, FILE * file )

{
      int oerrno = errno;
    
      gpt_flush_buffer(b );

      b->yy_input_file = file;
      b->yy_fill_buffer = 1;

    /* If b is the current buffer, then gpt_init_buffer was _probably_
     * called from gptrestart() or through yy_get_next_buffer.
     * In that case, we don't want to reset the lineno or column.
     */
    if (b != YY_CURRENT_BUFFER){
        b->yy_bs_lineno = 1;
        b->yy_bs_column = 0;
    }

        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
    
      errno = oerrno;
}

/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
 * 
 */
    void gpt_flush_buffer (YY_BUFFER_STATE  b )
{
      if ( ! b )
            return;

      b->yy_n_chars = 0;

      /* We always need two end-of-buffer characters.  The first causes
       * a transition to the end-of-buffer state.  The second causes
       * a jam in that state.
       */
      b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
      b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;

      b->yy_buf_pos = &b->yy_ch_buf[0];

      b->yy_at_bol = 1;
      b->yy_buffer_status = YY_BUFFER_NEW;

      if ( b == YY_CURRENT_BUFFER )
            gpt_load_buffer_state( );
}

/** Pushes the new state onto the stack. The new state becomes
 *  the current state. This function will allocate the stack
 *  if necessary.
 *  @param new_buffer The new state.
 *  
 */
void gptpush_buffer_state (YY_BUFFER_STATE new_buffer )
{
      if (new_buffer == NULL)
            return;

      gptensure_buffer_stack();

      /* This block is copied from gpt_switch_to_buffer. */
      if ( YY_CURRENT_BUFFER )
            {
            /* Flush out information for old buffer. */
            *(yy_c_buf_p) = (yy_hold_char);
            YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
            YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
            }

      /* Only push if top exists. Otherwise, replace top. */
      if (YY_CURRENT_BUFFER)
            (yy_buffer_stack_top)++;
      YY_CURRENT_BUFFER_LVALUE = new_buffer;

      /* copied from gpt_switch_to_buffer. */
      gpt_load_buffer_state( );
      (yy_did_buffer_switch_on_eof) = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  
 */
void gptpop_buffer_state (void)
{
      if (!YY_CURRENT_BUFFER)
            return;

      gpt_delete_buffer(YY_CURRENT_BUFFER );
      YY_CURRENT_BUFFER_LVALUE = NULL;
      if ((yy_buffer_stack_top) > 0)
            --(yy_buffer_stack_top);

      if (YY_CURRENT_BUFFER) {
            gpt_load_buffer_state( );
            (yy_did_buffer_switch_on_eof) = 1;
      }
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void gptensure_buffer_stack (void)
{
      int num_to_alloc;
    
      if (!(yy_buffer_stack)) {

            /* First allocation is just for 2 elements, since we don't know if this
             * scanner will even need a stack. We use 2 instead of 1 to avoid an
             * immediate realloc on the next call.
         */
            num_to_alloc = 1;
            (yy_buffer_stack) = (struct yy_buffer_state**)gptalloc
                                                (num_to_alloc * sizeof(struct yy_buffer_state*)
                                                );
            if ( ! (yy_buffer_stack) )
                  YY_FATAL_ERROR( "out of dynamic memory in gptensure_buffer_stack()" );
                                                  
            memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
                        
            (yy_buffer_stack_max) = num_to_alloc;
            (yy_buffer_stack_top) = 0;
            return;
      }

      if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){

            /* Increase the buffer to prepare for a possible push. */
            int grow_size = 8 /* arbitrary grow size */;

            num_to_alloc = (yy_buffer_stack_max) + grow_size;
            (yy_buffer_stack) = (struct yy_buffer_state**)gptrealloc
                                                ((yy_buffer_stack),
                                                num_to_alloc * sizeof(struct yy_buffer_state*)
                                                );
            if ( ! (yy_buffer_stack) )
                  YY_FATAL_ERROR( "out of dynamic memory in gptensure_buffer_stack()" );

            /* zero only the new slots.*/
            memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
            (yy_buffer_stack_max) = num_to_alloc;
      }
}

/** Setup the input buffer state to scan directly from a user-specified character buffer.
 * @param base the character buffer
 * @param size the size in bytes of the character buffer
 * 
 * @return the newly allocated buffer state object. 
 */
YY_BUFFER_STATE gpt_scan_buffer  (char * base, yy_size_t  size )
{
      YY_BUFFER_STATE b;
    
      if ( size < 2 ||
           base[size-2] != YY_END_OF_BUFFER_CHAR ||
           base[size-1] != YY_END_OF_BUFFER_CHAR )
            /* They forgot to leave room for the EOB's. */
            return 0;

      b = (YY_BUFFER_STATE) gptalloc(sizeof( struct yy_buffer_state )  );
      if ( ! b )
            YY_FATAL_ERROR( "out of dynamic memory in gpt_scan_buffer()" );

      b->yy_buf_size = size - 2;    /* "- 2" to take care of EOB's */
      b->yy_buf_pos = b->yy_ch_buf = base;
      b->yy_is_our_buffer = 0;
      b->yy_input_file = 0;
      b->yy_n_chars = b->yy_buf_size;
      b->yy_is_interactive = 0;
      b->yy_at_bol = 1;
      b->yy_fill_buffer = 0;
      b->yy_buffer_status = YY_BUFFER_NEW;

      gpt_switch_to_buffer(b  );

      return b;
}

/** Setup the input buffer state to scan a string. The next call to gptlex() will
 * scan from a @e copy of @a str.
 * @param yystr a NUL-terminated string to scan
 * 
 * @return the newly allocated buffer state object.
 * @note If you want to scan bytes that may contain NUL values, then use
 *       gpt_scan_bytes() instead.
 */
YY_BUFFER_STATE gpt_scan_string (yyconst char * yystr )
{
    
      return gpt_scan_bytes(yystr,strlen(yystr) );
}

/** Setup the input buffer state to scan the given bytes. The next call to gptlex() will
 * scan from a @e copy of @a bytes.
 * @param bytes the byte buffer to scan
 * @param len the number of bytes in the buffer pointed to by @a bytes.
 * 
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE gpt_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
{
      YY_BUFFER_STATE b;
      char *buf;
      yy_size_t n;
      int i;
    
      /* Get memory for full buffer, including space for trailing EOB's. */
      n = _yybytes_len + 2;
      buf = (char *) gptalloc(n  );
      if ( ! buf )
            YY_FATAL_ERROR( "out of dynamic memory in gpt_scan_bytes()" );

      for ( i = 0; i < _yybytes_len; ++i )
            buf[i] = yybytes[i];

      buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;

      b = gpt_scan_buffer(buf,n );
      if ( ! b )
            YY_FATAL_ERROR( "bad buffer in gpt_scan_bytes()" );

      /* It's okay to grow etc. this buffer, and we should throw it
       * away when we're done.
       */
      b->yy_is_our_buffer = 1;

      return b;
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

static void yy_fatal_error (yyconst char* msg )
{
      (void) fprintf( stderr, "%s\n", msg );
      exit( YY_EXIT_FAILURE );
}

/* Redefine yyless() so it works in section 3 code. */

#undef yyless
#define yyless(n) \
      do \
            { \
            /* Undo effects of setting up gpttext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
            gpttext[gptleng] = (yy_hold_char); \
            (yy_c_buf_p) = gpttext + yyless_macro_arg; \
            (yy_hold_char) = *(yy_c_buf_p); \
            *(yy_c_buf_p) = '\0'; \
            gptleng = yyless_macro_arg; \
            } \
      while ( 0 )

/* Accessor  methods (get/set functions) to struct members. */

/** Get the current line number.
 * 
 */
int gptget_lineno  (void)
{
        
    return gptlineno;
}

/** Get the input stream.
 * 
 */
FILE *gptget_in  (void)
{
        return gptin;
}

/** Get the output stream.
 * 
 */
FILE *gptget_out  (void)
{
        return gptout;
}

/** Get the length of the current token.
 * 
 */
int gptget_leng  (void)
{
        return gptleng;
}

/** Get the current token.
 * 
 */

char *gptget_text  (void)
{
        return gpttext;
}

/** Set the current line number.
 * @param line_number
 * 
 */
void gptset_lineno (int  line_number )
{
    
    gptlineno = line_number;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param in_str A readable stream.
 * 
 * @see gpt_switch_to_buffer
 */
void gptset_in (FILE *  in_str )
{
        gptin = in_str ;
}

void gptset_out (FILE *  out_str )
{
        gptout = out_str ;
}

int gptget_debug  (void)
{
        return gpt_flex_debug;
}

void gptset_debug (int  bdebug )
{
        gpt_flex_debug = bdebug ;
}

static int yy_init_globals (void)
{
        /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from gptlex_destroy(), so don't allocate here.
     */

    (yy_buffer_stack) = 0;
    (yy_buffer_stack_top) = 0;
    (yy_buffer_stack_max) = 0;
    (yy_c_buf_p) = (char *) 0;
    (yy_init) = 0;
    (yy_start) = 0;

/* Defined in main.c */
#ifdef YY_STDINIT
    gptin = stdin;
    gptout = stdout;
#else
    gptin = (FILE *) 0;
    gptout = (FILE *) 0;
#endif

    /* For future reference: Set errno on error, since we are called by
     * gptlex_init()
     */
    return 0;
}

/* gptlex_destroy is for both reentrant and non-reentrant scanners. */
int gptlex_destroy  (void)
{
    
    /* Pop the buffer stack, destroying each element. */
      while(YY_CURRENT_BUFFER){
            gpt_delete_buffer(YY_CURRENT_BUFFER  );
            YY_CURRENT_BUFFER_LVALUE = NULL;
            gptpop_buffer_state();
      }

      /* Destroy the stack itself. */
      gptfree((yy_buffer_stack) );
      (yy_buffer_stack) = NULL;

    /* Reset the globals. This is important in a non-reentrant scanner so the next time
     * gptlex() is called, initialization will occur. */
    yy_init_globals( );

    return 0;
}

/*
 * Internal utility routines.
 */

#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
      register int i;
      for ( i = 0; i < n; ++i )
            s1[i] = s2[i];
}
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
      register int n;
      for ( n = 0; s[n]; ++n )
            ;

      return n;
}
#endif

void *gptalloc (yy_size_t  size )
{
      return (void *) malloc( size );
}

void *gptrealloc  (void * ptr, yy_size_t  size )
{
      /* The cast to (char *) in the following accommodates both
       * implementations that use char* generic pointers, and those
       * that use void* generic pointers.  It works with the latter
       * because both ANSI C and C++ allow castless assignment from
       * any pointer type to void*, and deal with argument conversions
       * as though doing an assignment.
       */
      return (void *) realloc( (char *) ptr, size );
}

void gptfree (void * ptr )
{
      free( (char *) ptr );   /* see gptrealloc() for (char *) cast */
}

#define YYTABLES_NAME "yytables"

#line 250 "DLD-FUNCTIONS/__gnuplot_raw__.l"



// ------------------------------------------------------------
// Interface to external gnuplot process(es), including gnuplot
// command parser.
// ------------------------------------------------------------

// The name of the shell command to execute to start gnuplot.
static std::string Vgnuplot_binary = GNUPLOT_BINARY;

// Append -title "Figure NN" to the gnuplot command?
static bool Vgnuplot_use_title_option = octave_env::have_x11_display ();

// Gnuplot command strings that we use.
static std::string Vgnuplot_command_plot = "pl";
static std::string Vgnuplot_command_replot = "rep";
static std::string Vgnuplot_command_splot = "sp";
static std::string Vgnuplot_command_using = "u";
static std::string Vgnuplot_command_with = "w";
static std::string Vgnuplot_command_axes = "ax";
static std::string Vgnuplot_command_title = "t";
static std::string Vgnuplot_command_end = "\n";

// Check if the parser state is such that a plot keyword can occur.

static bool
can_be_plotkw (void)
{
    return (gpt_allow_plotkw
          && (gpt_braces == 0)
          && (gpt_brackets == 0)
          && (gpt_parens == 0));
}

// Check to see if a character string matches any one of the plot
// option keywords.  Don't match abbreviations for clear, since that's
// not a gnuplot keyword (users will probably only expect to be able
// to abbreviate actual gnuplot keywords).

static int
is_plot_keyword (const std::string& s)
{
  if (almost_match ("title", s, 1))
    return TITLE;
  else if (almost_match ("using", s, 1))
    return USING;
  else if (almost_match ("with", s, 1))
    return WITH;
  else if (almost_match ("axes", s, 2) || almost_match ("axis", s, 2))
    return AXES;
  else if ("clear" == s)
    return CLEAR;
  else
    return 0;
}

// This is used to handle character strings.  Kludge alert.

static int
handle_string (char delim)
{
  int c;
  bool escape_pending = false;

  strbuf = std::string (1, delim);

  while ((c = yyinput ()) != EOF)
    {
      if (c == '\\')
      {
        if (escape_pending)
          {
            strbuf += static_cast<char> (c);
            escape_pending = false;
          }
        else
          {
            strbuf += static_cast<char> (c);
            escape_pending = true;
          }
        continue;
      }
      else if (c == '\n')
      {
        error ("unterminated string constant");
        break;
      }
      else if (c == delim)
      {
        if (escape_pending)
          strbuf += static_cast<char> (c);
        else
          {
            c = yyinput ();

            if (c == delim)
            {
              strbuf += static_cast<char> (c);
              strbuf += static_cast<char> (c);
            }
            else
            {
              yyunput (c, gpttext);
              strbuf += static_cast<char> (delim);
              return STRING;
            }
          }
      }
      else
      strbuf += static_cast<char> (c);

      escape_pending = false;
    }

  throw gpt_parse_error ("unterminated string");

  return 0;
}

// (Probably not necessesary, but current Matlab style plot functions
// break without this (they emit too short gnuplot commands))

static std::string
plot_style_token (const std::string& s)
{
  std::string retval;

  // FIXME -- specify minimum match length for these.
  static const char *plot_styles[] =
    {
      "boxes",
      "boxerrorbars",
      "boxxyerrorbars",
      "candlesticks",
      "dots",
      "errorbars",
      "financebars",
      "fsteps",
      "histeps",
      "impulses",
      "lines",
      "linespoints",
      "points",
      "steps",
      "vector",
      "xerrorbars",
      "xyerrorbars",
      "yerrorbars",
      0,
    };

  const char * const *tmp = plot_styles;
  while (*tmp)
    {
      if (almost_match (*tmp, s.c_str ()))
      {
        retval = *tmp;
        break;
      }

      tmp++;
    }

  return retval;
}

// Some predicates on tokens

// Return true for ":".

static bool
colonp (const int tok)
{
  return (tok == COLON);
}

// Return TRUE for "]".

static bool
endbracketp (const int tok)
{
  return (tok == END_BRACKET);
}

// Return TRUE for plot token, comma or end of input.

static bool
plottok_or_end_p (const int tok)
{
  return (tok == TITLE
        || tok == USING
        || tok == WITH
        || tok == AXES
        || tok == CLEAR
        || tok == COMMA
        || tok == 0);
}

// Equivalent to (colonp (tok) || plottok_or_end_p (tok)).

static bool
colon_plottok_or_end_p (const int tok)
{
  return (tok == COLON || plottok_or_end_p (tok));
}

// read until test is true and delimiters are balanced, or end of input.
// Return the last token in lasttok

static std::string
read_until (pred test, int& lasttok) throw (gpt_parse_error)
{
  int tok;

  // We have to maintain balanced delimiters per subexpression too.
  int brackets = 0;
  int parens = 0;
  int braces = 0;
  std::string s;

  tok = gptlex ();

  while (tok && ! (test (tok)
               && brackets == 0
               && parens == 0
               && braces == 0))
    {
      switch (tok)
      {
      case START_BRACKET:
        brackets++;
        break;

      case END_BRACKET:
        brackets--;
        break;

      case START_PAREN:
        parens++;
        break;

      case END_PAREN:
        parens--;
        break;

      case START_BRACE:
        braces++;
        break;

      case END_BRACE:
        braces--;
        break;

      default:
        break;
        }

      s += (tok == STRING ? strbuf : std::string (gpttext)) + " ";

      tok = gptlex ();
    }

  // Throw error only if we've reached the end token and the test
  // doesn't accept it.

  if (! test (tok) && ! tok)
    throw gpt_parse_error ("unexpected end of input");

  lasttok = tok;

  return s;
}

// Eval the two expressions giving limits of range and print it.

static std::string
printrange (std::string starts, std::string ends)
{
  octave_value startv, endv;
  int status;
  std::string s;
  std::ostringstream range_buf;

  range_buf << "[";

  if (! starts.empty ())
    {
      startv = eval_string (starts, true, status);
      if (! startv.is_real_scalar ())
      throw gpt_parse_error ();
      startv.print_raw (range_buf);
    }

    range_buf << ":";

    if (! ends.empty ())
      {
      endv = eval_string (ends, true, status);
      if (! endv.is_real_scalar ())
        throw gpt_parse_error ();
        endv.print_raw (range_buf);
      }

    range_buf << "]";

    s = range_buf.str ();

    return s;
}

// Handle plot parameters.

// Parse, evaluate and print colon separated expressions in the using
// plot parameter. The use of trailing format string is not supported.

static std::string
handle_using (int& lasttok)
{
  int tok;
  std::string expr_str;
  std::string retstr = Vgnuplot_command_using + " ";
  bool out = false;

  octave_value tmp_data;
  int status;
  while (! out)
    {
      expr_str = read_until (colon_plottok_or_end_p, tok);

      if (! expr_str.empty () &&  expr_str[0] == '(')
      retstr += expr_str;
      else
      {
        tmp_data = eval_string (expr_str, true, status);
        if (status != 0 || ! tmp_data.is_real_scalar ())
          throw gpt_parse_error ();

        std::ostringstream tmp_buf;
        tmp_data.print_raw (tmp_buf);
        retstr += tmp_buf.str ();
      }

      if (tok == COLON)
      retstr += ":";
      else
      out = true;
    }

  lasttok = tok;

  return retstr;
}

// Presently just passes the linewidth, pointtype etc. tokens as they are.

static std::string
handle_style (int& lasttok)
{
  std::string retstr = Vgnuplot_command_with + " ";
  std::string style;

  lasttok = gptlex ();

  if (lasttok != IDENT)
    throw gpt_parse_error ("expected plot style token");

  style = std::string (gpttext);
  style = plot_style_token (style);

  if (! style.empty ())
    retstr += style;
  else
    retstr += std::string (gpttext);

  // FIXME -- should evaluate the remaining tokens, but this
  // needs changes in the parser.
  retstr += " " + read_until (plottok_or_end_p, lasttok);

  return retstr;
}

// Axes has only one qualifier keyword, which is not evaluated.

static std::string
handle_axes (int& lasttok)
{
  return Vgnuplot_command_axes + " " + read_until (plottok_or_end_p, lasttok);
}

static void
write_data (std::ostream& os, const octave_value& val,
          int ndim = 2, bool parametric = false,
          const std::string& name = std::string ())
{
  switch (ndim)
    {
    case 2:
      save_ascii_data_for_plotting (os, val, name);
      break;

    case 3:
      save_three_d (os, val, parametric);
      break;

    default:
      gripe_2_or_3_dim_plot ();
      break;
    }
}

static void
write_inline_data (std::ostream& os, const octave_value& val,
               int ndim = 2, bool parametric = false)
{
  write_data (os, val, ndim, parametric);
  os << "e" << std::endl;
}

static std::string
save_in_tmp_file (const octave_value& val, int ndim = 2,
              bool parametric = false)
{
  std::string name = file_ops::tempnam ("", "oct-");

  if (! name.empty ())
    {
      std::ofstream file (name.c_str ());

      if (file)
      write_data (file, val, ndim, parametric, name);
      else
      {
        error ("couldn't open temporary output file `%s'", name.c_str ());
        name.resize (0);
      }
    }

  return name;
}

#define WARN_OBSOLETE(nm) \
  do \
    { \
      static bool warned = false; \
 \
      if (! warned) \
        { \
          warning ("%s: this function is obsolete and will be removed from a future version of Octave", nm); \
 \
          warned = true; \
        } \
    } \
  while (0)

DEFUN_DLD (__gnuplot_save_data__, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} __gnuplot_save_data__ (@var{data}, @var{ndim}, @var{parametric})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  octave_value retval;

  int nargin = args.length ();

  if (nargin > 0 && nargin < 4)
    {
      WARN_OBSOLETE ("__gnuplot_save_data__");

      int ndim = 2;
      bool parametric = false;

      if (nargin > 1)
      {
        ndim = args(1).int_value ();

        if (! error_state)
          {
            if (nargin > 2)
            parametric = args(2).bool_value ();
          }
      }

      if (! error_state)
      {
        std::string file = save_in_tmp_file (args(0), ndim, parametric);

        mark_for_deletion (file);

        retval = file;
      }
    }
  else
    print_usage ();

  return retval;
}

static int
get_current_figure (void)
{
  int retval = 1;

  octave_value cf = get_global_value ("__current_figure__", true);

  if (cf.is_defined ())
    retval = cf.int_value ();
  else
    set_global_value ("__current_figure__", retval);

  return retval;
}

class
gnuplot
{
protected:

  gnuplot (void)
    : plot_line_count (0), parametric_plot (false), 
      use_title_option (Vgnuplot_use_title_option),
      gnuplot_exe (Vgnuplot_binary),
      gnuplot_terminal_type (), plot_stream () { }

public:

  ~gnuplot (void) { }

  static bool have_instance (void);

  static bool ensure_instance (void);

  static bool ensure_plot_stream (void);

  static void open (void);

  static void close (void);

  static void close_all (void);

  static bool plot_stream_event_handler (pid_t pid, int status);

  static void send (const std::string& cmd)
  {
    if (ensure_plot_stream ())
      instance->do_send (cmd);
  }

  static void send_raw (const std::string& cmd)
  {
    if (ensure_plot_stream ())
      instance->do_send_raw (cmd);
  }

  static void send_inline_data (const octave_value& val, int ndim,
                        bool parametric)
  {
    if (ensure_plot_stream ())
      instance->do_send_inline_data (val, ndim, parametric);
  }

  static void clear (void)
  {
    if (ensure_plot_stream ())
      instance->do_clear ();
  }

  static void set (const string_vector& argv)
  {
    if (ensure_plot_stream ())
      instance->do_set (argv);
  }

  static void show (const string_vector& argv)
  {
    if (ensure_plot_stream ())
      instance->do_show (argv);
  }

  static void set_gnuplot_exe (const std::string& exe)
  {
    if (ensure_instance ())
      instance->do_set_gnuplot_exe (exe);
  }

  static void set_gnuplot_use_title_option (bool opt)
  {
    if (ensure_instance ())
      instance->do_set_gnuplot_use_title_option (opt);
  }

  // FIXME -- should only remove tmp files associated with
  // gnuplot?
  static void cleanup_tmp_files (void) { ::cleanup_tmp_files (); }

  static void plot (const string_vector& argv)
  {
    if (ensure_plot_stream ())
      instance->do_plot (argv);
  }

private:

  static gnuplot *instance;

  static std::map<int, gnuplot *> instance_map;

  // The number of lines we've plotted so far.
  int plot_line_count;

  // Is this a parametric plot?  Makes a difference for 3D plotting.
  bool parametric_plot;

  // Should we append '-title "TITLE"' to the gnuplot command?
  bool use_title_option;

  // The executable program to run.
  std::string gnuplot_exe;

  // The gnuplot terminal type.
  std::string gnuplot_terminal_type;

  // Pipe to gnuplot.
  oprocstream *plot_stream;

  pid_t pid (void) const;

  static gnuplot *lookup_by_pid (pid_t pid);

  void do_open (void);

  void do_close (void);

  void delete_plot_stream (void);

  void reset_plot_stream (void);

  void do_send (const std::string& cmd);

  void do_send_raw (const std::string& cmd);

  void do_send_inline_data (const octave_value& val, int ndim,
                      bool parametric);

  void do_clear (void);

  void do_set (const string_vector& argv);

  void do_show (const string_vector& argv);

  void do_set_gnuplot_exe (const std::string& exe) { gnuplot_exe = exe; }

  void do_set_gnuplot_use_title_option (bool opt) { use_title_option = opt; }

  void do_plot (const string_vector& argv);

  std::string
  makeplot (std::string caller, std::string args) throw (gpt_parse_error);

  std::string handle_title (int& lasttok);
};

gnuplot *gnuplot::instance = 0;

std::map<int, gnuplot *> gnuplot::instance_map;

bool
gnuplot::have_instance (void)
{
  int current_figure = get_current_figure ();

  if (instance_map.find (current_figure) != instance_map.end ())
    {
      instance = instance_map[current_figure];
      return true;
    }
  else
    return false;
}

bool
gnuplot::ensure_instance (void)
{
  if (! have_instance ())
    {
      instance = new gnuplot ();

      if (! instance)
      {
        ::error ("unable to create gnuplot object!");

        return false;
      }
      else
      instance_map[get_current_figure ()] = instance;
    }

  return true;
}

bool
gnuplot::ensure_plot_stream (void)
{
  if (ensure_instance ())
    {
      instance->do_open ();

      if (error_state)
      return false;
    }

  return true;
}

void
gnuplot::close (void)
{
  if (have_instance ())
    {
      instance->do_close ();

      instance_map.erase (get_current_figure ());
    }
}

void
gnuplot::close_all (void)
{
  for (std::map<int, gnuplot *>::const_iterator p = instance_map.begin ();
       p != instance_map.end ();
       p++)
    {
      gnuplot *elt = p->second;

      elt->do_close ();
    }
}

pid_t
gnuplot::pid (void) const
{
  return plot_stream ? plot_stream->pid () : -1;
}

gnuplot *
gnuplot::lookup_by_pid (pid_t pid)
{
  gnuplot *retval = 0;

  for (std::map<int, gnuplot *>::const_iterator p = instance_map.begin ();
       p != instance_map.end ();
       p++)
    {
      gnuplot *elt = p->second;

      if (elt && elt->pid () == pid)
      {
        retval = elt;
        break;
      }
    }

  return retval;
}

void
gnuplot::do_open (void)
{
  static bool initialized = false;

  if (plot_stream && ! *plot_stream)
    do_close ();

  if (! plot_stream)
    {
      initialized = false;

      plot_line_count = 0;

      std::string cmd;

      if (gnuplot_exe.empty ())
      cmd = "gnuplot";
      else
        cmd = "\"" + gnuplot_exe + "\"";

      // FIXME -- I'm not sure this is the right thing to do,
      // but without it, C-c at the octave prompt will kill gnuplot...

#if defined (HAVE_POSIX_SIGNALS)
      sigset_t nset, oset;
      sigemptyset (&nset);
      sigaddset (&nset, SIGINT);
      sigprocmask (SIG_BLOCK, &nset, &oset);
#else
      volatile octave_interrupt_handler old_interrupt_handler
      = octave_ignore_interrupts ();
#endif

      if (use_title_option)
      {
        std::ostringstream buf;

        buf << cmd << " -title \"Figure " << get_current_figure () << "\"";

        cmd = buf.str ();
      }

      plot_stream = new oprocstream (cmd.c_str ());

      if (plot_stream && *plot_stream)
      octave_child_list::insert (plot_stream->pid (),
                           plot_stream_event_handler);
      else
      {
        delete_plot_stream ();

        error ("plot: unable to open pipe to `%s'", cmd.c_str ());
      }

#if defined (HAVE_POSIX_SIGNALS)
      sigprocmask (SIG_SETMASK, &oset, 0);
#else
      octave_set_interrupt_handler (old_interrupt_handler);
#endif
    }

  if (! error_state && plot_stream && *plot_stream && ! initialized)
    {
      initialized = true;

      do_send_raw ("set style data lines\n");

      if (! gnuplot_terminal_type.empty ())
      do_send_raw ("set term " + gnuplot_terminal_type
                 + Vgnuplot_command_end + "\n");
    }
}

void
gnuplot::delete_plot_stream (void)
{
  do_send_raw ("\nquit\n");

  delete plot_stream;
  plot_stream = 0;
}

void
gnuplot::reset_plot_stream (void)
{
  delete_plot_stream ();

  plot_line_count = 0;
  parametric_plot = false;
}

void
gnuplot::do_close (void)
{
  if (plot_stream)
    {
      octave_child_list::remove (plot_stream->pid ());

      delete_plot_stream ();
    }

  plot_line_count = 0;
}

bool
gnuplot::plot_stream_event_handler (pid_t pid, int status)
{
  bool retval = false;

  if (pid > 0)
    {
      if (WIFEXITED (status) || WIFSIGNALLED (status))
      {
        gnuplot *plotter = gnuplot::lookup_by_pid (pid);

        // We should only print a warning or request removal of the
        // process from the child list if the process died
        // unexpectedly.  If do_close is responsible for
        // gnuplot's death, then plotter will be 0 here and we don't
        // need to do anything.

        if (plotter)
          {
            plotter->reset_plot_stream ();

            warning ("connection to external plotter (pid = %d) lost --", pid);
            // Request removal of this PID from the list of child
            // processes.

            retval = true;
          }
      }
    }

  return retval;
}

void
gnuplot::do_send (const std::string& cmd)
{
  int replot_len = Vgnuplot_command_replot.length ();

  bool is_replot = (Vgnuplot_command_replot == cmd.substr (0, replot_len));

  if (! (plot_line_count == 0 && is_replot))
    do_send_raw (cmd);
}

void
gnuplot::do_send_raw (const std::string& cmd)
{
  if (plot_stream && *plot_stream)
    {
      *plot_stream << cmd;

      plot_stream->flush ();
    }
}

void
gnuplot::do_send_inline_data (const octave_value& val, int ndim,
                        bool parametric)
{
  if (plot_stream && *plot_stream)
    {
      write_inline_data (*plot_stream, val, ndim, parametric);

      plot_stream->flush ();
    }
}

void
gnuplot::do_clear (void)
{
  do_send_raw ("clear\n");

  // FIXME -- instead of just clearing these things, it would
  // be nice if we could reset things to a user-specified default
  // state.

  do_send_raw ("set title\n");
  do_send_raw ("set xlabel\n");
  do_send_raw ("set ylabel\n");
  do_send_raw ("set nogrid\n");
  do_send_raw ("set nolabel\n");

  // This makes a simple `replot' not work after a `clearplot' command
  // has been issued.

  plot_line_count = 0;
}

void
gnuplot::do_set (const string_vector& argv)
{
  int argc = argv.length ();

  std::ostringstream plot_buf;

  if (argc > 1)
    {
      if (almost_match ("parametric", argv[1], 3))
      parametric_plot = true;
      else if (almost_match ("noparametric", argv[1], 5))
      parametric_plot = false;
      else if (almost_match ("term", argv[1], 1))
      {
        gnuplot_terminal_type = "";
        std::ostringstream buf;
        int i;
        for (i = 2; i < argc-1; i++)
          buf << argv[i] << " ";
        if (i < argc)
          buf << argv[i];
        buf << Vgnuplot_command_end;
        gnuplot_terminal_type = buf.str ();
      }
    }

  int i;
  for (i = 0; i < argc-1; i++)
    plot_buf << argv[i] << " ";

  if (i < argc)
    plot_buf << argv[i];

  plot_buf << Vgnuplot_command_end;

  do_send_raw (plot_buf.str ());
}

void
gnuplot::do_show (const string_vector& argv)
{
  int argc = argv.length ();

  std::ostringstream plot_buf;

  int i;
  for (i = 0; i < argc-1; i++)
    plot_buf << argv[i] << " ";
  if (i < argc)
    plot_buf << argv[i];

  plot_buf << Vgnuplot_command_end;

  do_send (plot_buf.str ());
}

void
gnuplot::do_plot (const string_vector& argv)
{
  std::string s;

  for (int i = 1; i < argv.length (); i++)
    s += argv[i] + " ";

  try
    {
      std::string cmd = makeplot (argv[0], s);

      do_send (cmd);
    }
  catch (gpt_parse_error& e)
    {
      if (e.msg.empty ())
      error ("could not parse plot command");
      else
      error (e.msg.c_str ());
    }
}

// Parse and evaluate parameter string and pass it to gnuplot pipe.

std::string
gnuplot::makeplot (std::string caller, std::string args)
  throw (gpt_parse_error)
{
  std::string retval;

  YY_BUFFER_STATE bstate;

  bstate = gpt_scan_string (args.c_str ());
  gpt_switch_to_buffer (bstate);
  std::string outstr;
  int ndim = 2;

  if (caller == "replot")
    {
      ndim = 1;
      outstr += Vgnuplot_command_replot + " ";
    }
  else if (caller == "plot")
    {
      ndim = 2;
      plot_line_count = 0;
      outstr += Vgnuplot_command_plot + " ";
    }
  else if (caller == "splot")
    {
      ndim = 3;
      plot_line_count = 0;
      outstr += Vgnuplot_command_splot + " ";
    }
  else
    throw gpt_parse_error ("unknown plot command");

  gpt_quote_is_transpose = false;
  gpt_allow_plotkw = false;
  gpt_parens = 0;
  gpt_braces = 0;
  gpt_brackets = 0;

  int tok;
  tok = gptlex ();
  if (plottok_or_end_p (tok) && caller != "replot")
    throw gpt_parse_error ("must have something to plot");

  while (tok)
    {
      bool title_set = false;
      bool using_set = false;
      bool style_set = false;
      bool axes_set = false;

      if (tok == START_BRACKET)
      {
        if (caller == "replot")
          throw gpt_parse_error ("can't specify new plot ranges with `replot' or while hold is on");

        std::string xrange_start_str = read_until (colonp, tok);
        std::string xrange_end_str = read_until (endbracketp, tok);
        outstr += printrange (xrange_start_str, xrange_end_str) + " ";
        tok = gptlex ();
        if (tok == START_BRACKET)
          {
            std::string yrange_start_str = read_until (colonp, tok);
            std::string yrange_end_str = read_until (endbracketp, tok);
            outstr += printrange (yrange_start_str, yrange_end_str) + " ";
            tok = gptlex ();
            if (tok == START_BRACKET && caller == "splot")
            {
              std::string zrange_start_str = read_until (colonp, tok);
              std::string zrange_end_str = read_until (endbracketp, tok);
              outstr += printrange (zrange_start_str, zrange_end_str) + " ";
              tok = gptlex ();
                }
            }
        }

      if (plottok_or_end_p (tok))
      return std::string ();
      else
      {
        std::string file;
        plot_line_count++;

        std::string plot_expr_str;
        plot_expr_str += std::string (gpttext) + " ";
        plot_expr_str += read_until (plottok_or_end_p, tok);

        int status = 0;
        octave_value tmp_data = eval_string (plot_expr_str,
                                     true, status);

        if (status != 0 || ! tmp_data.is_defined ())
          throw gpt_parse_error ();

        std::ostringstream tmp_buf;
        tmp_data.print_raw (tmp_buf);

        if (tmp_data.is_string ())
          {
            file = file_ops::tilde_expand (tmp_data.string_value ());
            // FIXME -- perhaps should check if the file exists?
            outstr += file + " ";
          }
        else
          {
            switch (ndim)
            {
            case 2:
              file = save_in_tmp_file (tmp_data, ndim);
              break;

            case 3:
              file = save_in_tmp_file (tmp_data, ndim,
                                 parametric_plot);
              break;

            default:
              gripe_2_or_3_dim_plot ();
              break;
            }

            if (file.length () > 0)
            {
              mark_for_deletion (file);
              outstr += "'" + file + "' ";
            }
          }
        }

      std::string title_str;
      std::string using_str;
      std::string style_str;
      std::string axes_str;

      bool out = false;
      while (tok && ! out)
      {
        switch (tok)
          {
          case COMMA:
            out = true;
            break;

          case TITLE:
            if (! title_set)
            title_str += handle_title (tok) + " ";
            else
            throw gpt_parse_error ("only one title option may be specified");
            title_set = true;
            break;

          case USING:
            if (! using_set)
            using_str += handle_using (tok) + " ";
            else
            throw gpt_parse_error ("only one using option may be specified");
            using_set = true;
            break;

          case WITH:
            if (! style_set)
            style_str += handle_style (tok) + " ";
            else
            throw gpt_parse_error ("only one style option may be specified");
            style_set = true;
            break;

          case AXES:
            if (! axes_set)
            axes_str += handle_axes (tok) + " ";
            else
            throw gpt_parse_error ("only one axes option may be specified");
            axes_set = true;
            break;

          default:
            tok = 0;
            break;
            }
        }

        if (! title_set)
        {
            std::ostringstream tmp_buf;
            tmp_buf << Vgnuplot_command_title << " \"line "
                    << plot_line_count << "\" ";
            title_str = tmp_buf.str ();
          title_set = true;
        }

      // Plot parameters have to be output in this order.
      if (using_set)
        outstr += using_str;

      if (axes_set)
        outstr += axes_str;

      if (title_set)
        outstr += title_str;

      if (style_set)
        outstr += style_str;

      if (out)
        {
          // Saw comma on while loop.
            outstr += ", ";
            gpt_quote_is_transpose = false;
            gpt_allow_plotkw = false;
            gpt_parens = 0;
            gpt_braces = 0;
            gpt_brackets = 0;
            tok = gptlex ();
        }
    }

  outstr += Vgnuplot_command_end;

  return outstr;
}

// Title has one string expression which is evaluated and printed to the
// gnuplot command string.

std::string
gnuplot::handle_title (int& lasttok)
{
  int tok;
  std::string retstr = Vgnuplot_command_title + " ";
  std::string title_expr_str;

  title_expr_str += read_until (plottok_or_end_p, tok);

  int status;
  octave_value tmp_data = eval_string (title_expr_str, true, status);

  if (status != 0 || ! tmp_data.is_defined ())
    throw gpt_parse_error ();

  std::ostringstream tmp_buf;
  if (tmp_data.is_string ())
    {
      tmp_buf << '"';
      tmp_data.print_raw (tmp_buf);
      tmp_buf << '"';
    }
  else
    {
      warning ("line title must be a string");
      tmp_buf << '"' << "line " << plot_line_count << '"';
    }

  retstr += tmp_buf.str ();

  lasttok = tok;

  return retstr;
}

// The static instance of this class is here so that
// gnuplot::close_all will be called when the .oct file is unloaded.

class
gnuplot_X
{
public:
  gnuplot_X (void) { }
  ~gnuplot_X (void) { gnuplot::close_all (); }
};

static gnuplot_X X;

// -----------------------
// User-callable functions
// -----------------------

DEFUN_DLD (gnuplot_binary, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_binary ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_binary (@var{new_val})\n\
Query or set the name of the program invoked by the plot command.\n\
The default value @code{\"gnuplot\"}.  @xref{Installation}.\n\
@end deftypefn")
{
  octave_value retval = SET_INTERNAL_VARIABLE (gnuplot_binary);

  if (! error_state && args.length () == 1)
    gnuplot::set_gnuplot_exe (Vgnuplot_binary);

  return retval;
}

DEFUN_DLD (gnuplot_command_plot, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} = } gnuplot_command_plot ()\n\
@deftypefnx {Loadable Function} {@var{old_val} = } gnuplot_command_plot (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_plot");

  return SET_INTERNAL_VARIABLE (gnuplot_command_plot);
}

DEFUN_DLD (gnuplot_command_replot, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_replot ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_replot (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_replot");

  return SET_INTERNAL_VARIABLE (gnuplot_command_replot);
}

DEFUN_DLD (gnuplot_command_splot, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_splot ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_splot (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_splot");

  return SET_INTERNAL_VARIABLE (gnuplot_command_splot);
}

DEFUN_DLD (gnuplot_command_using, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_using ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_using (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_using");

  return SET_INTERNAL_VARIABLE (gnuplot_command_using);
}

DEFUN_DLD (gnuplot_command_with, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_with ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_with (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_with");

  return SET_INTERNAL_VARIABLE (gnuplot_command_with);
}

DEFUN_DLD (gnuplot_command_axes, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_axes ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_axes (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_axes");

  return SET_INTERNAL_VARIABLE (gnuplot_command_axes);
}

DEFUN_DLD (gnuplot_command_title, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_title ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_title (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_title");

  return SET_INTERNAL_VARIABLE (gnuplot_command_title);
}

DEFUN_DLD (gnuplot_command_end, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_command_end ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_command_end (@var{new_val})\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_end");

  return SET_INTERNAL_VARIABLE (gnuplot_command_end);
}

DEFUN_DLD (gnuplot_use_title_option, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{val} =} gnuplot_use_title_option ()\n\
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_use_title_option (@var{new_val})\n\
If enabled, append @samp{-title \"Figure NN\"} to the gnuplot command.\n\
By default, this feature is enabled if the @code{DISPLAY} environment\n\
variable is set when Octave starts.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("gnuplot_command_use_title_option");

  return SET_INTERNAL_VARIABLE (gnuplot_use_title_option);
}

DEFUN_DLD (__clear_plot_window__, , ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} clearplot\n\
@deftypefnx {Loadable Function} {} clg\n\
Clear the plot window and any titles or axis labels.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("__clear_plot_window__");

  gnuplot::clear ();

  return octave_value_list ();
}

DEFUN_DLD (closeplot, , ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} closeplot\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
\n\
Close stream to the @code{gnuplot} subprocess.  If you are using X11,\n\
this will close the plot window.\n\
@seealso{close}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("closeplot");

  gnuplot::close ();

  return octave_value_list ();
}

DEFUN_DLD (purge_tmp_files, , ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} purge_tmp_files\n\
Delete the temporary files created by the plotting commands.\n\
\n\
Octave creates temporary data files for @code{gnuplot} and then sends\n\
commands to @code{gnuplot} through a pipe.  Octave will delete the\n\
temporary files on exit, but if you are doing a lot of plotting you may\n\
want to clean up in the middle of a session.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  WARN_OBSOLETE ("purge_tmp_files");

  gnuplot::cleanup_tmp_files ();

  return octave_value_list ();
}
 
DEFUN_DLD (__gnuplot_raw__, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} __gnuplot_raw__ (@var{string})\n\
Send @var{string} directly to gnuplot subprocess.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  if (args.length () == 1 && args(0).is_string ())
    {
      WARN_OBSOLETE ("__gnuplot_raw__");

      std::string cmd = args(0).string_value ();

      gnuplot::send_raw (cmd);
    }
  else
    print_usage ();

  return octave_value_list ();
}

DEFUN_DLD (__gnuplot_send_inline_data__, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Loadable Function} {} __gnuplot_send_inline_data__ (@var{data}, @var{ndim}, @var{parametric})\n\
Send @var{val} to gnuplot subprocess as inline data.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deftypefn")
{
  octave_value retval;

  int nargin = args.length ();

  if (nargin > 0 && nargin < 4)
    {
      WARN_OBSOLETE ("__gnuplot_send_inline_data__");

      int ndim = 2;
      bool parametric = false;

      if (nargin > 1)
      {
        ndim = args(1).int_value ();

        if (! error_state)
          {
            if (nargin > 2)
            parametric = args(2).bool_value ();
          }
      }

      if (! error_state)
      gnuplot::send_inline_data (args(0), ndim, parametric);
    }
  else
    print_usage ();

  return retval;
}

DEFUN_DLD (__gnuplot_set__, args, ,
  "-*- texinfo -*-\n\
@deffn {Loadable Function} __gnuplot_set__ options\n\
Set plotting options for gnuplot\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deffn")
{
  WARN_OBSOLETE ("__gnuplot_set__");

  string_vector argv = args.make_argv ("set");

  if (! error_state)
    gnuplot::set (argv);

  return octave_value_list ();
}

DEFUN_DLD (__gnuplot_show__, args, ,
  "-*- texinfo -*-\n\
@deffn {Loadable Function} __gnuplot_show__ options\n\
Show plotting options.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}\n\
@end deffn")
{
  WARN_OBSOLETE ("__gnuplot_show__");

  string_vector argv = args.make_argv ("show");

  if (! error_state)
    gnuplot::show (argv);

  return octave_value_list ();
}

DEFUN_DLD (__gnuplot_plot__, args, ,
  "-*- texinfo -*-\n\
Plot with gnuplot.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}")
{
  WARN_OBSOLETE ("__gnuplot_plot__");

  string_vector argv = args.make_argv ("plot");

  if (! error_state)
    gnuplot::plot (argv);

  return octave_value_list ();
}

DEFUN_DLD (__gnuplot_splot__, args, ,
  "-*- texinfo -*-\n\
Plot with gnuplot.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}")
{
  WARN_OBSOLETE ("__gnuplot_splot__");

  string_vector argv = args.make_argv ("splot");

  if (! error_state)
    gnuplot::plot (argv);

  return octave_value_list ();
}

DEFUN_DLD (__gnuplot_replot__, args, ,
  "-*- texinfo -*-\n\
Plot with gnuplot.\n\
\n\
@strong{This function is obsolete and will be removed from a future version\n\
of Octave.}")
{
  WARN_OBSOLETE ("__gnuplot_replot__");

  string_vector argv = args.make_argv ("replot");

  if (! error_state)
    gnuplot::plot (argv);

  return octave_value_list ();
}

/*
;;; Local Variables: ***
;;; mode: C++ ***
;;; End: ***
*/


Generated by  Doxygen 1.6.0   Back to index