#184 Intrinsic preprocessor string support enhancements

open
nobody
None
5
2010-12-30
2010-12-30
p1ranha-rob
No

As a heavy preprocessor user, I would definitely like to see the addition of the following preprocessor additions.
Note that the syntax is in keeping with the current nasm preprocessor syntax:

%strchr  %%pos 'StringToSearch', 'x'            ; %%pos assigned 0
%strstr  %%pos  'StringToSearch', 'To'          ; %% pos assigned 7

as well as their case-insenstive counterparts:

%strchri  %%pos 'StringToSearch', 'X'
%strstri  %%pos  'StringtoSearch', 'TO'

Also nice to haves would be ctype.h is* functions - eg:

%isalpha %%bool 'X'       ; %%bool assigned 1
%isdigit %%bool 'X'         ; %%bool assigned 0
%isalnum %%bool 'X'
%ispunc %%bool 'X'
%isspace %%bool 'X'

where 'X' can be any preprocessor defined string variable or literal

Oh, and a regex command would be incredible

Discussion

  • nasm64developer

    nasm64developer - 2010-12-30

    > As a heavy preprocessor user, I would definitely like to see the addition
    > of the following preprocessor additions.
    > Note that the syntax is in keeping with the current nasm preprocessor
    > syntax:
    >
    > %strchr  %%pos 'StringToSearch', 'x'            ; %%pos assigned 0
    > %strstr  %%pos  'StringToSearch', 'To'          ; %% pos assigned 7
    >
    > as well as their case-insenstive counterparts:
    >
    > %strchri  %%pos 'StringToSearch', 'X'
    > %strstri  %%pos  'StringtoSearch', 'TO'

    I once added %STRPOS to my NASM version -- so yeah, this *is* useful. :-)

    Note that there is a difference between C and NASM when it comes to what
    that "i" means. In C you will get case-insensitive comparisons. In NASM you
    will get a result with a case-insensitive name.

    > Also nice to haves would be ctype.h is* functions - eg:
    >
    > %isalpha %%bool 'X'       ; %%bool assigned 1
    > %isdigit %%bool 'X'         ; %%bool assigned 0
    > %isalnum %%bool 'X'
    > %ispunc %%bool 'X'
    > %isspace %%bool 'X'
    >
    > where 'X' can be any preprocessor defined string variable or literal

    You would probably want to match C, i.e. require single character operands.

    Also, NASM does have %if[id|num|str|token|empty], %strlen, and %substr. So
    most of you you are looking for can already be implemented with macros.

    > Oh, and a regex command would be incredible

    You'd end up picking one of many regex standards or implementations.

    Also, you might as well go for %SYSTEM ... to execute arbitrary things.

    Personally I believe that regex support is best left to tools other than NASM.

     
  • H. Peter Anvin

    H. Peter Anvin - 2011-01-03

    These and a lot of other things would be nicer to have as preprocessor functions; the existing "define a single-line macro" stuff really is an ugly hack.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks