Re: about contrib/dbase/dbf.c (fwd): conversion of non-ascii - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: about contrib/dbase/dbf.c (fwd): conversion of non-ascii
Date
Msg-id 200309100033.h8A0XBo17455@candle.pha.pa.us
Whole thread Raw
In response to Re: about contrib/dbase/dbf.c (fwd): conversion of non-ascii dbf  (Andriy Tkachuk <ant@imt.com.ua>)
List pgsql-patches
I already applied your DBF patch, but I just found a cleaner way ---
patch attached and applied.

---------------------------------------------------------------------------

Andriy Tkachuk wrote:
> Hi folks.
>
> I suppose, that Bruse was busy to answer on my last mail on this topic.
> But I love, when something work rather then it do not :)
>
> What do you think about this little patch?
>
> Sorry if i put this msg into wrong list, but i didn't find
> more appropriate for this contrib. I will be appreciate if
> you put me into right one.
>
> Thanks,
>  Andriy.
>
> http://www.imt.com.ua
>
> ---------- Forwarded message ----------
>
> The code above skips anything but chars between 0x21 and 0x7E.
> My dbf have cyrillic charset, so any filds, that doesn't end on "." (dot)
> are truncated. Moreover "chars between 0x21 and 0x7E" means, that
> dbf2pg is not working for not ascii charset unless string ends on
> some ascii symbol, usually punctuation.
>
> What else than isspace one must skip (trim) in 'C' (char) field in dbf?
>
> On Thu, 24 Jul 2003, Bruce Momjian wrote:
>
> >
> > Can we assume anything in that range is a space?  There must be a better
> > way.
> >
> >
> > ---------------------------------------------------------------------------
> >
> > Andriy Tkachuk wrote:
> > > Bruse, what about this:
> > >
> > > Index: contrib/dbase/dbf.c
> > > ===================================================================
> > > RCS file: /projects/cvsroot/pgsql-server/contrib/dbase/dbf.c,v
> > > retrieving revision 1.5
> > > diff -r1.5 dbf.c
> > > 337c337
> > > <                       while ((i > 0) && ((*end < 0x21) || (*end > 0x7E)))
> > > ---
> > > >                       while ((i > 0) && isspace(*end))
> > >
> > > it fixes an bug for me with cyrillic conversion.
> > >
> > > Thanks,
> > >     Andriy.
> > >
> > >
> >
> > --
> >   Bruce Momjian                        |  http://candle.pha.pa.us
> >   pgman@candle.pha.pa.us               |  (610) 359-1001
> >   +  If your life is a hard drive,     |  13 Roberts Road
> >   +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
> >
>
> --
>   Because strait is the gate, and narrow is the way, which leadeth unto
>    life, and few there be that find it. (MAT 7:14)
>   Ask, and it shall be given you; seek, and ye shall find;
>    knock, and it shall be opened unto you... (MAT 7:7)
>
> ANT17-RIPE
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: contrib/dbase/dbf.c
===================================================================
RCS file: /cvsroot/pgsql-server/contrib/dbase/dbf.c,v
retrieving revision 1.5
diff -c -c -r1.5 dbf.c
*** contrib/dbase/dbf.c    5 Sep 2002 20:57:00 -0000    1.5
--- contrib/dbase/dbf.c    10 Sep 2003 00:31:41 -0000
***************
*** 334,340 ****
          {
              end = &dbffield[fields[t].db_flen - 1];
              i = fields[t].db_flen;
!             while ((i > 0) && ((*end < 0x21) || (*end > 0x7E)))
              {
                  end--;
                  i--;
--- 334,340 ----
          {
              end = &dbffield[fields[t].db_flen - 1];
              i = fields[t].db_flen;
!             while (i > 0 && !isprint(*end))
              {
                  end--;
                  i--;
***************
*** 346,352 ****
          {
              end = dbffield;
              i = fields[t].db_flen;
!             while ((i > 0) && ((*end < 0x21) || (*end > 0x7E)))
              {
                  end++;
                  i--;
--- 346,352 ----
          {
              end = dbffield;
              i = fields[t].db_flen;
!             while (i > 0 && !isprint(*end))
              {
                  end++;
                  i--;

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Minor lmgr code cleanup
Next
From: Christoph Dalitz
Date:
Subject: Re: WIN32_CONSOLE usage