macaddr format fix

From: Mike Wyer <mw(at)doc(dot)ic(dot)ac(dot)uk>
To: pgsql-patches(at)postgresql(dot)org
Subject: macaddr format fix
Date: 2002-06-06 21:33:14
Message-ID: Pine.LNX.4.42.0206062232251.13015-200000@kungfu.doc.ic.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hi,

The macaddr datatype understands most formats of MAC address, except 12
hex digits with no separators, eg 00AABBCCDDEE
This is easily remedied with the following patch (against 7.2.1):

--- src/backend/utils/adt/mac.c.old Tue May 28 16:48:34 2002
+++ src/backend/utils/adt/mac.c Tue May 28 16:49:47 2002
@@ -39,6 +39,8 @@

count = sscanf(str, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e,
&f);
if (count != 6)
+ count = sscanf(str, "%2x%2x%2x%2x%2x%2x", &a, &b, &c,
&d, &e, &f);
+ if (count != 6)
count = sscanf(str, "%x-%x-%x-%x-%x-%x", &a, &b, &c, &d,
&e, &f);
if (count != 6)
count = sscanf(str, "%2x%2x%2x:%2x%2x%2x", &a, &b, &c,
&d, &e, &f);

########################## END ########################################

It simply adds two lines to the current checks, and works very well.

Cheers,
Mike Wyer
--
Mike Wyer <mw(at)doc(dot)ic(dot)ac(dot)uk> || "Woof?"
http://www.doc.ic.ac.uk/~mw || Gaspode the Wonder Dog
Work: +44 020 7594 8440 ||
Mobile: +44 07900 897543 || ICQ: 43922064

Attachment Content-Type Size
postgresql-7.2.1-macaddr.patch text/plain 481 bytes

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tatsuo Ishii 2002-06-07 01:28:26 Re: Chinese GB18030 support is implemented!
Previous Message Bill Huang 2002-06-06 07:54:05 Re: [PATCHES] Chinese GB18030 support is implemented!