delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2009/11/11/03:46:18

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Str|mberg <ams AT sister DOT ludd DOT ltu DOT se>
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: <hddtej$g02$1@aioe.org>
References: <0008cd2e-63c9-43cb-82d4-11aece7c209f AT c3g2000yqd DOT googlegroups DOT com> <200911100429 DOT nAA4T6BM021619 AT envy DOT delorie DOT com> <b74a4c40-3d78-4952-98b0-ff9777f0594d AT p35g2000yqh DOT googlegroups DOT com> <200911102010 DOT nAAKAxKI006111 AT envy DOT delorie DOT com> <ebf65bf7-5445-44cc-a73f-7dd40fbe49d3 AT v30g2000yqm DOT googlegroups 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 <rugxulo AT gmail DOT com> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019