static void VPrintMsg (const FilePos* Pos, const char* Desc, const char* Format, va_list ap) /* Format and output an error/warning message. */ { StrBuf S = STATIC_STRBUF_INITIALIZER; /* Format the actual message */ StrBuf Msg = STATIC_STRBUF_INITIALIZER; SB_VPrintf (&Msg, Format, ap); SB_Terminate (&Msg); /* Format the message header */ SB_Printf (&S, "%s(%u): %s: ", SB_GetConstBuf (GetFileName (Pos->Name)), Pos->Line, Desc); /* Append the message to the message header */ SB_Append (&S, &Msg); /* Delete the formatted message */ SB_Done (&Msg); /* Add a new line and terminate the generated full message */ SB_AppendChar (&S, '\n'); SB_Terminate (&S); /* Output the full message */ fputs (SB_GetConstBuf (&S), stderr); /* Delete the buffer for the full message */ SB_Done (&S); }
void CfgWarning (const FilePos* Pos, const char* Format, ...) /* Print a warning message adding file name and line number of a given file */ { StrBuf Buf = STATIC_STRBUF_INITIALIZER; va_list ap; va_start (ap, Format); SB_VPrintf (&Buf, Format, ap); va_end (ap); Warning ("%s(%u): %s", GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); SB_Done (&Buf); }
void Internal (const char* Format, ...) /* Print a message about an internal assembler error and die. */ { va_list ap; StrBuf S = STATIC_STRBUF_INITIALIZER; va_start (ap, Format); SB_VPrintf (&S, Format, ap); SB_Terminate (&S); va_end (ap); fprintf (stderr, "Internal assembler error: %s\n", SB_GetConstBuf (&S)); SB_Done (&S); exit (EXIT_FAILURE); }
void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) /* Add a line to the given code segment */ { const char* L; CodeEntry* E; char Token[IDENTSIZE+10]; /* Format the line */ StrBuf Buf = STATIC_STRBUF_INITIALIZER; SB_VPrintf (&Buf, Format, ap); /* Skip whitespace */ L = SkipSpace (SB_GetConstBuf (&Buf)); /* Check which type of instruction we have */ E = 0; /* Assume no insn created */ switch (*L) { case '\0': /* Empty line, just ignore it */ break; case ';': /* Comment or hint, ignore it for now */ break; case '.': /* Control instruction */ ReadToken (L, " \t", Token, sizeof (Token)); Error ("ASM code error: Pseudo instruction `%s' not supported", Token); break; default: E = ParseInsn (S, LI, L); break; } /* If we have a code entry, transfer the labels and insert it */ if (E) { CS_AddEntry (S, E); } /* Cleanup the string buffer */ SB_Done (&Buf); }