diff options
Diffstat (limited to 'contrib/isn/isn.c')
-rw-r--r-- | contrib/isn/isn.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index dac760b111..b698cb00ff 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -4,10 +4,10 @@ * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * * Author: German Mendez Bravo (Kronuz) - * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.14 2010/02/26 02:00:32 momjian Exp $ + * contrib/isn/isn.c * *------------------------------------------------------------------------- */ @@ -341,8 +341,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept) enum isn_type type = INVALID; char buf[MAXEAN13LEN + 1]; - char *firstdig, - *aux; + char *aux; unsigned digval; unsigned search; ean13 ret = ean; @@ -354,7 +353,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept) /* convert the number */ search = 0; - firstdig = aux = buf + 13; + aux = buf + 13; *aux = '\0'; /* terminate string; aux points to last digit */ do { @@ -528,8 +527,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType) const unsigned (*TABLE_index)[2]; enum isn_type type = INVALID; - char *firstdig, - *aux; + char *aux; unsigned digval; unsigned search; char valid = '\0'; /* was the number initially written with a @@ -546,7 +544,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType) /* convert the number */ search = 0; - firstdig = aux = result + MAXEAN13LEN; + aux = result + MAXEAN13LEN; *aux = '\0'; /* terminate string; aux points to last digit */ *--aux = valid; /* append '!' for numbers with invalid but * corrected check digit */ @@ -573,7 +571,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType) /* find out what type of hyphenation is needed: */ if (!strncmp("978-", result, search)) - { /* ISBN */ + { /* ISBN -13 978-range */ /* The string should be in this form: 978-??000000000-0" */ type = ISBN; TABLE = ISBN_range; @@ -593,6 +591,13 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType) TABLE = ISMN_range; TABLE_index = ISMN_index; } + else if (!strncmp("979-", result, search)) + { /* ISBN-13 979-range */ + /* The string should be in this form: 979-??000000000-0" */ + type = ISBN; + TABLE = ISBN_range_new; + TABLE_index = ISBN_index_new; + } else if (*result == '0') { /* UPC */ /* The string should be in this form: 000-00000000000-0" */ |