]> granicus.if.org Git - postgresql/blobdiff - contrib/isn/isn.c
pgindent run for 9.4
[postgresql] / contrib / isn / isn.c
index b698cb00ff5ecc8a1c49d7b1f8721bba715d5c07..11247449799a816be166ea31e041ec1b54574695 100644 (file)
@@ -4,7 +4,7 @@
  *       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
@@ -365,19 +365,19 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
                *--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;
        }
@@ -570,28 +570,28 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
        }
 
        /* 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;
@@ -813,13 +813,13 @@ string2ean(const char *str, bool errorOK, ean13 *result,
                        /* 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;
@@ -827,7 +827,7 @@ string2ean(const char *str, bool errorOK, ean13 *result,
                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);