quote: make the input argument to nasm_quote() const

Whereas nasm_unquote() unquotes the argument in place, nasm_quote()
has to allocate a new string (since the new string will *always* be
longer than the old string!)  Make the old string const since we're
making a copy anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-05-10 02:54:15 -07:00
parent c74a709885
commit b157701b17
2 changed files with 4 additions and 3 deletions

View file

@ -42,9 +42,10 @@
#include "nasmlib.h"
#include "quote.h"
char *nasm_quote(char *str, size_t len)
char *nasm_quote(const char *str, size_t len)
{
char c, c1, *p, *q, *nstr, *ep;
const char *p, *ep;
char c, c1, *q, *nstr;
unsigned char uc;
bool sq_ok, dq_ok;
size_t qlen;

View file

@ -36,7 +36,7 @@
#include "compiler.h"
char *nasm_quote(char *str, size_t len);
char *nasm_quote(const char *str, size_t len);
size_t nasm_unquote(char *str, char **endptr);
char *nasm_skip_string(char *str);