Skip to content

glue substitution operator _ put into quotes produces unexpected result 20 1A 20 #327

@ped7g

Description

@ped7g
  DEFINE QUOTE "
  DEFINE FNAME file.bin
  INCBIN QUOTE _ FNAME _ QUOTE

Currently somewhat works, but the glues are not stripped, so they become part of the resulting string literal including the internal implementation binary value used to mark glues (20 1A 20 -> space, Control character: Substitute, space)

bug: look into glue processing, I think those glues should be processed as they were active during substitution before they have become part of string literal inside quotes.


This was found when discussing different options how to work with bare defines of filenames with Janko, like how to DISPLAY them, and there were some other ideas mentioned:

  INCBIN \"FNAME\" ; let substitution replace `\"` with quote and know that it should apply inside as well
  ; con: what about INCLUDE <FNAME> ? .. add also `\<` and `\>` to substitution rules?

  ; operators converting things into string literals:

  INCBIN STRING(FNAME) ; possible keyword collision with legacy symbol STRING

  INCBIN s(FNAME)  ; shorter, less likely to collide, probably better variant

  INCBIN ""(FNAME)  ; but FNAME can contain also `)`, so it would have to be escaped
    ; (and `)` in filename is not unlikely)

  ; somehow reusing the current macro args delimiter `<>` ... (it has escaping defined)

  ; all of these would produce `""` literal, so again no support for `include <system include>`

I guess "fixing" the glue is in the end least invasive, as that is very new feature anyway - if there's something to fix in the first place. So explore first this option. It puts pressure on user to know the trick with DEFINE QUOTE ", but otherwise seems to not need any other extension of anything.

The string literal operators look interesting, but feels like this should be then major change adding all kind of string manipulation operators, so the possible keyword clashes and regressions on legacy code bases are worth it. So string operators smell like v2.x. Glue fix smells like next version.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions