X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Foid.c;h=8ae75083ca59bd99a83b03db733a4f2b45644411;hb=8619c87efd449df46e51100488f7367e6832f4d4;hp=0fb1b1dbea76c75c8d88bc286053782596c8235f;hpb=2f5963dcec74ca26d9b0c2d75b007d98efe56f2e;p=yaz-moved-to-github.git diff --git a/src/oid.c b/src/oid.c index 0fb1b1d..8ae7508 100644 --- a/src/oid.c +++ b/src/oid.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2004, Index Data + * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: oid.c,v 1.5 2004-12-22 23:45:13 adam Exp $ + * $Id: oid.c,v 1.8 2005-05-26 21:46:41 adam Exp $ */ /** @@ -493,7 +493,6 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, nmem_mutex_enter (oid_mutex); if (!oident) { - char desc_str[200]; struct oident_list *oident_list; oident_list = (struct oident_list *) nmem_malloc (oid_nmem, sizeof(*oident_list)); @@ -503,14 +502,20 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, if (!desc) { + char desc_str[OID_SIZE*10]; int i; - sprintf (desc_str, "%d", *oid); - for (i = 1; i < 12 && oid[i] >= 0; i++) - sprintf (desc_str+strlen(desc_str), ".%d", oid[i]); - desc = desc_str; + *desc_str = '\0'; + if (*oid >= 0) + { + sprintf (desc_str, "%d", *oid); + for (i = 1; i < OID_SIZE && oid[i] >= 0; i++) + sprintf (desc_str+strlen(desc_str), ".%d", oid[i]); + } + oident->desc = nmem_strdup(oid_nmem, desc_str); } - oident->desc = nmem_strdup (oid_nmem, desc); + else + oident->desc = nmem_strdup(oid_nmem, desc); if (value == VAL_DYNAMIC) oident->value = (enum oid_value) (++oid_value_dynamic); else @@ -542,7 +547,7 @@ static oid_value oid_getval_raw(const char *name) int val = 0, i = 0, oid[OID_SIZE]; struct oident *oident; - while (isdigit (*name)) + while (isdigit (*(const unsigned char *) name)) { val = val*10 + (*name - '0'); name++; @@ -568,7 +573,7 @@ oid_value oid_getvalbyname(const char *name) struct oident_list *ol; oid_init (); - if (isdigit (*name)) + if (isdigit (*(const unsigned char *) name)) return oid_getval_raw (name); for (ol = oident_table; ol; ol = ol->next) if (!yaz_matchstr(ol->oident.desc, name))