Skip to content

Commit 0ee113c

Browse files
Fabian GiesenH. Peter Anvin
authored andcommitted
Don't assume pragma directives are a single word
pragma->tail is described as "anything after the operation", but existing parsing passed just the first whitespace-delimited word. Change the parsing to just strip leading and trailing white space off the rest of the line, but keep interior spaces if there are any. This is preparation for a build_version pragma for Mach-O matching the llvm-as .build_version syntax. Signed-off-by: Fabian Giesen <fabian.giesen@epicgames.com>
1 parent b4697f0 commit 0ee113c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

asm/pragma.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,16 @@ void process_pragma(char *str)
242242
else
243243
pragma.opcode = directive_find(pragma.opname);
244244

245-
pragma.tail = nasm_trim_spaces(p);
245+
/*
246+
* This used to use nasm_trim_spaces, but that assumes a single word.
247+
* Instead, strip spaces at either end of the directive, but allow
248+
* interior spaces.
249+
*/
250+
p = nasm_zap_spaces_fwd(p);
251+
pragma.tail = p;
252+
p += strlen(p);
253+
while (p > pragma.tail && nasm_isspace(p[-1]))
254+
*--p = 0;
246255

247256
/*
248257
* Search the global pragma namespaces. This is done

0 commit comments

Comments
 (0)