/*
* 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 2001, 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "gnu_msgfmt.h"
#include "gnu_lex.h"
#include "y.tab.h"
static int backlen = 0;
/*
* get_mb() returns one multibyte character.
*
* This function uses the iconv() function to find out one
* multibyte character from a sequence of bytes in the file stream.
* The conversion from the codeset specified in the PO file to UTF-8
* is performed. The funcition reads another byte and calls iconv(),
* until iconv() successfully returns as a valid UTF-8 character has
* been converted or returns EILSEQ. If iconv() successfully returned,
* the function returns the read bytes as one character. Otherwise,
* returns error. The string converted to UTF-8 in outbuf won't be
* used at all.
*/
static size_t
{
int c;
const char *inptr;
char *outptr;
/* no conversion */
return (insize);
}
for (; ; ) {
errno = 0;
/* iconv failed */
switch (errno) {
case EILSEQ:
/* invalid character found */
/* NOTREACHED */
case EINVAL:
/* not enough input */
if (insize == MB_LEN_MAX) {
/* invalid character found */
/* NOTREACHED */
}
if (c == EOF) {
/* NOTREACHED */
}
/* initialize the conversion */
continue;
/* NOTREACHED */
default:
/* should never happen */
/* NOTREACHED */
}
/* NOTREACHED */
}
return (insize);
/* NOTRECHED */
}
}
static void
po_uninput(int c)
{
if (c == '\n')
cur_line--;
}
static void
{
if (backlen) {
/* NOTREACHED */
}
}
}
static struct ch *
po_getc(void)
{
int c;
if (backlen) {
backlen = 0;
return (&och);
}
for (; ; ) {
if (c == EOF) {
/* error happend */
/* NOTREACHED */
}
return (&och);
}
if (c == '\\') {
if (c == '\n') {
/* this newline should be escaped */
cur_line++;
continue;
} else {
po_uninput(c);
return (&och);
}
/* NOTREACHED */
}
if (c == '\n') {
cur_line++;
return (&och);
}
if (isascii((unsigned char)c)) {
/* single byte ascii */
return (&och);
}
return (&och);
}
/* NOTREACHED */
}
static void
{
char *tmp;
}
static struct ch *
expand_es(void)
{
int c, n, loop;
/* NOTREACHED */
}
/* not a valid escape sequence */
return (pch);
}
case '"':
case '\\':
break;
case 'b':
break;
case 'f':
break;
case 'n':
break;
case 'r':
break;
case 't':
break;
case 'v':
break;
case 'a':
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
/* octal */
for (n = 0, loop = 0; ; ) {
n = n * 8 + c - '0';
loop++;
if (loop >= 3)
break;
/* NOTREACHED */
}
break;
}
break;
case 'x':
/* hex */
/* NOTREACHED */
}
break;
}
if (!isxdigit((unsigned char)c)) {
break;
}
if (isdigit((unsigned char)c)) {
n = c - '0';
} else if (isupper((unsigned char)c)) {
n = c - 'A' + 10;
} else {
n = c - 'a' + 10;
}
/* NOTREACHED */
}
break;
}
if (!isxdigit((unsigned char)c)) {
break;
}
n *= 16;
if (isdigit((unsigned char)c)) {
n += c - '0';
} else if (isupper((unsigned char)c)) {
n += c - 'A' + 10;
} else {
n += c - 'a' + 10;
}
break;
default:
break;
}
return (&och);
}
int
yylex(void)
{
unsigned int uc;
char *buf;
for (; ; ) {
/* EOF */
return (0);
}
/* multi byte */
return (CHR);
}
/* single byte */
case ' ':
case '\t':
case '\n':
break;
case '#':
/* comment start */
buf_pos = 0;
}
return (COMMENT);
/* NOTREACHED */
case '[':
case ']':
/* NOTREACHED */
case '"':
buf_pos = 0;
for (; ; ) {
/* EOF */
/* NOTREACHED */
}
if (uc == '\n') {
/* NOTREACHED */
}
if (uc == '"')
break;
if (uc == '\\')
}
MBUFSIZE);
}
return (STR);
/* NOTREACHED */
default:
buf_pos = 0;
KBUFSIZE);
}
/* push back the last char */
if (buf_pos > MAX_KW_LEN) {
/* kbuf is longer than any keywords */
return (SYMBOL);
}
return (DOMAIN);
return (MSGID);
return (MSGID_PLURAL);
return (MSGSTR);
} else {
return (SYMBOL);
}
/* NOTREACHED */
}
buf_pos = 0;
NBUFSIZE);
}
/* push back the last char */
return (NUM);
}
/* just a char */
return (CHR);
/* NOTREACHED */
}
}
}