]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - typedef.c
Update README
[xonotic/gmqcc.git] / typedef.c
index dcc4e20b377a37a498859cb151d1773621ad1d53..011886147386068ed296bfee34e13356cd202743 100644 (file)
--- a/typedef.c
+++ b/typedef.c
@@ -20,9 +20,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#include <string.h>
-#include <stdint.h> /* replace if stdint.h doesn't exist! */
-#include <limits.h>
 #include "gmqcc.h"
 static typedef_node *typedef_table[1024];
 
@@ -65,12 +62,12 @@ void typedef_clear() {
        }
 }
 
-int typedef_add(const char *from, const char *to) {
+int typedef_add(struct lex_file *file, const char *from, const char *to) {
        unsigned int  hash = typedef_hash(to);
        typedef_node *find = typedef_table[hash];
        
        if (find)
-               return error(ERROR_PARSE, "typedef for %s already exists or conflicts\n", to);
+               return error(file, ERROR_PARSE, "typedef for %s already exists or conflicts\n", to);
        
        /* check if the type exists first */
        if (strncmp(from, "float",  sizeof("float"))  == 0 ||
@@ -80,7 +77,7 @@ int typedef_add(const char *from, const char *to) {
            strncmp(from, "void",   sizeof("void"))   == 0) {
                
                typedef_table[hash]       = mem_a(sizeof(typedef_node));
-               typedef_table[hash]->name = strdup(from);
+               typedef_table[hash]->name = util_strdup(from);
                return -100;
        } else {
                /* search the typedefs for it (typedef-a-typedef?) */
@@ -91,5 +88,5 @@ int typedef_add(const char *from, const char *to) {
                        return -100;
                }
        }
-       return error(ERROR_PARSE, "cannot typedef `%s` (not a type)\n", from);
+       return error(file, ERROR_PARSE, "cannot typedef `%s` (not a type)\n", from);
 }