Richard Levitte - VMS Whacker on  wrote...
| In message <[EMAIL PROTECTED]> on Tue, 10 May 2005 01:37:09 +0200, Rhialto 
<[EMAIL PROTECTED]> said:
| 
| rhialto> ifelse( TWM_TYPE, ctwm,                                              
    
| rhialto>   [define(CTWM_VERSION, substr(translit(                     
| rhialto>           substr(TWM_VERSION, 0, index(TWM_VERSION-, [-])), [.])000, 
0, 3) )dnl
| rhialto> ],[define(CTWM_VERSION, 0)dnl         
| rhialto> ])dnl
| rhialto> 
| rhialto> and this breaks now, since it expects the "-" to be there...
| 
| Replace that with the following:
| 
| ifelse( TWM_TYPE, ctwm,
|   [define(CTWM_VERSION, substr(translit(
|           substr(TWM_VERSION, 0, regexp(TWM_VERSION, [[-A-Za-z]])), [.])000,
|         0, 3) )dnl
| ],[define(CTWM_VERSION, 0)dnl
| ])dnl
| 

This code with the lines...
  changecom()dnl       # Do not remove comments from the result
  changequote([,])dnl  # m4 quoting interferes with shell escapes

does work,  however  regexp()  is not universial on all machines.
It is a GNU-ism.

Here is what I have...

=======8<--------CUT HERE----------axes/crowbars permitted---------------
dnl
dnl Convert version number to a 3 digit number, from versions such as...
dnl     3.5,  3.5.2, 3.6 or 3.7-alpha5  3.7beta4
dnl for use in ctwm version specific additions.  For example:
dnl    ifelse( eval( CTWM_VERSION >= 352 ), 1, [....], [.....])
dnl This is not easy, so I use multiple steps to achieve the goal.
ifelse( TWM_TYPE, ctwm, [dnl
define(TMP_A, translit(TWM_VERSION, [ab-], [~~~]))dnl
define(TMP_B, substr(TMP_A, 0, index(TMP_A[~], [~])))dnl
define(TMP_C, translit(TMP_B, [.]))dnl
define(TMP_D, substr(TMP_C[000], 0, 3))dnl
define(CTWM_VERSION, TMP_D)dnl
undefine(TMP_A)undefine(TMP_B)undefine(TMP_C)undefine(TMP_D)dnl
],[define(CTWM_VERSION, 0)])dnl
# [TWM_VERSION]  => "TWM_VERSION"
# [CTWM_VERSION] => "CTWM_VERSION"
#
=======8<--------CUT HERE----------axes/crowbars permitted---------------

Basicaly it replaces the characters with a special one, then looks for
that to find the index for the sub-string to junk.

ASIDE:  the old code also adds an extra space on the end of the define.

NOTE: this works fine in my "m4" runs, but ctwm seems to have problems
seeing the options wrapped like this for 3.7beta5.

   ifelse ( eval( CTWM_VERSION >= 360 ), 1, [dnl Only if CTWM  Version >= 3.6
   ...
   ])dnl

Does anyone have an idea why?


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
           Out testing new time machine. Be back yesterday!
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/

Reply via email to