~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Date: 2010-06-03 18:36:21 UTC
  • mto: (1596.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1597.
  • Revision ID: mordred@inaugust.com-20100603183621-5oynj605rotubigg
Fixed utf-8 space handling in client output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2184
2184
    if (not U8_IS_SINGLE(*pos))
2185
2185
    {
2186
2186
      int length;
2187
 
      if ((length= U8_LENGTH(*pos)))
 
2187
      if ((length= U8_SEQUENCE_LENGTH(*pos)))
2188
2188
      {
2189
2189
        if (!*ml_comment || preserve_comments)
2190
2190
        {
3166
3166
  tee_puts("", PAGER);
3167
3167
}
3168
3168
 
 
3169
static uint32_t num_cells(const char *in_string, const char *end_string)
 
3170
{
 
3171
  uint32_t length= 0;
 
3172
  while (in_string < end_string)
 
3173
  {
 
3174
    length++;
 
3175
    in_string += U8_SEQUENCE_LENGTH(*in_string);
 
3176
  }
 
3177
  return length;
 
3178
}
3169
3179
 
3170
3180
static void
3171
3181
print_table_data(drizzle_result_st *result)
3198
3208
      /* Check if the max_byte value is really the maximum in terms
3199
3209
         of visual length since multibyte characters can affect the
3200
3210
         length of the separator. */
3201
 
      length= U8_LENGTH(*(drizzle_column_name(field)));
 
3211
      length= num_cells(drizzle_column_name(field),
 
3212
                        drizzle_column_name(field) + name_length);
3202
3213
 
3203
3214
      if (name_length == drizzle_column_max_size(field))
3204
3215
      {
3236
3247
    for (uint32_t off=0; (field = drizzle_column_next(result)) ; off++)
3237
3248
    {
3238
3249
      uint32_t name_length= (uint32_t) strlen(drizzle_column_name(field));
3239
 
      uint32_t numcells= U8_LENGTH(*drizzle_column_name(field));
 
3250
      uint32_t numcells= num_cells(drizzle_column_name(field),
 
3251
                                   drizzle_column_name(field) + name_length);
3240
3252
      uint32_t display_length= drizzle_column_max_size(field) + name_length -
3241
3253
                               numcells;
3242
3254
      tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
3299
3311
        We need to find how much screen real-estate we will occupy to know how
3300
3312
        many extra padding-characters we should send with the printing function.
3301
3313
      */
3302
 
      visible_length= U8_LENGTH(*buffer);
 
3314
      visible_length= num_cells(buffer, buffer + data_length);
3303
3315
      extra_padding= data_length - visible_length;
3304
3316
 
3305
3317
      if (field_max_length > MAX_COLUMN_LENGTH)
3527
3539
    else for (const char *end=pos+length ; pos != end ; pos++)
3528
3540
    {
3529
3541
      int l;
3530
 
      if ((l = U8_LENGTH(*pos)))
 
3542
      if ((l = U8_SEQUENCE_LENGTH(*pos)))
3531
3543
      {
3532
3544
        while (l--)
3533
3545
          tee_putc(*pos++, PAGER);