Re: [HACKERS] Did the inet type get backed out?

Поиск
Список
Период
Сортировка
От Tom Ivar Helbekkmo
Тема Re: [HACKERS] Did the inet type get backed out?
Дата
Msg-id 86vhlkxumm.fsf@athene.nhh.no
обсуждение исходный текст
Ответ на Re: [HACKERS] Did the inet type get backed out?  (Bruce Momjian <maillist@candle.pha.pa.us>)
Ответы Re: [HACKERS] Did the inet type get backed out?
Re: [HACKERS] Did the inet type get backed out?
Список pgsql-hackers
Bruce Momjian <maillist@candle.pha.pa.us> writes:

> I just ifdef'ed out the calls to the non-existant functions.  That is
> all.

You probably meant to.  What you did was to #ifdef out all the calls
to the missing inet_cidr_*() functions in the code that D'Arcy added,
_and_ the ones to the existing inet_net_*() ones that are needed for
the code to work at all.  Easy mistake to make when things are named
so similarly.

If you remove the erroneous #ifdef BAD stuff, and apply the following
patch to the (current) inet_net_pton.c, we'll have a working INET type
again, only missing the improvements that D'Arcy and Paul cooperated
to hash out.

Oh, and D'Arcy: about documentation: should you and I maybe bounce a
file of SGML back and forth a couple of times, getting the type and
functions properly described?  I can start it off if you like, but I'm
not sure I'll be able to find time to do it until monday...

-tih

*** inet_net_pton.c.old    Fri Oct 16 19:44:25 1998
--- inet_net_pton.c.new    Fri Oct 16 19:45:40 1998
***************
*** 100,133 ****

      ch = *src++;
      if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
!         && isascii(src[1]) && isxdigit(src[1]))
!     {
          /* Hexadecimal: Eat nybble string. */
          if (size <= 0)
              goto emsgsize;
-         tmp = 0;
          dirty = 0;
!         src++;                    /* skip x or X. */
!         while ((ch = *src++) != '\0' &&
!                isascii(ch) && isxdigit(ch))
!         {
              if (isupper(ch))
                  ch = tolower(ch);
              n = strchr(xdigits, ch) - xdigits;
              assert(n >= 0 && n <= 15);
!             tmp = (tmp << 4) | n;
              if (++dirty == 2) {
                  if (size-- <= 0)
                      goto emsgsize;
                  *dst++ = (u_char) tmp;
!                 tmp = 0, dirty = 0;
              }
          }
!         if (dirty) {
              if (size-- <= 0)
                  goto emsgsize;
!             tmp <<= 4;
!             *dst++ = (u_char) tmp;
          }
      }
      else if (isascii(ch) && isdigit(ch))
--- 100,131 ----

      ch = *src++;
      if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
!         && isascii(src[1]) && isxdigit(src[1])) {
          /* Hexadecimal: Eat nybble string. */
          if (size <= 0)
              goto emsgsize;
          dirty = 0;
!         src++;    /* skip x or X. */
!         while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
              if (isupper(ch))
                  ch = tolower(ch);
              n = strchr(xdigits, ch) - xdigits;
              assert(n >= 0 && n <= 15);
!             if (dirty == 0)
!                 tmp = n;
!             else
!                 tmp = (tmp << 4) | n;
              if (++dirty == 2) {
                  if (size-- <= 0)
                      goto emsgsize;
                  *dst++ = (u_char) tmp;
!                 dirty = 0;
              }
          }
!         if (dirty) {  /* Odd trailing nybble? */
              if (size-- <= 0)
                  goto emsgsize;
!             *dst++ = (u_char) (tmp << 4);
          }
      }
      else if (isascii(ch) && isdigit(ch))

--
Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"

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

Предыдущее
От: jwieck@debis.com (Jan Wieck)
Дата:
Сообщение: where to get stylesheet?
Следующее
От: "Ean R . Schuessler"
Дата:
Сообщение: PostgreSQL grows to enormous size.