From 36b11dc2962c99e6c13b39234aa40f22039784d4 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 10 Aug 1990 18:01:50 +0000 Subject: [PATCH] improved REAL constant and string constant stab generation --- lang/m2/comp/stab.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index 41e39a225..657a8f6d9 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -340,16 +340,28 @@ stb_string(df, kind) adds_db_str(sprint(buf, "c%ld;", df->con_const.TOK_INT)); break; case T_REAL: + addc_db_str('r'); if (! df->con_const.TOK_REAL) { char buf2[FLT_STRLEN]; flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN); - adds_db_str(sprint(buf, "r%s;", buf2)); + adds_db_str(buf2); } - else adds_db_str(sprint(buf, "r%s;", df->con_const.TOK_REAL)); + else adds_db_str(df->con_const.TOK_REAL); + addc_db_str(';'); break; - case T_STRING: - adds_db_str(sprint(buf, "s'%s';", df->con_const.TOK_STR)); + case T_STRING: { + register char *p = df->con_const.TOK_STR; + + adds_db_str("s'"); + while (*p) { + if (*p == '\'' || *p == '\\') { + addc_db_str('\\'); + } + addc_db_str(*p++); + } + adds_db_str("';"); + } break; case T_ENUMERATION: addc_db_str('e'); -- 2.34.1