[Bug 156840] (gcc4 O1+) perl-DBD-pg Placeholders no longer functioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug report.

Summary: (gcc4 O1+) perl-DBD-pg Placeholders no longer functioning


https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=156840





------- Additional Comments From jakub@xxxxxxxxxx  2005-05-24 14:49 EST -------
That's complete overkill.  If you look at the (very ugly) loop counting the
execsize, there is room in statement buffer for that sprintf, so the
patch I apparently forgot to provide is enough if all you care about is to make
it work.

--- dbdimp.c.jj 2005-04-06 16:40:20.000000000 -0400
+++ dbdimp.c    2005-05-24 07:40:21.000000000 -0400
@@ -1243,7 +1243,7 @@ int dbd_st_prepare_statement (sth, imp_s
        for (currseg=imp_sth->seg; NULL != currseg; currseg=currseg->nextseg) {
                strcat(statement, currseg->segment);
                if (currseg->placeholder) {
-                       sprintf(statement, "%s$%d", statement,
currseg->placeholder);
+                       sprintf(strchr(statement, '\0'), "$%d",
currseg->placeholder);
                }
        }



Calling pow in a loop is insane though:
/* The parameter itself: dollar sign plus digit(s) */
for (x=1; x<7; x++) {
        if (currseg->placeholder < pow(10,x))
                break;
}
if (x>=7)
        croak("Too many placeholders!");
execsize += x+1;
Guess e.g. #include <limits.h> and
#define DBD_STRINGIFY_1(x) #x
#define DBD_STRINGIFY(x) DBD_STRINGIFY_1 (x)
execsize += strlen (DBD_STRINGIFY (INT_MAX)) + 2;
would be far cheaper (well, assuming CHAR_BIT 8 one can write
execsize += sizeof (int) * 3 + 2; as well).  The strlen will be
optimized out by the compiler (unlike the expensive pow calls).


-- 
Configure bugmail: https://bugzilla.redhat.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux