/*
* Copyright 1989 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/*
* xstr - extract and hash strings in a C program
*
* Bill Joy UCB
* November, 1978
*/
void onintr(void);
char *savestr(char *);
void cleanup(void);
void process(char *);
int octdigit(char);
void inithash(void);
void flushsh(void);
void prstr(char *);
void xsdotc(void);
int lastchr(char *);
int istail(char *, char *);
int cflg;
int vflg;
int readstd;
int tmpfd;
int
{
argc--;
if (*cp == 0) {
readstd++;
continue;
}
do switch (*cp++) {
case 'c':
cflg++;
continue;
case 'l':
argc--;
continue;
case 'v':
vflg++;
continue;
default:
"usage: xstr [ -v ] [ -c ] [ -l label ] [ - ] [ name ... ]\n");
} while (*cp);
}
inithash();
else {
if (tmpfd == -1) {
exit(9);
}
}
if (readstd == 0)
else
readstd = 0;
}
flushsh();
if (cflg == 0)
xsdotc();
(void) cleanup();
return (0);
}
void
{
char *cp;
int c;
int incomm = 0;
int ret;
for (;;) {
(void) cleanup();
exit(3);
}
break;
}
if (linebuf[0] == '#') {
else
continue;
}
switch (c) {
case '"':
if (incomm)
goto def;
goto out;
break;
case '\'':
if (incomm)
goto def;
(void) putchar(c);
if (*cp)
break;
case '/':
goto def;
incomm = 1;
cp++;
(void) printf("/*");
continue;
case '*':
incomm = 0;
cp++;
(void) printf("*/");
continue;
}
goto def;
def:
default:
(void) putchar(c);
break;
}
}
}
out:
}
{
int c, ch;
char *tp;
while ((c = *cp++) != 0) {
switch (c) {
case '"':
cp++;
goto out;
case '\\':
c = *cp++;
if (c == 0)
break;
if (c == '\n') {
== NULL) {
(void) cleanup();
exit(3);
}
return (-1);
}
continue;
}
tp++)
if (c == ch) {
c = *tp;
goto gotc;
}
if (!octdigit(c)) {
*dp++ = '\\';
break;
}
c -= '0';
break;
break;
break;
}
gotc:
*dp++ = c;
}
out:
*dp = 0;
}
int
octdigit(char c)
{
}
void
inithash(void)
{
return;
for (;;) {
break;
}
}
int
{
int c;
*buf++ = c;
*buf++ = 0;
}
int
{
tellpt++;
}
struct hash {
char *hstr;
short hnew;
{
int i;
if (i >= 0)
}
perror("xstr");
(void) cleanup();
exit(8);
}
}
void
flushsh(void)
{
int i;
for (i = 0; i < BUCKETS; i++)
new++;
else
old++;
return;
for (i = 0; i < BUCKETS; i++)
(void) cleanup();
exit(4);
}
}
}
}
void
{
if (vflg == 0)
return;
if (!new)
else
}
void
{
int c;
while ((c = (*cp++ & 0377)) != 0)
if (c < ' ')
else if (c == 0177)
else if (c > 0200)
else
}
void
xsdotc(void)
{
for (;;) {
int i, c;
for (i = 0; i < 8; i++) {
onintr();
}
goto out;
}
}
}
out:
}
char *
{
char *dp;
perror("xstr");
exit(8);
}
}
int
{
cp++;
return ((int)*cp);
}
int
{
return (-1);
return (d);
}
void
onintr(void)
{
(void) cleanup();
exit(7);
}
void
cleanup(void)
{
if (strings[0] == '/') {
}
}