~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/substr_functions/substr_functions.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *  Copyright (C) 2010 Stewart Smith
6
6
 *
7
7
 *  This program is free software; you can redistribute it and/or modify
20
20
 
21
21
#include "config.h"
22
22
 
 
23
#include <algorithm>
 
24
 
 
25
#include <drizzled/charset_info.h>
 
26
#include <drizzled/function/str/strfunc.h>
23
27
#include <drizzled/plugin/function.h>
24
 
#include <algorithm>
25
28
 
26
29
using namespace std;
27
30
using namespace drizzled;
28
31
 
29
 
#include <drizzled/function/str/strfunc.h>
30
 
 
31
32
class SubstrFunction :public Item_str_func
32
33
{
33
34
  String tmp_value;
86
87
      (args[1]->unsigned_flag && ((uint64_t) start > INT32_MAX)))
87
88
    return &my_empty_string;
88
89
 
89
 
  start= ((start < 0) ? res->numchars() + start : start - 1);
 
90
  start= ((start < 0) ?
 
91
          static_cast<int64_t>(res->numchars() + start)
 
92
          : start - 1);
90
93
  start= res->charpos((int) start);
91
94
  if ((start < 0) || ((uint) start + 1 > res->length()))
92
95
    return &my_empty_string;
276
279
  "SUBSTR and SUBSTR",
277
280
  PLUGIN_LICENSE_GPL,
278
281
  initialize, /* Plugin Init */
279
 
  NULL,   /* system variables */
 
282
  NULL,   /* depends */
280
283
  NULL    /* config options */
281
284
}
282
285
DRIZZLE_DECLARE_PLUGIN_END;