shithub: rgbds

Download patch

ref: ec44b554e8b54a02cb1ea60eac678d70f9af6db7
parent: 01a710a47d6a5f21f8cfda72f7cfc6d23563a090
parent: ff2ba7290cfc3e59e9c93432a14e890e64ac430b
author: AntonioND <[email protected]>
date: Sun Apr 2 13:03:03 EDT 2017

Merge pull request #150 from Ben10do/deprecation-positions

Add a warning() function, similiar to other error handlers

--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -27,6 +27,7 @@
 
 noreturn void fatalerror(const char *fmt, ...);
 void yyerror(const char *fmt, ...);
+void warning(const char *fmt, ...);
 
 #define	YY_FATAL_ERROR fatalerror
 
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1282,7 +1282,7 @@
 					{
 						out_AbsByte(0xE9);
 						if( nPass==1 )
-							printf("warning:'JP [HL]' is obsolete, use 'JP HL' instead.\n");
+							warning("'JP [HL]' is obsolete, use 'JP HL' instead.\n");
 					}
 				|	T_Z80_JP T_MODE_HL
 					{ out_AbsByte(0xE9); }
@@ -1300,7 +1300,7 @@
 					{
 						out_AbsByte(0x0A|(2<<4));
 						if( nPass==1 )
-							printf("warning:'LDI A,HL' is obsolete, use 'LDI A,[HL]' or 'LD A,[HL+] instead.\n");
+							warning("'LDI A,HL' is obsolete, use 'LDI A,[HL]' or 'LD A,[HL+] instead.\n");
 					}
 				|	T_Z80_LDI T_MODE_A comma T_MODE_HL_IND
 					{ out_AbsByte(0x0A|(2<<4)); }
@@ -1312,7 +1312,7 @@
 					{
 						out_AbsByte(0x0A|(3<<4));
 						if( nPass==1 )
-							printf("warning:'LDD A,HL' is obsolete, use 'LDD A,[HL]' or 'LD A,[HL-] instead.\n");
+							warning("'LDD A,HL' is obsolete, use 'LDD A,[HL]' or 'LD A,[HL-] instead.\n");
 					}
 				|	T_Z80_LDD T_MODE_A comma T_MODE_HL_IND
 					{ out_AbsByte(0x0A|(3<<4)); }
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -226,9 +226,9 @@
 void
 verror(const char *fmt, va_list args)
 {
-	fprintf(stderr, "ERROR:\t");
+	fprintf(stderr, "ERROR: ");
 	fstk_Dump();
-	fprintf(stderr, " :\n\t");
+	fprintf(stderr, ":\n\t");
 	vfprintf(stderr, fmt, args);
 	fprintf(stderr, "\n");
 	nErrors += 1;
@@ -251,6 +251,21 @@
 	verror(fmt, args);
 	va_end(args);
 	exit(5);
+}
+
+void
+warning(const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	
+	fprintf(stderr, "warning: ");
+	fstk_Dump();
+	fprintf(stderr, ":\n\t");
+	vfprintf(stderr, fmt, args);
+	fprintf(stderr, "\n");
+	
+	va_end(args);
 }
 
 static void