Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. /* asmerr.c */
  2. /*****************************************************************************/
  3. /* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
  4. /*                                                                           */
  5. /* AS-Portierung                                                             */
  6. /*                                                                           */
  7. /* Error Message Writing                                                     */
  8. /*                                                                           */
  9. /*****************************************************************************/
  10.  
  11.  
  12. #include "stdinc.h"
  13. #include <string.h>
  14. #include <ctype.h>
  15. #include <stdarg.h>
  16.  
  17. #include "asmdef.h"
  18. #include "asmsub.h"
  19. #include "asmpars.h"
  20. #include "console.h"
  21. #include "strutil.h"
  22. #include "nlmessages.h"
  23. #include "stdhandl.h"
  24. #include "as.h"
  25. #include "as.rsc"
  26. #include "ioerrs.h"
  27. #include "cmdarg.h"
  28. #include "asmerr.h"
  29.  
  30. typedef struct sExpectError
  31. {
  32.   struct sExpectError *pNext;
  33.   tErrorNum Num;
  34. } tExpectError;
  35.  
  36. Word ErrorCount, WarnCount;
  37. static tExpectError *pExpectErrors = NULL;
  38. static Boolean InExpect = False;
  39. static Boolean treat_warnings_as_errors,
  40.                warn_sign_extension;
  41.  
  42. static void ClearExpectErrors(void)
  43. {
  44.   tExpectError *pOld;
  45.  
  46.   while (pExpectErrors)
  47.   {
  48.     pOld = pExpectErrors;
  49.     pExpectErrors = pExpectErrors->pNext;
  50.     free(pOld);
  51.   }
  52. }
  53.  
  54. static void AddExpectError(tExpectError *pExpectError)
  55. {
  56.   pExpectError->pNext = pExpectErrors;
  57.   pExpectErrors = pExpectError;
  58. }
  59.  
  60. /*!------------------------------------------------------------------------
  61.  * \fn     FindAndTakeExpectError(tErrorNum Num)
  62.  * \brief  check whether a certain error was expected
  63.  * \param  Num number of error message that was expected
  64.  * \return True if ther was an expectation
  65.  * ------------------------------------------------------------------------ */
  66.  
  67. Boolean FindAndTakeExpectError(tErrorNum Num)
  68. {
  69.   tExpectError *pRun, *pPrev;
  70.  
  71.   for (pRun = pExpectErrors, pPrev = NULL; pRun; pPrev = pRun, pRun = pRun->pNext)
  72.     if (Num == pRun->Num)
  73.     {
  74.       if (pPrev)
  75.         pPrev->pNext = pRun->pNext;
  76.       else
  77.         pExpectErrors = pRun->pNext;
  78.       free(pRun);
  79.       return True;
  80.     }
  81.   return False;
  82. }
  83.  
  84. /*!------------------------------------------------------------------------
  85.  * \fn     GenLineMarker(char *pDest, unsigned DestSize, char Marker, const struct sLineComp *pLineComp, * const char *pPrefix)
  86.  * \brief  print a line, optionally with a marking of a component below
  87.  * \param  pDest where to write
  88.  * \param  DestSize destination buffer size
  89.  * \param  Marker character to use for marking
  90.  * \param  pLineComp position and length of optional marker
  91.  * \param  pPrefix what to print before (under)line
  92.  * ------------------------------------------------------------------------ */
  93.  
  94. static void GenLineMarker(char *pDest, unsigned DestSize, char Marker, const struct sLineComp *pLineComp, const char *pPrefix)
  95. {
  96.   char *pRun;
  97.   int z;
  98.  
  99.   strmaxcpy(pDest, pPrefix, DestSize);
  100.   pRun = pDest + strlen(pDest);
  101.  
  102.   for (z = 0; (z < pLineComp->StartCol) && (pRun - pDest + 1 < (int)DestSize); z++)
  103.     *pRun++ = ' ';
  104.   for (z = 0; (z < (int)pLineComp->Len) && (pRun - pDest + 1 < (int)DestSize); z++)
  105.     *pRun++ = Marker;
  106.   *pRun = '\0';
  107. }
  108.  
  109. /*!------------------------------------------------------------------------
  110.  * \fn     GenLineForMarking(char *pDest, unsigned DestSize, const char *pSrc, const char *pPrefix)
  111.  * \brief  generate a line, in compressed form for optional marking of a component below
  112.  * \param  pDest where to write
  113.  * \param  DestSize destination buffer size
  114.  * \param  pSrc line to print/underline
  115.  * \param  pPrefix what to print before (under)line
  116.  * ------------------------------------------------------------------------ */
  117.  
  118. static void GenLineForMarking(char *pDest, unsigned DestSize, const char *pSrc, const char *pPrefix)
  119. {
  120.   char *pRun;
  121.  
  122.   strmaxcpy(pDest, pPrefix, DestSize);
  123.   pRun = pDest + strlen(pDest);
  124.  
  125.   /* replace TABs in line with spaces - column counting counts TAB as one character */
  126.  
  127.   for (; *pSrc && (pRun - pDest + 1 < (int)DestSize); pSrc++)
  128.     *pRun++ = TabCompressed(*pSrc);
  129.   *pRun = '\0';
  130. }
  131.  
  132. /*!------------------------------------------------------------------------
  133.  * \fn     EmergencyStop(void)
  134.  * \brief  instantly stop upon fatal error
  135.  * ------------------------------------------------------------------------ */
  136.  
  137. static void EmergencyStop(void)
  138. {
  139.   CloseIfOpen(&ErrorFile);
  140.   CloseIfOpen(&LstFile);
  141.   if (ShareMode != 0)
  142.   {
  143.     CloseIfOpen(&ShareFile);
  144.     unlink(ShareName);
  145.   }
  146.   if (MacProOutput)
  147.   {
  148.     CloseIfOpen(&MacProFile);
  149.     unlink(MacProName);
  150.   }
  151.   if (MacroOutput)
  152.   {
  153.     CloseIfOpen(&MacroFile);
  154.     unlink(MacroName);
  155.   }
  156.   if (MakeDebug)
  157.     CloseIfOpen(&Debug);
  158.   if (CodeOutput)
  159.   {
  160.     CloseIfOpen(&PrgFile);
  161.     unlink(OutName);
  162.   }
  163. }
  164.  
  165. /*!------------------------------------------------------------------------
  166.  * \fn     ErrorNum2String(tErrorNum Num, char Buf, int BufSize)
  167.  * \brief  convert error # to string
  168.  * \param  Num numeric error
  169.  * \param  Buf buffer for complex messages
  170.  * \param  BufSize capacity of Buf
  171.  * \return * to message
  172.  * ------------------------------------------------------------------------ */
  173.  
  174. static const char *ErrorNum2String(tErrorNum Num, char *Buf, int BufSize)
  175. {
  176.   int msgno = -1;
  177.  
  178.   *Buf = '\0';
  179.   switch (Num)
  180.   {
  181.     case ErrNum_UselessDisp:
  182.       msgno = Num_ErrMsgUselessDisp; break;
  183.     case ErrNum_ShortAddrPossible:
  184.       msgno = Num_ErrMsgShortAddrPossible; break;
  185.     case ErrNum_ShortJumpPossible:
  186.       msgno = Num_ErrMsgShortJumpPossible; break;
  187.     case ErrNum_NoShareFile:
  188.       msgno = Num_ErrMsgNoShareFile; break;
  189.     case ErrNum_BigDecFloat:
  190.       msgno = Num_ErrMsgBigDecFloat; break;
  191.     case ErrNum_PrivOrder:
  192.       msgno = Num_ErrMsgPrivOrder; break;
  193.     case ErrNum_DistNull:
  194.       msgno = Num_ErrMsgDistNull; break;
  195.     case ErrNum_WrongSegment:
  196.       msgno = Num_ErrMsgWrongSegment; break;
  197.     case ErrNum_InAccSegment:
  198.       msgno = Num_ErrMsgInAccSegment; break;
  199.     case ErrNum_PhaseErr:
  200.       msgno = Num_ErrMsgPhaseErr; break;
  201.     case ErrNum_Overlap:
  202.       msgno = Num_ErrMsgOverlap; break;
  203.     case ErrNum_OverlapReg:
  204.       msgno = Num_ErrMsgOverlapReg; break;
  205.     case ErrNum_NoCaseHit:
  206.       msgno = Num_ErrMsgNoCaseHit; break;
  207.     case ErrNum_InAccPage:
  208.       msgno = Num_ErrMsgInAccPage; break;
  209.     case ErrNum_RMustBeEven:
  210.       msgno = Num_ErrMsgRMustBeEven; break;
  211.     case ErrNum_Obsolete:
  212.       msgno = Num_ErrMsgObsolete; break;
  213.     case ErrNum_Unpredictable:
  214.       msgno = Num_ErrMsgUnpredictable; break;
  215.     case ErrNum_AlphaNoSense:
  216.       msgno = Num_ErrMsgAlphaNoSense; break;
  217.     case ErrNum_Senseless:
  218.       msgno = Num_ErrMsgSenseless; break;
  219.     case ErrNum_RepassUnknown:
  220.       msgno = Num_ErrMsgRepassUnknown; break;
  221.     case  ErrNum_AddrNotAligned:
  222.       msgno = Num_ErrMsgAddrNotAligned; break;
  223.     case ErrNum_IOAddrNotAllowed:
  224.       msgno = Num_ErrMsgIOAddrNotAllowed; break;
  225.     case ErrNum_Pipeline:
  226.       msgno = Num_ErrMsgPipeline; break;
  227.     case ErrNum_DoubleAdrRegUse:
  228.       msgno = Num_ErrMsgDoubleAdrRegUse; break;
  229.     case ErrNum_NotBitAddressable:
  230.       msgno = Num_ErrMsgNotBitAddressable; break;
  231.     case ErrNum_StackNotEmpty:
  232.       msgno = Num_ErrMsgStackNotEmpty; break;
  233.     case ErrNum_NULCharacter:
  234.       msgno = Num_ErrMsgNULCharacter; break;
  235.     case ErrNum_PageCrossing:
  236.       msgno = Num_ErrMsgPageCrossing; break;
  237.     case ErrNum_WUnderRange:
  238.       msgno = Num_ErrMsgWUnderRange; break;
  239.     case ErrNum_WOverRange:
  240.       msgno = Num_ErrMsgWOverRange; break;
  241.     case ErrNum_NegDUP:
  242.       msgno = Num_ErrMsgNegDUP; break;
  243.     case ErrNum_ConvIndX:
  244.       msgno = Num_ErrMsgConvIndX; break;
  245.     case ErrNum_NullResMem:
  246.       msgno = Num_ErrMsgNullResMem; break;
  247.     case ErrNum_BitNumberTruncated:
  248.       msgno = Num_ErrMsgBitNumberTruncated; break;
  249.     case ErrNum_InvRegisterPointer:
  250.       msgno = Num_ErrMsgInvRegisterPointer; break;
  251.     case ErrNum_MacArgRedef:
  252.       msgno = Num_ErrMsgMacArgRedef; break;
  253.     case ErrNum_Deprecated:
  254.       msgno = Num_ErrMsgDeprecated; break;
  255.     case ErrNum_SrcLEThanDest:
  256.       msgno = Num_ErrMsgSrcLEThanDest; break;
  257.     case ErrNum_TrapValidInstruction:
  258.       msgno = Num_ErrMsgTrapValidInstruction; break;
  259.     case ErrNum_PaddingAdded:
  260.       msgno = Num_ErrMsgPaddingAdded; break;
  261.     case ErrNum_RegNumWraparound:
  262.       msgno = Num_ErrMsgRegNumWraparound; break;
  263.     case ErrNum_IndexedForIndirect:
  264.       msgno = Num_ErrMsgIndexedForIndirect; break;
  265.     case ErrNum_NotInNormalMode:
  266.       msgno = Num_ErrMsgNotInNormalMode; break;
  267.     case ErrNum_NotInPanelMode:
  268.       msgno = Num_ErrMsgNotInPanelMode; break;
  269.     case ErrNum_ArgOutOfRange:
  270.       msgno = Num_ErrMsgArgOutOfRange; break;
  271.     case ErrNum_TrySkipMultiwordInstruction:
  272.       msgno = Num_ErrMsgTrySkipMultiwordInstruction; break;
  273.     case ErrNum_SignExtension:
  274.       msgno = Num_ErrMsgSignExtension; break;
  275.     case ErrNum_MeansE:
  276.       msgno = Num_ErrMsgMeansE; break;
  277.     case ErrNum_NeedShortIO:
  278.       msgno = Num_ErrMsgNeedShortIO; break;
  279.     case ErrNum_DoubleDef:
  280.       msgno = Num_ErrMsgDoubleDef; break;
  281.     case ErrNum_SymbolUndef:
  282.       msgno = Num_ErrMsgSymbolUndef; break;
  283.     case ErrNum_InvSymName:
  284.       msgno = Num_ErrMsgInvSymName; break;
  285.     case ErrNum_InvFormat:
  286.       msgno = Num_ErrMsgInvFormat; break;
  287.     case ErrNum_UseLessAttr:
  288.       msgno = Num_ErrMsgUseLessAttr; break;
  289.     case ErrNum_TooLongAttr:
  290.       msgno = Num_ErrMsgTooLongAttr; break;
  291.     case ErrNum_UndefAttr:
  292.       msgno = Num_ErrMsgUndefAttr; break;
  293.     case ErrNum_WrongArgCnt:
  294.       msgno = Num_ErrMsgWrongArgCnt; break;
  295.     case ErrNum_CannotSplitArg:
  296.       msgno = Num_ErrMsgCannotSplitArg; break;
  297.     case ErrNum_WrongOptCnt:
  298.       msgno = Num_ErrMsgWrongOptCnt; break;
  299.     case ErrNum_OnlyImmAddr:
  300.       msgno = Num_ErrMsgOnlyImmAddr; break;
  301.     case ErrNum_InvOpSize:
  302.       msgno = Num_ErrMsgInvOpSize; break;
  303.     case ErrNum_ConfOpSizes:
  304.       msgno = Num_ErrMsgConfOpSizes; break;
  305.     case ErrNum_UndefOpSizes:
  306.       msgno = Num_ErrMsgUndefOpSizes; break;
  307.     case ErrNum_StringOrIntButFloat:
  308.       msgno = Num_ErrMsgStringOrIntButFloat; break;
  309.     case ErrNum_IntButFloat:
  310.       msgno = Num_ErrMsgIntButFloat; break;
  311.     case ErrNum_FloatButString:
  312.       msgno = Num_ErrMsgFloatButString; break;
  313.     case ErrNum_OpTypeMismatch:
  314.       msgno = Num_ErrMsgOpTypeMismatch; break;
  315.     case ErrNum_StringButInt:
  316.       msgno = Num_ErrMsgStringButInt; break;
  317.     case ErrNum_StringButFloat:
  318.       msgno = Num_ErrMsgStringButFloat; break;
  319.     case ErrNum_TooManyArgs:
  320.       msgno = Num_ErrMsgTooManyArgs; break;
  321.     case ErrNum_IntButString:
  322.       msgno = Num_ErrMsgIntButString; break;
  323.     case ErrNum_IntOrFloatButString:
  324.       msgno = Num_ErrMsgIntOrFloatButString; break;
  325.     case ErrNum_ExpectString:
  326.       msgno = Num_ErrMsgExpectString; break;
  327.     case ErrNum_ExpectInt:
  328.       msgno = Num_ErrMsgExpectInt; break;
  329.     case ErrNum_StringOrIntOrFloatButReg:
  330.       msgno = Num_ErrMsgStringOrIntOrFloatButReg; break;
  331.     case ErrNum_ExpectIntOrString:
  332.       msgno = Num_ErrMsgExpectIntOrString; break;
  333.     case ErrNum_ExpectReg:
  334.       msgno = Num_ErrMsgExpectReg; break;
  335.     case ErrNum_RegWrongTarget:
  336.       msgno = Num_ErrMsgRegWrongTarget; break;
  337.     case ErrNum_FloatButInt:
  338.       msgno = Num_ErrMsgFloatButInt; break;
  339.     case ErrNum_NoRelocs:
  340.       msgno = Num_ErrMsgNoRelocs; break;
  341.     case ErrNum_IntOrFloatButReg:
  342.       msgno = Num_ErrMsgIntOrFloatButReg; break;
  343.     case ErrNum_IntOrStringButReg:
  344.       msgno = Num_ErrMsgIntOrStringButReg; break;
  345.     case ErrNum_IntButReg:
  346.       msgno = Num_ErrMsgIntButReg; break;
  347.     case ErrNum_UnresRelocs:
  348.       msgno = Num_ErrMsgUnresRelocs; break;
  349.     case ErrNum_Unexportable:
  350.       msgno = Num_ErrMsgUnexportable; break;
  351.     case ErrNum_UnknownInstruction:
  352.       msgno = Num_ErrMsgUnknownInstruction; break;
  353.     case ErrNum_BrackErr:
  354.       msgno = Num_ErrMsgBrackErr; break;
  355.     case ErrNum_DivByZero:
  356.       msgno = Num_ErrMsgDivByZero; break;
  357.     case ErrNum_UnderRange:
  358.       msgno = Num_ErrMsgUnderRange; break;
  359.     case ErrNum_OverRange:
  360.       msgno = Num_ErrMsgOverRange; break;
  361.     case ErrNum_NotPwr2:
  362.       msgno = Num_ErrMsgNotPwr2; break;
  363.     case ErrNum_NotAligned:
  364.       msgno = Num_ErrMsgNotAligned; break;
  365.     case ErrNum_DistTooBig:
  366.       msgno = Num_ErrMsgDistTooBig; break;
  367.     case ErrNum_TargOnDiffPage:
  368.       msgno = Num_ErrMsgTargOnDiffPage; break;
  369.     case ErrNum_InAccReg:
  370.       msgno = Num_ErrMsgInAccReg; break;
  371.     case ErrNum_NoShortAddr:
  372.       msgno = Num_ErrMsgNoShortAddr; break;
  373.     case ErrNum_InvAddrMode:
  374.       msgno = Num_ErrMsgInvAddrMode; break;
  375.     case ErrNum_AddrMustBeEven:
  376.       msgno = Num_ErrMsgAddrMustBeEven; break;
  377.     case ErrNum_AddrMustBeAligned:
  378.       msgno = Num_ErrMsgAddrMustBeAligned; break;
  379.     case ErrNum_InvParAddrMode:
  380.       msgno = Num_ErrMsgInvParAddrMode; break;
  381.     case ErrNum_UndefCond:
  382.       msgno = Num_ErrMsgUndefCond; break;
  383.     case ErrNum_IncompCond:
  384.       msgno = Num_ErrMsgIncompCond; break;
  385.     case ErrNum_UnknownFlag:
  386.       msgno = Num_ErrMsgUnknownFlag; break;
  387.     case ErrNum_DuplicateFlag:
  388.       msgno = Num_ErrMsgDuplicateFlag; break;
  389.     case ErrNum_UnknownInt:
  390.       msgno = Num_ErrMsgUnknownInt; break;
  391.     case ErrNum_DuplicateInt:
  392.       msgno = Num_ErrMsgDuplicateInt; break;
  393.     case ErrNum_JmpDistTooBig:
  394.       msgno = Num_ErrMsgJmpDistTooBig; break;
  395.     case ErrNum_JmpDistIsZero:
  396.       msgno = Num_ErrMsgJmpDistIsZero; break;
  397.     case ErrNum_DistIsOdd:
  398.       msgno = Num_ErrMsgDistIsOdd; break;
  399.     case ErrNum_SkipTargetMismatch:
  400.       msgno = Num_ErrMsgSkipTargetMismatch; break;
  401.     case ErrNum_InvShiftArg:
  402.       msgno = Num_ErrMsgInvShiftArg; break;
  403.     case ErrNum_Only1:
  404.       msgno = Num_ErrMsgOnly1; break;
  405.     case ErrNum_Range18:
  406.       msgno = Num_ErrMsgRange18; break;
  407.     case ErrNum_ShiftCntTooBig:
  408.       msgno = Num_ErrMsgShiftCntTooBig; break;
  409.     case ErrNum_InvRegList:
  410.       msgno = Num_ErrMsgInvRegList; break;
  411.     case ErrNum_InvCmpMode:
  412.       msgno = Num_ErrMsgInvCmpMode; break;
  413.     case ErrNum_InvCPUType:
  414.       msgno = Num_ErrMsgInvCPUType; break;
  415.     case ErrNum_InvFPUType:
  416.       msgno = Num_ErrMsgInvFPUType; break;
  417.     case ErrNum_InvPMMUType:
  418.       msgno = Num_ErrMsgInvPMMUType; break;
  419.     case ErrNum_InvCtrlReg:
  420.       msgno = Num_ErrMsgInvCtrlReg; break;
  421.     case ErrNum_InvReg:
  422.       msgno = Num_ErrMsgInvReg; break;
  423.     case ErrNum_DoubleReg:
  424.       msgno = Num_ErrMsgDoubleReg; break;
  425.     case ErrNum_RegBankMismatch:
  426.       msgno = Num_ErrMsgRegBankMismatch; break;
  427.     case ErrNum_UndefRegSize:
  428.       msgno = Num_ErrMsgUndefRegSize; break;
  429.     case ErrNum_InvOpOnReg:
  430.       msgno = Num_ErrMsgInvOpOnReg; break;
  431.     case ErrNum_NoSaveFrame:
  432.       msgno = Num_ErrMsgNoSaveFrame; break;
  433.     case ErrNum_NoRestoreFrame:
  434.       msgno = Num_ErrMsgNoRestoreFrame; break;
  435.     case ErrNum_UnknownMacArg:
  436.       msgno = Num_ErrMsgUnknownMacArg; break;
  437.     case ErrNum_MissEndif:
  438.       msgno = Num_ErrMsgMissEndif; break;
  439.     case ErrNum_InvIfConst:
  440.       msgno = Num_ErrMsgInvIfConst; break;
  441.     case ErrNum_DoubleSection:
  442.       msgno = Num_ErrMsgDoubleSection; break;
  443.     case ErrNum_InvSection:
  444.       msgno = Num_ErrMsgInvSection; break;
  445.     case ErrNum_MissingEndSect:
  446.       msgno = Num_ErrMsgMissingEndSect; break;
  447.     case ErrNum_WrongEndSect:
  448.       msgno = Num_ErrMsgWrongEndSect; break;
  449.     case ErrNum_NotInSection:
  450.       msgno = Num_ErrMsgNotInSection; break;
  451.     case ErrNum_UndefdForward:
  452.       msgno = Num_ErrMsgUndefdForward; break;
  453.     case ErrNum_ContForward:
  454.       msgno = Num_ErrMsgContForward; break;
  455.     case ErrNum_InvFuncArgCnt:
  456.       msgno = Num_ErrMsgInvFuncArgCnt; break;
  457.     case ErrNum_MsgMissingLTORG:
  458.       msgno = Num_ErrMsgMissingLTORG; break;
  459.     case ErrNum_InstructionNotSupported:
  460.       as_snprintf(Buf, BufSize, getmessage(Num_ErrMsgInstructionNotOnThisCPUSupported), MomCPUIdent);
  461.       break;
  462.     case ErrNum_FPUNotEnabled:
  463.       msgno = Num_ErrMsgFPUNotEnabled; break;
  464.     case ErrNum_PMMUNotEnabled:
  465.       msgno = Num_ErrMsgPMMUNotEnabled; break;
  466.     case ErrNum_FullPMMUNotEnabled:
  467.       msgno = Num_ErrMsgFullPMMUNotEnabled; break;
  468.     case ErrNum_Z80SyntaxNotEnabled:
  469.       msgno = Num_ErrMsgZ80SyntaxNotEnabled; break;
  470.     case ErrNum_Z80SyntaxExclusive:
  471.       msgno = Num_ErrMsgZ80SyntaxExclusive; break;
  472.     case ErrNum_FPUInstructionNotSupported:
  473.       as_snprintf(Buf, BufSize, getmessage(Num_ErrMsgInstructionNotOnThisFPUSupported), MomFPUIdent);
  474.       break;
  475.     case ErrNum_AddrModeNotSupported:
  476.       as_snprintf(Buf, BufSize, getmessage(Num_ErrMsgAddrModeNotOnThisCPUSupported), MomCPUIdent);
  477.       break;
  478.     case ErrNum_CustomNotEnabled:
  479.       msgno = Num_ErrMsgCustomNotEnabled; break;
  480.     case ErrNum_InvBitPos:
  481.       msgno = Num_ErrMsgInvBitPos; break;
  482.     case ErrNum_OnlyOnOff:
  483.       msgno = Num_ErrMsgOnlyOnOff; break;
  484.     case ErrNum_StackEmpty:
  485.       msgno = Num_ErrMsgStackEmpty; break;
  486.     case ErrNum_NotOneBit:
  487.       msgno = Num_ErrMsgNotOneBit; break;
  488.     case ErrNum_MissingStruct:
  489.       msgno = Num_ErrMsgMissingStruct; break;
  490.     case ErrNum_OpenStruct:
  491.       msgno = Num_ErrMsgOpenStruct; break;
  492.     case ErrNum_WrongStruct:
  493.       msgno = Num_ErrMsgWrongStruct; break;
  494.     case ErrNum_PhaseDisallowed:
  495.       msgno = Num_ErrMsgPhaseDisallowed; break;
  496.     case ErrNum_InvStructDir:
  497.       msgno = Num_ErrMsgInvStructDir; break;
  498.     case ErrNum_DoubleStruct:
  499.       msgno = Num_ErrMsgDoubleStruct; break;
  500.     case ErrNum_UnresolvedStructRef:
  501.       msgno = Num_ErrMsgUnresolvedStructRef; break;
  502.     case ErrNum_DuplicateStructElem:
  503.       msgno = Num_ErrMsgDuplicateStructElem; break;
  504.     case ErrNum_NotRepeatable:
  505.       msgno = Num_ErrMsgNotRepeatable; break;
  506.     case ErrNum_ShortRead:
  507.       msgno = Num_ErrMsgShortRead; break;
  508.     case ErrNum_UnknownCodepage:
  509.       msgno = Num_ErrMsgUnknownCodepage; break;
  510.     case ErrNum_RomOffs063:
  511.       msgno = Num_ErrMsgRomOffs063; break;
  512.     case ErrNum_InvFCode:
  513.       msgno = Num_ErrMsgInvFCode; break;
  514.     case ErrNum_InvFMask:
  515.       msgno = Num_ErrMsgInvFMask; break;
  516.     case ErrNum_InvMMUReg:
  517.       msgno = Num_ErrMsgInvMMUReg; break;
  518.     case ErrNum_Level07:
  519.       msgno = Num_ErrMsgLevel07; break;
  520.     case ErrNum_InvBitMask:
  521.       msgno = Num_ErrMsgInvBitMask; break;
  522.     case ErrNum_InvRegPair:
  523.       msgno = Num_ErrMsgInvRegPair; break;
  524.     case ErrNum_OpenMacro:
  525.       msgno = Num_ErrMsgOpenMacro; break;
  526.     case ErrNum_OpenIRP:
  527.       msgno = Num_ErrMsgOpenIRP; break;
  528.     case ErrNum_OpenIRPC:
  529.       msgno = Num_ErrMsgOpenIRPC; break;
  530.     case ErrNum_OpenREPT:
  531.       msgno = Num_ErrMsgOpenREPT; break;
  532.     case ErrNum_OpenWHILE:
  533.       msgno = Num_ErrMsgOpenWHILE; break;
  534.     case ErrNum_EXITMOutsideMacro:
  535.       msgno = Num_ErrMsgEXITMOutsideMacro; break;
  536.     case ErrNum_TooManyMacParams:
  537.       msgno = Num_ErrMsgTooManyMacParams; break;
  538.     case ErrNum_UndefKeyArg:
  539.       msgno = Num_ErrMsgUndefKeyArg; break;
  540.     case ErrNum_NoPosArg:
  541.       msgno = Num_ErrMsgNoPosArg; break;
  542.     case ErrNum_DoubleMacro:
  543.       msgno = Num_ErrMsgDoubleMacro; break;
  544.     case ErrNum_FirstPassCalc:
  545.       msgno = Num_ErrMsgFirstPassCalc; break;
  546.     case ErrNum_TooManyNestedIfs:
  547.       msgno = Num_ErrMsgTooManyNestedIfs; break;
  548.     case ErrNum_MissingIf:
  549.       msgno = Num_ErrMsgMissingIf; break;
  550.     case ErrNum_RekMacro:
  551.       msgno = Num_ErrMsgRekMacro; break;
  552.     case ErrNum_UnknownFunc:
  553.       msgno = Num_ErrMsgUnknownFunc; break;
  554.     case ErrNum_InvFuncArg:
  555.       msgno = Num_ErrMsgInvFuncArg; break;
  556.     case ErrNum_FloatOverflow:
  557.       msgno = Num_ErrMsgFloatOverflow; break;
  558.     case ErrNum_InvArgPair:
  559.       msgno = Num_ErrMsgInvArgPair; break;
  560.     case ErrNum_NotOnThisAddress:
  561.       msgno = Num_ErrMsgNotOnThisAddress; break;
  562.     case ErrNum_NotFromThisAddress:
  563.       msgno = Num_ErrMsgNotFromThisAddress; break;
  564.     case ErrNum_JmpTargOnDiffPage:
  565.       msgno = Num_ErrMsgJmpTargOnDiffPage; break;
  566.     case ErrNum_TargOnDiffSection:
  567.       msgno = Num_ErrMsgTargOnDiffSection; break;
  568.     case ErrNum_CodeOverflow:
  569.       msgno = Num_ErrMsgCodeOverflow; break;
  570.     case ErrNum_AdrOverflow:
  571.       msgno = Num_ErrMsgAdrOverflow; break;
  572.     case ErrNum_MixDBDS:
  573.       msgno = Num_ErrMsgMixDBDS; break;
  574.     case ErrNum_NotInStruct:
  575.       msgno = Num_ErrMsgNotInStruct; break;
  576.     case ErrNum_ParNotPossible:
  577.       msgno = Num_ErrMsgParNotPossible; break;
  578.     case ErrNum_InvSegment:
  579.       msgno = Num_ErrMsgInvSegment; break;
  580.     case ErrNum_UnknownSegment:
  581.       msgno = Num_ErrMsgUnknownSegment; break;
  582.     case ErrNum_UnknownSegReg:
  583.       msgno = Num_ErrMsgUnknownSegReg; break;
  584.     case ErrNum_InvString:
  585.       msgno = Num_ErrMsgInvString; break;
  586.     case ErrNum_InvRegName:
  587.       msgno = Num_ErrMsgInvRegName; break;
  588.     case ErrNum_InvArg:
  589.       msgno = Num_ErrMsgInvArg; break;
  590.     case ErrNum_NoIndir:
  591.       msgno = Num_ErrMsgNoIndir; break;
  592.     case ErrNum_NotInThisSegment:
  593.       msgno = Num_ErrMsgNotInThisSegment; break;
  594.     case ErrNum_NotInMaxmode:
  595.       msgno = Num_ErrMsgNotInMaxmode; break;
  596.     case ErrNum_OnlyInMaxmode:
  597.       msgno = Num_ErrMsgOnlyInMaxmode; break;
  598.     case ErrNum_PackCrossBoundary:
  599.       msgno = Num_ErrMsgPackCrossBoundary; break;
  600.     case ErrNum_UnitMultipleUsed:
  601.       msgno = Num_ErrMsgUnitMultipleUsed; break;
  602.     case ErrNum_MultipleLongRead:
  603.       msgno = Num_ErrMsgMultipleLongRead; break;
  604.     case ErrNum_MultipleLongWrite:
  605.       msgno = Num_ErrMsgMultipleLongWrite; break;
  606.     case ErrNum_LongReadWithStore:
  607.       msgno = Num_ErrMsgLongReadWithStore; break;
  608.     case ErrNum_TooManyRegisterReads:
  609.       msgno = Num_ErrMsgTooManyRegisterReads; break;
  610.     case ErrNum_OverlapDests:
  611.       msgno = Num_ErrMsgOverlapDests; break;
  612.     case ErrNum_TooManyBranchesInExPacket:
  613.       msgno = Num_ErrMsgTooManyBranchesInExPacket; break;
  614.     case ErrNum_CannotUseUnit:
  615.       msgno = Num_ErrMsgCannotUseUnit; break;
  616.     case ErrNum_InvEscSequence:
  617.       msgno = Num_ErrMsgInvEscSequence; break;
  618.     case ErrNum_InvPrefixCombination:
  619.       msgno = Num_ErrMsgInvPrefixCombination; break;
  620.     case ErrNum_ConstantRedefinedAsVariable:
  621.       msgno = Num_ErrMsgConstantRedefinedAsVariable; break;
  622.     case ErrNum_VariableRedefinedAsConstant:
  623.       msgno = Num_ErrMsgVariableRedefinedAsConstant; break;
  624.     case ErrNum_StructNameMissing:
  625.       msgno = Num_ErrMsgStructNameMissing; break;
  626.     case ErrNum_EmptyArgument:
  627.       msgno = Num_ErrMsgEmptyArgument; break;
  628.     case ErrNum_Unimplemented:
  629.       msgno = Num_ErrMsgUnimplemented; break;
  630.     case ErrNum_FreestandingUnnamedStruct:
  631.       msgno = Num_ErrMsgFreestandingUnnamedStruct; break;
  632.     case ErrNum_STRUCTEndedByENDUNION:
  633.       msgno = Num_ErrMsgSTRUCTEndedByENDUNION; break;
  634.     case ErrNum_AddrOnDifferentPage:
  635.       msgno = Num_ErrMsgAddrOnDifferentPage; break;
  636.     case ErrNum_UnknownMacExpMod:
  637.       msgno = Num_ErrMsgUnknownMacExpMod; break;
  638.     case ErrNum_TooManyMacExpMod:
  639.       msgno = Num_ErrMsgTooManyMacExpMod; break;
  640.     case ErrNum_ConflictingMacExpMod:
  641.       msgno = Num_ErrMsgConflictingMacExpMod; break;
  642.     case ErrNum_InvalidPrepDir:
  643.       msgno = Num_ErrMsgInvalidPrepDir; break;
  644.     case ErrNum_ExpectedError:
  645.       msgno = Num_ErrMsgExpectedError; break;
  646.     case ErrNum_NoNestExpect:
  647.       msgno = Num_ErrMsgNoNestExpect; break;
  648.     case ErrNum_MissingENDEXPECT:
  649.       msgno = Num_ErrMsgMissingENDEXPECT; break;
  650.     case ErrNum_MissingEXPECT:
  651.       msgno = Num_ErrMsgMissingEXPECT; break;
  652.     case ErrNum_NoDefCkptReg:
  653.       msgno = Num_ErrMsgNoDefCkptReg; break;
  654.     case ErrNum_InvBitField:
  655.       msgno = Num_ErrMsgInvBitField; break;
  656.     case ErrNum_ArgValueMissing:
  657.       msgno = Num_ErrMsgArgValueMissing; break;
  658.     case ErrNum_UnknownArg:
  659.       msgno = Num_ErrMsgUnknownArg; break;
  660.     case ErrNum_IndexRegMustBe16Bit:
  661.       msgno = Num_ErrMsgIndexRegMustBe16Bit; break;
  662.     case ErrNum_IOAddrRegMustBe16Bit:
  663.       msgno = Num_ErrMsgIOAddrRegMustBe16Bit; break;
  664.     case ErrNum_SegAddrRegMustBe32Bit:
  665.       msgno = Num_ErrMsgSegAddrRegMustBe32Bit; break;
  666.     case ErrNum_NonSegAddrRegMustBe16Bit:
  667.       msgno = Num_ErrMsgNonSegAddrRegMustBe16Bit; break;
  668.     case ErrNum_InvStructArgument:
  669.       msgno = Num_ErrMsgInvStructArgument; break;
  670.     case ErrNum_TooManyArrayDimensions:
  671.       msgno = Num_ErrMsgTooManyArrayDimensions; break;
  672.     case ErrNum_InvIntFormat:
  673.       msgno = Num_ErrMsgInvIntFormat; break;
  674.     case ErrNum_InvIntFormatList:
  675.       msgno = Num_ErrMsgInvIntFormatList; break;
  676.     case ErrNum_InvScale:
  677.       msgno = Num_ErrMsgInvScale; break;
  678.     case ErrNum_ConfStringOpt:
  679.       msgno = Num_ErrMsgConfStringOpt; break;
  680.     case ErrNum_UnknownStringOpt:
  681.       msgno = Num_ErrMsgUnknownStringOpt; break;
  682.     case ErrNum_InvCacheInvMode:
  683.       msgno = Num_ErrMsgInvCacheInvMode; break;
  684.     case ErrNum_InvCfgList:
  685.       msgno = Num_ErrMsgInvCfgList; break;
  686.     case ErrNum_ConfBitBltOpt:
  687.       msgno = Num_ErrMsgConfBitBltOpt; break;
  688.     case ErrNum_UnknownBitBltOpt:
  689.       msgno = Num_ErrMsgUnknownBitBltOpt; break;
  690.     case ErrNum_InvCBAR:
  691.       msgno = Num_ErrMsgInvCBAR; break;
  692.     case ErrNum_InAccPageErr:
  693.       msgno = Num_ErrMsgInAccPageErr; break;
  694.     case ErrNum_InAccFieldErr:
  695.       msgno = Num_ErrMsgInAccFieldErr; break;
  696.     case ErrNum_TargInDiffField:
  697.       msgno = Num_ErrMsgTargInDiffField; break;
  698.     case ErrNum_InvCombination:
  699.       msgno = Num_ErrMsgInvCombination; break;
  700.     case ErrNum_UnmappedChar:
  701.       msgno = Num_ErrMsgUnmappedChar; break;
  702.     case ErrNum_NoTarget:
  703.       msgno = Num_ErrMsgNoTarget; break;
  704.     case ErrNum_MultiCharInvLength:
  705.       msgno = Num_ErrMsgMultiCharInvLength; break;
  706.     case ErrNum_InternalError:
  707.       msgno = Num_ErrMsgInternalError; break;
  708.     case ErrNum_OpeningFile:
  709.       msgno = Num_ErrMsgOpeningFile; break;
  710.     case ErrNum_ListWrError:
  711.       msgno = Num_ErrMsgListWrError; break;
  712.     case ErrNum_FileReadError:
  713.       msgno = Num_ErrMsgFileReadError; break;
  714.     case ErrNum_FileWriteError:
  715.       msgno = Num_ErrMsgFileWriteError; break;
  716.     case ErrNum_HeapOvfl:
  717.       msgno = Num_ErrMsgHeapOvfl; break;
  718.     case ErrNum_StackOvfl:
  719.       msgno = Num_ErrMsgStackOvfl; break;
  720.     case ErrNum_MaxIncLevelExceeded:
  721.       msgno = Num_ErrMsgMaxIncLevelExceeded; break;
  722.     default:
  723.       as_snprintf(Buf, BufSize, "%s %d", getmessage(Num_ErrMsgIntError), (int) Num);
  724.   }
  725.   return (msgno != -1) ? getmessage(msgno) : Buf;
  726. }
  727.  
  728. /*!------------------------------------------------------------------------
  729.  * \fn     WrErrorString(const char *pMessage, const char *pAdd, Boolean Warning, Boolean Fatal,
  730.                          const char *pExtendError, const struct sLineComp *pLineComp)
  731.  * \brief  write error message, combined with string component of current src line
  732.  * \param  pMessage textual error message
  733.  * \param  Warning error is warning?
  734.  * \param  Fatal error is fatal?
  735.  * \param  pExtendError extended error explanation
  736.  * \param  pLineComp associated string component
  737.  * ------------------------------------------------------------------------ */
  738.  
  739. void WrErrorString(const char *pMessage, const char *pAdd, Boolean Warning, Boolean Fatal,
  740.                    const char *pExtendError, const struct sLineComp *pLineComp)
  741. {
  742.   String ErrStr[4];
  743.   unsigned ErrStrCount = 0, z;
  744.   char *p;
  745.   int l;
  746.   const char *pLeadIn = GNUErrors ? "" : "> > > ";
  747.   FILE *pErrFile;
  748.   Boolean ErrorsWrittenToListing = False;
  749.  
  750.   if (treat_warnings_as_errors && Warning && !Fatal)
  751.     Warning = False;
  752.  
  753.   strcpy(ErrStr[ErrStrCount], pLeadIn);
  754.   p = GetErrorPos();
  755.   if (p)
  756.   {
  757.     l = strlen(p) - 1;
  758.     if ((l >= 0) && (p[l] == ' '))
  759.       p[l] = '\0';
  760.     strmaxcat(ErrStr[ErrStrCount], p, STRINGSIZE);
  761.     free(p);
  762.   }
  763.   if (pLineComp)
  764.   {
  765.     char Num[20];
  766.  
  767.     as_snprintf(Num, sizeof(Num), ":%d", pLineComp->StartCol + 1);
  768.     strmaxcat(ErrStr[ErrStrCount], Num, STRINGSIZE);
  769.   }
  770.   if (Warning || !GNUErrors)
  771.   {
  772.     strmaxcat(ErrStr[ErrStrCount], ": ", STRINGSIZE);
  773.     strmaxcat(ErrStr[ErrStrCount], getmessage(Warning ? Num_WarnName : Num_ErrName), STRINGSIZE);
  774.   }
  775.   strmaxcat(ErrStr[ErrStrCount], pAdd, STRINGSIZE);
  776.   strmaxcat(ErrStr[ErrStrCount], ": ", STRINGSIZE);
  777.   if (Warning)
  778.     WarnCount++;
  779.   else
  780.     ErrorCount++;
  781.  
  782.   strmaxcat(ErrStr[ErrStrCount], pMessage, STRINGSIZE);
  783.   if ((ExtendErrors > 0) && pExtendError)
  784.   {
  785.     if (GNUErrors)
  786.       strmaxcat(ErrStr[ErrStrCount], " '", STRINGSIZE);
  787.     else
  788.       strcpy(ErrStr[++ErrStrCount], pLeadIn);
  789.     strmaxcat(ErrStr[ErrStrCount], pExtendError, STRINGSIZE);
  790.     if (GNUErrors)
  791.       strmaxcat(ErrStr[ErrStrCount], "'", STRINGSIZE);
  792.   }
  793.   if ((ExtendErrors > 1) || ((ExtendErrors > 0) && pLineComp))
  794.   {
  795.     strcpy(ErrStr[++ErrStrCount], "");
  796.     GenLineForMarking(ErrStr[ErrStrCount], STRINGSIZE, OneLine.p_str, pLeadIn);
  797.     if (pLineComp)
  798.     {
  799.       strcpy(ErrStr[++ErrStrCount], "");
  800.       GenLineMarker(ErrStr[ErrStrCount], STRINGSIZE, '~', pLineComp, pLeadIn);
  801.     }
  802.   }
  803.  
  804.   if (strcmp(LstName, "/dev/null") && !Fatal)
  805.   {
  806.     for (z = 0; z <= ErrStrCount; z++)
  807.       WrLstLine(ErrStr[z]);
  808.     ErrorsWrittenToListing = True;
  809.   }
  810.  
  811.   if (!ErrorFile)
  812.     OpenWithStandard(&ErrorFile, ErrorName);
  813.   pErrFile = ErrorFile ? ErrorFile : stdout;
  814.   if (strcmp(LstName, "!1") || !ListOn || !ErrorsWrittenToListing)
  815.   {
  816.     for (z = 0; z <= ErrStrCount; z++)
  817.       if (ErrorFile)
  818.         fprintf(pErrFile, "%s\n", ErrStr[z]);
  819.       else
  820.         WrConsoleLine(ErrStr[z], True);
  821.   }
  822.  
  823.   if (Fatal)
  824.     fprintf(pErrFile, "%s\n", getmessage(Num_ErrMsgIsFatal));
  825.   else if (MaxErrors && (ErrorCount >= MaxErrors))
  826.   {
  827.     fprintf(pErrFile, "%s\n", getmessage(Num_ErrMsgTooManyErrors));
  828.     Fatal = True;
  829.   }
  830.  
  831.   if (Fatal)
  832.   {
  833.     EmergencyStop();
  834.     exit(3);
  835.   }
  836. }
  837.  
  838. /*!------------------------------------------------------------------------
  839.  * \fn     WrXErrorPos(tErrorNum Num, const char *pExtendError, const struct sLineComp *pLineComp)
  840.  * \brief  write number-coded error message, combined with extended explamation and string component of current src line
  841.  * \param  Num error number
  842.  * \param  pExtendError extended error explanation
  843.  * \param  pLineComp associated string component
  844.  * ------------------------------------------------------------------------ */
  845.  
  846. void WrXErrorPos(tErrorNum Num, const char *pExtendError, const struct sLineComp *pLineComp)
  847. {
  848.   String h;
  849.   char Add[11];
  850.   const char *pErrorMsg;
  851.  
  852.   if (FindAndTakeExpectError(Num))
  853.     return;
  854.  
  855.   if (!CodeOutput && (Num == ErrNum_UnknownInstruction))
  856.     return;
  857.  
  858.   if (SuppWarns && (Num < 1000))
  859.     return;
  860.  
  861.   switch (Num)
  862.   {
  863.     case ErrNum_SignExtension:
  864.       if (!warn_sign_extension)
  865.         return;
  866.       break;
  867.     default:
  868.       break;
  869.   }
  870.  
  871.   pErrorMsg = ErrorNum2String(Num, h, sizeof(h));
  872.  
  873.   if (((Num == ErrNum_JmpTargOnDiffPage) || (Num == ErrNum_JmpDistTooBig))
  874.    && !Repass)
  875.     JmpErrors++;
  876.  
  877.   if (NumericErrors)
  878.     as_snprintf(Add, sizeof(Add), " #%d", (int)Num);
  879.   else
  880.     *Add = '\0';
  881.   WrErrorString(pErrorMsg, Add, Num < 1000, Num >= 10000, pExtendError, pLineComp);
  882. }
  883.  
  884. /*!------------------------------------------------------------------------
  885.  * \fn     WrStrErrorPos(tErrorNum Num, const const struct sLineComp *pLineComp)
  886.  * \brief  write number-coded error message, combined with string component of current src line
  887.  * \param  Num error number
  888.  * \param  pStrComp associated string component
  889.  * ------------------------------------------------------------------------ */
  890.  
  891. void WrStrErrorPos(tErrorNum Num, const struct sStrComp *pStrComp)
  892. {
  893.   WrXErrorPos(Num, pStrComp->str.p_str, &pStrComp->Pos);
  894. }
  895.  
  896. /*!------------------------------------------------------------------------
  897.  * \fn     WrError(tErrorNum Num)
  898.  * \brief  write number-coded error message, without any explanation
  899.  * \param  Num error number
  900.  * ------------------------------------------------------------------------ */
  901.  
  902. void WrError(tErrorNum Num)
  903. {
  904.   WrXErrorPos(Num, NULL, NULL);
  905. }
  906.  
  907. /*!------------------------------------------------------------------------
  908.  * \fn     WrXError(tErrorNum Num, const char *pExtError)
  909.  * \brief  write number-coded error message with extended explanation
  910.  * \param  Num error number
  911.  * \param  pExtendError extended error explanation
  912.  * ------------------------------------------------------------------------ */
  913.  
  914. void WrXError(tErrorNum Num, const char *pExtError)
  915. {
  916.   WrXErrorPos(Num, pExtError, NULL);
  917. }
  918.  
  919. /*!------------------------------------------------------------------------
  920.  * \fn     void ChkIO(tErrorNum ErrNo)
  921.  * \brief  check for I/O error and report given error if yes
  922.  * \param  ErrNo error number to report if error occured
  923.  * ------------------------------------------------------------------------ */
  924.  
  925. void ChkIO(tErrorNum ErrNo)
  926. {
  927.   int io;
  928.  
  929.   io = errno;
  930.   if ((io == 0) || (io == 19) || (io == 25))
  931.     return;
  932.  
  933.   WrXError(ErrNo, GetErrorMsg(io));
  934. }
  935.  
  936. /*!------------------------------------------------------------------------
  937.  * \fn     ChkXIO(tErrorNum ErrNo, char *pExtError)
  938.  * \brief  check for I/O error and report given error if yes
  939.  * \param  ErrNo error number to report if error occured
  940.  * \param  pExtError, file name, as plain string
  941.  * ------------------------------------------------------------------------ */
  942.  
  943. void ChkXIO(tErrorNum ErrNo, char *pExtError)
  944. {
  945.   tStrComp TmpComp;
  946.  
  947.   StrCompMkTemp(&TmpComp, pExtError, 0);
  948.   ChkStrIO(ErrNo, &TmpComp);
  949. }
  950.  
  951. /*!------------------------------------------------------------------------
  952.  * \fn     void ChkIO(tErrorNum ErrNo)
  953.  * \brief  check for I/O error and report given error if yes
  954.  * \param  ErrNo error number to report if error occured
  955.  * \param  pComp, file name, as string component with position
  956.  * ------------------------------------------------------------------------ */
  957.  
  958. void ChkStrIO(tErrorNum ErrNo, const struct sStrComp *pComp)
  959. {
  960.   int io;
  961.   String s;
  962.  
  963.   io = errno;
  964.   if ((io == 0) || (io == 19) || (io == 25))
  965.     return;
  966.  
  967.   as_snprintf(s, STRINGSIZE, "%s: %s", pComp->str.p_str, GetErrorMsg(io));
  968.   if ((pComp->Pos.StartCol >= 0) || pComp->Pos.Len)
  969.     WrXErrorPos(ErrNo, s, &pComp->Pos);
  970.   else
  971.     WrXError(ErrNo, s);
  972. }
  973.  
  974. /*!------------------------------------------------------------------------
  975.  * \fn     CodeEXPECT(Word Code)
  976.  * \brief  process EXPECT command
  977.  * ------------------------------------------------------------------------ */
  978.  
  979. void CodeEXPECT(Word Code)
  980. {
  981.   UNUSED(Code);
  982.  
  983.   if (!ChkArgCnt(1, ArgCntMax));
  984.   else if (InExpect) WrStrErrorPos(ErrNum_NoNestExpect, &OpPart);
  985.   else
  986.   {
  987.     int z;
  988.     Boolean OK;
  989.     tErrorNum Num;
  990.  
  991.     for (z = 1; z <= ArgCnt; z++)
  992.     {
  993.       tSymbolFlags flags;
  994.  
  995.       Num = (tErrorNum)EvalStrIntExpressionWithFlags(&ArgStr[z], UInt16, &OK, &flags);
  996.       if (!OK)
  997.         continue;
  998.       if (mFirstPassUnknownOrQuestionable(flags))
  999.         WrStrErrorPos(ErrNum_FirstPassCalc, &ArgStr[z]);
  1000.       else if (Num)
  1001.       {
  1002.         tExpectError *pNew = (tExpectError*)calloc(1, sizeof(*pNew));
  1003.         pNew->Num = Num;
  1004.         AddExpectError(pNew);
  1005.       }
  1006.     }
  1007.     InExpect = True;
  1008.   }
  1009. }
  1010.  
  1011. /*!------------------------------------------------------------------------
  1012.  * \fn     CodeENDEXPECT(Word Code)
  1013.  * \brief  process ENDEXPECT command
  1014.  * ------------------------------------------------------------------------ */
  1015.  
  1016. void CodeENDEXPECT(Word Code)
  1017. {
  1018.   UNUSED(Code);
  1019.  
  1020.   if (!ChkArgCnt(0, 0));
  1021.   else if (!InExpect) WrStrErrorPos(ErrNum_MissingEXPECT, &OpPart);
  1022.   else
  1023.   {
  1024.     tExpectError *pCurr;
  1025.     String h;
  1026.  
  1027.     while (pExpectErrors)
  1028.     {
  1029.       pCurr = pExpectErrors;
  1030.       pExpectErrors = pCurr->pNext;
  1031.       WrXError(ErrNum_ExpectedError, ErrorNum2String(pCurr->Num, h, sizeof(h)));
  1032.       free(pCurr);
  1033.     }
  1034.     InExpect = False;
  1035.   }
  1036. }
  1037.  
  1038. /*!------------------------------------------------------------------------
  1039.  * \fn     AsmErrPassInit(void)
  1040.  * \brief  module initialization prior to (another) pass through sources
  1041.  * ------------------------------------------------------------------------ */
  1042.  
  1043. void AsmErrPassInit(void)
  1044. {
  1045.   ErrorCount = 0;
  1046.   WarnCount = 0;
  1047.   ClearExpectErrors();
  1048.   InExpect = False;
  1049. }
  1050.  
  1051. /*!------------------------------------------------------------------------
  1052.  * \fn     AsmErrPassExit(void)
  1053.  * \brief  module checks & cleanups after a pass through sources
  1054.  * ------------------------------------------------------------------------ */
  1055.  
  1056. void AsmErrPassExit(void)
  1057. {
  1058.   if (InExpect)
  1059.     WrError(ErrNum_MissingENDEXPECT);
  1060.   ClearExpectErrors();
  1061.   InExpect = False;
  1062. }
  1063.  
  1064. static as_cmd_result_t cmd_treat_warnings_as_errors(Boolean negate, const char *p_arg)
  1065. {
  1066.   UNUSED(p_arg);
  1067.  
  1068.   treat_warnings_as_errors = !negate;
  1069.   return e_cmd_ok;
  1070. }
  1071.  
  1072. static as_cmd_result_t cmd_warn_sign_extension(Boolean negate, const char *p_arg)
  1073. {
  1074.   UNUSED(p_arg);
  1075.  
  1076.   if (negate)
  1077.     return e_cmd_err;
  1078.   warn_sign_extension = True;
  1079.   return e_cmd_ok;
  1080. }
  1081.  
  1082. static as_cmd_result_t cmd_no_warn_sign_extension(Boolean negate, const char *p_arg)
  1083. {
  1084.   UNUSED(p_arg);
  1085.  
  1086.   if (negate)
  1087.     return e_cmd_err;
  1088.   warn_sign_extension = False;
  1089.   return e_cmd_ok;
  1090. }
  1091.  
  1092. static const as_cmd_rec_t cmd_params[] =
  1093. {
  1094.   { "werror"                     , cmd_treat_warnings_as_errors },
  1095.   { "wimplicit-sign-extension"   , cmd_warn_sign_extension      },
  1096.   { "wno-implicit-sign-extension", cmd_no_warn_sign_extension   }
  1097. };
  1098.  
  1099. /*!------------------------------------------------------------------------
  1100.  * \fn     asmerr_init(void)
  1101.  * \brief  module setup
  1102.  * ------------------------------------------------------------------------ */
  1103.  
  1104. void asmerr_init(void)
  1105. {
  1106.   treat_warnings_as_errors = False;
  1107.   warn_sign_extension = True;
  1108.   as_cmd_register(cmd_params, as_array_size(cmd_params));
  1109. }
  1110.