~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Robert Klahn
  • Date: 2009-07-17 03:11:10 UTC
  • mto: (1093.1.23 captain)
  • mto: This revision was merged to the branch mainline in revision 1099.
  • Revision ID: rklahn@quad-20090717031110-0sn0vgfk1dzdbwg1
Replace typedef struct LINE_BUFFER with class LineBuffer, encapsulating current logic

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <algorithm>
39
39
#include <mystrings/m_ctype.h>
40
40
#include <stdarg.h>
41
 
#include "client/my_readline.h"
 
41
#include "client/linebuffer.h"
42
42
#include <signal.h>
43
43
#include <sys/ioctl.h>
44
44
#include <drizzled/configmake.h>
147
147
  int exit_status;
148
148
  uint32_t query_start_line;
149
149
  char *file_name;
150
 
  LINE_BUFFER *line_buff;
 
150
  LineBuffer *line_buff;
151
151
  bool batch,add_to_history;
152
152
} STATUS;
153
153
 
1240
1240
 
1241
1241
  if (status.batch && !status.line_buff)
1242
1242
  {
1243
 
    status.line_buff =batch_readline_init(opt_max_input_line+512, stdin);
1244
 
    if (status.line_buff == NULL)
 
1243
    try
 
1244
    {
 
1245
      status.line_buff= new LineBuffer(opt_max_input_line+512, stdin);
 
1246
    } 
 
1247
    catch (...)
1245
1248
    {
1246
1249
      free_defaults(defaults_argv);
1247
1250
      my_end(0);
1341
1344
    if (!write_history(histfile_tmp))
1342
1345
      my_rename(histfile_tmp, histfile, MYF(MY_WME));
1343
1346
  }
1344
 
  batch_readline_end(status.line_buff);
 
1347
  delete status.line_buff;
 
1348
  status.line_buff= 0;
1345
1349
 
1346
1350
  if (sig >= 0)
1347
1351
    put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0);
1693
1697
  case 'e':
1694
1698
    status.batch= 1;
1695
1699
    status.add_to_history= 0;
1696
 
    if (!status.line_buff)
1697
 
      ignore_errors= 0;                         // do it for the first -e only
1698
 
    if (!(status.line_buff= batch_readline_command(status.line_buff, argument)))
1699
 
      return 1;
 
1700
    try
 
1701
    {
 
1702
      if (!status.line_buff)
 
1703
        status.line_buff= new LineBuffer(opt_max_input_line+512,NULL);
 
1704
      status.line_buff->add_string(argument);
 
1705
    } 
 
1706
    catch (...)
 
1707
    {
 
1708
      my_end(0);
 
1709
      exit(1);
 
1710
    }
1700
1711
    break;
1701
1712
  case 'o':
1702
1713
    if (argument == disabled_my_option)
1847
1858
  {
1848
1859
    if (!interactive)
1849
1860
    {
1850
 
      line=batch_readline(status.line_buff);
 
1861
      if (status.line_buff)
 
1862
        line= status.line_buff->readline();
 
1863
      else
 
1864
        line= 0;
1851
1865
      /*
1852
1866
        Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
1853
1867
        Editors like "notepad" put this marker in
3657
3671
{
3658
3672
  char source_name[FN_REFLEN], *end;
3659
3673
  const char *param;
3660
 
  LINE_BUFFER *line_buff;
 
3674
  LineBuffer *line_buff;
3661
3675
  int error;
3662
3676
  STATUS old_status;
3663
3677
  FILE *sql_file;
3685
3699
    return put_info(buff, INFO_ERROR, 0 ,0);
3686
3700
  }
3687
3701
 
3688
 
  if (!(line_buff=batch_readline_init(opt_max_input_line+512,sql_file)))
 
3702
  try
 
3703
  {
 
3704
    line_buff= new LineBuffer(opt_max_input_line+512,sql_file);
 
3705
  }
 
3706
  catch (...)
3689
3707
  {
3690
3708
    fclose(sql_file);
3691
 
    return put_info("Can't initialize batch_readline", INFO_ERROR, 0 ,0);
 
3709
    return put_info("Can't initialize LineBuffer", INFO_ERROR, 0, 0);
3692
3710
  }
3693
3711
 
3694
3712
  /* Save old status */
3706
3724
  // Continue as before
3707
3725
  status=old_status;
3708
3726
  fclose(sql_file);
3709
 
  batch_readline_end(line_buff);
 
3727
  delete status.line_buff;
 
3728
  line_buff= status.line_buff= 0;
3710
3729
  return error;
3711
3730
}
3712
3731