lint: move outqchar from common to lint1
This commit is contained in:
parent
73d18e3648
commit
5f36d6b263
|
@ -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
|
||||
|
|
|
@ -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 *);
|
||||
|
|
|
@ -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, 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
|
||||
|
|
Loading…
Reference in New Issue