Re: The dbase conrtib doesn't compile

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: The dbase conrtib doesn't compile
Дата
Msg-id 200112210428.fBL4SeE26781@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: The dbase conrtib doesn't compile  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > In HEAD contrib/dbase:
> > gcc -pipe -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I../../src/
> > interf
> > aces/libpq -I. -I../../src/include   -c -o dbf2pg.o dbf2pg.c
> > dbf2pg.c:19: iconv.h: No such file or directory
> 
> Looks like someone took a shortcut in dealing with <iconv.h>.
> What the heck is that, anyway, and do we need the ifdef'd code at all?
> 
> (FWIW, the code compiles fine if you do have <iconv.h>)

I see that now too.  Seems we need to test for libiconv and set
HAVE_ICONV_H accordingly, and the link line too.  If I comment out the
define, it does not compile so the conditionals in the code are not
correct anyway.

The following patch does allow it to compile with HAVE_ICONV_H not
defined;  clearly a step in the right direction.  Of course, you will
still need to remove the -liconv from the link line.

I wonder if the best solution is to not assume libiconv exists.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026 
Index: contrib/dbase/dbf2pg.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/dbase/dbf2pg.c,v
retrieving revision 1.4
diff -c -r1.4 dbf2pg.c
*** contrib/dbase/dbf2pg.c    2001/10/25 05:49:19    1.4
--- contrib/dbase/dbf2pg.c    2001/12/21 04:27:48
***************
*** 742,753 ****
--- 742,755 ----             case 'U':                 username = (char *) strdup(optarg);                 break;
+ #ifdef HAVE_ICONV_H             case 'F':                 charset_from = (char *) strdup(optarg);
break;            case 'T':                 charset_to = (char *) strdup(optarg);                 break;
 
+ #endif             case ':':                 usage();                 printf("missing argument!\n");
***************
*** 806,813 ****
--- 808,817 ----             free(username);         if (password)             free(password);
+ #ifdef HAVE_ICONV_H         if (charset_from)             iconv_close(iconv_d);
+ #endif         exit(1);     } 
***************
*** 846,853 ****
--- 850,859 ----             free(username);         if (password)             free(password);
+ #ifdef HAVE_ICONV_H         if (charset_from)             iconv_close(iconv_d);
+ #endif         exit(1);     } 
***************
*** 864,871 ****
--- 870,879 ----                 free(username);             if (password)                 free(password);
+ #ifdef HAVE_ICONV_H             if (charset_from)                 iconv_close(iconv_d);
+ #endif             exit(1);         }         if (del)
***************
*** 880,887 ****
--- 888,897 ----                     free(username);                 if (password)                     free(password);
+ #ifdef HAVE_ICONV_H                 if (charset_from)                     iconv_close(iconv_d);
+ #endif                 exit(1);             }             if (verbose > 1)
***************
*** 903,910 ****
--- 913,922 ----                 free(username);             if (password)                 free(password);
+ #ifdef HAVE_ICONV_H             if (charset_from)                 iconv_close(iconv_d);
+ #endif             exit(1);         }         if (verbose > 1)
***************
*** 933,939 ****
--- 945,953 ----         free(username);     if (password)         free(password);
+ #ifdef HAVE_ICONV_H     if (charset_from)         iconv_close(iconv_d);
+ #endif     exit(0); }

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Christopher Kings-Lynne"
Дата:
Сообщение: Re: contrib idea
Следующее
От: Tom Lane
Дата:
Сообщение: Re: The dbase conrtib doesn't compile