~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1020
1020
static void window_resize(int sig);
1021
1021
#endif
1022
1022
 
 
1023
static inline int is_prefix(const char *s, const char *t)
 
1024
{
 
1025
  while (*t)
 
1026
    if (*s++ != *t++) return 0;
 
1027
  return 1;                                     /* WRONG */
 
1028
}
 
1029
 
1023
1030
/**
1024
1031
  Shutdown the server that we are currently connected to.
1025
1032
 
2062
2069
          {
2063
2070
            for (pos++ ;
2064
2071
                 *pos && (*pos != *delimiter ||
2065
 
                          !is_prefix(pos + 1, delimiter + 1)) ; pos++)
 
2072
                          strncmp(pos + 1, delimiter + 1,
 
2073
                                  strlen(delimiter + 1))) ; pos++)
2066
2074
              ;  // Remove parameters
2067
2075
            if (!*pos)
2068
2076
              pos--;
2113
2121
      buffer->clear();
2114
2122
      break;
2115
2123
    }
2116
 
    else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter))
 
2124
    else if (!*ml_comment && !*in_string && !strncmp(pos, delimiter,
 
2125
                                                     strlen(delimiter)))
2117
2126
    {
2118
2127
      // Found a statement. Continue parsing after the delimiter
2119
2128
      pos+= delimiter_length;
2813
2822
    {
2814
2823
      *pos++= ',';
2815
2824
      *pos++= ' ';
2816
 
      pos= int10_to_str(warnings, pos, 10);
 
2825
      char warnings_buff[20];
 
2826
      memset(warnings_buff,0,20);
 
2827
      sprintf(warnings_buff, "%d", warnings);
 
2828
      strcpy(pos, warnings_buff);
 
2829
      pos+= strlen(warnings_buff);
2817
2830
      pos= strcpy(pos, " warning")+8;
2818
2831
      if (warnings != 1)
2819
2832
        *pos++= 's';
4245
4258
static void nice_time(double sec,char *buff,bool part_second)
4246
4259
{
4247
4260
  uint32_t tmp;
 
4261
  ostringstream tmp_buff_str;
 
4262
 
4248
4263
  if (sec >= 3600.0*24)
4249
4264
  {
4250
4265
    tmp=(uint32_t) floor(sec/(3600.0*24));
4251
4266
    sec-= 3600.0*24*tmp;
4252
 
    buff= int10_to_str((long) tmp, buff, 10);
 
4267
    tmp_buff_str << tmp;
4253
4268
 
4254
4269
    if (tmp > 1)
4255
 
      buff= strcpy(buff," days ")+6;
 
4270
      tmp_buff_str << " days ";
4256
4271
    else
4257
 
      buff= strcpy(buff," day ")+5;
 
4272
      tmp_buff_str << " day ";
4258
4273
 
4259
4274
  }
4260
4275
  if (sec >= 3600.0)
4261
4276
  {
4262
4277
    tmp=(uint32_t) floor(sec/3600.0);
4263
4278
    sec-=3600.0*tmp;
4264
 
    buff=int10_to_str((long) tmp, buff, 10);
 
4279
    tmp_buff_str << tmp;
4265
4280
 
4266
4281
    if (tmp > 1)
4267
 
      buff= strcpy(buff, " hours ")+7;
 
4282
      tmp_buff_str << " hours ";
4268
4283
    else
4269
 
      buff= strcpy(buff, " hour ")+6;
 
4284
      tmp_buff_str << " hour ";
4270
4285
  }
4271
4286
  if (sec >= 60.0)
4272
4287
  {
4273
4288
    tmp=(uint32_t) floor(sec/60.0);
4274
4289
    sec-=60.0*tmp;
4275
 
    buff=int10_to_str((long) tmp, buff, 10);
4276
 
    buff= strcpy(buff," min ")+5;
 
4290
    tmp_buff_str << tmp << " min ";
4277
4291
  }
4278
4292
  if (part_second)
4279
 
    sprintf(buff,"%.2f sec",sec);
 
4293
    tmp_buff_str.precision(2);
4280
4294
  else
4281
 
    sprintf(buff,"%d sec",(int) sec);
 
4295
    tmp_buff_str.precision(0);
 
4296
  tmp_buff_str << sec << " sec";
 
4297
  strcpy(buff, tmp_buff_str.str().c_str());
4282
4298
}
4283
4299
 
4284
4300
 
4469
4485
 
4470
4486
static void add_int_to_prompt(int toadd)
4471
4487
{
4472
 
  char buffer[16];
4473
 
  int10_to_str(toadd, buffer, 10);
4474
 
  processed_prompt->append(buffer);
 
4488
  ostringstream buffer;
 
4489
  buffer << toadd;
 
4490
  processed_prompt->append(buffer.str().c_str());
4475
4491
}
4476
4492
 
4477
4493
static void init_username()