mkstr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 1992 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* from UCB 4.1 10/01/80 */
#include <stdio.h>
#include <locale.h>
long ftell();
char *calloc();
/*
* mkstr - create a string error message file by massaging C source
*
* Bill Joy UCB August 1977
*
* Modified March 1978 to hash old messages to be able to recompile
* without addding messages to the message file (usually)
*
* Based on an earlier program conceived by Bill Joy and Chuck Haley
*
* Program to create a string error message file
* from a group of C programs. Arguments are the name
* of the file where the strings are to be placed, the
* prefix of the new files where the processed source text
* is to be placed, and the files to be processed.
*
* The program looks for 'error("' in the source stream.
* Whenever it finds this, the following characters from the '"'
* to a '"' are replaced by 'seekpt' where seekpt is a
* pointer into the error message file.
* If the '(' is not immediately followed by a '"' no change occurs.
*
* The optional '-' causes strings to be added at the end of the
* existing error message file for recompilation of single routines.
*/
char *progname;
char usagestr[] = "usage: %s [ - ] mesgfile prefix file ...\n";
int argc;
char *argv[];
{
char addon = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 3)
inithash();
do {
process();
} while (argc > 0);
exit(0);
/* NOTREACHED */
}
process()
{
register char *cp;
register c;
for (;;) {
c = getchar();
if (c == EOF)
return;
if (c != 'e') {
putchar(c);
continue;
}
if (match("error(")) {
c = getchar();
if (c != '"')
putchar(c);
else
copystr();
}
}
}
char *ocp;
{
register char *cp;
register c;
c = getchar();
if (c != *cp) {
ungetchar(c);
return (0);
}
}
return (1);
}
copystr()
{
register c, ch;
char buf[512];
for (;;) {
c = getchar();
if (c == EOF)
break;
switch (c) {
case '"':
*cp++ = 0;
goto out;
case '\\':
c = getchar();
switch (c) {
case 'b':
c = '\b';
break;
case 't':
c = '\t';
break;
case 'r':
c = '\r';
break;
case 'n':
c = '\n';
break;
case '\n':
continue;
case 'f':
c = '\f';
break;
case '0':
c = 0;
break;
case '\\':
break;
default:
if (!octdigit(c))
break;
c -= '0';
break;
break;
break;
}
}
*cp++ = c;
}
out:
*cp = 0;
}
octdigit(c)
char c;
{
return (c >= '0' && c <= '7');
}
inithash()
{
char buf[512];
int mesgpt = 0;
}
}
#define NBUCKETS 511
struct hash {
long hval;
unsigned hpt;
char *str;
char really;
unsigned fakept;
{
int i;
char buf[512];
long hashval = 0;
register char *cp;
if (really)
if (i < 0)
i += NBUCKETS;
if (really != 0)
/*
fprintf(stderr, gettext("Got (from %d) %s\n"), hp->hpt, buf);
*/
break;
}
if (really) {
}
}
/*
fprintf(stderr, gettext("%s hashed to %ld at %d\n"), str, hp->hval, hp->hpt);
*/
}
char *obuf;
register int rmdr;
{
register c;
*buf++ = c;
*buf++ = 0;
}