Module Name: src Committed By: rillig Date: Sat Sep 4 14:48:27 UTC 2021
Modified Files: src/usr.bin/xlint/common: emit.c externs.h src/usr.bin/xlint/lint1: emit1.c Log Message: lint: move outqchar from common to lint1 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/emit1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/emit.c diff -u src/usr.bin/xlint/common/emit.c:1.15 src/usr.bin/xlint/common/emit.c:1.16 --- src/usr.bin/xlint/common/emit.c:1.15 Sat Sep 4 14:42:30 2021 +++ src/usr.bin/xlint/common/emit.c Sat Sep 4 14:48:27 2021 @@ -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 <sys/cdefs.h> #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 <stdio.h> @@ -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 Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.23 src/usr.bin/xlint/common/externs.h:1.24 --- src/usr.bin/xlint/common/externs.h:1.23 Sat Sep 4 14:42:30 2021 +++ src/usr.bin/xlint/common/externs.h Sat Sep 4 14:48:27 2021 @@ -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 *); Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.55 src/usr.bin/xlint/lint1/emit1.c:1.56 --- src/usr.bin/xlint/lint1/emit1.c:1.55 Sat Sep 4 14:26:32 2021 +++ src/usr.bin/xlint/lint1/emit1.c Sat Sep 4 14:48:27 2021 @@ -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 <sys/cdefs.h> #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, 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