diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-05-17 09:05:20 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-05-17 09:05:20 +0200 |
commit | e3a8295c5784d36e1a2b1fb0823fda164366e067 (patch) | |
tree | 6fe6da8f3cf0a87a98f0b5057aeba73c88716504 /lib | |
parent | c29e85f9a9ed0e6780a55891c0af77c0ead137d3 (diff) | |
download | libtasn1-e3a8295c5784d36e1a2b1fb0823fda164366e067.tar.gz libtasn1-e3a8295c5784d36e1a2b1fb0823fda164366e067.tar.bz2 libtasn1-e3a8295c5784d36e1a2b1fb0823fda164366e067.zip |
Revert "simplify ltostr()"
This reverts commit f93acf7f0a3f19692c71fc9022981b6f64ffdbc1.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parser_aux.c | 35 | ||||
-rw-r--r-- | lib/parser_aux.h | 8 |
2 files changed, 35 insertions, 8 deletions
diff --git a/lib/parser_aux.c b/lib/parser_aux.c index 2ca4e61..31d1770 100644 --- a/lib/parser_aux.c +++ b/lib/parser_aux.c @@ -531,6 +531,41 @@ _asn1_delete_list_and_nodes (void) } } + +char * +_asn1_ltostr (long v, char *str) +{ + long d, r; + char temp[20]; + int count, k, start; + + if (v < 0) + { + str[0] = '-'; + start = 1; + v = -v; + } + else + start = 0; + + count = 0; + do + { + d = v / 10; + r = v - d * 10; + temp[start + count] = '0' + (char) r; + count++; + v = d; + } + while (v); + + for (k = 0; k < count; k++) + str[k + start] = temp[start + count - k - 1]; + str[count + start] = 0; + return str; +} + + /******************************************************************/ /* Function : _asn1_change_integer_value */ /* Description: converts into DER coding the value assign to an */ diff --git a/lib/parser_aux.h b/lib/parser_aux.h index ee01725..f1e9a07 100644 --- a/lib/parser_aux.h +++ b/lib/parser_aux.h @@ -25,14 +25,6 @@ /***************************************/ /* Functions used by ASN.1 parser */ /***************************************/ - -inline static char * -_asn1_ltostr (long v, char *str) -{ - sprintf(str, "%ld", v); - return str; -} - asn1_node _asn1_add_static_node (unsigned int type); asn1_node |