diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:30:49 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:30:49 +0000 |
commit | 6ca64b5cf2d4c0c2698d4298e88dde274f766ac4 (patch) | |
tree | c37af6ea1ae5159b8bea55a94b120359ba9188c3 /utils/static_utoa.h | |
parent | e1458e933f41a95bb5f98aeffbc15242ef7752f1 (diff) |
named_enum, itoa, cdec replace --a-b=x with --a_b=x
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@536 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/static_utoa.h')
-rwxr-xr-x | utils/static_utoa.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/utils/static_utoa.h b/utils/static_utoa.h index 3af9fbb6..d15ed35b 100755 --- a/utils/static_utoa.h +++ b/utils/static_utoa.h @@ -5,35 +5,19 @@ #include "utoa.h" namespace { +static const int utoa_bufsize=40; // 64bit safe. +static const int utoa_bufsizem1=utoa_bufsize-1; // 64bit safe. THREADLOCAL char utoa_buf[utoa_bufsize]; // to put end of string character at buf[20] } inline char *static_utoa(unsigned n) { + assert(utoa_buf[utoa_bufsizem1]==0); return utoa(utoa_buf+utoa_bufsizem1,n); } inline char *static_itoa(int n) { + assert(utoa_buf[utoa_bufsizem1]==0); return itoa(utoa_buf+utoa_bufsizem1,n); } -#ifdef ITOA_SAMPLE -# include <cstdio> -# include <sstream> -# include <iostream> -using namespace std; - -int main(int argc,char *argv[]) { - printf("d U d U d U\n"); - for (int i=1;i<argc;++i) { - int n; - unsigned un; - sscanf(argv[i],"%d",&n); - sscanf(argv[i],"%u",&un); - printf("%d %u %s",n,un,static_itoa(n)); - printf(" %s %s %s\n",static_utoa(un),itos(n).c_str(),utos(un).c_str()); - } - return 0; -} -#endif - #endif |