------- Comment #5 from steven at gcc dot gnu dot org 2006-07-22 16:36 ------- We do the loop-and-putc thing in ASM_OUTPUT_LIMITED_STRING and in dw2_asm_output_nstring as well. Probably it's best to add some kind of generic "escaped string" print function, something like the one below that I'll try to actually make work:
void asm_output_string_with_escapes (const char *str, size_t len, const char escapes[255], const char *escapes_fmt /* e.g. "\\%03o" */ size_t escapes_fmt_len) { size_t i, j, len, escaped_len; char *escaped_str; escaped_len = len; for (i = 0; i < len; i++) { int c = str[i]; if (c == '\"' || c == '\\') escaped_len++; else if (escapes[c]) escaped_len += escapes_fmt_len; } str = xmalloc (escaped_len + 1); for (i = 0, j = 0; i < len; i++) { int c = str[i]; if (!escapes[c]) { if (c == '\"' || c == '\\') escaped_str[j++] = '\\'; escaped_str[j++] = c; } else { /* ??? Must also handle things like \t and \b here. */ snprintf (&escaped_str[j], escapes_fmt_len, escapes_fmt, c); j += escapes_fmt_len; } } escaped_str[j] = '\0'; fputs (escaped_str, asm_out_file); free (escaped_str); } -- steven at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |steven at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2006-02-08 04:02:15 |2006-07-22 16:36:32 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25468