comparison lwasm/lwasm.c @ 209:52d9dd71f555

Make warning actually work. Make warnings actually work instead of being treated as errors. Also correct compiler warnings related to warning and error handling.
author William Astle <lost@l-w.ca>
date Sat, 09 Jun 2012 16:03:36 -0600
parents 348e2816ce32
children 5d969517db74
comparison
equal deleted inserted replaced
208:fa835b780ffb 209:52d9dd71f555
187 void lwasm_register_error(asmstate_t *as, line_t *l, const char *msg, ...) 187 void lwasm_register_error(asmstate_t *as, line_t *l, const char *msg, ...)
188 { 188 {
189 lwasm_error_t *e; 189 lwasm_error_t *e;
190 va_list args; 190 va_list args;
191 char errbuff[1024]; 191 char errbuff[1024];
192 int r; 192
193
194 if (!l) 193 if (!l)
195 return; 194 return;
196 195
197 va_start(args, msg); 196 va_start(args, msg);
198 197
201 e -> next = l -> err; 200 e -> next = l -> err;
202 l -> err = e; 201 l -> err = e;
203 202
204 as -> errorcount++; 203 as -> errorcount++;
205 204
206 r = vsnprintf(errbuff, 1024, msg, args); 205 (void)vsnprintf(errbuff, 1024, msg, args);
207 e -> mess = lw_strdup(errbuff); 206 e -> mess = lw_strdup(errbuff);
208 207
209 va_end(args); 208 va_end(args);
210 } 209 }
211 210
212 void lwasm_register_warning(asmstate_t *as, line_t *l, const char *msg, ...) 211 void lwasm_register_warning(asmstate_t *as, line_t *l, const char *msg, ...)
213 { 212 {
214 lwasm_error_t *e; 213 lwasm_error_t *e;
215 va_list args; 214 va_list args;
216 char errbuff[1024]; 215 char errbuff[1024];
217 int r;
218 216
219 if (!l) 217 if (!l)
220 return; 218 return;
221 219
222 va_start(args, msg); 220 va_start(args, msg);
223 221
224 e = lw_alloc(sizeof(lwasm_error_t)); 222 e = lw_alloc(sizeof(lwasm_error_t));
225 223
226 e -> next = l -> err; 224 e -> next = l -> warn;
227 l -> err = e; 225 l -> warn = e;
228 226
229 as -> errorcount++; 227 as -> warningcount++;
230 228
231 r = vsnprintf(errbuff, 1024, msg, args); 229 (void)vsnprintf(errbuff, 1024, msg, args);
232 e -> mess = lw_strdup(errbuff); 230 e -> mess = lw_strdup(errbuff);
233 231
234 va_end(args); 232 va_end(args);
235 } 233 }
236 234