X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Martin Str|mberg Newsgroups: comp.os.msdos.djgpp Subject: Re: GAS ".code16" and DJASM quirks ... Date: Wed, 11 Nov 2009 08:42:59 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 47 Message-ID: References: <0008cd2e-63c9-43cb-82d4-11aece7c209f AT c3g2000yqd DOT googlegroups DOT com> <200911100429 DOT nAA4T6BM021619 AT envy DOT delorie DOT com> <200911102010 DOT nAAKAxKI006111 AT envy DOT delorie DOT com> NNTP-Posting-Host: qaUouysPpK6BiNgOdUVuCg.user.aioe.org X-Complaints-To: abuse AT aioe DOT org X-Notice: Filtered by postfilter v. 0.8.0 Cancel-Lock: sha1:qRoAVcjzFYhJWrn0aMdhCQqwaqk= User-Agent: tin/1.4.7-20030322 ("Suggestions") (UNIX) (SunOS/5.9 (sun4u)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Rugxulo wrote: > ======================================= > *** tony_y.bk1 Tue Nov 10 17:37:22 2009 > --- tony.y Tue Nov 10 21:26:58 2009 > *************** > *** 2335,2340 **** > --- 2335,2341 ---- > { > int c, c2, i, oldc; > struct opcode *opp, op; > + char str[33], str2[33]; No. #define MAX 32 #define CHARS "0-9a-fA-FhHxX" char str[MAX+1+1], ... /* One for nul and one for "h"->"0x" transformation. */ char format[1+ sizeof("2147483647") /* INT_MAX */ +1+ sizeof(CHARS) +1+1]; sprintf(format "%%%d[%s]", MAX, CHARS); /* Possibly error handling here too. */ > ! fscanf(infile, "%[0-9a-fA-FhHxX]",str); fscanf(infile, format, str); > ! > ! if (str[strlen(str)-1] == 'h' || str[strlen(str)-1] == 'H') > ! { > ! str[strlen(str)-1]='\0'; > ! strcpy(str2,"0x"); > ! strcat(str2,str); Why not sprintf(str2, "0x%s", str)? /* Again some proper size! */ > ! strcpy(str,str2); > ! } > ! sscanf(str, "%i", &(yylval.i)); > ! > ! > #endif > sprintf(last_token, "%d", yylval.i); > return NUMBER; > ======================================= Thanks! MartinS