Re: [cc65] octal character constants bug (again :=P)

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-09-30 22:34:52


On Tue, Sep 30, 2003 at 10:05:16PM +0200, Groepaz wrote:
> can you (briefly :=P) tell what the standard says on that then? (ie, what are
> the properties of escaped numerics?) i thought that escaped numeric
> characters shouldnt be translated like this.... mmmmh. is this even defined
> at all? or is it implementation defined?
                                                      
    5.2.1 Character sets

    2 In a character constant or string literal, members of the execution
      character set shall be represented by corresponding members of the
      source character set or by escape sequences consisting of the backslash
      \ followed by one or more characters. A byte with all bits set to 0,
      called the null character, shall exist in the basic execution character
      set; it is used to terminate a character string.

I would interpret this as if the current behaviour of cc65 is correct. It's
also easy to remember: Any character or string constant is translated into the
target character set.

> however, i am
> still not quite sure if this translation should take place... what about
> binary data that's embedded into the c-program, translation would be fatal
> here? (maybe such thing is simply considered non portable by the standard?)

If you don't want the translation, don't use character constants. For binary
data it is not a good idea to use character constants, why not just use
numbers:

        printf("%3d : %3d\n",010,8);

works as expected.

> a) each character has exactly one corrosponding escaped numeric. since both
> will be translated, a check like ('A' == '\101') must work on all targets
> (ie, its portable)

Not exactly. Two characters of the source character set may be translated into
the same character of the execution character set. But you check will be ok.

> b) the same as a), but for escaped characters ('\n' etc)

The represenation of character like \n depends on the target platform, so a
check like ('\n' == '\101') depends on the target platform.

> c) a binary value does not need to corrospond to a character in the target
> characterset. comparison and/or assignments of binary values with/to
> characters/strings is dependend on the target characterset and thus not
> portable. (like the tests i have pasted :=P)

Yes, same as in b)

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-30 22:35:05 CEST