ad_page_contract_filter_proc_integer (public)

 ad_page_contract_filter_proc_integer name value_varname

Defined in packages/acs-tcl/tcl/tcl-documentation-procs.tcl

Checks whether the value is a valid integer, and removes any leading zeros so as not to confuse Tcl into thinking it's octal. Allows negative numbers.

Parameters:
name
value_varname
Author:
Lars Pind <lars@pinds.com>
Created:
25 July 2000

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_page_contract_filters ad_page_contract_filters (test acs-tcl) ad_page_contract_filter_proc_integer ad_page_contract_filter_proc_integer test_ad_page_contract_filters->ad_page_contract_filter_proc_integer _ _ (public) ad_page_contract_filter_proc_integer->_ ad_complain ad_complain (public) ad_page_contract_filter_proc_integer->ad_complain util::trim_leading_zeros util::trim_leading_zeros (public) ad_page_contract_filter_proc_integer->util::trim_leading_zeros

Testcases:
ad_page_contract_filters
Source code:
upvar $value_varname value

    #
    # We can't really use "string is integer -strict", since it allows
    # numbers, which are invalid for e.g. SQL... e.g. "0x40".
    #
    ## First simple a quick check avoiding the slow regexp
    #if {[string is integer -strict $value]} {
    #    return 1
    #}

    if { [regexp {^(-)?(\d+)$} $value _ sign rest] } {
        # Trim the value for any leading zeros
        set value $sign[util::trim_leading_zeros $rest]
        # the string might be still too large, so check again...
        if {[string is integer -strict $value]} {
            return 1
        }
    }
    ad_complain [_ acs-tcl.lt_name_is_not_an_intege]
    return 0
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: