]> git.sur5r.net Git - cc65/blobdiff - src/ca65/macro.c
New module strstack
[cc65] / src / ca65 / macro.c
index 6494277709cbc4448015b3f91fe61b8ebb37021e..3b60297d09175250035155613819878474434a2e 100644 (file)
@@ -7,7 +7,7 @@
 /*                                                                           */
 /*                                                                           */
 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
+/*               Römerstraße 52                                              */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
@@ -70,7 +70,10 @@ static HashNode* HT_GetHashNode (void* Entry);
 /* Given a pointer to the user entry data, return a pointer to the hash node */
 
 static int HT_Compare (const void* Key1, const void* Key2);
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
 
 
 
@@ -175,9 +178,12 @@ static HashNode* HT_GetHashNode (void* Entry)
 
 
 static int HT_Compare (const void* Key1, const void* Key2)
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
 {
-    return (strcmp (Key1, Key2) == 0);
+    return strcmp (Key1, Key2);
 }
 
 
@@ -305,7 +311,7 @@ static void MacSkipDef (unsigned Style)
        if (Tok != TOK_EOF) {
            SkipUntilSep ();
        } else {
-           Error (ERR_ENDMACRO_EXPECTED);
+           Error ("`.ENDMACRO' expected");
        }
     } else {
        /* Skip until end of line */
@@ -324,7 +330,7 @@ void MacDef (unsigned Style)
 
     /* We expect a macro name here */
     if (Tok != TOK_IDENT) {
-       Error (ERR_IDENT_EXPECTED);
+       Error ("Identifier expected");
        MacSkipDef (Style);
        return;
     }
@@ -332,7 +338,7 @@ void MacDef (unsigned Style)
     /* Did we already define that macro? */
     if (HT_Find (&MacroTab, SVal) != 0) {
                /* Macro is already defined */
-       Error (ERR_SYM_ALREADY_DEFINED, SVal);
+       Error ("A macro named `%s' is already defined", SVal);
        /* Skip tokens until we reach the final .endmacro */
        MacSkipDef (Style);
                return;
@@ -374,8 +380,8 @@ void MacDef (unsigned Style)
                IdDesc* List = M->Params;
                while (1) {
                    if (strcmp (List->Id, SVal) == 0) {
-                       Error (ERR_SYM_ALREADY_DEFINED, SVal);
-                   }
+                       Error ("Duplicate symbol `%s'", SVal);
+                   }                                 
                    if (List->Next == 0) {
                        break;
                    } else {
@@ -423,7 +429,7 @@ void MacDef (unsigned Style)
            }
            /* May not have end of file in a macro definition */
            if (Tok == TOK_EOF) {
-               Error (ERR_ENDMACRO_EXPECTED);
+               Error ("`.ENDMACRO' expected");
                goto Done;
            }
        } else {
@@ -445,7 +451,7 @@ void MacDef (unsigned Style)
 
                /* Need an identifer */
                if (Tok != TOK_IDENT) {
-                   Error (ERR_IDENT_EXPECTED);
+                   Error ("Identifier expected");
                    SkipUntilSep ();
                    break;
                }
@@ -656,8 +662,8 @@ static void StartExpClassic (Macro* M)
 
                /* Check for maximum parameter count */
        if (E->ParamCount >= M->ParamCount) {
-           Error (ERR_TOO_MANY_PARAMS);
-           SkipUntilSep ();
+           Error ("Too many macro parameters");
+           SkipUntilSep ();                    
            break;
        }
 
@@ -669,7 +675,7 @@ static void StartExpClassic (Macro* M)
 
            /* Check for end of file */
            if (Tok == TOK_EOF) {
-               Error (ERR_UNEXPECTED_EOF);
+               Error ("Unexpected end of file");
                return;
            }
 
@@ -726,7 +732,7 @@ static void StartExpDefine (Macro* M)
 
                /* Check if there is really a parameter */
                if (TokIsSep (Tok) || Tok == TOK_COMMA) {
-                   Error (ERR_MACRO_PARAM_EXPECTED);
+                   Error ("Macro parameter expected");
                    SkipUntilSep ();
                    return;
                }
@@ -761,7 +767,7 @@ static void StartExpDefine (Macro* M)
                    if (Tok == TOK_COMMA) {
                        NextTok ();
                    } else {
-                       Error (ERR_COMMA_EXPECTED);
+                       Error ("`,' expected");
                    }
                }
     }