summaryrefslogtreecommitdiff
path: root/assemble.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-05-30 10:42:30 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-05-30 10:42:30 -0700
commit418ca70d4e973cdd63195c266614acc45216b3f4 (patch)
tree0625a5438b7c932421203f14ffd2577c8b414d11 /assemble.c
parent5ff39dc78d06991d4161698cfbd7b6084af4fb37 (diff)
downloadnasm-418ca70d4e973cdd63195c266614acc45216b3f4.tar.gz
nasm-418ca70d4e973cdd63195c266614acc45216b3f4.tar.bz2
nasm-418ca70d4e973cdd63195c266614acc45216b3f4.zip
Introduce %depend and %pathsearch, and make incbin a macro
Introduce new preprocessor directives %depend and %pathsearch, and make incbin a standard macro using these filenames. This lets us remove the code that makes incbin search the path.
Diffstat (limited to 'assemble.c')
-rw-r--r--assemble.c52
1 files changed, 7 insertions, 45 deletions
diff --git a/assemble.c b/assemble.c
index 245aea4..442ed2a 100644
--- a/assemble.c
+++ b/assemble.c
@@ -119,7 +119,6 @@
#include "nasmlib.h"
#include "assemble.h"
#include "insns.h"
-#include "preproc.h"
#include "tables.h"
/* Initialized to zero by the C standard */
@@ -369,8 +368,6 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, uint32_t cp,
static char fname[FILENAME_MAX];
FILE *fp;
int32_t len;
- char *prefix = "", *combine;
- char **pPrevPath = NULL;
len = FILENAME_MAX - 1;
if (len > instruction->eops->stringlen)
@@ -378,30 +375,14 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, uint32_t cp,
strncpy(fname, instruction->eops->stringval, len);
fname[len] = '\0';
- while (1) { /* added by alexfru: 'incbin' uses include paths */
- combine = nasm_malloc(strlen(prefix) + len + 1);
- strcpy(combine, prefix);
- strcat(combine, fname);
-
- if ((fp = fopen(combine, "rb")) != NULL) {
- nasm_free(combine);
- break;
- }
-
- nasm_free(combine);
- pPrevPath = pp_get_include_path_ptr(pPrevPath);
- if (pPrevPath == NULL)
- break;
- prefix = *pPrevPath;
- }
-
- if (fp == NULL)
+ fp = fopen(fname, "rb");
+ if (!fp) {
error(ERR_NONFATAL, "`incbin': unable to open file `%s'",
fname);
- else if (fseek(fp, 0L, SEEK_END) < 0)
+ } else if (fseek(fp, 0L, SEEK_END) < 0) {
error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'",
fname);
- else {
+ } else {
static char buf[2048];
int32_t t = instruction->times;
int32_t base = 0;
@@ -694,34 +675,15 @@ int64_t insn_size(int32_t segment, int64_t offset, int bits, uint32_t cp,
char fname[FILENAME_MAX];
FILE *fp;
int32_t len;
- char *prefix = "", *combine;
- char **pPrevPath = NULL;
len = FILENAME_MAX - 1;
if (len > instruction->eops->stringlen)
len = instruction->eops->stringlen;
strncpy(fname, instruction->eops->stringval, len);
fname[len] = '\0';
-
- /* added by alexfru: 'incbin' uses include paths */
- while (1) {
- combine = nasm_malloc(strlen(prefix) + len + 1);
- strcpy(combine, prefix);
- strcat(combine, fname);
-
- if ((fp = fopen(combine, "rb")) != NULL) {
- nasm_free(combine);
- break;
- }
-
- nasm_free(combine);
- pPrevPath = pp_get_include_path_ptr(pPrevPath);
- if (pPrevPath == NULL)
- break;
- prefix = *pPrevPath;
- }
-
- if (fp == NULL)
+
+ fp = fopen(fname, "rb");
+ if (!fp)
error(ERR_NONFATAL, "`incbin': unable to open file `%s'",
fname);
else if (fseek(fp, 0L, SEEK_END) < 0)