home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / utils / bug / 2107 < prev    next >
Encoding:
Text File  |  1992-11-24  |  3.0 KB  |  115 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!black.clarku.edu!kbasye
  3. From: kbasye@black.clarku.edu (Ken Basye)
  4. Subject: Make 3.62 bugs
  5. Message-ID: <9211232229.AA26709@black.clarku.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: kbasye@black.clarku.edu
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Mon, 23 Nov 1992 12:29:37 GMT
  11. Approved: bug-gnu-utils@prep.ai.mit.edu
  12. Lines: 101
  13.  
  14. I have found what I believe are two bugs (or perhaps limitations) in
  15. GNU make 3.62.  Both bugs concern lack of error detection during the
  16. processing of conditionals.
  17.  
  18. The first bug is exercised by leaving the ENDIF off of a conditional.
  19. If the conditional has no ELSE, then the error is detected only when
  20. the condition is false.  If there is an ELSE, then the error is
  21. detected when the condition is true.  In either case, if the end of
  22. the file is reached while lines are being ignored, an error is
  23. signalled, whereas if eof is reached while lines are not being
  24. ignored, no error is signaled and lines are all processed.
  25.  
  26. The second bug is exercised by having a second ELSE following an
  27. IF-ELSE.  This should be an error, but is accepted without complaint,
  28. regardless of whether the condition is true or false.  
  29.  
  30. ifeq (cond)
  31.     body1
  32. else
  33.     body2
  34. else
  35.     body3
  36. endif
  37.  
  38. To further confuse things, if cond succeeds, then both body1 and body3
  39. are processed, while if cond fails, then only body2 is processed.  I
  40. discovered these bugs in the process of building a three-way switch,
  41. so that both body2 and body3 were also IF-ENDIF's.  
  42.  
  43. An example makefile with a correct three-way switch and two fragments
  44. illustrating the bugs follows.  Thanks very much for GNU make and all
  45. the other programs.
  46.     
  47. Sincerely,
  48.  
  49. kbasye@black.clarku.edu     
  50. Ken Basye
  51. Dept. of Math and CS
  52. Clark University
  53. 950 Main St.
  54. Worcester, MA  01610
  55.  
  56. ____________________________________________________________________
  57.  
  58. # Change this variable to vary conditions
  59. VAR = val3
  60.  
  61. CC1 = default
  62.  
  63. # This looks like the correct way to build a three-way switch.
  64. # It works the way it should.
  65. ifeq ($(VAR),val1)
  66.   CC1 = compiler1
  67. else 
  68.   ifeq ($(VAR),val2)
  69.     CC1 = compiler2
  70.   else 
  71.     ifeq ($(VAR),val3)
  72.       CC1 = g++
  73.     endif 
  74.   endif 
  75. endif 
  76.  
  77.  
  78. CC2 = default
  79. # This fragment should lose because the first IF has two
  80. # ELSE's.  The second ELSE cannot belong to the second IF, since that
  81. # is terminated by the first ENDIF.  This is accepted silently, and
  82. # the lines following the second ELSE are processed if the first
  83. # condition is true.  In this case, this has no effect.
  84. ifeq ($(VAR),val1)
  85.   CC2 = compiler1
  86. else 
  87.   ifeq ($(VAR),val2)
  88.     CC2 = compiler2
  89.   endif
  90. else
  91.   ifeq ($(VAR),val3)
  92.     CC2 = g++
  93.   endif
  94. endif
  95.  
  96. CC3 = default
  97.  
  98. # This fragment should lose because there is no ENDIF for the IF
  99. # It *does* lose if the test succeeds, but not if it fails.  This
  100. # behaviour is reversed if the ELSE is removed.
  101. #ifeq ($(VAR),val1)
  102. #  CC3 = compiler1
  103. #else 
  104. #  CC3 = g++
  105.  
  106.  
  107. test : 
  108.     echo $(VAR) $(CC1) $(CC2) $(CC3)
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.