Обсуждение: Access to localized_str_tolower()

Поиск
Список
Период
Сортировка

Access to localized_str_tolower()

От
"David E. Wheeler"
Дата:
Howdy,

In my original implementation of citext, which I'm going to start  
using for an app I'm developing, I pull in the wstring_lower function  
from oracle_compat.c by simply declaring it at the top of citext.c,  
just as if it were in an include file:
  extern char * wstring_lower  (char *str);

After I ported it to CVS HEAD, however, and discovered the  
str_tolower() function in formatting.c, I wanted to try to make use of  
it in 8.3, as well. But when I tried to include it in citext.c, it  
simply didn't work. I put this at the top of citext.c:
  extern char * localized_str_tolower(char *buff);

But when I try to use it, like so:
    lcstr = localized_str_tolower(VARDATA_ANY(left));    rcstr = localized_str_tolower(VARDATA_ANY(right));

I get a compile-time error:

Undefined symbols:  "_localized_str_tolower", referenced from:      _citextcmp in citext.o      _citextcmp in citext.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [citext.so] Error 1

So, stupid C question, I'm sure: How can I use this function from my  
module?

Oh, and on a side note, should I localized_str_tolower() or just  
str_tolower()?

Thanks,

David


Re: Access to localized_str_tolower()

От
Bruce Momjian
Дата:
David E. Wheeler wrote:
> Howdy,
> 
> In my original implementation of citext, which I'm going to start  
> using for an app I'm developing, I pull in the wstring_lower function  
> from oracle_compat.c by simply declaring it at the top of citext.c,  
> just as if it were in an include file:
> 
>    extern char * wstring_lower  (char *str);
> 
> After I ported it to CVS HEAD, however, and discovered the  
> str_tolower() function in formatting.c, I wanted to try to make use of  
> it in 8.3, as well. But when I tried to include it in citext.c, it  
> simply didn't work. I put this at the top of citext.c:
> 
>    extern char * localized_str_tolower(char *buff);
> 
> But when I try to use it, like so:
> 
>      lcstr = localized_str_tolower(VARDATA_ANY(left));
>      rcstr = localized_str_tolower(VARDATA_ANY(right));
> 
> I get a compile-time error:
> 
> Undefined symbols:
>    "_localized_str_tolower", referenced from:
>        _citextcmp in citext.o
>        _citextcmp in citext.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make: *** [citext.so] Error 1
> 
> So, stupid C question, I'm sure: How can I use this function from my  
> module?
> 
> Oh, and on a side note, should I localized_str_tolower() or just  
> str_tolower()?

I am not sure what localized_str_tolower() is but I think you should
call  str_tolower directly if you want to pass char*, and lower() if you
want to pass 'text'.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Access to localized_str_tolower()

От
"David E. Wheeler"
Дата:
On Jul 1, 2008, at 10:38, Bruce Momjian wrote:

>> Oh, and on a side note, should I localized_str_tolower() or just
>> str_tolower()?
>
> I am not sure what localized_str_tolower() is but I think you should
> call  str_tolower directly if you want to pass char*, and lower() if  
> you
> want to pass 'text'.
From formatting.c in 8.3.1:

#if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
#define USE_WIDE_UPPER_LOWER
/* externs are in oracle_compat.c */
extern char *wstring_upper(char *str);
extern char *wstring_lower(char *str);

static char *localized_str_toupper(char *buff);
static char *localized_str_tolower(char *buff);
#else
#define localized_str_toupper str_toupper
#define localized_str_tolower str_tolower
#endif

So I assumed it was preferred. FWIW, str_tolower() doesn't work in  
8.3, either (note that it is not declared in formatting.h the way it  
is in CVS HEAD).

Best,




Re: Access to localized_str_tolower()

От
Bruce Momjian
Дата:
David E. Wheeler wrote:
> On Jul 1, 2008, at 10:38, Bruce Momjian wrote:
> 
> >> Oh, and on a side note, should I localized_str_tolower() or just
> >> str_tolower()?
> >
> > I am not sure what localized_str_tolower() is but I think you should
> > call  str_tolower directly if you want to pass char*, and lower() if  
> > you
> > want to pass 'text'.
> 
>  From formatting.c in 8.3.1:
> 
> #if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
> #define USE_WIDE_UPPER_LOWER
> /* externs are in oracle_compat.c */
> extern char *wstring_upper(char *str);
> extern char *wstring_lower(char *str);
> 
> static char *localized_str_toupper(char *buff);
> static char *localized_str_tolower(char *buff);
> #else
> #define localized_str_toupper str_toupper
> #define localized_str_tolower str_tolower
> #endif
> 
> So I assumed it was preferred. FWIW, str_tolower() doesn't work in  
> 8.3, either (note that it is not declared in formatting.h the way it  
> is in CVS HEAD).

That whole use of localized_* is gone in CVS HEAD --- we now have a
cleaner API.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Access to localized_str_tolower()

От
"David E. Wheeler"
Дата:
On Jul 1, 2008, at 11:11, Bruce Momjian wrote:

> That whole use of localized_* is gone in CVS HEAD --- we now have a
> cleaner API.

I know. The patch I sent in uses it. However, I still have a version I  
want to use on 8.3. So what would be the proper function to use in  
8.3.x and how can I get at it?

Thanks,

David


Re: Access to localized_str_tolower()

От
Bruce Momjian
Дата:
David E. Wheeler wrote:
> On Jul 1, 2008, at 11:11, Bruce Momjian wrote:
> 
> > That whole use of localized_* is gone in CVS HEAD --- we now have a
> > cleaner API.
> 
> I know. The patch I sent in uses it. However, I still have a version I  
> want to use on 8.3. So what would be the proper function to use in  
> 8.3.x and how can I get at it?

Uh, good question.  I found the upper/lower handling in 8.3 to be pretty
convoluted.  The big problem is that the macros are used in formatting.c
to call the proper functions, and you can't easily reproduce that
without copying the macros, which is what you have to do because
localized* is not compiled on all platforms.   

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Access to localized_str_tolower()

От
Tom Lane
Дата:
"David E. Wheeler" <david@kineticode.com> writes:
>  From formatting.c in 8.3.1:
> static char *localized_str_toupper(char *buff);
> static char *localized_str_tolower(char *buff);

These are static --- that's why you can't get at them from outside
the module.

I think your best bet for an 8.3 version of citext is just to
copy-and-paste a lot of code from HEAD.
        regards, tom lane


Re: Access to localized_str_tolower()

От
"David E. Wheeler"
Дата:
On Jul 1, 2008, at 11:59, Tom Lane wrote:

> These are static --- that's why you can't get at them from outside
> the module.
>
> I think your best bet for an 8.3 version of citext is just to
> copy-and-paste a lot of code from HEAD.

Well, that's what I'd done already; I was just trying to make it  
simpler. So, well, now I don't have to do anything. :-)

Thanks,

David