Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Sep 29, 2012
2 parents 4d86230 + 4f1dafa commit e8639fd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
results/*.out
sql/italian_codes--*.sql
dist
12 changes: 6 additions & 6 deletions META.json
Expand Up @@ -2,28 +2,28 @@
"name": "italian_codes",
"abstract": "Validation domains for Italian fiscal codes",
"description": "The package contains validation domains for Italian codes, such as Codice Fiscale and Partita IVA",
"version": "1.0beta1",
"version": "1.0.0",
"maintainer": "Daniele Varrazzo <daniele.varrazzo@gmail.com>",
"license": "BSD",
"license": "bsd",
"provides": {
"italian_codes": {
"abstract": "Validation domains for Italian fiscal codes",
"file": "sql/italian_codes.sql",
"docfile": "doc/italian_codes.rst",
"version": "1.0beta1"
"version": "1.0.0"
}
},
"release_status": "testing",
"release_status": "stable",
"resources": {
"homepage": "https://github.com/dvarrazzo/italian_codes",
"bugtracker": {
"web": "https://github.com/dvarrazzo/italian_codes/issues",
"web": "https://github.com/dvarrazzo/italian_codes/issues"
},
"repository": {
"url": "git://github.com/dvarrazzo/italian_codes.git",
"web": "https://github.com/dvarrazzo/italian_codes",
"type": "git"
},
}
},
"generated_by": "Daniele Varrazzo <daniele.varrazzo@gmail.com>",
"meta-spec": {
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Expand Up @@ -6,8 +6,9 @@

EXTENSION = italian_codes
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
EXT_LONGVER = $(shell grep '"version":' META.json | head -1 | sed -e 's/\s*"version":\s*"\(.*\)",/\1/')

DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
SQL = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
DOCS = $(wildcard doc/*.rst)
TESTS = $(wildcard test/sql/*.sql)
TESTS_OUT = $(wildcard test/expected/*.out)
Expand All @@ -16,6 +17,15 @@ REGRESS_OPTS = --inputdir=test --load-language=plpgsql
PG_CONFIG = pg_config
PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo no || echo yes)

PKGFILES = COPYING README.rst Makefile \
META.json $(EXTENSION).control \
$(SQL) $(DOCS) $(TESTS) $(TESTS_OUT)

PKGNAME = $(EXTENSION)-$(EXT_LONGVER)
SRCPKG = $(SRCPKG_TGZ) $(SRCPKG_ZIP)
SRCPKG_TGZ = dist/$(PKGNAME).tar.gz
SRCPKG_ZIP = dist/$(PKGNAME).zip

ifeq ($(PG91),yes)
all: sql/$(EXTENSION)--$(EXTVERSION).sql

Expand All @@ -24,7 +34,21 @@ sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql

DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
else
DATA = sql/$(EXTENSION).sql sql/uninstall_$(EXTENSION).sql
endif

PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

sdist: $(SRCPKG)

$(SRCPKG): $(PKGFILES)
ln -sf . $(PKGNAME)
mkdir -p dist
rm -f $(SRCPKG_TGZ)
tar czvf $(SRCPKG_TGZ) $(addprefix $(PKGNAME)/,$^)
rm -f $(SRCPKG_ZIP)
zip -r $(SRCPKG_ZIP) $(addprefix $(PKGNAME)/,$^)
rm $(PKGNAME)

1 change: 1 addition & 0 deletions italian_codes.control
Expand Up @@ -7,3 +7,4 @@
comment = 'Validation domains for Italian fiscal codes'
default_version = '1.0'
relocatable = true
superuser = false
13 changes: 4 additions & 9 deletions sql/italian_codes.sql
Expand Up @@ -135,14 +135,9 @@ create function _cf_error_16(s text) returns text as
$$
begin
-- Check the basic pattern. If it doesn't match, slow check for errors.
-- Note the final '|' char: if missing, in case of no match, the function
-- returns no row, not null (because regexp_matches is a SRF). The result
-- is that the if block is skipped altogether. Yes, it sucks. Big times.
if regexp_matches(s,
'[A-Z]{6}'
'[0-9L-NP-V]{2}[A-Z][0-9L-NP-V]{2}'
'[A-Z][0-9L-NP-V]{3}[A-Z]|')
= array[''] then
if s !~ '^[A-Z]{6}'
'[0-9L-NP-V]{2}[A-Z][0-9L-NP-V]{2}'
'[A-Z][0-9L-NP-V]{3}[A-Z]$' then
for i in 1 .. 16 loop
declare
t text := substring('CCCCCCNNCNNCNNNC', i, 1);
Expand Down Expand Up @@ -214,7 +209,7 @@ create function _cf_error_11(s text) returns text as
$$
begin
-- Check the basic pattern. If it doesn't match, slow check for errors.
if regexp_matches(s, '[0-9]{11}|') = array[''] then
if s !~ '^[0-9]{11}$' then
for i in 1 .. 11 loop
declare
c text := substring(s, i, 1);
Expand Down

0 comments on commit e8639fd

Please sign in to comment.