diff options
Diffstat (limited to 'devel/nasm/patches/patch-ac')
-rw-r--r-- | devel/nasm/patches/patch-ac | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/devel/nasm/patches/patch-ac b/devel/nasm/patches/patch-ac new file mode 100644 index 00000000000..14ba1d6c299 --- /dev/null +++ b/devel/nasm/patches/patch-ac @@ -0,0 +1,118 @@ +$NetBSD: patch-ac,v 1.1 2005/01/06 13:06:10 adrianp Exp $ + +--- preproc.c.orig 2004-12-16 10:49:55 -0500 ++++ preproc.c 2004-12-16 10:51:48 -0500 +@@ -528,7 +528,7 @@ + fname++; + fnlen = strcspn(fname, "\""); + line = nasm_malloc(20 + fnlen); +- sprintf(line, "%%line %d %.*s", lineno, fnlen, fname); ++ snprintf(line, 20+fnlen,"%%line %d %.*s", lineno, fnlen, fname); + nasm_free(oldline); + } + if (tasm_compatible_mode) +@@ -1043,7 +1043,7 @@ + char *p, *q = t->text + 2; + + q += strspn(q, "$"); +- sprintf(buffer, "..@%lu.", ctx->number); ++ snprintf(buffer, sizeof(buffer), "..@%lu.", ctx->number); + p = nasm_strcat(buffer, q); + nasm_free(t->text); + t->text = p; +@@ -1520,23 +1520,30 @@ + t = t->next; + continue; + } +- else if (tt->type == TOK_WHITESPACE) ++ if (tt->type == TOK_WHITESPACE) + { + tt = tt->next; + continue; + } +- else if (tt->type != t->type || +- mstrcmp(tt->text, t->text, casesense)) ++ if (tt->type != t->type) + { + j = FALSE; /* found mismatching tokens */ + break; + } +- else ++ /* Unify surrounding quotes for strings */ ++ if (t->type == TOK_STRING) + { +- t = t->next; +- tt = tt->next; +- continue; ++ tt->text[0] = t->text[0]; ++ tt->text[strlen(tt->text) - 1] = t->text[0]; + } ++ if (mstrcmp(tt->text, t->text, casesense) != 0) ++ { ++ j = FALSE; /* found mismatching tokens */ ++ break; ++ } ++ ++ t = t->next; ++ tt = tt->next; + } + if ((t->type != TOK_OTHER || strcmp(t->text, ",")) || tt) + j = FALSE; /* trailing gunk on one end or other */ +@@ -1954,7 +1961,7 @@ + free_tlist(tt); + + /* Now define the macro for the argument */ +- sprintf(directive, "%%define %s (%s+%d)", arg, StackPointer, ++ snprintf(directive, sizeof(directive), "%%define %s (%s+%d)", arg, StackPointer, + offset); + do_directive(tokenise(directive)); + offset += size; +@@ -2051,13 +2058,13 @@ + free_tlist(tt); + + /* Now define the macro for the argument */ +- sprintf(directive, "%%define %s (%s-%d)", local, StackPointer, ++ snprintf(directive, sizeof(directive), "%%define %s (%s-%d)", local, StackPointer, + offset); + do_directive(tokenise(directive)); + offset += size; + + /* Now define the assign to setup the enter_c macro correctly */ +- sprintf(directive, "%%assign %%$localsize %%$localsize+%d", ++ snprintf(directive, sizeof(directive), "%%assign %%$localsize %%$localsize+%d", + size); + do_directive(tokenise(directive)); + +@@ -3182,12 +3189,12 @@ + */ + case '0': + type = TOK_NUMBER; +- sprintf(tmpbuf, "%d", mac->nparam); ++ snprintf(tmpbuf, sizeof(tmpbuf), "%d", mac->nparam); + text = nasm_strdup(tmpbuf); + break; + case '%': + type = TOK_ID; +- sprintf(tmpbuf, "..@%lu.", mac->unique); ++ snprintf(tmpbuf, sizeof(tmpbuf), "..@%lu.", mac->unique); + text = nasm_strcat(tmpbuf, t->text + 2); + break; + case '-': +@@ -4067,7 +4074,7 @@ + return; + + va_start(arg, fmt); +- vsprintf(buff, fmt, arg); ++ vsnprintf(buff, sizeof(buff), fmt, arg); + va_end(arg); + + if (istk && istk->mstk && istk->mstk->name) +@@ -4530,7 +4537,7 @@ + make_tok_num(Token * tok, long val) + { + char numbuf[20]; +- sprintf(numbuf, "%ld", val); ++ snprintf(numbuf, sizeof(numbuf), "%ld", val); + tok->text = nasm_strdup(numbuf); + tok->type = TOK_NUMBER; + } |