* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
*
* Author: German Mendez Bravo (Kronuz)
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/isn/isn.c
*--aux = '0'; /* fill the remaining EAN13 with '0' */
/* find out the data type: */
- if (!strncmp("978", buf, 3))
+ if (strncmp("978", buf, 3) == 0)
{ /* ISBN */
type = ISBN;
}
- else if (!strncmp("977", buf, 3))
+ else if (strncmp("977", buf, 3) == 0)
{ /* ISSN */
type = ISSN;
}
- else if (!strncmp("9790", buf, 4))
+ else if (strncmp("9790", buf, 4) == 0)
{ /* ISMN */
type = ISMN;
}
- else if (!strncmp("979", buf, 3))
+ else if (strncmp("979", buf, 3) == 0)
{ /* ISBN-13 */
type = ISBN;
}
}
/* find out what type of hyphenation is needed: */
- if (!strncmp("978-", result, search))
+ if (strncmp("978-", result, search) == 0)
{ /* ISBN -13 978-range */
/* The string should be in this form: 978-??000000000-0" */
type = ISBN;
TABLE = ISBN_range;
TABLE_index = ISBN_index;
}
- else if (!strncmp("977-", result, search))
+ else if (strncmp("977-", result, search) == 0)
{ /* ISSN */
/* The string should be in this form: 977-??000000000-0" */
type = ISSN;
TABLE = ISSN_range;
TABLE_index = ISSN_index;
}
- else if (!strncmp("979-0", result, search + 1))
+ else if (strncmp("979-0", result, search + 1) == 0)
{ /* ISMN */
/* The string should be in this form: 979-0?000000000-0" */
type = ISMN;
TABLE = ISMN_range;
TABLE_index = ISMN_index;
}
- else if (!strncmp("979-", result, search))
+ else if (strncmp("979-", result, search) == 0)
{ /* ISBN-13 979-range */
/* The string should be in this form: 979-??000000000-0" */
type = ISBN;
/* now get the subtype of EAN13: */
if (buf[3] == '0')
type = UPC;
- else if (!strncmp("977", buf + 3, 3))
+ else if (strncmp("977", buf + 3, 3) == 0)
type = ISSN;
- else if (!strncmp("978", buf + 3, 3))
+ else if (strncmp("978", buf + 3, 3) == 0)
type = ISBN;
- else if (!strncmp("9790", buf + 3, 4))
+ else if (strncmp("9790", buf + 3, 4) == 0)
type = ISMN;
- else if (!strncmp("979", buf + 3, 3))
+ else if (strncmp("979", buf + 3, 3) == 0)
type = ISBN;
if (accept != EAN13 && accept != ANY && type != accept)
goto eanwrongtype;
case ISMN:
strncpy(buf, "9790", 4); /* this isn't for sure yet, for now
* ISMN it's only 9790 */
- valid = (valid && ((rcheck = checkdig(buf + 3, 10)) == check || magic));
+ valid = (valid && ((rcheck = checkdig(buf, 13)) == check || magic));
break;
case ISBN:
strncpy(buf, "978", 3);