During the investigation of some SSQLS problem, I noticed that the
custom.pl script generated unnecessary code for the set() functions, due
to the $set variable not being emptied after a pass. Have a look at your
custom-macros.h, look for "Begin Compare 3" and you'll notice that the
elements 1,1,2,1,2,3 are being assigned, instead of just 1,2,3.
While at it, I did some other changes, here is the summary:
- Reset $set.
- Have custom.pl work in strict+warning mode.
- Generate sql_cmp() for unsigned long and long too. Pros: I saw no
reason not to include them, and it allows to have long fields in
SQLSS structures.
All in all, nothing critical - for now. I'm indeed preparing a patch
that lets one have nullable fields in a SQLSS struct...
Best regards,
-Waba.
--- ./mysql++-2.0.7/lib/custom.pl 2006-02-01 22:13:35.000000000 +0100
+++ custom.pl 2006-02-01 23:17:30.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
########################################################################
# custom.pl - Generates custom.h and custom-macros.h, as these files
@@ -38,6 +38,8 @@
# No user-serviceable parts below.
+use strict;
+
open (OUT0, ">custom.h");
open (OUT, ">custom-macros.h");
@@ -65,9 +67,9 @@
}
---
-@types = ("char", "unsigned char", "tiny_int", "int", "unsigned int",
- "short int", "unsigned short int");
-foreach $type (@types) {
+my @types = ("char", "unsigned char", "tiny_int", "int", "unsigned int",
+ "short int", "unsigned short int", "unsigned long", "long");
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -77,7 +79,7 @@
}
@types = ("double", "float");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -89,7 +91,7 @@
}
@types = ("longlong", "ulonglong");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -140,7 +142,9 @@
{return sql_compare_##NAME<mysqlpp::sql_dummy>(*this,other);}
---
-foreach $j (1..$max_data_members) {
+my ($parm0, $parm1);
+
+foreach my $j (1..$max_data_members) {
$parm0 .= "T$j, C$j";
$parm0 .= ", " unless $j == $max_data_members;
$parm1 .= "C$j";
@@ -166,11 +170,14 @@
// ---------------------------------------------------
---
-foreach $i (1..$max_data_members) {
+
+foreach my $i (1..$max_data_members) {
+ my ($compr, $define, $compp, $set, $parm2);
$compr = ""; $parm2 = ""; $define = "";
$compr = " int cmp; \\\n" unless $i == 1;
$compp = "";
- foreach $j (1..$i) {
+ $set = "";
+ foreach my $j (1..$i) {
$compr .= " if (cmp = mysqlpp::sql_cmp(x.C$j , y.C$j )) return cmp; \\\n"
unless $j == $i;
$compr .= " return mysqlpp::sql_cmp(x.C$j , y.C$j );" if $j == $i;
@@ -228,20 +235,20 @@
---
-foreach $i (1..$max_data_members) {
- $parm_complete = "";
- $parm_order = ""; $parm_order2c = "";
- $parm_simple = ""; $parm_simple2c = "";
- $parm_simple_b = ""; $parm_simple2c_b = "";
- $parm_names = ""; $parm_names2c = "";
- $defs = ""; $popul = ""; $parmc = ""; $parmC = "";
- $value_list = ""; $field_list = ""; $equal_list = "";
- $value_list_cus = ""; $cus_field_list = ""; $cus_equal_list = "";
- $create_bool = ""; $create_list = "";
- $cusparms1 = ""; $cusparms2 = ""; $cusparmsv = "";
- $cusparms11 = ""; $cusparms22 = "";
- $names = "";$enums = "";
- foreach $j (1 .. $i) {
+foreach my $i (1..$max_data_members) {
+ my $parm_complete = "";
+ my $parm_order = ""; my $parm_order2c = "";
+ my $parm_simple = ""; my $parm_simple2c = "";
+ my $parm_simple_b = ""; my $parm_simple2c_b = "";
+ my $parm_names = ""; my $parm_names2c = "";
+ my $defs = ""; my $popul = ""; my $parmc = ""; my $parmC = "";
+ my $value_list = ""; my $field_list = ""; my $equal_list = "";
+ my $value_list_cus = ""; my $cus_field_list = ""; my $cus_equal_list = "";
+ my $create_bool = ""; my $create_list = "";
+ my $cusparms1 = ""; my $cusparms2 = ""; my $cusparmsv = "";
+ my $cusparms11 = ""; my $cusparms22 = "";
+ my $names = "";my $enums = "";
+ foreach my $j (1 .. $i) {
$parm_complete .= "T$j, I$j, N$j, O$j";
$parm_complete .= ", " unless $j == $i;
$parm_order .= "T$j, I$j, O$j";
@@ -315,7 +322,7 @@
$parmc .= "I$j";
$parmc .= ", " unless $j == $max_data_members;
}
- foreach $j ($i+1 .. $max_data_members) {
+ foreach my $j ($i+1 .. $max_data_members) {
$parmC .= "0, 0";
$parmC .= ", " unless $j == $max_data_members;
$parmc .= "0";
@@ -327,7 +334,7 @@
// Begin Create $i
// ---------------------------------------------------
---
- $out = <<"---";
+ my $out = <<"---";
#define sql_create_basic_c_order_$i(NAME, CMP, CONTR, $parm_order)
struct NAME;
@@ -878,7 +885,7 @@
sub prepare {
- local $_ = @_[0];
+ local $_ = $_[0];
s/\n+$//;
s/\n[\n ]*\n/\n/g;
s/\n+/\\\n/g;
Attachment: [application/pgp-signature] Digital signature signature.asc