Skip to content

Commit c455ac1

Browse files
committed
odbc: Check ODBC attribute list is sorted
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
1 parent 05d70d3 commit c455ac1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

include/freetds/Makefile.am

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ DISTCLEANFILES = sysconfdir.h \
4949
sysconfdir.h: Makefile
5050
echo '#define FREETDS_SYSCONFDIR "$(sysconfdir)"' >$@
5151

52-
all-am: sysconfdir.h
52+
all-am: sysconfdir.h odbc_attributes_sorted
5353

5454
GENERATED_HEADER_FILES = encodings.h charset_lookup.h
5555
EXTRA_DIST = $(GENERATED_HEADER_FILES)
@@ -65,4 +65,11 @@ charset_lookup.h: encodings.h
6565
encodings.h: encodings.pl alternative_character_sets.h character_sets.h Makefile
6666
perl $(srcdir)/encodings.pl $(srcdir) $(GPERF) > $@.tmp 2> /dev/null
6767
mv $@.tmp $@
68+
69+
odbc_attributes_sorted: odbc_attributes.pl odbc.h Makefile
70+
perl $(srcdir)/odbc_attributes.pl $(srcdir)
71+
touch $@
72+
else
73+
odbc_attributes_sorted: odbc.h Makefile
74+
touch $@
6875
endif

include/freetds/odbc_attributes.pl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/perl
2+
## This file is in the public domain.
3+
use strict;
4+
use File::Basename;
5+
6+
my $basename = basename($0);
7+
my $srcdir = "$ARGV[0]/";
8+
9+
# check list of attributes is alphabetically sorted
10+
my $filename = "${srcdir}odbc.h";
11+
my $prev = '';
12+
open ODBC, $filename or die qq($basename: could not open "$filename"\n);
13+
while(<ODBC>){
14+
next unless /^\sODBC_PARAM\((.*?)\)/;
15+
my $attr = $1;
16+
die "$attr following $prev" if lc($attr) le lc($prev);
17+
$prev = $attr;
18+
}
19+
close ODBC;

0 commit comments

Comments
 (0)