Author: turnstep
Date: Mon Jan 28 13:07:52 2008
New Revision: 10659

Modified:
   DBD-Pg/trunk/Makefile.PL
   DBD-Pg/trunk/Pg.xs
   DBD-Pg/trunk/dbdimp.c
   DBD-Pg/trunk/dbdimp.h
   DBD-Pg/trunk/quote.c
   DBD-Pg/trunk/quote.h

Log:
Many C fixes and Makefile tweaks, thanks to Andy Lester.


Modified: DBD-Pg/trunk/Makefile.PL
==============================================================================
--- DBD-Pg/trunk/Makefile.PL    (original)
+++ DBD-Pg/trunk/Makefile.PL    Mon Jan 28 13:07:52 2008
@@ -123,7 +123,7 @@
        $comp_opts .= ' -Wunknown-pragmas -Wstrict-aliasing';
        $comp_opts .= ' -Wall'; ## all of above, but we enumerate anyway
        $comp_opts .= ' -Wextra -Wdeclaration-after-statement -Wendif-labels 
-Wpointer-arith';
-       $comp_opts .= ' -Wbad-function-cast -Wcast-qual -Wcast-align 
-Wconversion -Wsign-compare -Waggregate-return';
+       $comp_opts .= ' -Wbad-function-cast -Wcast-qual -Wcast-align 
-Wsign-compare -Waggregate-return';
        $comp_opts .= ' -Wmissing-prototypes -Wmissing-declarations 
-Wmissing-format-attribute -Wpacked -Winline -Winvalid-pch';
        $comp_opts .= ' -Wdisabled-optimization'; ## Not terribly useful
        $comp_opts .= ' -Wnested-externs'; ## Does not like Perl__notused (from 
DBIXS;)
@@ -176,6 +176,19 @@
        $string =~ s/dependancy/dependency/g; ## why not, while we are here
        $string =~ s#(BASEEXT\)/g)#$1; s/^do\\\(/dontdo\\\(/#;
 
+        my $tags = <<'MAKE_FRAG';
+.PHONY: tags
+
+tags:
+       ctags -f tags --recurse --totals \
+               --exclude=blib \
+               --exclude=.svn \
+               --exclude='*~' \
+               --languages=Perl,C --langmap=c:+.h,Perl:+.t \
+
+MAKE_FRAG
+        $string = "$string\n$tags\n";
+
        $string .= <<'MAKE_SPLINT';
 
 ## This must be version 3.1.2 or better: earlier versions have many 

Modified: DBD-Pg/trunk/Pg.xs
==============================================================================
--- DBD-Pg/trunk/Pg.xs  (original)
+++ DBD-Pg/trunk/Pg.xs  Mon Jan 28 13:07:52 2008
@@ -196,12 +196,6 @@
        CODE:
        {
                D_imp_dbh(dbh);
-               sql_type_info_t *type_info;
-               char *to_quote;
-               char *quoted;
-               STRLEN len=0;
-               STRLEN retlen=0;
-               SV **svp;
 
                SvGETMAGIC(to_quote_sv);
 
@@ -215,6 +209,11 @@
                        RETVAL = pg_stringify_array(to_quote_sv, ",", 
imp_dbh->pg_server_version);
                }
                else {
+                       sql_type_info_t *type_info;
+                       char *quoted;
+                       const char *to_quote;
+                       STRLEN retlen=0;
+                       STRLEN len=0;
 
                        /* If no valid type is given, we default to unknown */
                        if (!type_sv || !SvOK(type_sv)) {
@@ -227,6 +226,7 @@
                                        type_info = 
sql_type_data(SvIV(type_sv));
                                }
                                else {
+                                       SV **svp;
                                        if ((svp = 
hv_fetch((HV*)SvRV(type_sv),"pg_type", 7, 0)) != NULL) {
                                                type_info = 
pg_type_data(SvIV(*svp));
                                        }
@@ -283,7 +283,6 @@
        {
                int retval;
                int asyncflag = 0;
-               SV **svp;
 
                if (strlen(statement)<1) { /* Corner case */
                        XST_mUNDEF(0);
@@ -291,6 +290,7 @@
                }
 
                if (attr && SvROK(attr) && SvTYPE(SvRV(attr)) == SVt_PVHV) {
+                       SV **svp;
                        if ((svp = hv_fetch((HV*)SvRV(attr),"pg_async", 8, 0)) 
!= NULL) {
                           asyncflag = SvIV(*svp);
                        }
@@ -301,7 +301,7 @@
                }
                else { /* We've got bind arguments, so we do the whole 
prepare/execute route */
                        imp_sth_t *imp_sth;
-                       SV * sth = dbixst_bounce_method("prepare", 3);
+                       SV * const sth = dbixst_bounce_method("prepare", 3);
                        if (!SvROK(sth))
                                XSRETURN_UNDEF;
                        imp_sth = (imp_sth_t*)(DBIh_COM(sth));
@@ -392,7 +392,7 @@
        SV * dbh
        int mode
        CODE:
-               unsigned int ret = pg_db_lo_creat(dbh, mode);
+               const unsigned int ret = pg_db_lo_creat(dbh, mode);
                ST(0) = (ret > 0) ? sv_2mortal(newSVuv(ret)) : &sv_undef;
 
 
@@ -402,7 +402,7 @@
        unsigned int lobjId
        int mode
        CODE:
-               int ret = pg_db_lo_open(dbh, lobjId, mode);
+               const int ret = pg_db_lo_open(dbh, lobjId, mode);
                ST(0) = (ret >= 0) ? sv_2mortal(newSViv(ret)) : &sv_undef;
 
 
@@ -421,7 +421,7 @@
        char * buf
        size_t len
        PREINIT:
-               SV *bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2);
+               SV * const bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2);
                int ret;
        CODE:
                sv_setpvn(bufsv,"",0); /* Make sure we can grow it safely */
@@ -443,7 +443,7 @@
        char * buf
        size_t len
        CODE:
-               int ret = pg_db_lo_write(dbh, fd, buf, len);
+               const int ret = pg_db_lo_write(dbh, fd, buf, len);
                ST(0) = (ret >= 0) ? sv_2mortal(newSViv(ret)) : &sv_undef;
 
 
@@ -454,7 +454,7 @@
        int offset
        int whence
        CODE:
-               int ret = pg_db_lo_lseek(dbh, fd, offset, whence);
+               const int ret = pg_db_lo_lseek(dbh, fd, offset, whence);
                ST(0) = (ret >= 0) ? sv_2mortal(newSViv(ret)) : &sv_undef;
 
 
@@ -463,7 +463,7 @@
        SV * dbh
        int fd
        CODE:
-               int ret = pg_db_lo_tell(dbh, fd);
+               const int ret = pg_db_lo_tell(dbh, fd);
                ST(0) = (ret >= 0) ? sv_2mortal(newSViv(ret)) : &sv_undef;
 
 
@@ -480,7 +480,7 @@
        SV * dbh
        char * filename
        CODE:
-               unsigned int ret = pg_db_lo_import(dbh, filename);
+               const unsigned int ret = pg_db_lo_import(dbh, filename);
                ST(0) = (ret > 0) ? sv_2mortal(newSVuv(ret)) : &sv_undef;
 
 
@@ -610,9 +610,9 @@
        CODE:
        {
                int type_num = 0;
-               sql_type_info_t *type_info;
 
                if (type_sv && SvOK(type_sv)) {
+                       sql_type_info_t *type_info;
                        if SvMAGICAL(type_sv)
                                (void)mg_get(type_sv);
                        type_info = pg_type_data(SvIV(type_sv));

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Mon Jan 28 13:07:52 2008
@@ -78,14 +78,14 @@
        (SvROK(h) && SvTYPE(SvRV(h)) == SVt_PVHV &&                             
        \
         SvRMAGICAL(SvRV(h)) && (SvMAGIC(SvRV(h)))->mg_type == 'P')
 
-static void pg_error(SV *h, ExecStatusType error_num, char *error_msg);
+static void pg_error(SV *h, ExecStatusType error_num, const char *error_msg);
 static void pg_warn (void * arg, const char * message);
 static ExecStatusType _result(imp_dbh_t *imp_dbh, const char *sql);
 static ExecStatusType _sqlstate(imp_dbh_t *imp_dbh, PGresult *result);
 static int dbd_db_rollback_commit (SV *dbh, imp_dbh_t *imp_dbh, char * action);
 static void dbd_st_split_statement (imp_sth_t *imp_sth, int version, char 
*statement);
 static int dbd_st_prepare_statement (SV *sth, imp_sth_t *imp_sth);
-static int is_high_bit_set(unsigned char *val, STRLEN size);
+static int is_high_bit_set(const unsigned char *val, STRLEN size);
 static int dbd_st_deallocate_statement(SV *sth, imp_sth_t *imp_sth);
 static PGTransactionStatusType dbd_db_txn_status (imp_dbh_t *imp_dbh);
 static int pg_db_start_txn (SV *dbh, imp_dbh_t *imp_dbh);
@@ -118,9 +118,9 @@
 
        /* Figure out how large our connection string is going to be */
        connect_string_size = strlen(dbname);
-       if (strlen(uid))
+       if (*uid)
                connect_string_size += strlen("user='' ") + 2*strlen(uid);
-       if (strlen(pwd))
+       if (*pwd)
                connect_string_size += strlen("password='' ") + 2*strlen(pwd);
        New(0, conn_str, connect_string_size+1, char); /* freed below */
 
@@ -139,7 +139,7 @@
        *dest = '\0';
 
        /* Add in the user and/or password if they exist, escaping single 
quotes and backslashes */
-       if (strlen(uid)) {
+       if (*uid) {
                strcat(conn_str, " user='");
                dest = conn_str;
                while(*dest != '\0')
@@ -152,7 +152,7 @@
                *dest = '\0';
                strcat(conn_str, "'");
        }
-       if (strlen(pwd)) {
+       if (*pwd) {
                strcat(conn_str, " password='");
                dest = conn_str;
                while(*dest != '\0')
@@ -266,7 +266,7 @@
 /* ================================================================== */
 
 /* Database specific error handling. */
-static void pg_error (SV * h, ExecStatusType error_num, char * error_msg)
+static void pg_error (SV * h, ExecStatusType error_num, const char * error_msg)
 {
        D_imp_xxh(h);
        char *      err;
@@ -1838,7 +1838,6 @@
        int          status = -1;
        seg_t *      currseg;
        bool         oldprepare = DBDPG_TRUE;
-       int          params = 0;
        Oid *        paramTypes = NULL;
        ph_t *       currph;
 
@@ -1930,6 +1929,7 @@
                status = _result(imp_dbh, statement);
        }
        else {
+               int params = 0;
                if (imp_sth->numbound!=0) {
                        params = imp_sth->numphs;
                        Newz(0, paramTypes, (unsigned)imp_sth->numphs, Oid);
@@ -2316,7 +2316,6 @@
 SV * pg_destringify_array(imp_dbh_t *imp_dbh, unsigned char * input, 
sql_type_info_t * coltype) {
 
        AV*    av;              /* The main array we are returning a reference 
to */
-       AV*    newav;           /* Temporary array */
        AV*    currentav;       /* The current array level */
        AV*    topav;           /* Where each item starts at */
        char*  string;
@@ -2363,7 +2362,7 @@
                        string[section_size++] = *input;
                }
                else if ('{' == *input) {
-                       newav = newAV();
+                       AV * const newav = newAV();
                        av_push(currentav, newRV_noinc((SV*)newav));
                        currentav = newav;
                }
@@ -2378,8 +2377,7 @@
                        string[section_size++] = *input;
                }
 
-               if ('}' == *input
-                       || (coltype->array_delimeter == *input && '}' != 
*(input-1))) {
+               if ('}' == *input || (coltype->array_delimeter == *input && '}' 
!= *(input-1))) {
                        string[section_size] = '\0';
                        if (4 == section_size && 0 == strncmp(string, "NULL", 
4) && '"' != *(input-1)) {
                                av_push(currentav, &PL_sv_undef);
@@ -2573,7 +2571,6 @@
        Oid *         paramTypes = NULL;
        seg_t *       currseg;
        char *        statement = NULL;
-       char *        cmdStatus = NULL;
        int           num_fields;
        int           ret = -2;
        
@@ -2906,11 +2903,13 @@
        }
        else if (PGRES_COMMAND_OK == status) {
                /* non-select statement */
+               char *cmdStatus = NULL;
                if (imp_sth->result) {
                        cmdStatus = PQcmdStatus(imp_sth->result);
                }
                if (dbis->debug >= 5)
                        (void)PerlIO_printf(DBILOGFP, "dbdpg: Status was 
PGRES_COMMAND_OK\n");
+                /* XXX DANGER We could be comparing against NULL */
                if ((0==strncmp(cmdStatus, "DELETE", 6)) || 
(0==strncmp(cmdStatus, "INSERT", 6)) || 
                        (0==strncmp(cmdStatus, "UPDATE", 6))) {
                        ret = atoi(PQcmdTuples(imp_sth->result));
@@ -2953,7 +2952,7 @@
 
 
 /* ================================================================== */
-static int is_high_bit_set(unsigned char * val, STRLEN size)
+static int is_high_bit_set(const unsigned char * val, STRLEN size)
 {
        while (*val && size--)
                if (*val++ & 0x80) return 1;
@@ -3102,11 +3101,11 @@
 
 /* ================================================================== */
 /* Pop off savepoints to the specified savepoint name */
-static void pg_db_free_savepoints_to (imp_dbh_t * imp_dbh, char * savepoint)
+static void pg_db_free_savepoints_to (imp_dbh_t * imp_dbh, const char 
*savepoint)
 {
        I32 i;
        for (i = av_len(imp_dbh->savepoints); i >= 0; i--) {
-               SV * elem = av_pop(imp_dbh->savepoints);
+               SV * const elem = av_pop(imp_dbh->savepoints);
                if (strEQ(SvPV_nolen(elem), savepoint)) {
                        sv_2mortal(elem);
                        break;
@@ -3189,9 +3188,8 @@
                        /* If a savepoint has been set, rollback to the last 
savepoint instead of the entire transaction */
                        I32     alen = av_len(imp_dbh->savepoints);
                        if (alen > -1) {
-                               SV              *sp = Nullsv;
                                char    *cmd;
-                               sp = *av_fetch(imp_dbh->savepoints, alen, 0);
+                               SV * const sp = *av_fetch(imp_dbh->savepoints, 
alen, 0);
                                New(0, cmd, SvLEN(sp) + 13, char); /* Freed 
below */
                                if (dbis->debug >= 4)
                                        (void)PerlIO_printf(DBILOGFP, "dbdpg: 
Rolling back to savepoint %s\n", SvPV_nolen(sp));
@@ -3628,7 +3626,7 @@
 
 
 /* ================================================================== */
-int pg_db_rollback_to (SV * dbh, imp_dbh_t * imp_dbh, char * savepoint)
+int pg_db_rollback_to (SV * dbh, imp_dbh_t * imp_dbh, const char *savepoint)
 {
        int    status;
        char * action;
@@ -3930,11 +3928,8 @@
 
 /* ================================================================== */
 /* Return the result of an asynchronous query, waiting if needed */
-int dbdpg_result (h, imp_dbh)
-                SV *h;
-                imp_dbh_t *imp_dbh;
+int dbdpg_result (SV *h, imp_dbh_t *imp_dbh)
 {
-
        PGresult *result;
        ExecStatusType status = PGRES_FATAL_ERROR;
        int rows;
@@ -4023,11 +4018,8 @@
 ==================================================================
 */
 
-int dbdpg_ready (h, imp_dbh)
-                SV *h;
-                imp_dbh_t *imp_dbh;
+int dbdpg_ready(SV *h, imp_dbh_t *imp_dbh)
 {
-
        if (dbis->debug >= 4) {
                (void)PerlIO_printf(DBILOGFP, "dbdpg: pg_st_ready, async_status 
is %d\n",imp_dbh->async_status);
        }
@@ -4056,11 +4048,8 @@
 NOTE: We only return true if we cancelled and rolled back!
 */
 
-int dbdpg_cancel(h, imp_dbh)
-        SV *h;
-        imp_dbh_t *imp_dbh;
+int dbdpg_cancel(SV *h, imp_dbh_t *imp_dbh)
 {
-
        PGcancel *cancel;
        char errbuf[256];
        PGresult *result;
@@ -4123,15 +4112,11 @@
 } /* end of dbdpg_cancel */
 
 
-int dbdpg_cancel_sth(sth, imp_sth)
-        SV *sth;
-        imp_sth_t *imp_sth;
+int dbdpg_cancel_sth(SV *sth, imp_sth_t *imp_sth)
 {
+        D_imp_dbh_from_sth;
 
-    D_imp_dbh_from_sth;
-       bool cancel_result;
-
-       cancel_result = dbdpg_cancel(sth, imp_dbh);
+       const bool cancel_result = dbdpg_cancel(sth, imp_dbh);
 
        dbd_st_finish(sth, imp_sth);
 

Modified: DBD-Pg/trunk/dbdimp.h
==============================================================================
--- DBD-Pg/trunk/dbdimp.h       (original)
+++ DBD-Pg/trunk/dbdimp.h       Mon Jan 28 13:07:52 2008
@@ -122,7 +122,7 @@
 void pg_db_pg_server_trace (SV *dbh, FILE *fh);
 void pg_db_pg_server_untrace (SV *dbh);
 int pg_db_savepoint (SV *dbh, imp_dbh_t *imp_dbh, char * savepoint);
-int pg_db_rollback_to (SV *dbh, imp_dbh_t *imp_dbh, char * savepoint);
+int pg_db_rollback_to (SV *dbh, imp_dbh_t *imp_dbh, const char * savepoint);
 int pg_db_release (SV *dbh, imp_dbh_t *imp_dbh, char * savepoint);
 unsigned int pg_db_lo_creat (SV *dbh, int mode);
 int pg_db_lo_open (SV *dbh, unsigned int lobjId, int mode);

Modified: DBD-Pg/trunk/quote.c
==============================================================================
--- DBD-Pg/trunk/quote.c        (original)
+++ DBD-Pg/trunk/quote.c        Mon Jan 28 13:07:52 2008
@@ -3,7 +3,7 @@
    $Id$
 
    Copyright (c) 2003-2008 Greg Sabino Mullane and others: see the Changes file
-   
+
    You may distribute under the terms of either the GNU General Public
    License or the Artistic License, as specified in the Perl README file.
 
@@ -12,10 +12,7 @@
 #include "Pg.h"
 #include "types.h"
 
-char * null_quote(string, len, retlen)
-       char *string;
-       STRLEN len;
-       STRLEN *retlen;
+char * null_quote(const char *string, STRLEN len, STRLEN *retlen)
 {
        char *result;
        New(0, result, len+1, char);
@@ -26,15 +23,13 @@
 }
 
 
-char * quote_string(string, len, retlen)
-                char * string;
-                STRLEN len;
-                STRLEN * retlen;
+char * quote_string(const char *string, STRLEN len, STRLEN *retlen)
 {
        char * result;
        STRLEN oldlen = len;
 
-       result = string;
+       const char * const tmp = string;
+
        (*retlen) = 2;
        while (len > 0 && *string != '\0') {
                if (*string == '\'' || *string == '\\') {
@@ -44,7 +39,7 @@
                string++;
                len--;
        }
-       string = result;
+       string = tmp;
        New(0, result, 1+(*retlen), char);
        *result++ = '\'';
        len = oldlen;
@@ -61,15 +56,13 @@
 }
 
 
-char * quote_geom(string, len, retlen)
-       char * string;
-       STRLEN len;
-       STRLEN * retlen;
+char * quote_geom(const char *string, STRLEN len, STRLEN *retlen)
 {
        char * result;
+        const char *tmp;
 
        len = 0; /* stops compiler warnings. Remove entirely someday */
-       result = string;
+       tmp = string;
        (*retlen) = 2;
        while (*string != '\0') {
                if (*string !=9 && *string != 32 && *string != '(' && *string 
!= ')'
@@ -78,7 +71,7 @@
                (*retlen)++;
                string++;
        }
-       string = result;
+       string = tmp;
        New(0, result, 1+(*retlen), char);
        *result++ = '\'';
        while (*string != '\0') {
@@ -89,15 +82,12 @@
        return result - (*retlen);
 }
 
-char * quote_path(string, len, retlen)
-       char * string;
-       STRLEN len;
-       STRLEN * retlen;
+char * quote_path(const char *string, STRLEN len, STRLEN *retlen)
 {
        char * result;
+       const char * const tmp = string;
 
        len = 0; /* stops compiler warnings. Remove entirely someday */
-       result = string;
        (*retlen) = 2;
        while (*string != '\0') {
                if (*string !=9 && *string != 32 && *string != '(' && *string 
!= ')'
@@ -107,7 +97,7 @@
                (*retlen)++;
                string++;
        }
-       string = result;
+       string = tmp;
        New(0, result, 1+(*retlen), char);
        *result++ = '\'';
        while (*string != '\0') {
@@ -118,15 +108,12 @@
        return result - (*retlen);
 }
 
-char * quote_circle(string, len, retlen)
-       char * string;
-       STRLEN len;
-       STRLEN * retlen;
+char * quote_circle(const char *string, STRLEN len, STRLEN *retlen)
 {
        char * result;
+       const char * const tmp = string;
 
        len = 0; /* stops compiler warnings. Remove entirely someday */
-       result = string;
        (*retlen) = 2;
        while (*string != '\0') {
                if (*string !=9 && *string != 32 && *string != '(' && *string 
!= ')'
@@ -136,7 +123,7 @@
                (*retlen)++;
                string++;
        }
-       string = result;
+       string = tmp;
        New(0, result, 1+(*retlen), char);
        *result++ = '\'';
        while (*string != '\0') {
@@ -148,12 +135,9 @@
 }
 
 
-char * quote_bytea(string, len, retlen)
-                unsigned char * string;
-                STRLEN len;
-                STRLEN * retlen;
+char * quote_bytea(char *string, STRLEN len, STRLEN *retlen)
 {
-       unsigned char * result;
+       char * result;
        STRLEN oldlen = len;
 
        result = string;
@@ -175,7 +159,7 @@
                len--;
        }
        string = result;
-       New(0, result, 1+(*retlen), unsigned char);
+       New(0, result, 1+(*retlen), char);
        *result++ = '\'';
        len = oldlen;
        while (len > 0) {
@@ -204,10 +188,7 @@
        return (char *)result - (*retlen);
 }
 
-char * quote_sql_binary(string, len, retlen)
-                unsigned char *string;
-                STRLEN len;
-                STRLEN *retlen;
+char * quote_sql_binary(char *string, STRLEN len, STRLEN *retlen)
 {
        
        /* We are going to return a quote_bytea() for backwards compat but
@@ -219,18 +200,15 @@
 
 
 
-char * quote_bool(value, len, retlen) 
-                char *value;
-                STRLEN len;
-                STRLEN *retlen;
+char * quote_bool(const char *value, STRLEN len, STRLEN *retlen) 
 {
        char *result;
        long int int_value;
        STRLEN  max_len=6;
        
        len = 0;
-       if (isDIGIT(*(char*)value)) {
-               /* For now -- will go away when quote* take SVs */
+       if (isDIGIT(*(const char*)value)) {
+               /* For now -- will go away when quote* take SVs */
                int_value = atoi(value);
        } else {
                int_value = 42; /* Not true, not false. Just is */
@@ -252,20 +230,18 @@
 
 
 
-char * quote_integer(value, len, retlen) 
-                char *value;
-                STRLEN len;
-                STRLEN *retlen;
+char * quote_integer(const char *value, STRLEN len, STRLEN *retlen) 
 {
        char *result;
        STRLEN max_len=6;
+        const int intval = *((const int*)value);
        len = 0;
 
        New(0, result, max_len, char);
        
-       if (0 == *((int*)value) )
+       if (0 == intval)
                strncpy(result,"FALSE\0",6);
-       if (1 == *((int*)value))
+       else if (1 == intval)
                strncpy(result,"TRUE\0",5);
        
        *retlen = strlen(result);
@@ -276,29 +252,23 @@
 
 
 
-void dequote_char(string, retlen)
-                char *string;
-                STRLEN *retlen;
+void dequote_char(const char *string, STRLEN *retlen)
 {
        /* TODO: chop_blanks if requested */
        *retlen = strlen(string);
 }
 
 
-void dequote_string (string, retlen)
-                char *string;
-                STRLEN *retlen;
+void dequote_string(const char *string, STRLEN *retlen)
 {
        *retlen = strlen(string);
 }
 
 
 
-void dequote_bytea(string, retlen)
-                unsigned char *string;
-                STRLEN *retlen;
+void dequote_bytea(char *string, STRLEN *retlen)
 {
-       unsigned char *result;
+       char *result;
 
        (*retlen) = 0;
 
@@ -315,9 +285,9 @@
                                string +=2;
                        }
                        else if (
-                                                        (*(string+1) >= '0' && 
*(string+1) <= '3') &&
-                                                        (*(string+2) >= '0' && 
*(string+2) <= '7') &&
-                                                        (*(string+3) >= '0' && 
*(string+3) <= '7'))
+                                (*(string+1) >= '0' && *(string+1) <= '3') &&
+                                (*(string+2) >= '0' && *(string+2) <= '7') &&
+                                (*(string+3) >= '0' && *(string+3) <= '7'))
                                {
                                        *result++ = (*(string+1)-'0')*64 + 
(*(string+2)-'0')*8 + (*(string+3)-'0');
                                        string += 4;
@@ -332,7 +302,6 @@
                }
        }
        *result = '\0';
-       string = result - (*retlen);
        return;
 }
 
@@ -343,9 +312,7 @@
        it might be nice to let people go the other way too. Say when talking
        to something that uses SQL_BINARY
  */
-void dequote_sql_binary (string, retlen)
-                unsigned char *string;
-                STRLEN *retlen;
+void dequote_sql_binary(char *string, STRLEN *retlen)
 {
        /* We are going to retun a dequote_bytea(), JIC */
        warn("Use of SQL_BINARY invalid in dequote()");
@@ -356,9 +323,7 @@
 
 
 
-void dequote_bool (string, retlen)
-                char *string;
-                STRLEN *retlen;
+void dequote_bool(char *string, STRLEN *retlen)
 {
        switch(*string){
        case 'f': *string = '0'; break;
@@ -371,9 +336,7 @@
 
 
 
-void null_dequote (string, retlen)
-                char *string;
-                STRLEN *retlen;
+void null_dequote(const char *string, STRLEN *retlen)
 {
        *retlen = strlen(string);
 }

Modified: DBD-Pg/trunk/quote.h
==============================================================================
--- DBD-Pg/trunk/quote.h        (original)
+++ DBD-Pg/trunk/quote.h        Mon Jan 28 13:07:52 2008
@@ -1,19 +1,19 @@
 
 #ifndef DBDQUOTEH
 #define DBDQUOTEH
-char * null_quote(char *string, STRLEN len, STRLEN *retlen);
-char * quote_string(char *string, STRLEN len, STRLEN *retlen);
-char * quote_bytea(unsigned char *string, STRLEN len, STRLEN *retlen);
-char * quote_sql_binary(unsigned char *string, STRLEN len, STRLEN *retlen);
-char * quote_bool(char *string, STRLEN len, STRLEN *retlen);
-char * quote_integer(char *string, STRLEN len, STRLEN *retlen);
-char * quote_geom(char *string, STRLEN len, STRLEN *retlen);
-char * quote_path(char *string, STRLEN len, STRLEN *retlen);
-char * quote_circle(char *string, STRLEN len, STRLEN *retlen);
-void dequote_char(char *string, STRLEN *retlen);
-void dequote_string(char *string, STRLEN *retlen);
-void dequote_bytea(unsigned char *string, STRLEN *retlen);
-void dequote_sql_binary(unsigned char *string, STRLEN *retlen);
+char * null_quote(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_string(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_bytea(char *string, STRLEN len, STRLEN *retlen);
+char * quote_sql_binary(char *string, STRLEN len, STRLEN *retlen);
+char * quote_bool(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_integer(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_geom(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_path(const char *string, STRLEN len, STRLEN *retlen);
+char * quote_circle(const char *string, STRLEN len, STRLEN *retlen);
+void dequote_char(const char *string, STRLEN *retlen);
+void dequote_string(const char *string, STRLEN *retlen);
+void dequote_bytea(char *string, STRLEN *retlen);
+void dequote_sql_binary(char *string, STRLEN *retlen);
 void dequote_bool(char *string, STRLEN *retlen);
-void null_dequote(char *string, STRLEN *retlen);
+void null_dequote(const char *string, STRLEN *retlen);
 #endif /*DBDQUOTEH*/

Reply via email to