diff --git a/usr.bin/xlint/common/emit.c b/usr.bin/xlint/common/emit.c index 1ae524fa95fc..5a3c310a28df 100644 --- a/usr.bin/xlint/common/emit.c +++ b/usr.bin/xlint/common/emit.c @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.16 2021/09/04 14:48:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.16 2021/09/04 14:48:27 rillig Exp $"); #endif #include @@ -131,57 +131,6 @@ outchar(char c) *ob.o_next++ = c; } -#if defined(IS_LINT1) -/* write a character to the output buffer, quoted if necessary */ -void -outqchar(char c) -{ - - if (ch_isprint(c) && c != '\\' && c != '"' && c != '\'') { - outchar(c); - } else { - outchar('\\'); - switch (c) { - case '\\': - outchar('\\'); - break; - case '"': - outchar('"'); - break; - case '\'': - outchar('\''); - break; - case '\b': - outchar('b'); - break; - case '\t': - outchar('t'); - break; - case '\n': - outchar('n'); - break; - case '\f': - outchar('f'); - break; - case '\r': - outchar('r'); - break; - case '\v': - outchar('v'); - break; - case '\a': - outchar('a'); - break; - default: - outchar((char)((((unsigned char)c >> 6) & 07) + '0')); - outchar((char)((((unsigned char)c >> 3) & 07) + '0')); - outchar((char)((c & 07) + '0')); - break; - } - } -} -#endif - /* * write a string to the output buffer * the string must not contain any characters which diff --git a/usr.bin/xlint/common/externs.h b/usr.bin/xlint/common/externs.h index 19edebfd6698..6ebcdd609714 100644 --- a/usr.bin/xlint/common/externs.h +++ b/usr.bin/xlint/common/externs.h @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.23 2021/09/04 14:42:30 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.24 2021/09/04 14:48:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -60,7 +60,6 @@ extern void outopen(const char *); extern void outclose(void); extern void outclr(void); extern void outchar(char); -extern void outqchar(char); extern void outstrg(const char *); extern void outint(int); extern void outname(const char *); diff --git a/usr.bin/xlint/lint1/emit1.c b/usr.bin/xlint/lint1/emit1.c index 2255923a1136..cde5099bc955 100644 --- a/usr.bin/xlint/lint1/emit1.c +++ b/usr.bin/xlint/lint1/emit1.c @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.55 2021/09/04 14:26:32 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.56 2021/09/04 14:48:27 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit1.c,v 1.55 2021/09/04 14:26:32 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.56 2021/09/04 14:48:27 rillig Exp $"); #endif #include "lint1.h" @@ -431,6 +431,56 @@ outcall(const tnode_t *tn, bool rvused, bool rvdisc) outtype(tn->tn_type); } +/* write a character to the output buffer, quoted if necessary */ +static void +outqchar(char c) +{ + + if (ch_isprint(c) && c != '\\' && c != '"' && c != '\'') { + outchar(c); + return; + } + + outchar('\\'); + switch (c) { + case '\\': + outchar('\\'); + break; + case '"': + outchar('"'); + break; + case '\'': + outchar('\''); + break; + case '\b': + outchar('b'); + break; + case '\t': + outchar('t'); + break; + case '\n': + outchar('n'); + break; + case '\f': + outchar('f'); + break; + case '\r': + outchar('r'); + break; + case '\v': + outchar('v'); + break; + case '\a': + outchar('a'); + break; + default: + outchar((char)((((unsigned char)c >> 6) & 07) + '0')); + outchar((char)((((unsigned char)c >> 3) & 07) + '0')); + outchar((char)((c & 07) + '0')); + break; + } +} + /* * extracts potential format specifiers for printf() and scanf() and * writes them, enclosed in "" and quoted if necessary, to the output buffer