From: matze Date: Sun, 29 Jul 2007 01:12:19 +0000 (+0000) Subject: length check X-Git-Tag: rgb2rv6~73 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=70ac2eb0bf1c5a24b981f4494eceda431a18a660;p=c128-kasse length check git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@36 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/general.c b/general.c index 9f0c6c6..03bc576 100644 --- a/general.c +++ b/general.c @@ -29,7 +29,13 @@ char *get_input() { return output; } -char * format_euro(char * s, int cent){ +char * format_euro(char * s, int maxlen, int cent){ + int tmp = cent; + int len = 5; // 1 char at least + 4 (== strlen(",EUR")) + while ((tmp/=10) > 0) + len++; + if (len>maxlen) + return NULL; sprintf(s, "%d,%dEUR", cent/100, cent%100); return s; } diff --git a/general.h b/general.h index 1a607f1..6d55870 100644 --- a/general.h +++ b/general.h @@ -2,7 +2,7 @@ #define GENERAL_H_ typedef unsigned char BYTE; char *get_input(); -char * format_euro(char * s, int cent); +char * format_euro(char * s, int maxlen, int cent); void c128_perror(BYTE, char*); extern BYTE _oserror; #endif /*GENERAL_H_*/