Clinton and Jafar,

For my own understanding and for some modifications I am currently doing
to the unicon runtime system, I am going through the source code. C is
not my programming language and I am having to play catchup with how
people write C code as well as understanding it various foibles (of
which there are many). I have found the following couple of items (so
far) in relation to some macros that are used. Are you able to clarify
why the differences?

Found in src/h/rmacros.h

/*
 * Assign a C string to a descriptor. Assume it is reasonable to use the
 *   descriptor expression more than once, but not the string expression.
 */
#define AsgnCStr(d,s) (StrLoc(d) = (s), StrLen(d) = strlen(StrLoc(d)))

Found in src/runtime/rposix.r

#define String(d, s) do {           \
      int len = strlen(s);          \
      StrLoc(d) = alcstr((s), len); \
      StrLen(d) = len;              \
} while (0)

Found in src/runtime/fxposix.ri

#define String(d, s) do {                               \
      int len = strlen(s);                              \
      Protect(StrLoc(d) = alcstr((s), len), runerr(0)); \
      StrLen(d) = len;                                  \
} while (0)

Now both AsgnCStr(d,s) and the first String(d,s) are found in
src/runtime/rposix.r, my question is - should we look at rationalising
these macros into a single applicable macro or is there a specific
reason why there are different versions of what appears to be the same
function code?

Similarly, I have found the following for the macro tonum(c):

Found in src/icont/llex.c

#if !EBCDIC
   #define tonum(c)     (isdigit(c) ? (c - '0') : ((c & 037) + 9))
#endif                                  /* !EBCDIC */

Found in src/common/dconsole.c

#if !EBCDIC
   #define tonum(c)     (isdigit(c) ? (c)-'0' : 10+(((c)|(040))-'a'))
#endif

Found in src/common/yylex.h

#if !EBCDIC
   #define tonum(c)        (isdigit(c) ? (c - '0') : ((c & 037) + 9))
#endif                                  /* !EBCDIC */

Found in src/runtime/rlrgint.r

#if !EBCDIC
#define tonum(c)     (isdigit(c) ? (c)-'0' : 10+(((c)|(040))-'a'))
#endif                                  /* !EBCDIC */

Found in src/runtime/cnv.r

#if !EBCDIC
#define tonum(c)        (isdigit(c) ? (c)-'0' : 10+(((c)|(040))-'a'))
#endif                                  /* EBCDIC */

Again, variations on a theme, is there reasons for defining in so many
places and should these be combined into a single applicable common macro?

Any clarifications are appreciated. I have also noticed that there are a
number of places where a macro is defined that hides a procedure written
elsewhere and redirects the code to a field of a runtime structure that
contains a pointer to the original procedure. Is there specific
functional reasons for this or was this just a quick fixup to solve a
bug in a previous incarnation? The example I was following was the
alcstr macro in the String macro as shown above.

Finally a question relating to the preprocessor. The macro definition
facilities in the preprocessor are not very complete, no functional
macros for example. Is there any reason why M4 or its ilk (or even a
unicon version of M4) are not being used?



regards

Bruce Rennie





------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to