Mercurial > hg > index.cgi
comparison lwasm/pseudo.c @ 10:127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
author | lost@l-w.ca |
---|---|
date | Sat, 22 Jan 2011 10:37:53 -0700 |
parents | 7317fbe024af |
children | 7e92484cfbc3 |
comparison
equal
deleted
inserted
replaced
9:6eed14cccac9 | 10:127e5b1e01c0 |
---|---|
19 | 19 |
20 */ | 20 */ |
21 | 21 |
22 #include <stdio.h> | 22 #include <stdio.h> |
23 #include <ctype.h> | 23 #include <ctype.h> |
24 #include <string.h> | |
24 | 25 |
25 #include <lw_alloc.h> | 26 #include <lw_alloc.h> |
26 | 27 |
27 #include "lwasm.h" | 28 #include "lwasm.h" |
28 #include "instab.h" | 29 #include "instab.h" |
1032 PARSEFUNC(pseudo_parse_include) | 1033 PARSEFUNC(pseudo_parse_include) |
1033 { | 1034 { |
1034 char *fn, *p2; | 1035 char *fn, *p2; |
1035 char *p3; | 1036 char *p3; |
1036 int delim = 0; | 1037 int delim = 0; |
1038 int len; | |
1037 | 1039 |
1038 if (!**p) | 1040 if (!**p) |
1039 { | 1041 { |
1040 lwasm_register_error(as, l, "Missing filename"); | 1042 lwasm_register_error(as, l, "Missing filename"); |
1041 return; | 1043 return; |
1057 fn = lw_strndup(*p, p2 - *p); | 1059 fn = lw_strndup(*p, p2 - *p); |
1058 (*p) = p2; | 1060 (*p) = p2; |
1059 if (delim && **p) | 1061 if (delim && **p) |
1060 (*p)++; | 1062 (*p)++; |
1061 | 1063 |
1062 (void)(0 == asprintf(&p3, "include:%s", fn)); | 1064 len = strlen(fn) + 8; |
1065 p3 = lw_alloc(len + 1); | |
1066 sprintf(p3, "include:%s", fn); | |
1063 input_open(as, p3); | 1067 input_open(as, p3); |
1064 lw_free(p3); | 1068 lw_free(p3); |
1065 | 1069 |
1066 l -> len = 0; | 1070 l -> len = 0; |
1067 } | 1071 } |