]> git.sur5r.net Git - cc65/commitdiff
Use "Assertion failed" as default message for .assert if no message was
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 20 Apr 2005 09:28:26 +0000 (09:28 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 20 Apr 2005 09:28:26 +0000 (09:28 +0000)
given.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3474 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/pseudo.c

index 3a9caac6d83b14cccdb40abe46e668f91fe56eae..84f6f5eb4884ebdc1c5e2a3c0cbfb32050174408 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2004 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2005, Ullrich von Bassewitz                                      */
+/*                Römerstraße 52                                             */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -384,8 +384,8 @@ static void DoAssert (void)
         "ERROR"
     };
 
-    int  Action;
-    long Val;
+    int      Action;
+    unsigned Msg;
 
     /* First we have the expression that has to evaluated */
     ExprNode* Expr = Expression ();
@@ -414,19 +414,36 @@ static void DoAssert (void)
             Error ("Illegal assert action specifier");
     }
     NextTok ();
-    ConsumeComma ();
 
-    /* Read the message */
-    if (Tok != TOK_STRCON) {
-       ErrorSkip ("String constant expected");
-        return;
+    /* We can have an optional message. If no message is present, use
+     * "Assertion failed".
+     */
+    if (Tok == TOK_COMMA) {
+
+        /* Skip the comma */
+        NextTok ();
+
+        /* Read the message */
+        if (Tok != TOK_STRCON) {
+            ErrorSkip ("String constant expected");
+            return;
+        }
+
+        /* Translate the message into a string id. We can then skip the input
+         * string.
+         */
+        Msg = GetStringId (SVal);
+        NextTok ();
+
+    } else {
+
+        /* Use "Assertion failed" */
+        Msg = GetStringId ("Assertion failed");
+
     }
 
     /* Remember the assertion */
-    AddAssertion (Expr, Action, GetStringId (SVal));
-
-    /* Skip the message */
-    NextTok ();
+    AddAssertion (Expr, Action, Msg);
 }