Article 13726 of alt.sources:
Path: nntpd.lkg.dec.com!lead.zk3.dec.com!pa.dec.com!news1.digital.com!nntp-hub2.barrnet.net!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!uunet!in1.uu.net!news.iij.ad.jp!wnoc-tyo-news!waseda.ac.jp!cfi.waseda!wsdnws.cfi.waseda.ac.jp!seiichi
From: seiichi@muraoka.info.waseda.ac.jp (YOSHIDA Seiichi)
Newsgroups: alt.sources
Subject: pad2ps-3.1 (8/11)
Followup-To: alt.sources
Date: 03 Nov 1996 10:32:24 GMT
Organization: Centre for Infomatics, Waseda University
Lines: 4472
Distribution: world
Message-ID: <SEIICHI.96Nov3193224@muras5.muraoka.info.waseda.ac.jp>
NNTP-Posting-Host: unknown@muras5.muraoka.info.waseda.ac.jp
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Xref: nntpd.lkg.dec.com alt.sources:13726

#!/bin/sh
# This is `pad2ps-3.1.08' (part 8 of a multipart archive).
# Do not concatenate these parts, unpack them in order with `/bin/sh'.
# File `pad2ps-3.1/src/c2pad/token.c' is being continued...
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if test ! -r _sh23946/seq; then
  $echo 'Please unpack part 1 first!'
  exit 1
fi
shar_sequence=`cat _sh23946/seq`
if test "$shar_sequence" != 8; then
  $echo 'Please unpack part' "$shar_sequence" 'next!'
  exit 1
fi
if test ! -f _sh23946/new; then
  $echo 'x -' 'STILL SKIPPING' 'pad2ps-3.1/src/c2pad/token.c'
else
  $echo 'x -' 'continuing file' 'pad2ps-3.1/src/c2pad/token.c'
  sed 's/^X//' << 'SHAR_EOF' >> pad2ps-3.1/src/c2pad/token.c &&
X		    get_ch();
X		    return;
X		case '=':
X		    token = Less_eq;
X		    append_ch();
X		    get_ch();
X		    return;
X		default:
X		    token = Less;
X		    return;
X	    }
X	case '>':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    switch(ch){
X		case '>':
X		    token = Rshift;
X		    append_ch();
X		    get_ch();
X		    return;
X		case '=':
X		    token = Great_eq;
X		    append_ch();
X		    get_ch();
X		    return;
X		default:
X		    token = Great;
X		    return;
X		}
X	case '&':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '&'){
X		token=And;
X		return;
X	    }else{
X		token = And2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '|':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '|'){
X		token = Or;
X		return;
X	    }else{
X		token = Or2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '=':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '='){
X		token = Equal;
X		return;
X	    }else{
X		token = Equal2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '!':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '='){
X		token = Not;
X		return;
X	    }else{
X		token = Neq;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '^':
X	    newline = Off;
X	    token = Exp;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '*':
X	    newline = Off;
X	    token = Times;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '+':
X	    newline = Off;
X	    token = Plus;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '-':
X	    newline = Off;
X	    token = Minus;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '(':
X	    newline = Off;
X	    token = Lpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ')':
X	    newline = Off;
X	    token = Rpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '{':
X	    newline = Off;
X	    token = Lbrace;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '}':
X	    newline = Off;
X	    token = Rbrace;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '[':
X	    newline = Off;
X	    token = Lbracket;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ']':
X	    newline = Off;
X	    token = Rbracket;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '?':
X	    newline = Off;
X	    token = Question;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ':':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != ':'){
X		token = Colon;
X		return;
X	    }else{
X		token = Colon2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case ';':
X	    newline = Off;
X	    token = Semicolon;
X	    set_ch();
X	    get_ch();
X	    return;
X	default:
X	    newline = Off;
X	    if(isdigit(ch)){
X		token = Num;
X		set_ch();
X		get_ch();
X		while(isdigit(ch)){
X		    append_ch();
X		    get_ch();
X		}
X		return;
X	    }
X
X	    if(isalpha(ch)  ||  ch == '_'){
X		token = Name;
X		set_ch();
X		get_ch();
X		while(isalnum(ch)  ||  (char)ch == '_'){
X		    append_ch();
X		    get_ch();
X		}
X
X		if(strcmp(word,"if") == 0)
X		    token = If;
X		else if(strcmp(word,"else") == 0)
X		    token = Else;
X		else if(strcmp(word,"while") == 0)
X		    token = While;
X		else if(strcmp(word,"for") == 0)
X		    token = For;
X		else if(strcmp(word,"do") == 0)
X		    token = Do;
X		else if(strcmp(word,"switch") == 0)
X		    token = Switch;
X		else if(strcmp(word,"case") == 0)
X		    token = Case;
X		else if(strcmp(word,"default") == 0)
X		    token = Default;
X		else if(strcmp(word,"return") == 0)
X		    token = Return;
X		else if(strcmp(word,"break") == 0)
X		    token = Break;
X		else if(strcmp(word,"continue") == 0)
X		    token = Continue;
X		else if(strcmp(word,"goto") == 0)
X		    token = Goto;
X		else if(strcmp(word,"public") == 0)
X		    token = Public;
X		else if(strcmp(word,"private") == 0)
X		    token = Private;
X		else if(strcmp(word,"protected") == 0)
X		    token = Protected;
X		else if(strcmp(word,"ifdef") == 0)
X		    token = Ifdef;
X		else if(strcmp(word,"ifndef") == 0)
X		    token = Ifndef;
X		else if(strcmp(word,"elif") == 0)
X		    token = Elif;
X		else if(strcmp(word,"endif") == 0)
X		    token = Endif;
X		else if(strcmp(word,"define") == 0)
X		    token = Define;
X		else if(strcmp(word,"undef") == 0)
X		    token = Undef;
X		else if(strcmp(word,"defined") == 0)
X		    token = Defined;
X
X		return;
X	    }
X
X	    token = Str;
X	    set_ch();
X	    get_ch();
X	    return;
X    }
}
X
void set_ch(void)
/* set the character just read */
{
X    *word = ch;
X    *(word + 1) = '\0';
X    word_ptr = 1;
}
X
void append_ch(void)
/* append the character just read */
{
X    *(word + word_ptr) = ch;
X    *(word + word_ptr + 1) = '\0';
X    word_ptr++;
}
X
void get_ch(void)
/* get a characte */
{
X    if(ch == 0){
X	ch = getc(input_stream);
X	pch = getc(input_stream);
X    }else{
X	ch = pch;
X	pch = getc(input_stream);
X    }
X
X    while(ch == '\\'  &&  pch == '\n'){		/* discard '\' at the end of line */
X	line_count++;
X	ch = getc(input_stream);
X	pch = getc(input_stream);
X    }
X
X    if(ch == '\n')
X	line_count++;
}
X
#ifndef PRINT_COMMENT_IMMEDIATELY
void preserve_comment(void)
/* preserve comment */
{
X    char *s;
X    int l;
X
X    l = strlen(word);
X    s = (char *)malloc((l+3) * sizeof(char));
X    strcpy(s,word);
X    strcat(s,"\n");
X
X    if(comm == NULL)
X	comm = s;
X    else
X	comm = joint(2,comm,s);
}
#endif
SHAR_EOF
  $echo 'File' 'pad2ps-3.1/src/c2pad/token.c' 'is complete' &&
  $shar_touch -am 0820130496 'pad2ps-3.1/src/c2pad/token.c' &&
  chmod 0644 'pad2ps-3.1/src/c2pad/token.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/c2pad/token.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/c2pad/token.c:' 'MD5 check failed'
2719ffd4c0bed7703684e0b4d3aa14ea  pad2ps-3.1/src/c2pad/token.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/c2pad/token.c'`"
    test 10052 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/c2pad/token.c:' 'original size' '10052,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/c2pad/Makefile.in ==============
if test -f 'pad2ps-3.1/src/c2pad/Makefile.in' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/c2pad/Makefile.in' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/c2pad/Makefile.in' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/c2pad/Makefile.in' &&
### Makefile of c2pad  by S. Yoshida
X
### configuration by configure
X
prefix = @prefix@
exec_prefix = @exec_prefix@
LIBDIR = @libdir@/pad2ps
X
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
X
CC = @CC@
X
LIBS = @LIBS@ -L../lib -lpublic
X
### make commands
X
CFLAGS = -O2
LDFLAGS =
MFLAGS =
X
INCLUDES = -I.. -I../lib
X
HDRS = c2pad.h
SRCS = c2pad.c ifdef.c parser.c token.c
OBJS = c2pad.o ifdef.o parser.o token.o
X
TARGS = c2pad
X
all: ${TARGS}
X
c2pad: ${OBJS} ${HDRS}
X	$(CC) $(LDFLAGS) ${OBJS} -o $@ $(LIBS)
X
%.o: %.c
X	$(CC) $(CFLAGS) $(INCLUDES) -c $<
X
install: ${TARGS}
X	$(INSTALL) -d $(LIBDIR)
X	if [ -f $(LIBDIR)/c2pad ]; then rm -f $(LIBDIR)/c2pad; fi
X	$(INSTALL_PROGRAM) c2pad $(LIBDIR)
X
clean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X
distclean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X	rm -f Makefile
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/c2pad/Makefile.in' &&
  chmod 0644 'pad2ps-3.1/src/c2pad/Makefile.in' ||
  $echo 'restore of' 'pad2ps-3.1/src/c2pad/Makefile.in' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/c2pad/Makefile.in:' 'MD5 check failed'
a7a127b00adc2ac13ddfbf9bcdb76a9d  pad2ps-3.1/src/c2pad/Makefile.in
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/c2pad/Makefile.in'`"
    test 848 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/c2pad/Makefile.in:' 'original size' '848,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/csh2pad/parser.c ==============
if test ! -d 'pad2ps-3.1/src/csh2pad'; then
  $echo 'x -' 'creating directory' 'pad2ps-3.1/src/csh2pad'
  mkdir 'pad2ps-3.1/src/csh2pad'
fi
if test -f 'pad2ps-3.1/src/csh2pad/parser.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/csh2pad/parser.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/csh2pad/parser.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/csh2pad/parser.c' &&
/*                                                                  */
/*  parser.c -- Translate C shell program to PADEL and print result */
/*                                                                  */
/*  csh2pad  by S. Yoshida                                          */
/*                                                                  */
X
#include "config.h"
X
#include <string.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include <ctype.h>
#include "csh2pad.h"
#include "lib.h"
X
#define MAKE_STRING_WHILE(X)	{\
X				    count_paren = 0;\
X				    cat_flag_tmp = 0;\
X				    key_tmp[0] = '\0';\
X				    if(token == LL)\
X					cat_flag_tmp = 1;\
X				    set_str();\
X				    get_token();\
X				    while(X){\
X					if(token == Ret){\
X					    append(" ");\
X					    *sp = '\0';\
X					    do{\
X						get_token();\
X					    }while(token == Sp);\
X					}else{\
X					    if(token == Sp){\
X						strcat(sp,word);\
X						if(cat_flag_tmp == 2)\
X						    cat_flag_tmp = 0;\
X					    }else{\
X						if(token == Lpar)\
X						     count_paren--;\
X						if(token == Rpar)\
X						     count_paren++;\
X						if(cat_flag_tmp == 1)\
X						    cat_flag_tmp = 2;\
X						if(cat_flag_tmp == 2)\
X						    strcat(key_tmp,word);\
X						if(token == LL)\
X						    cat_flag_tmp = 1;\
X						if(*sp != '\0')\
X						    append(sp);\
X						*sp = '\0';\
X						append_str();\
X					    }\
X					    get_token();\
X					}\
X				    }\
X				    if(*sp != '\0')\
X					append(sp);\
X				    *sp = '\0';\
X				}
X
#define END_OF_LINE()		{\
X				    tt = token; get_token();\
X				    if(strlen(key)==0){\
X					while(token == Sp)\
X					    get_token();\
X					if(tt != Ret  &&  token == Ret)\
X					    get_token();\
X				    }\
X				}
X
static char *str = NULL;
static int nest_level = 0;
static int count_paren = 0;
static token_type tt = Nontoken;
static char key_tmp[BUFSIZ] = {'\0'};
static int cat_flag_tmp = 0;
X
static void body(void);
static void command(void);
static void for_statement(void);
static void if_statement(void);
static void condition(void);
X
static void set_str(void);
static void append_str(void);
static void append(char *);
static void print_str(void);
static void print_hsp(void);
X
void parser(void)
/* output */
{
#ifdef DEBUG
X    if(quiet == Off)
X	fprintf(stderr,"Translating C shell program into PADEL starts...");
#endif
X
X    puts("{");
X    get_token();
X    body();
X    puts("}");
X
#ifdef DEBUG
X    if(quiet == Off)
X	fprintf(stderr,"done\n");
#endif
}
X
void body(void)
{
X    char sp[BUFSIZ] = {'\0'};
X
X    while(token != Eof){
X	if (cat_flag > 0) {	/* such as "cat << EOF" */
X	    puts("{");
X	    while (cat_flag > 0  &&  token != Eof) {
X		MAKE_STRING_WHILE(token != Ret  &&  token != Eof);
X		if (strcmp(str,key) == 0) {
X		    key[0] = '\0';
X		    cat_flag = 0;
X		    free(str);
X		    str = NULL;
X		} else {
X		    printf("> ");
X		    print_str();
X		    putchar('\n');
X		}
X		get_token();
X	    }
X	    puts("}");
X	}
X
X	while(token == Sp)
X	    get_token();
X
X	if (token == End  ||  token == Else  ||  token == Endif  ||  token == Endsw  ||  token == Rpar)
X	    return;
X
X	command();
X    }
}
X
void command(void)
{
X    char sp[BUFSIZ] = {'\0'};
X    char buf[BUFSIZ];
X    int i,p;
X
X    switch(token){
X	case Foreach:
X	case While:
X	case Switch:
X	    for_statement();
X	    break;
X	case If:
X	    if_statement();
X	    break;
X	case Case:
X	case Default:
X	    MAKE_STRING_WHILE(token != Colon  &&  token != Eof);
X	    nest_level--;
X	    print_hsp();
X	    nest_level++;
X	    print_str();
X	    printf(":\n");
X	    get_token();
X	    while(token == Sp  ||  token == Ret)
X		get_token();
X	    break;
X	case Ret:
X	    putchar('\n');
X	    get_token();
X	    break;
X	case Semicolon:
X	    print_hsp();
X	    printf("{    }\n");
X	    END_OF_LINE();
X	    break;
X	case Break:
X	case Breaksw:
X	case Continue:
X	case Goto:
X	    MAKE_STRING_WHILE(token != Semicolon  &&  token != Ret  &&  token != Eof);
X	    print_hsp();
X	    print_str();
X	    putchar('\n');
X	    END_OF_LINE();
X	    break;
X	case Lpar:
X            putchar('\n');
X            END_OF_LINE();
X            nest_level++;
X            body();             /* repetition body */
X            nest_level--;
X            END_OF_LINE();
X            break;
X	case Label:
X	    set_str();
X	    print_str();
X	    putchar('\n');
X	    END_OF_LINE();
X	    break;
X	default:
X	    MAKE_STRING_WHILE(((token != Semicolon  &&  token != Ret  &&  token != Rpar  &&  token !=  And2  &&  token != Or2)  ||  count_paren < 0)  &&  token != Eof);
X	    /* such as "cat << EOF" */
X	    if (strlen(key_tmp) > 0) {
X		if (key_tmp[0] == '"'  ||  key_tmp[0] == '\'') {
X		    key_tmp[strlen(key_tmp) - 1] = '\0';
X		    strcpy(key,key_tmp+1);
X		} else {
X		    strcpy(key,key_tmp);
X		}
X	    }
X	    if (token == Ret)
X		cat_flag = strlen(key);
X
X	    print_hsp();
X	    if(token == Rpar){
X		print_str();
X		putchar('\n');
X		return;
X	    }else if(token == And2  ||  token == Or2){  /* condition */
X		sprintf(buf,"%s )",word);
X
X		get_token();
X		while (token == Sp  ||  token == Ret) {
X		    get_token();
X		}
X
X		printf("if ( ");
X		print_str();
X		fputs(buf,stdout);
X
X		if (token == Lpar) {
X		    puts(" {");
X		    END_OF_LINE();
X		    nest_level++;
X		    body();             /* repetition body*/
X		    nest_level--;
X		    print_hsp();
X		    puts("}");
X		} else {
X		    putchar('\n');
X		    nest_level++;
X		    command();          /* repetition body */
X		    nest_level--;
X		    return;
X		}
X	    }else{
X		print_str();
X		putchar('\n');
X		for(i = 0 ; i < count_paren ; i++)
X		    putchar('\n');
X	    }
X	    END_OF_LINE();
X    }
}
X
void for_statement(void)
{
X    int i;
X    char sp[BUFSIZ] = {'\0'};
X    token_type type;
X
X    type = token;
X
X    set_str();
X    print_hsp();
X
X    if (type == Foreach)
X	printf("for");
X    else
X	print_str();
X
X    get_token();
X    while (token == Sp) {
X	strcat(sp,word);
X	get_token();
X    }
X    fputs(sp,stdout);
X
X    if (type == Foreach) {
X	putchar('(');
X	MAKE_STRING_WHILE(token != Ret  &&  token != Semicolon  &&  token != Eof);
X	i = strlen(str) - 1;
X	while(isspace(str[i])  &&  i >= 0)
X	    str[i--] = '\0';
X	print_str();
X	printf(")%s{\n",sp);
X    } else {
X	condition();
X	print_str();
X	printf("%s{\n",sp);
X	while (token != Ret  &&  token != Semicolon  &&  token != Eof)
X	    get_token();
X    }
X    END_OF_LINE();
X
X    nest_level++;
X    if(type == Switch)
X	nest_level++;
X    body();				/* repetition body */
X    nest_level--;
X    if(type == Switch)
X	nest_level--;
X
X    print_hsp();
X    puts("}");
X
X    while (token != Ret  &&  token != Semicolon  &&  token != Eof)
X	get_token();
X    END_OF_LINE();
}
X
void if_statement(void)
{
X    char sp[BUFSIZ] = {'\0'};
X
X    set_str();
X
X    if(elseif_flag == On)	/*spacing at the head of line is not required with "else if" */
X	elseif_flag = Off;
X    else
X	print_hsp();
X
X    print_str();
X
X    get_token();
X    while (token == Sp) {
X	strcat(sp,word);
X	get_token();
X    }
X    fputs(sp,stdout);
X
X    condition();
X    print_str();
X
X    sp[0] = '\0';
X    while (token == Sp) {
X	strcat(sp,word);
X	get_token();
X    }
X
X    if (token != Then) {
X	putchar('\n');
X	nest_level++;
X	command();
X	nest_level--;
X
X	while (token == Sp)
X	    get_token();
X	if (token != Else)
X	    return;
X	else {
X	    print_hsp();
X	    printf("else");
X	}
X    } else {
X	printf("%s{\n",sp);
X	while (token != Ret  &&  token != Semicolon  &&  token != Eof)
X	    get_token();
X	END_OF_LINE();
X
X	nest_level++;
X	body();
X	nest_level--;
X
X	print_hsp();
X	if (token == Endif) {
X	    puts("}");
X	    while (token != Ret  &&  token != Semicolon  &&  token != Eof)
X		get_token();
X	    END_OF_LINE();
X	    return;
X 	} else
X	    printf("}%selse",sp);
X    }
X
X    sp[0] = '\0';
X    no_print_comment_flag = On;
X    get_token();
X    while (token == Sp) {
X	strcat(sp,word);
X	get_token();
X    }
X    no_print_comment_flag = Off;
X
X    if (token == If) {
X	fputs(sp,stdout);
X	elseif_flag = On;
X	if_statement();
X    } else {
X	if (token == Comment)	/* comment right after "else" */
X	    printf("%s\n%s\n{\n",sp,word);
X	else
X	    printf("%s{\n",sp);
X	END_OF_LINE();
X
X	nest_level++;
X	body();
X	nest_level--;
X
X	print_hsp();
X	puts("}");
X
X	while (token != Ret  &&  token != Semicolon  &&  token != Eof)
X	    get_token();
X	END_OF_LINE();
X    }
}
X
void condition(void)
{
X    char sp[BUFSIZ] = {'\0'};
X
X    append_str();
X    get_token();
X
X    while(token != Rpar  &&  token != Eof){
X	if(token == Lpar)
X	    condition();
X	else{
X	    if(token == Sp)
X		strcat(sp,word);
X	    else{
X		if(*sp != '\0')
X		    append(sp);
X		*sp = '\0';
X		append_str();
X	    }
X
X	    get_token();
X	}
X    }
X
X    if(*sp != '\0')
X	append(sp);
X    append_str();
X    get_token();
}
X
void set_str(void)
{
X    int l;
X
X    l = strlen(word);
X    str = (char *)malloc((l+2) * sizeof(char));
X    strcpy(str,word);
}
X
void append_str(void)
{
X    int l;
X    char *s;
X
X    l = strlen(word);
X    s = (char *)malloc((l+2) * sizeof(char));
X    strcpy(s,word);
X    str = joint(2,str,s);
}
X
void append(char *p)
{
X    int l;
X    char *s;
X
X    l = strlen(p);
X    s = (char *)malloc((l+2) * sizeof(char));
X    strcpy(s,p);
X    str = joint(2,str,s);
}
X
void print_str(void)
{
X    if(str != NULL){
X	printf("%s",str);
X	free(str);
X	str = NULL;
X    }
}
X
void print_hsp(void)
{
X    int i;
X
X    for(i = 0 ; i < nest_level * tab ; i++)
X	putchar(' ');
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/csh2pad/parser.c' &&
  chmod 0644 'pad2ps-3.1/src/csh2pad/parser.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/csh2pad/parser.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/csh2pad/parser.c:' 'MD5 check failed'
f4c7e04a705a1d2b1a4e3f60668827c2  pad2ps-3.1/src/csh2pad/parser.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/csh2pad/parser.c'`"
    test 9156 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/csh2pad/parser.c:' 'original size' '9156,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/csh2pad/token.c ==============
if test -f 'pad2ps-3.1/src/csh2pad/token.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/csh2pad/token.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/csh2pad/token.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/csh2pad/token.c' &&
/*                                 */
/*  token.c -- get token           */
/*                                 */
/*  csh2pad  by S. Yoshida         */
/*                                 */
X
#include "config.h"
X
#include <string.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include <ctype.h>
#include "csh2pad.h"
#include "lib.h"
X
static int ch = 0;
static int pch = 0;		/* read one character in ahead */
static int word_ptr = 0;	/* pointer to the end of word */
static bool newline = On;	/* whether at the head of line or not */
static bool comm_flag = Off;	/*  whether in comment or not */
X
static void set_ch(void);
static void append_ch(void);
static void get_ch(void);
static int p_getchar(FILE *);
X
void get_token(void)
/* get token */
{
X    if(token == Eof)
X	fatal_error("input file terminates unexpectedly.");
X
X    if(ch == 0)
X	get_ch();
X
X    if(cat_flag > 0){
X	if(ch == '\n')
X	    token = Ret;
X	else{
X	    token = Str;
X	    *word = ch;
X	    *(word+1) = '\0';
X	}
X	get_ch();
X	return;
X    }
X
X    switch(ch){
X	case EOF:
X	    token = Eof;
X	    *word = '\0';
X	    return;
X	case '\n':
X	    newline = On;
X	    token = Ret;
X	    *word = ' ';
X	    *(word+1) = '\0';
X	    get_ch();
X	    cat_flag = strlen(key);
X	    return;
X	case ' ':
X	case '\t':
X	    token = Sp;
X	    set_ch();
X	    get_ch();
X	    while(ch == ' '  ||  ch == '\t'){
X		append_ch();
X		get_ch();
X	    }
X	    return;
X	case '#':
X	    comm_flag = On;
X	    set_ch();
X	    get_ch();
X	    while(ch != '\n'){
X		append_ch();
X		get_ch();
X	    }
X
X	    /* do not print at this place */
X	    if (no_print_comment_flag == On) {
X		char buf[BUFSIZ];
X		strcpy(buf,"// ");
X		strcat(buf,word);
X		comm_flag = Off;
X
X		if(word[strlen(word)-1] == '\\'  ||  newline == On){
X		    set_ch();
X		    get_ch();
X		}else{
X		    cat_flag = strlen(key);
X		}
X
X		newline = On;
X		strcpy(word,buf);
X		token = Comment;
X		return;
X	    }
X
X	    if (elseif_flag == On) {
X	        putchar('\n');
X		elseif_flag = Off;
X	    }
X	    printf("// ");
X	    puts(word);
X	    comm_flag = Off;
X	    set_ch();
X	    get_ch();
X	    if(word[strlen(word)-1] != '\\'  &&  newline != On){	/* insert return code if it is not a comment at the head of line */
X		newline = On;
X		token = Ret;
X		cat_flag = strlen(key);
X	    }else{
X		newline = On;
X		get_token();
X	    }
X	    return;
X	case '"':
X	    newline = Off;
X	    set_ch();
X
X	    do{
X		get_ch();
X		if(ch == '\n'){
X		    ch = '\\'; append_ch();
X		    ch = 'n'; append_ch();
X		}else if(ch == '\\'){
X		    append_ch();
X		    get_ch(); append_ch();
X		    ch = ' ';
X		}else
X		    append_ch();
X	    }while(ch != '"');
X
X	    get_ch();
X
X	    token = Str;
X	    return;
X	case '\'':
X	    newline = Off;
X	    set_ch();
X
X	    do{
X		get_ch();
X		if(ch == '\n'){
X		    ch = '\\'; append_ch();
X		    ch = 'n'; append_ch();
X		}else if(ch == '\\'){
X		    append_ch();
X		    get_ch(); append_ch();
X		    ch = ' ';
X		}else
X		    append_ch();
X	    }while(ch != '\'');
X
X	    get_ch();
X
X	    token = Str;
X	    return;
X	case '`':
X	    newline = Off;
X	    set_ch();
X
X	    do{
X		get_ch();
X		if(ch == '\n'){
X		    ch = '\\'; append_ch();
X		    ch = 'n'; append_ch();
X		}else if(ch == '\\'){
X		    append_ch();
X		    get_ch(); append_ch();
X		    ch = ' ';
X		}else
X		    append_ch();
X	    }while(ch != '`');
X
X	    get_ch();
X
X	    token = Str;
X	    return;
X	case '&':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if (ch == '&') {
X		token = And2;
X		append_ch();
X		get_ch();
X	    } else
X		token = Str;
X	    return;
X	case '|':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if (ch == '|') {
X		token = Or2;
X		append_ch();
X		get_ch();
X	    } else
X		token = Str;
X	    return;
X	case '<':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if (ch == '<') {
X		token = LL;
X		append_ch();
X		get_ch();
X	    } else
X		token = Str;
X	    return;
X	case '\\':
X	    newline = Off;
X	    token = Str;
X	    set_ch();
X	    get_ch();
X	    append_ch();
X	    get_ch();
X	    return;
X	case '$':
X	    newline = Off;
X	    token = Str;
X	    set_ch();
X	    get_ch();
X	    if(ch == '#'){
X		append_ch();
X		get_ch();
X	    }
X	    return;
X	case '(':
X	    newline = Off;
X	    token = Lpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ')':
X	    newline = Off;
X	    token = Rpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ':':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    token = Colon;
X	    return;
X	case ';':
X	    newline = Off;
X	    token = Semicolon;
X	    set_ch();
X	    get_ch();
X	    return;
X	default:
X	    if(isdigit(ch)){
X		token = Num;
X		set_ch();
X		get_ch();
X		while(isdigit(ch)){
X		    append_ch();
X		    get_ch();
X		}
X		newline = Off;
X		return;
X	    }
X
X	    if(isalpha(ch)  ||  ch == '_'){
X		token = Name;
X		set_ch();
X		get_ch();
X		while(isalnum(ch)  ||  (char)ch == '_'){
X		    append_ch();
X		    get_ch();
X		}
X
X		if(strcmp(word,"if") == 0)
X		    token = If;
X		else if(strcmp(word,"then") == 0)
X		    token = Then;
X		else if(strcmp(word,"else") == 0)
X		    token = Else;
X		else if(strcmp(word,"endif") == 0)
X		    token = Endif;
X		else if(strcmp(word,"while") == 0)
X		    token = While;
X		else if(strcmp(word,"foreach") == 0)
X		    token = Foreach;
X		else if(strcmp(word,"end") == 0)
X		    token = End;
X		else if(strcmp(word,"switch") == 0)
X		    token = Switch;
X		else if(strcmp(word,"case") == 0)
X		    token = Case;
X		else if(strcmp(word,"default") == 0)
X		    token = Default;
X		else if(strcmp(word,"breaksw") == 0)
X		    token = Breaksw;
X		else if(strcmp(word,"endsw") == 0)
X		    token = Endsw;
X		else if(strcmp(word,"break") == 0)
X		    token = Break;
X		else if(strcmp(word,"continue") == 0)
X		    token = Continue;
X		else if(strcmp(word,"goto") == 0)
X		    token = Goto;
X		else if(ch == ':'  &&  newline == On) {
X		    append_ch();
X		    get_ch();
X		    token = Label;
X		}
X
X		newline = Off;
X		return;
X	    }
X
X	    token = Str;
X	    set_ch();
X	    get_ch();
X	    newline = Off;
X	    return;
X    }
}
X
void set_ch(void)
/* set the character just read */
{
X    *word = ch;
X    *(word + 1) = '\0';
X    word_ptr = 1;
}
X
void append_ch(void)
/* append the character just read */
{
X    *(word + word_ptr) = ch;
X    *(word + word_ptr + 1) = '\0';
X    word_ptr++;
}
X
void get_ch(void)
/* get a character */
{
X    if(ch == 0){
X	ch = p_getchar(input_stream);
X	pch = p_getchar(input_stream);
X    }else{
X	ch = pch;
X	pch = p_getchar(input_stream);
X    }
X
X    if(comm_flag == Off  &&  
X       ch == '\\'  &&  pch == '\n'){	/* substitute '\' at the end of line to space */
X	line_count++;
X	ch = ' ';
X	pch = p_getchar(input_stream);
X	while(pch == ' '  ||  pch == '\t')
X	    pch = p_getchar(input_stream);
X    }
X
X    if(ch == '\n')
X	line_count++;
}
X
int p_getchar(FILE *fp)
/* read a character */
{
X    int c = 0;
X    while(((0 <= c  &&  c < ' '  &&  c != '\t'  &&  c != '\n')  ||  c == 0x7F)  &&  c != EOF){
X	c = getc(fp);
X    }
X    return c;
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/csh2pad/token.c' &&
  chmod 0644 'pad2ps-3.1/src/csh2pad/token.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/csh2pad/token.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/csh2pad/token.c:' 'MD5 check failed'
3f45c0a6c43d8464f81f6905772bb414  pad2ps-3.1/src/csh2pad/token.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/csh2pad/token.c'`"
    test 6779 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/csh2pad/token.c:' 'original size' '6779,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/csh2pad/csh2pad.c ==============
if test -f 'pad2ps-3.1/src/csh2pad/csh2pad.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/csh2pad/csh2pad.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/csh2pad/csh2pad.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/csh2pad/csh2pad.c' &&
/*                               */
/*  csh2pad.c -- main routine    */
/*                               */
/*  csh2pad  by S. Yoshida       */
/*                               */
X
#include "config.h"
X
#include <stdlib.h>
#include <string.h>
#include "csh2pad.h"
X
token_type token = None;	/* token */
char word[BUFSIZ] = {'\0'};	/* string just read */
X
bool no_print_comment_flag = Off;	/* do not print comment */
bool elseif_flag = Off;                 /* whether in middle of processing else if */
X
int tab = 4;			/* tab width */
X
char key[BUFSIZ] = {'\0'};	/* termination string in "cat << EOF" */
int cat_flag = 0;		/* whether in "cat << EOF" or not */
X
bool debug = Off;		/* -debug option */
bool quiet = Off;		/* -quiet option */
bool print_warning = Off;	/* whether printing warning or not */
int line_count = 1;		/* line in process */
X
FILE *input_stream;		/* input file */
X
X
#ifdef JAPANESE
static char kconv[BUFSIZ] = "nkf -e";	/* KANJI converter */
static bool noconv = Off;		/* -noconv */
#endif
static bool nohelp = Off;		/* -nohelp */
static bool stdin_flag = Off;		/* -stdin */
X
static char filename[BUFSIZ] = {'\0'};		/* name of input file */
static char command[BUFSIZ];			/* command */
X
static void option(int,char **);	/* handle options */
static void print_help(void);		/* print help messages */
X
int main(int argc,char **argv)
{
X    option(argc,argv);			/* handle options */
X
X    if(quiet == Off)
X	fprintf(stderr,"\ncsh2pad %s  by %s\n\n",VERSION,AUTHOR);
X
X    if(stdin_flag == On)
X	filename[0] = '\0';
X
#ifdef JAPANESE
X    if(noconv == Off)
X	sprintf(command,"cat %s | %s",filename,kconv);
X    else
#endif
X	sprintf(command,"cat %s",filename);
X
X    input_stream = popen(command,"r");
X
X    parser();
X
X    fclose(input_stream);
X
X    if(quiet == Off)
X	fprintf(stderr,"\n%d errors, %d warnings.\n",error_count,warning_count);
X
X    return 0;
}
X
void option(int argc,char **argv)
/* handle option */
{
X    int i;
X
X    for(i = 1 ; i < argc ; i++){
X	if(argv[i][0] != '-'){		/* file name */
X	    if(filename[0] == '\0')
X		strcpy(filename,argv[i]);
X	    else if(nohelp == Off){
X		print_help();
X		exit(1);
X	    }
X	}else{				/* options */
X	    switch(argv[i][1]){
#ifdef DEBUG
X		case 'd':
X		    if(strcmp(argv[i],"-debug") == 0){
X			debug = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#endif
X		case 'h':
X		    if(strcmp(argv[i],"-help") == 0){
X			print_help();
X			exit(0);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#ifdef JAPANESE
X		case 'k':
X		    if(strcmp(argv[i],"-kconv") == 0  &&  i + 1 < argc){
X			strcpy(kconv,argv[++i]);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#endif
X		case 'n':
X		    if(strcmp(argv[i],"-nohelp") == 0){
X			nohelp = On;
#ifdef JAPANESE
X		    }else if(strcmp(argv[i],"-noconv") == 0){
X			noconv = On;
#endif
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'q':
X		    if(strcmp(argv[i],"-quiet") == 0){
X			quiet = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 's':
X		    if(strcmp(argv[i],"-stdin") == 0){
X			stdin_flag = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 't':
X		    if(strcmp(argv[i],"-tab") == 0){
X			i++;
X			tab = atoi(argv[i]);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'w':
X		    if(strcmp(argv[i],"-warn") == 0){
X			print_warning = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		default:
X		    if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X	    }
X	}
X    }
}
X
void print_help(void)
{
X    fprintf(stderr,"\ncsh2pad %s  by %s\n\n",VERSION,AUTHOR);
X    fputs("usage: csh2pad [filename] [options]\n",stderr);
#ifdef DEBUG
X    fputs("-debug                  Print parser debug message.\n",stderr);
#endif
X    fputs("-help                   Print help message.\n",stderr);
#ifdef JAPANESE
X    fputs("-kconv converter        Kanji code converter [default: \"nkf -e\"].\n",stderr);
X    fputs("-noconv                 Do not convert kanji code.\n",stderr);
#endif
X    fputs("-nohelp                 Do not print help message.\n",stderr);
X    fputs("-quiet                  Do not print messages.\n",stderr);
X    fputs("-stdin                  Input from stdin.\n",stderr);
X    fputs("-tab width              Set TAB width [default: 4].\n",stderr);
X    fputs("-warn                   Print warnings.\n",stderr);
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/csh2pad/csh2pad.c' &&
  chmod 0644 'pad2ps-3.1/src/csh2pad/csh2pad.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/csh2pad/csh2pad.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/csh2pad/csh2pad.c:' 'MD5 check failed'
8a41eaddfd88e3fd44efbfa1e1dc706a  pad2ps-3.1/src/csh2pad/csh2pad.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/csh2pad/csh2pad.c'`"
    test 4516 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/csh2pad/csh2pad.c:' 'original size' '4516,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/csh2pad/csh2pad.h ==============
if test -f 'pad2ps-3.1/src/csh2pad/csh2pad.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/csh2pad/csh2pad.h' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/csh2pad/csh2pad.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/csh2pad/csh2pad.h' &&
/*                          */
/*  csh2pad.h               */
/*                          */
/*  csh2pad  by S. Yoshida  */
/*                          */
X
#ifndef _CSH2PAD_H
#define _CSH2PAD_H
X
#include "config.h"
X
#ifndef JAPANESE
#ifndef ENGLISH
#define ENGLISH		/* create output in English by default */
#endif
#endif
X
#include <stdio.h>
#include "lib.h"
#include "version.h"
X
typedef enum {
X    Nontoken, Eof, Comment,
X    Ret, Sp,
X    Str, Name, Num, Label,
X    And2, Or2, LL,
X    Lpar, Rpar,
X    Colon, Semicolon,
X    If, Then, Else, Endif, While, Foreach, End,
X    Switch, Case, Default, Breaksw, Endsw,
X    Break, Continue, Goto
} token_type;
X
X
extern token_type token;	/* token */
extern char word[];		/* string just read */
X
extern bool no_print_comment_flag;	/* do not print comment */
extern bool elseif_flag;                /* whether in middle of processing else if */
X
extern int tab;			/* tab width */
X
extern char key[];		/* termination string in "cat << EOF" */
extern int cat_flag;		/* whether in "cat << EOF" or not */
X
extern bool debug;		/* -debug option */
extern bool quiet;		/* -quiet option */
extern bool print_warning;	/* whether printing warning or not */
extern int line_count;		/* line in process */
X
extern FILE *input_stream;	/* input file */
X
X
/* parser.c */
extern void parser(void);		/* output */
X
/* token.c */
extern void get_token(void);		/* get token */
X
#endif  /* ! _CSH2PAD_H */
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/csh2pad/csh2pad.h' &&
  chmod 0644 'pad2ps-3.1/src/csh2pad/csh2pad.h' ||
  $echo 'restore of' 'pad2ps-3.1/src/csh2pad/csh2pad.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/csh2pad/csh2pad.h:' 'MD5 check failed'
8a4f8359b59d022622ed1843aa19938d  pad2ps-3.1/src/csh2pad/csh2pad.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/csh2pad/csh2pad.h'`"
    test 1423 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/csh2pad/csh2pad.h:' 'original size' '1423,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/csh2pad/Makefile.in ==============
if test -f 'pad2ps-3.1/src/csh2pad/Makefile.in' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/csh2pad/Makefile.in' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/csh2pad/Makefile.in' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/csh2pad/Makefile.in' &&
### Makefile of csh2pad  by S. Yoshida
X
### configuration by configure
X
prefix = @prefix@
exec_prefix = @exec_prefix@
LIBDIR = @libdir@/pad2ps
X
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
X
CC = @CC@
X
LIBS = @LIBS@ -L../lib -lpublic
X
### make commands
X
CFLAGS = -O2
LDFLAGS =
MFLAGS =
X
INCLUDES = -I.. -I../lib
X
HDRS = csh2pad.h
SRCS = csh2pad.c parser.c token.c
OBJS = csh2pad.o parser.o token.o
X
TARGS = csh2pad
X
all: ${TARGS}
X
csh2pad: ${OBJS} ${HDRS}
X	$(CC) $(LDFLAGS) ${OBJS} -o $@ $(LIBS)
X
%.o: %.c
X	$(CC) $(CFLAGS) $(INCLUDES) -c $<
X
install: ${TARGS}
X	$(INSTALL) -d $(LIBDIR)
X	if [ -f $(LIBDIR)/csh2pad ]; then rm -f $(LIBDIR)/csh2pad; fi
X	$(INSTALL_PROGRAM) csh2pad $(LIBDIR)
X
clean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X
distclean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X	rm -f Makefile
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/csh2pad/Makefile.in' &&
  chmod 0644 'pad2ps-3.1/src/csh2pad/Makefile.in' ||
  $echo 'restore of' 'pad2ps-3.1/src/csh2pad/Makefile.in' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/csh2pad/Makefile.in:' 'MD5 check failed'
443d317d97ea65b820675e3741219997  pad2ps-3.1/src/csh2pad/Makefile.in
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/csh2pad/Makefile.in'`"
    test 850 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/csh2pad/Makefile.in:' 'original size' '850,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/java2pad/java2pad.h ==============
if test ! -d 'pad2ps-3.1/src/java2pad'; then
  $echo 'x -' 'creating directory' 'pad2ps-3.1/src/java2pad'
  mkdir 'pad2ps-3.1/src/java2pad'
fi
if test -f 'pad2ps-3.1/src/java2pad/java2pad.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/java2pad/java2pad.h' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/java2pad/java2pad.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/java2pad/java2pad.h' &&
/*                           */
/*  java2pad.h               */
/*                           */
/*  java2pad  by S. Yoshida  */
/*                           */
X
#ifndef _JAVA2PAD_H
#define _JAVA2PAD_H
X
#include "config.h"
X
#ifndef JAPANESE
#ifndef ENGLISH
#define ENGLISH		/* output in English by default */
#endif
#endif
X
#include <stdio.h>
#include "lib.h"
#include "version.h"
X
X
typedef enum {
X    Nontoken, Eof, Comment,
X    Ret, Sp,
X    Str, Name, Num,
X    Lpar, Rpar, Lbrace, Rbrace, Lbracket, Rbracket,
X    Colon, Colon2, Semicolon,
X    Question,
X    Equal, Equal2, Neq, Less, Great, Less_eq, Great_eq,
X    Not, And, Or, And2, Or2,
X    Plus, Minus, Times, Divide, Exp, Lshift, Rshift,
X    If, Else, While, For, Do, Switch, Case, Default, Try, Catch,
X    Return, Break, Continue, Goto
} token_type;
X
X
extern token_type token;	/* token */
extern char word[];		/* string just read */
X
extern bool no_print_comment_flag;	/* do not print comment at this place */
extern bool elseif_flag;                /* whether in middle of processing else if */
X
extern int tab;			/* tab width */
extern bool optimize;		/* -O option */
extern bool semicolon;		/* -semicolon option */
X
extern bool debug;		/* -debug option */
extern bool quiet;		/* -quiet option */
extern bool print_warning;	/* whether to print warning */
extern int line_count;		/* line in process */
X
extern FILE *input_stream;	/* input file */
X
X
/* parser.c */
extern void parser(void);		/* output */
X
/* token.c */
extern void get_token(void);		/* get token */
X
#endif  /* ! _JAVA2PAD_H */
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/java2pad/java2pad.h' &&
  chmod 0644 'pad2ps-3.1/src/java2pad/java2pad.h' ||
  $echo 'restore of' 'pad2ps-3.1/src/java2pad/java2pad.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/java2pad/java2pad.h:' 'MD5 check failed'
e2f63f5e24c697635e0957cdf2f1feb2  pad2ps-3.1/src/java2pad/java2pad.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/java2pad/java2pad.h'`"
    test 1550 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/java2pad/java2pad.h:' 'original size' '1550,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/java2pad/parser.c ==============
if test -f 'pad2ps-3.1/src/java2pad/parser.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/java2pad/parser.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/java2pad/parser.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/java2pad/parser.c' &&
/*                                                       */
/*  parser.c -- Translate Java to PADEL and print result */
/*                                                       */
/*  java2pad  by S. Yoshida                              */
/*                                                       */
X
#include "config.h"
X
#include <string.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include <ctype.h>
#include "java2pad.h"
#include "lib.h"
X
#define MAKE_STRING_WHILE(X)	{\
X				    label_flag = On;\
X				    set_str();\
X				    get_token();\
X				    while(X){\
X					if(token == Ret){\
X					    append(" ");\
X					    *sp = '\0';\
X					    do{\
X						get_token();\
X					    }while(token == Sp);\
X					}else{\
X					    if(token == Sp)\
X						strcat(sp,word);\
X					    else{\
X						if(token == Question)\
X						    label_flag = Off;\
X						if(*sp != '\0')\
X						    append(sp);\
X						*sp = '\0';\
X						append_str();\
X					    }\
X					    get_token();\
X					}\
X				    }\
X				    if(*sp != '\0')\
X					append(sp);\
X				    *sp = '\0';\
X				}
X
#define END_OF_LINE()		{\
X				    while(token == Sp)\
X					get_token();\
X				    if(token == Ret)\
X					get_token();\
X				}
X
static char *str = NULL;
static int nest_level = 0;
static bool label_flag = On;
static bool in_class = Off;
X
static void function(void);
static void body(int);
static void command(void);
static void for_statement(void);
static void else_statement(bool);
static void do_statement(void);
static void try_statement(void);
static void condition(void);
static void paired_brace(void);
X
static void set_str(void);
static void append_str(void);
static void append(char *);
static void print_str(void);
static void print_hsp(void);
X
static int to_optimize(char *);
X
void parser(void)
/* output */
{
#ifdef DEBUG
X    if(quiet == Off)
X	fprintf(stderr,"Translating Java into PADEL starts...");
#endif
X
X    get_token();
X
X    while(token != Eof){
X	while(token == Sp)
X	    get_token();
X
X	if(token == Ret){		/* empty line */
X	    putchar('\n');
X	    get_token();
X	}else if(token != Eof)
X	    function();			/* declaration, function */
X    }
X
#ifdef DEBUG
X    if(quiet == Off)
X	fprintf(stderr,"done\n");
#endif
}
X
void function(void)
/* declaration, function */
{
X    char sp[BUFSIZ] = {'\0'};
X    bool ret_flag = Off;
X
X    MAKE_STRING_WHILE(token != Lpar  &&  token != Lbrace  &&  token != Lbracket  &&  token != Semicolon  &&  token != Eof);
X
X    if(token == Lpar){
X	condition();			/* argument list */
X	while(token == Sp  ||  token == Ret){
X	    if(token == Sp)
X		strcat(sp,word);
X	    else if(token == Ret)
X		ret_flag = On;
X	    get_token();
X	}
X
X	if(token != Semicolon){
X	    while(token != Lbrace)	/* type declaration of argument */
X		get_token();
X
X	    print_str();
X	    if(ret_flag == On)
X		printf("\n{\n");
X	    else
X		printf("%s\n{\n",sp);
X
X	    nest_level++;
X	    body(0);			/* function main */
X	    nest_level--;
X
X	    printf("}\n");
X
X	    END_OF_LINE();
X	    return;
X	}
X    }
X
X    if(token == Lbrace){		/* struct, class, and others */
X	if(in_class == Off){		/* class */
X	    printf("// ");
X	    print_str();
X	    putchar('\n');
X
X	    in_class = On;
X	    get_token();
X	    while(token != Rbrace  &&  token != Eof){
X		while(token == Sp)
X		    get_token();
X
X		if(token == Ret){		/* empty line */
X		    putchar('\n');
X		    get_token();
X		}else if(token != Eof)
X		    function();			/* declaration, function */
X	    }
X	    in_class = Off;
X	}else{
X	    paired_brace();
X	    while(token != Semicolon){
X		if(token == Lbrace)
X		    paired_brace();
X		else if(token == Lpar)
X		    condition();
X		else
X		    get_token();
X	    }
X	}
X    }
X
X    if(token == Lbracket){		/* array and others */
X	get_token();
X	while(token != Semicolon){
X	    if(token == Lbrace)
X		paired_brace();
X	    else if(token == Lpar)
X		condition();
X	    else
X		get_token();
X	}
X    }
X
X    if(token == Semicolon){		/* global variable declaration and others */
X	get_token();
X	END_OF_LINE();
X	if(str != NULL){
X	    free(str);
X	    str = NULL;
X	}
X	return;
X    }
}
X
void body(int flag)
{
X    if(flag != 1){
X	get_token();
X	END_OF_LINE();
X
X	while(token == Sp)
X	    get_token();
X    }
X
X    while(token != Rbrace  &&  token != Eof){
X	switch(token){
X	    case Ret:			/* empty line */
X		putchar('\n');
X		get_token();
X		break;
X	    case Lbrace:		/* emblaced by { } */
X		body(0);
X		END_OF_LINE();
X		break;
X	    default:
X		command();
X	}
X
X	while(token == Sp)
X	    get_token();
X    }
X
X    get_token();
}
X
void command(void)
{
X    char sp[BUFSIZ] = {'\0'};
X    char buf[BUFSIZ];
X    char *s;
X    int count;
X
X    switch(token){
X	case For:
X	case While:
X	case If:
X	case Switch:
X	    for_statement();
X	    break;
X	case Do:
X	    do_statement();
X	    break;
X	case Try:
X	    try_statement();
X	    break;
X	case Case:
X	case Default:
X	    MAKE_STRING_WHILE(token != Colon);
X	    nest_level--;
X	    print_hsp();
X	    nest_level++;
X	    print_str();
X	    printf(":\n");
X	    get_token();
X	    while(token == Sp  ||  token == Ret)
X		get_token();
X	    break;
X	case Semicolon:
X	    print_hsp();
X	    if(semicolon == On)
X		printf(";\n");
X	    else
X		printf("{    }\n");
X	    get_token();
X	    END_OF_LINE();
X	    break;
X	case Break:
X	case Continue:
X	case Goto:
X	    strcpy(buf,word);
X	    get_token();
X	    if (token == Sp  ||  token == Ret)
X		MAKE_STRING_WHILE(token == Sp  ||  token == Ret);
X	    if (token != Semicolon) {	/* reference exists */
X		print_hsp();
X		printf("refer (%s%s%s) {\n",str+1,word,str+1);
X		nest_level++;
X		print_hsp();
X		puts(buf);
X		nest_level--;
X		print_hsp();
X		puts("}");
X
X		free(str);
X		MAKE_STRING_WHILE(token != Semicolon  &&  token != Eof);
X		free(str);
X		str = NULL;
X	    } else {			/* no reference */
X		print_hsp();
X		fputs(buf,stdout);
X		if(str != NULL)
X		    print_str();
X		if(semicolon == On)
X		    putchar(';');
X		putchar('\n');
X	    }
X
X	    get_token();
X	    END_OF_LINE();
X	    break;
X	case Return:
X	default:
X	    MAKE_STRING_WHILE(token != Semicolon  &&  token != Lbrace
X			      &&  token != Colon);
X	    if(token == Colon  &&  label_flag == On){	/* label */
X		print_str();
X		printf(":\n");
X	    }else{
X		if(token == Colon){		/* (cond ? T : F) form */
X		    s = str;
X		    MAKE_STRING_WHILE(token != Semicolon);
X		    str = joint(2,s,str);
X		}else if(token == Lbrace){		/* struct and others */
X		    count = 1;
X		    s = str;
X		    while(token == Lbrace){
X			do{
X			    MAKE_STRING_WHILE(token != Rbrace  &&  token != Lbrace);
X			    s = joint(2,s,str);
X			    count += (token == Lbrace) ? 1 : -1;
X			}while(count > 0);
X			MAKE_STRING_WHILE(token != Semicolon  &&  token != Lbrace);
X			s = joint(2,s,str);
X		    }
X		    str = s;
X		}
X		if(to_optimize(str)){
X		    free(str);
X		}else{
X		    print_hsp();
X		    print_str();
X		    if(semicolon == On)
X			putchar(';');
X		    putchar('\n');
X		}
X	    }
X	    get_token();
X	    END_OF_LINE();
X    }
}
X
void for_statement(void)
{
X    char *old_str, sp[BUFSIZ] = {'\0'};
X    char ret_buf[BUFSIZ] = {'\0'}, comm_buf[BUFSIZ] = {'\0'};
X    bool ret_flag = Off;
X    token_type type;
X    int i,sp_len,ret_count = 0;
X    int flag = 0;
X
X    type = token;
X
X    old_str = str;
X    MAKE_STRING_WHILE(token != Lpar);
X    if(elseif_flag == On)	/* create string following "else" */
X	str = joint(2,old_str,str);
X    condition();
X    while(token == Sp  ||  token == Ret){
X	if(token == Sp)
X	    strcat(sp,word);
X	else if(token == Ret)
X	    ret_flag = On;
X	get_token();
X    }
X
X    if(type == Switch){		/* part in between "switch(){" and first "case" */
X	flag = 1;
X	old_str = str;
X	str = NULL;
X	get_token();
X	END_OF_LINE();
X	while(token == Sp)
X	    get_token();
X	while(token != Case  &&  token != Default  &&  token != Rbrace  &&  token != Eof){
X	    if(token == Ret){
X		putchar('\n');
X		get_token();
X	    }else
X		command();
X	    while(token == Sp)
X		get_token();
X	}
X	str = old_str;
X    }
X
X    if(elseif_flag == On)	/* spacing at the head of line in not required with "else if" */
X	elseif_flag = Off;
X    else
X	print_hsp();
X
X    print_str();
X
X    if(flag == 1  ||  token == Lbrace){
X	if(ret_flag == On){
X	    putchar('\n');
X	    print_hsp();
X	    printf("{\n");
X	}else
X	    printf("%s{\n",sp);
X
X	nest_level++;
X	if(type == Switch)
X	    nest_level++;
X	body(flag);				/* repetition body */
X	nest_level--;
X	if(type == Switch)
X	    nest_level--;
X
X	if(type != If){
X	    print_hsp();
X	    printf("}\n");
X	    END_OF_LINE();
X	}else{
X	    sp_len = nest_level * tab;
X	    for(i = 0 ; i < sp_len ; i++)
X		append(" ");
X	    append("}");
X	    print_str();
X	}
X
X	ret_flag = On;
X    }else{
X	putchar('\n');
X	nest_level++;
X	command();
X	nest_level--;
X	ret_flag = Off;
X    }
X
X    *sp = '\0';
X    ret_count = 0;
X    if(type == If){			/* whether "else" exists */
X	no_print_comment_flag = On;
X	while(token == Sp  ||  token == Ret  ||  token == Comment){
X	    if(token == Sp){
X		strcat(sp,word);
X	    }else if(token == Ret){
X		ret_count++;
X		strcat(ret_buf,"\n");
X	    }else if(token == Comment){
X		strcat(ret_buf,word);
X		strcat(comm_buf,word);
X		ret_count++;
X		if (word[strlen(word)-1] != '\n') {
X		    strcat(ret_buf,"\n");
X		    strcat(comm_buf,"\n");
X		    get_token();
X		    while (token == Sp)
X			get_token();
X		    if (token == Ret)
X			get_token();
X		    continue;
X		}
X	    }
X	    get_token();
X	}
X	no_print_comment_flag = Off;
X	if(token != Else){		/* if no "else" exists */
X	    print_str();
X	    if(ret_flag == On  &&  ret_count == 0)
X		strcpy(ret_buf,"\n");
X	    fputs(ret_buf,stdout);
X	    return;
X	}else{				/* if "else" exists */
X	    sp_len = nest_level * tab;
X	    if (*comm_buf != '\0') {
X		if(ret_flag == On)
X		    putchar('\n');
X		fputs(comm_buf,stdout);
X		ret_flag = Off;
X	    } else {
X		if(ret_flag == On){
X		    if(ret_count > 0){
X			putchar('\n');
X			ret_flag = Off;
X		    }else
X			sp_len = strlen(sp);
X		}
X	    }
X
X	    for(i = 0 ; i < sp_len ; i++)
X		append(" ");
X	    append("else");
X	    else_statement(ret_flag);
X	}
X    }
}
X
void else_statement(bool old_ret_flag)
{
X    char sp[BUFSIZ] = {'\0'};
X    bool ret_flag = Off;
X    bool mid_comm_flag = Off;
X
X    no_print_comment_flag = On;
X    get_token();
X    while(token == Sp  ||  token == Ret  ||  token == Comment){
X	if(token == Sp)
X	    strcat(sp,word);
X	else if(token == Ret)
X	    ret_flag = On;
X	else if(token == Comment){
X	    mid_comm_flag = On;
X	    if (old_ret_flag == On) {
X		putchar('\n');
X		old_ret_flag = Off;
X	    }
X	    if (word[strlen(word)-1] != '\n') {
X		puts(word);
X		get_token();
X		while (token == Sp)
X		    get_token();
X		if (token == Ret)
X		    get_token();
X		continue;
X	    }
X	    printf("%s",word);
X	}
X	get_token();
X    }
X    no_print_comment_flag = Off;
X
X    if(token == If){
X	if(ret_flag == Off){		/* else if */
X	    append(sp);
X	    if (mid_comm_flag = Off)
X	        elseif_flag = On;
X	    command();
X	}else{
X	    print_str();
X	    putchar('\n');
X	    nest_level++;
X	    command();
X	    nest_level--;
X	}
X    }else{
X	print_str();
X	if(token == Lbrace){
X	    if(ret_flag == On){
X		putchar('\n');
X		print_hsp();
X		printf("{\n");
X	    }else
X		printf("%s{\n",sp);
X
X	    nest_level++;
X	    body(0);			/* repetition body */
X	    nest_level--;
X
X	    print_hsp();
X	    printf("}\n");
X
X	    END_OF_LINE();
X	    return;
X	}else{
X	    putchar('\n');
X	    nest_level++;
X	    command();
X	    nest_level--;
X	}
X    }
}
X
void do_statement(void)
{
X    char sp[BUFSIZ] = {'\0'};
X    bool ret_flag = Off;
X
X    get_token();
X    while(token == Sp  ||  token == Ret){
X	if(token == Sp)
X	    strcat(sp,word);
X	else if(token == Ret)
X	    ret_flag = On;
X	get_token();
X    }
X
X    print_hsp();
X
X    if(token == Lbrace){
X	if(ret_flag == On)
X	    printf("do\n{\n");
X	else
X	    printf("do%s{\n",sp);
X
X	nest_level++;
X	body(0);				/* repetition body */
X	nest_level--;
X
X	print_hsp();
X	printf("}");
X    }else{
X	printf("do\n");
X	nest_level++;
X	command();
X	nest_level--;
X	while(token == Sp  ||  token == Ret)
X	    get_token();
X	print_hsp();
X    }
X
X    *sp = '\0';
X    MAKE_STRING_WHILE(token != Lpar);
X    condition();
X
X    print_str();
X    putchar('\n');
X
X    while(token != Semicolon)
X	get_token();
X    get_token();
X    END_OF_LINE();
}
X
void try_statement(void)
{
X    char sp[BUFSIZ] = {'\0'};
X    bool ret_flag = Off;
X
X    get_token();
X    while(token == Sp  ||  token == Ret){
X	if(token == Sp)
X	    strcat(sp,word);
X	else if(token == Ret)
X	    ret_flag = On;
X	get_token();
X    }
X
X    print_hsp();
X
X    if(token == Lbrace){
X	if(ret_flag == On)
X	    printf("try\n{\n");
X	else
X	    printf("try%s{\n",sp);
X
X	nest_level++;
X	body(0);				/* try body */
X	nest_level--;
X
X	print_hsp();
X	printf("}");
X
X	ret_flag = Off;
X	*sp = '\0';
X	while(token == Sp  ||  token == Ret){
X	    if(token == Ret)
X		ret_flag = On;
X	    else
X		strcat(sp,word);
X	    get_token();
X	}
X	if(ret_flag == On){
X	    putchar('\n');
X	    print_hsp();
X	}else
X	    fputs(sp,stdout);
X    }else{
X	printf("try\n");
X	nest_level++;
X	command();
X	nest_level--;
X	while(token == Sp  ||  token == Ret)
X	    get_token();
X	print_hsp();
X    }
X
X    *sp = '\0';
X    MAKE_STRING_WHILE(token != Lpar);
X    condition();
X
X    print_str();
X
X    ret_flag = Off;
X    *sp = '\0';
X    while(token == Sp  ||  token == Ret){
X	if(token == Sp)
X	    strcat(sp,word);
X	else if(token == Ret)
X	    ret_flag = On;
X	get_token();
X    }
X
X    if(token == Lbrace){
X	if(ret_flag == On)
X	    printf("\n{\n");
X	else
X	    printf("%s{\n",sp);
X
X	nest_level++;
X	body(0);				/* catch body */
X	nest_level--;
X
X	print_hsp();
X	puts("}");
X	get_token();
X	END_OF_LINE();
X    }else{
X	putchar('\n');
X	nest_level++;
X	command();
X	nest_level--;
X	while(token == Sp  ||  token == Ret)
X	    get_token();
X    }
}
X
void condition(void)
{
X    char sp[BUFSIZ] = {'\0'};
X
X    append_str();
X    get_token();
X
X    while(token != Rpar){
X	if(token == Lpar)
X	    condition();
X	else if(token == Ret){
X	    append(" ");
X	    *sp = '\0';
X	    do{
X		get_token();
X	    }while(token == Sp);
X	}else{
X	    if(token == Sp)
X		strcat(sp,word);
X	    else{
X		if(*sp != '\0')
X		    append(sp);
X		*sp = '\0';
X		append_str();
X	    }
X
X	    get_token();
X	}
X    }
X
X    if(*sp != '\0')
X	append(sp);
X    append_str();
X    get_token();
}
X
void paired_brace(void)
{
X    get_token();
X
X    while(token != Rbrace){
X	if(token == Lbrace)
X	    paired_brace();
X	else
X	    get_token();
X    }
X    get_token();
}
X
void set_str(void)
{
X    int l;
X
X    l = strlen(word);
X    str = (char *)malloc((l+2) * sizeof(char));
X    strcpy(str,word);
}
X
void append_str(void)
{
X    int l;
X    char *s;
X
X    l = strlen(word);
X    s = (char *)malloc((l+2) * sizeof(char));
X    strcpy(s,word);
X    str = joint(2,str,s);
}
X
void append(char *p)
{
X    int l;
X    char *s;
X
X    l = strlen(p);
X    s = (char *)malloc((l+2) * sizeof(char));
X    strcpy(s,p);
X    str = joint(2,str,s);
}
X
void print_str(void)
{
X    if(str != NULL){
X	printf("%s",str);
X	free(str);
X	str = NULL;
X    }
}
X
void print_hsp(void)
{
X    int i;
X
X    for(i = 0 ; i < nest_level * tab ; i++)
X	putchar(' ');
}
X
int to_optimize(char *s)
/* return 1 if discarded by optimization; otherwise return 0 */
{
X    int flag = 1;
X    char *p;
X
X    if(optimize == On){
X	for(p = s ; *p != '\0' ; p++){
X	    switch(*p){
X		case '_':
X		case ',':
X		case ';':
X		case '*':
X		case '[':
X		case ']':
X		case ' ':
X		case '\t':
X		    break;
X		default:
X		    if( ! (isalnum(*p)))
X			flag = 0;
X	    }
X	}
X	return flag;
X    }
X
X    return 0;
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/java2pad/parser.c' &&
  chmod 0644 'pad2ps-3.1/src/java2pad/parser.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/java2pad/parser.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/java2pad/parser.c:' 'MD5 check failed'
98a842d5ec8f9c0547772856bffbdfef  pad2ps-3.1/src/java2pad/parser.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/java2pad/parser.c'`"
    test 15113 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/java2pad/parser.c:' 'original size' '15113,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/java2pad/java2pad.c ==============
if test -f 'pad2ps-3.1/src/java2pad/java2pad.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/java2pad/java2pad.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/java2pad/java2pad.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/java2pad/java2pad.c' &&
/*                                */
/*  java2pad.c -- main routine    */
/*                                */
/*  java2pad  by S. Yoshida       */
/*                                */
X
#include "config.h"
X
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "java2pad.h"
X
token_type token = None;	/* token */
char word[BUFSIZ] = {'\0'};	/* string just read */
X
bool no_print_comment_flag = Off;	/* do not print comment at this place */
bool elseif_flag = Off;                 /* whether in middle of processing else if */
X
int tab = 4;			/* tab width */
bool optimize = Off;		/* -O option */
bool semicolon = Off;		/* -semicolon option */
X
bool debug = Off;		/* -debug option */
bool quiet = Off;		/* -quiet option */
bool print_warning = Off;	/* whether to print warning */
int line_count = 1;		/* line in process */
X
FILE *input_stream;		/* input file */
X
X
#ifdef JAPANESE
static char kconv[BUFSIZ] = "nkf -e";	/* KANJI converter */
static bool noconv = Off;		/* -noconv */
#endif
static bool nohelp = Off;		/* -nohelp */
static bool stdin_flag = Off;		/* -stdin */
X
static char filename[BUFSIZ] = {'\0'};		/* name of input file */
static char command[BUFSIZ];			/* command */
X
static char prepfile[BUFSIZ];		/* file name after treating pre-processor */
X
static void prep(void);			/* pre-processor (treat "\" at the end of line) */
static int p_getchar(FILE *);		/* get one character */
X
static void option(int,char **);	/* handle options */
static void print_help(void);		/* print help messages */
X
#if defined(HAVE_ATEXIT)
static void at_exit(void);		/* handle termination process */
#elif defined(HAVE_ON_EXIT)
static void at_exit(int,void *);	/* handle termination process */
#endif
X
int main(int argc,char **argv)
{
X    char tmp[BUFSIZ];
X    char *env;
X
X    /* handle exit() process */
#if defined(HAVE_ATEXIT)
X    atexit(at_exit);
#elif defined(HAVE_ON_EXIT)
X    on_exit(at_exit,NULL);
#endif
X
X    /* file name after treating pre-processor */
#ifdef TMP
X    strcpy(prepfile,TMP);
X    strcat(prepfile,"/");
#else
X    strcpy(prepfile,"/tmp/");
#endif
X    if((env = getenv("TMP")) != NULL  &&  strlen(env) > 0){
X	/* get the environment variable TMP */
X	strcpy(prepfile,env);
X	strcat(prepfile,"/");
X    }
X    strcat(prepfile,"java2pad-XXXXXX");
X
X    option(argc,argv);			/* handle options */
X
X    if(quiet == Off)
X	fprintf(stderr,"\njava2pad %s  by %s\n\n",VERSION,AUTHOR);
X
X    if(stdin_flag == On)
X	filename[0] = '\0';
X
#ifdef JAPANESE
X    if(noconv == Off)
X	sprintf(command,"cat %s | %s",filename,kconv);
X    else
#endif
X	sprintf(command,"cat %s",filename);
X
X    input_stream = popen(command,"r");
X
X    mktemp(prepfile);
X
X    prep();		/* pre-processor (treat "\" at the end of line) */
X
X    pclose(input_stream);
X
X    input_stream = fopen(prepfile,"r");
X
X    parser();
X
X    fclose(input_stream);
X
X    remove(prepfile);
X
X    if(quiet == Off)
X	fprintf(stderr,"\n%d errors, %d warnings.\n",error_count,warning_count);
X
X    return 0;
}
X
void prep(void)
/* pre-processor (treat "\" at the end of line) */
{
X    FILE *fp;
X    int ch;
X    int pch = 0;
X
X    fp = fopen(prepfile,"w");
X
X    ch = p_getchar(input_stream);
X    while(ch != EOF){
X	if(ch == '\\'){
X	    ch = p_getchar(input_stream);
X	    if(ch != '\n'){
X		fputc('\\',fp);
X		fputc(ch,fp);
X	    }
X	}else
X	    fputc(ch,fp);
X	pch = ch;
X	ch = p_getchar(input_stream);
X    }
X
X    fclose(fp);
}
X
int p_getchar(FILE *fp)
/* get a character */
{
X    int c = 0;
X    while(((0 <= c  &&  c < ' '  &&  c != '\t'  &&  c != '\n')  ||  c == 0x7F)  &&  c != EOF){
X	c = getc(fp);
X    }
X    return c;
}
X
void option(int argc,char **argv)
/* handle options */
{
X    int i,p;
X    char *ptr;
X
X    for(i = 1 ; i < argc ; i++){
X	if(argv[i][0] != '-'){		/* file name */
X	    if(filename[0] == '\0')
X		strcpy(filename,argv[i]);
X	    else if(nohelp == Off){
X		print_help();
X		exit(1);
X	    }
X	}else{				/* options */
X	    switch(argv[i][1]){
#ifdef DEBUG
X		case 'd':
X		    if(strcmp(argv[i],"-debug") == 0){
X			debug = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#endif
X		case 'h':
X		    if(strcmp(argv[i],"-help") == 0){
X			print_help();
X			exit(0);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#ifdef JAPANESE
X		case 'k':
X		    if(strcmp(argv[i],"-kconv") == 0  &&  i + 1 < argc){
X			strcpy(kconv,argv[++i]);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#endif
X		case 'n':
X		    if(strcmp(argv[i],"-nohelp") == 0){
X			nohelp = On;
X		    }else if(strcmp(argv[i],"-noopt") == 0){
X			optimize = Off;
#ifdef JAPANESE
X		    }else if(strcmp(argv[i],"-noconv") == 0){
X			noconv = On;
#endif
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'O':
X		    if(strcmp(argv[i],"-O") == 0){
X			optimize = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'q':
X		    if(strcmp(argv[i],"-quiet") == 0){
X			quiet = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 's':
X		    if(strcmp(argv[i],"-semicolon") == 0){
X			semicolon = On;
X		    }else if(strcmp(argv[i],"-stdin") == 0){
X			stdin_flag = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 't':
X		    if(strcmp(argv[i],"-tab") == 0){
X			i++;
X			tab = atoi(argv[i]);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'w':
X		    if(strcmp(argv[i],"-warn") == 0){
X			print_warning = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		default:
X		    if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X	    }
X	}
X    }
}
X
void print_help(void)
{
X    fprintf(stderr,"\njava2pad %s  by %s\n\n",VERSION,AUTHOR);
X    fputs("usage: java2pad [filename] [options]\n",stderr);
#ifdef DEBUG
X    fputs("-debug                  Print parser debug message.\n",stderr);
#endif
X    fputs("-help                   Print help message.\n",stderr);
#ifdef JAPANESE
X    fputs("-kconv converter        Kanji code converter [default: \"nkf -e\"].\n",stderr);
X    fputs("-noconv                 Do not convert kanji code.\n",stderr);
#endif
X    fputs("-nohelp                 Do not print help message.\n",stderr);
X    fputs("-noopt                  No optimizing.\n",stderr);
X    fputs("-O                      Optimizing.\n",stderr);
X    fputs("-quiet                  Do not print messages.\n",stderr);
X    fputs("-semicolon              Print ';' at EOL.\n",stderr);
X    fputs("-stdin                  Input from stdin.\n",stderr);
X    fputs("-tab width              Set TAB width [default: 4].\n",stderr);
X    fputs("-warn                   Print warnings.\n",stderr);
}
X
X
#if defined(HAVE_ATEXIT) || defined(HAVE_ON_EXIT)
#if defined(HAVE_ATEXIT)
void at_exit(void)
#elif defined(HAVE_ON_EXIT)
void at_exit(int val, void *p)
#endif
/* handle termination process */
{
X    remove(prepfile);
}
#endif
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/java2pad/java2pad.c' &&
  chmod 0644 'pad2ps-3.1/src/java2pad/java2pad.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/java2pad/java2pad.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/java2pad/java2pad.c:' 'MD5 check failed'
e500e04c3b0a1ff248491c61b7a82501  pad2ps-3.1/src/java2pad/java2pad.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/java2pad/java2pad.c'`"
    test 6965 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/java2pad/java2pad.c:' 'original size' '6965,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/java2pad/token.c ==============
if test -f 'pad2ps-3.1/src/java2pad/token.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/java2pad/token.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/java2pad/token.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/java2pad/token.c' &&
/*                                 */
/*  token.c -- get token           */
/*                                 */
/*  java2pad  by S. Yoshida        */
/*                                 */
X
#include "config.h"
X
#include <string.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include <ctype.h>
#include "java2pad.h"
#include "lib.h"
X
#define PRINT_COMMENT_IMMEDIATELY
X
static int ch = 0;
static int pch = 0;		/* read one character in ahead */
static int word_ptr = 0;	/* pointer to the end of word */
static bool newline = On;	/* whether it is the head of line */
static char *comm = NULL;	/* preserved comment */
X
static void set_ch(void);
static void append_ch(void);
static void get_ch(void);
X
#ifndef PRINT_COMMENT_IMMEDIATELY
static void preserve_comment(void);
#endif
X
void get_token(void)
/* get token */
{
X    int old_ch;
X
X    if(token == Eof)
X	fatal_error("input file terminates unexpectedly.");
X
#ifndef PRINT_COMMENT_IMMEDIATELY
X    if(newline == On  &&  comm != NULL){
X	/* print preserved commen */
X
X	/* do not print at this place */
X	if (no_print_comment_flag == On) {
X	    strcpy(word,comm);
X	    free(comm);
X	    comm = NULL;
X	    token = Comment;
X	    return;
X	}
X
X	printf("%s",comm);
X	free(comm);
X	comm = NULL;
X    }
#endif
X
X    if(ch == 0)
X	get_ch();
X
X    switch(ch){
X	case EOF:
X	    token = Eof;
X	    *word = '\0';
X	    return;
X	case '\n':
X	    newline = On;
X	    token = Ret;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ' ':
X	case '\t':
X	    token = Sp;
X	    set_ch();
X	    get_ch();
X	    while(ch == ' '  ||  ch == '\t'){
X		append_ch();
X		get_ch();
X	    }
X	    return;
X	case '/':
X	    set_ch();
X	    get_ch();
X	    if(ch != '*'  &&  ch != '/'){
X		newline = Off;
X		token = Divide;
X		return;
X	    }else if(ch == '*'){	/* C style comment*/
X		append_ch();
X		get_ch(); append_ch();
X
X		do{
X		    old_ch = ch;
X		    get_ch(); append_ch();
X		}while(old_ch != '*'  ||  ch != '/');
X
X		get_ch();
X
#ifndef PRINT_COMMENT_IMMEDIATELY
X		if(newline == On){	/* print immediately if the comment is at the head of line */
#endif
X		    /* do not print at this place */
X		    if (no_print_comment_flag == On) {
#ifdef PRINT_COMMENT_IMMEDIATELY
X			if(newline == Off)
X			    strcat(word,"\n");
#endif
X			token = Comment;
X			return;
X		    }
X
#ifdef PRINT_COMMENT_IMMEDIATELY
X		    if (elseif_flag == On) {
X		        putchar('\n');
X			elseif_flag = Off;
X		    }
#endif
X		    puts(word);
X
#ifdef PRINT_COMMENT_IMMEDIATELY
X		    if(newline == Off){
X			get_token();
X			return;
X		    }
#endif
X
X		    get_token();
X		    while(token == Sp)
X			get_token();
X		    if(token == Ret)
X			get_token();
#ifndef PRINT_COMMENT_IMMEDIATELY
X		}else{		/* all other comments are preserved, and are printed after inserting return code */
X		    preserve_comment();
X		    get_token();
X		}
#endif
X		return;
X	    }else{			/* C++ style comment */
X		append_ch();
X		get_ch();
X
X		while(ch != '\n'){
X		    append_ch();
X		    get_ch();
X		}
X
#ifndef PRINT_COMMENT_IMMEDIATELY
X		if(newline == On){	/*  print immediately if the comment is at the head of line */
#endif
X		    /* do not print at this place */
X		    if (no_print_comment_flag == On) {
X			get_ch();
X			strcat(word,"\n");
X			token = Comment;
X			return;
X		    }
X
#ifdef PRINT_COMMENT_IMMEDIATELY
X		    if (elseif_flag == On) {
X		        putchar('\n');
X			elseif_flag = Off;
X		    }
#endif
X		    puts(word);
X
#ifdef PRINT_COMMENT_IMMEDIATELY
X		    if(newline == On)
#endif
X		    get_ch();
X		    get_token();
#ifndef PRINT_COMMENT_IMMEDIATELY
X		}else{		/* all other comments are preserved, and are printed after inserting return code */
X		    preserve_comment();
X		    get_token();
X		}
#endif
X		return;
X	    }
X	case '"':
X	    newline = Off;
X	    set_ch();
X
X	    do{
X		get_ch();
X		if(ch == '\n'){
X		    ch = '\\'; append_ch();
X		    ch = 'n'; append_ch();
X		}else if(ch == '\\'){
X		    append_ch();
X		    get_ch(); append_ch();
X		    ch = ' ';
X		}else
X		    append_ch();
X	    }while(ch != '"');
X
X	    get_ch();
X
X	    token = Str;
X	    return;
X	case '\'':
X	    newline = Off;
X	    set_ch();
X
X	    do{
X		get_ch();
X		if(ch == '\n'){
X		    ch = '\\'; append_ch();
X		    ch = 'n'; append_ch();
X		}else if(ch == '\\'){
X		    append_ch();
X		    get_ch(); append_ch();
X		    ch = ' ';
X		}else
X		    append_ch();
X	    }while(ch != '\'');
X
X	    get_ch();
X
X	    token = Str;
X	    return;
X	case '<':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    switch(ch){
X		case '<':
X		    token = Lshift;
X		    append_ch();
X		    get_ch();
X		    return;
X		case '=':
X		    token = Less_eq;
X		    append_ch();
X		    get_ch();
X		    return;
X		default:
X		    token = Less;
X		    return;
X	    }
X	case '>':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    switch(ch){
X		case '>':
X		    token = Rshift;
X		    append_ch();
X		    get_ch();
X		    return;
X		case '=':
X		    token = Great_eq;
X		    append_ch();
X		    get_ch();
X		    return;
X		default:
X		    token = Great;
X		    return;
X		}
X	case '&':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '&'){
X		token=And;
X		return;
X	    }else{
X		token = And2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '|':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '|'){
X		token = Or;
X		return;
X	    }else{
X		token = Or2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '=':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '='){
X		token = Equal;
X		return;
X	    }else{
X		token = Equal2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '!':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != '='){
X		token = Not;
X		return;
X	    }else{
X		token = Neq;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case '^':
X	    newline = Off;
X	    token = Exp;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '*':
X	    newline = Off;
X	    token = Times;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '+':
X	    newline = Off;
X	    token = Plus;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '-':
X	    newline = Off;
X	    token = Minus;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '(':
X	    newline = Off;
X	    token = Lpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ')':
X	    newline = Off;
X	    token = Rpar;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '{':
X	    newline = Off;
X	    token = Lbrace;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '}':
X	    newline = Off;
X	    token = Rbrace;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '[':
X	    newline = Off;
X	    token = Lbracket;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ']':
X	    newline = Off;
X	    token = Rbracket;
X	    set_ch();
X	    get_ch();
X	    return;
X	case '?':
X	    newline = Off;
X	    token = Question;
X	    set_ch();
X	    get_ch();
X	    return;
X	case ':':
X	    newline = Off;
X	    set_ch();
X	    get_ch();
X	    if(ch != ':'){
X		token = Colon;
X		return;
X	    }else{
X		token = Colon2;
X		append_ch();
X		get_ch();
X		return;
X	    }
X	case ';':
X	    newline = Off;
X	    token = Semicolon;
X	    set_ch();
X	    get_ch();
X	    return;
X	default:
X	    newline = Off;
X	    if(isdigit(ch)){
X		token = Num;
X		set_ch();
X		get_ch();
X		while(isdigit(ch)){
X		    append_ch();
X		    get_ch();
X		}
X		return;
X	    }
X
X	    if(isalpha(ch)  ||  ch == '_'){
X		token = Name;
X		set_ch();
X		get_ch();
X		while(isalnum(ch)  ||  (char)ch == '_'){
X		    append_ch();
X		    get_ch();
X		}
X
X		if(strcmp(word,"if") == 0)
X		    token = If;
X		else if(strcmp(word,"else") == 0)
X		    token = Else;
X		else if(strcmp(word,"while") == 0)
X		    token = While;
X		else if(strcmp(word,"for") == 0)
X		    token = For;
X		else if(strcmp(word,"do") == 0)
X		    token = Do;
X		else if(strcmp(word,"switch") == 0)
X		    token = Switch;
X		else if(strcmp(word,"case") == 0)
X		    token = Case;
X		else if(strcmp(word,"default") == 0)
X		    token = Default;
X		else if(strcmp(word,"try") == 0)
X		    token = Try;
X		else if(strcmp(word,"catch") == 0)
X		    token = Catch;
X		else if(strcmp(word,"return") == 0)
X		    token = Return;
X		else if(strcmp(word,"break") == 0)
X		    token = Break;
X		else if(strcmp(word,"continue") == 0)
X		    token = Continue;
X		else if(strcmp(word,"goto") == 0)
X		    token = Goto;
X
X		return;
X	    }
X
X	    token = Str;
X	    set_ch();
X	    get_ch();
X	    return;
X    }
}
X
void set_ch(void)
/* set the character just read */
{
X    *word = ch;
X    *(word + 1) = '\0';
X    word_ptr = 1;
}
X
void append_ch(void)
/* append the character just read */
{
X    *(word + word_ptr) = ch;
X    *(word + word_ptr + 1) = '\0';
X    word_ptr++;
}
X
void get_ch(void)
/* get one character */
{
X    if(ch == 0){
X	ch = getc(input_stream);
X	pch = getc(input_stream);
X    }else{
X	ch = pch;
X	pch = getc(input_stream);
X    }
X
X    while(ch == '\\'  &&  pch == '\n'){		/* discard '\' at the end of line */
X	line_count++;
X	ch = getc(input_stream);
X	pch = getc(input_stream);
X    }
X
X    if(ch == '\n')
X	line_count++;
}
X
#ifndef PRINT_COMMENT_IMMEDIATELY
void preserve_comment(void)
/* preserve comment */
{
X    char *s;
X    int l;
X
X    l = strlen(word);
X    s = (char *)malloc((l+3) * sizeof(char));
X    strcpy(s,word);
X    strcat(s,"\n");
X
X    if(comm == NULL)
X	comm = s;
X    else
X	comm = joint(2,comm,s);
}
#endif
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/java2pad/token.c' &&
  chmod 0644 'pad2ps-3.1/src/java2pad/token.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/java2pad/token.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/java2pad/token.c:' 'MD5 check failed'
c0e97acfc8ede3e40984f8faa924032d  pad2ps-3.1/src/java2pad/token.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/java2pad/token.c'`"
    test 9059 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/java2pad/token.c:' 'original size' '9059,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/java2pad/Makefile.in ==============
if test -f 'pad2ps-3.1/src/java2pad/Makefile.in' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/java2pad/Makefile.in' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/java2pad/Makefile.in' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/java2pad/Makefile.in' &&
### Makefile of java2pad  by S. Yoshida
X
### configuration by configure
X
prefix = @prefix@
exec_prefix = @exec_prefix@
LIBDIR = @libdir@/pad2ps
X
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
X
CC = @CC@
X
LIBS = @LIBS@ -L../lib -lpublic
X
### make commands
X
CFLAGS = -O2
LDFLAGS =
MFLAGS =
X
INCLUDES = -I.. -I../lib
X
HDRS = java2pad.h
SRCS = java2pad.c parser.c token.c
OBJS = java2pad.o parser.o token.o
X
TARGS = java2pad
X
all: ${TARGS}
X
java2pad: ${OBJS} ${HDRS}
X	$(CC) $(LDFLAGS) ${OBJS} -o $@ $(LIBS)
X
%.o: %.c
X	$(CC) $(CFLAGS) $(INCLUDES) -c $<
X
install: ${TARGS}
X	$(INSTALL) -d $(LIBDIR)
X	if [ -f $(LIBDIR)/java2pad ]; then rm -f $(LIBDIR)/java2pad; fi
X	$(INSTALL_PROGRAM) java2pad $(LIBDIR)
X
clean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X
distclean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X	rm -f Makefile
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/java2pad/Makefile.in' &&
  chmod 0644 'pad2ps-3.1/src/java2pad/Makefile.in' ||
  $echo 'restore of' 'pad2ps-3.1/src/java2pad/Makefile.in' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/java2pad/Makefile.in:' 'MD5 check failed'
4a7f003fbe55329f8d03891f73a90ccd  pad2ps-3.1/src/java2pad/Makefile.in
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/java2pad/Makefile.in'`"
    test 859 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/java2pad/Makefile.in:' 'original size' '859,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/lib/stack.c ==============
if test ! -d 'pad2ps-3.1/src/lib'; then
  $echo 'x -' 'creating directory' 'pad2ps-3.1/src/lib'
  mkdir 'pad2ps-3.1/src/lib'
fi
if test -f 'pad2ps-3.1/src/lib/stack.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/lib/stack.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/lib/stack.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/lib/stack.c' &&
/*                           */
/*  stack.c -- handle stack  */
/*                           */
/*  by S. Yoshida            */
/*                           */
X
#include "config.h"
X
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include "lib.h"
X
static STACK *sp = NULL;
X
void push(void *ptr)
{
X    STACK *tmp;
X
X    tmp = (STACK *)malloc(sizeof(STACK));
X    tmp->ptr = ptr;
X    tmp->prev = sp;
X    sp = tmp;
}
X
void *pop(void)
{
X    void *ptr;
X    STACK *s;
X
X    ptr = sp->ptr;
X    s = sp;
X    sp = sp->prev;
X    free(s);
X    return ptr;
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/lib/stack.c' &&
  chmod 0644 'pad2ps-3.1/src/lib/stack.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/lib/stack.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/lib/stack.c:' 'MD5 check failed'
b75215059da5db8c8b37e2dd14ef84cc  pad2ps-3.1/src/lib/stack.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/lib/stack.c'`"
    test 543 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/lib/stack.c:' 'original size' '543,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/lib/string.c ==============
if test -f 'pad2ps-3.1/src/lib/string.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/lib/string.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/lib/string.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/lib/string.c' &&
/*                            */
/*  string.c -- handle string */
/*                            */
/*  by S. Yoshida             */
/*                            */
X
#include "config.h"
X
#include <stdarg.h>
#include <string.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#include "lib.h"
X
char *joint(int n,char *ptr,...)
/* concatenate strings */
{
X    int i,l1,l2;
X    char *p,*p1,*p2;
X    va_list argptr;
X
X    va_start(argptr,ptr);
X    p1 = ptr;
X
X    for(i = 1 ; i < n ; i++){
X	p2 = va_arg(argptr,char *);
X
X	if(p1 == NULL)
X	    p1 = p2;
X	else{
X	    if(p2 != NULL){
X		l1 = strlen(p1); l2 = strlen(p2);
X		p = (char *)malloc((l1+l2+2)*sizeof(char));
X		strcpy(p,p1); strcat(p,p2);
X		free(p1); free(p2);
X		p1 = p;
X	    }
X	}
X    }
X    va_end(argptr);
X
X    return p1;
}
X
int is_euc(char c)
/* Japanese character? */
{
X    if((unsigned char)c >= 0x80)
X	return 1;
X    else
X	return 0;
}
X
int include_euc(char *s)
/* include Japanese characters? */
{
X    int i,l;
X
X    l = strlen(s);
X
X    for(i = 0 ; i < l ; i++){
X	if(is_euc(*(s+i)))
X	    return 1;
X    }
X
X    return 0;
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/lib/string.c' &&
  chmod 0644 'pad2ps-3.1/src/lib/string.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/lib/string.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/lib/string.c:' 'MD5 check failed'
3ec80d59aa4f00c82e26bdc1422efe8f  pad2ps-3.1/src/lib/string.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/lib/string.c'`"
    test 1070 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/lib/string.c:' 'original size' '1070,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/lib/lib.h ==============
if test -f 'pad2ps-3.1/src/lib/lib.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/lib/lib.h' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/lib/lib.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/lib/lib.h' &&
/*                         */
/*  lib.h                  */
/*                         */
/*  pad2ps  by S. Yoshida  */
/*                         */
X
#ifndef _LIB_H
#define _LIB_H
X
#include "config.h"
X
#include <stdio.h>
X
typedef struct _STACK STACK;
X
typedef enum {
X    On, Off, None
} bool;
X
struct _STACK {
X    void *ptr;
X    STACK *prev;
};
X
extern int warning_count;	/* warning count */
extern int error_count;		/* error count */
X
#define greater(x,y)	((x)>=(y)? (x):(y))	/* return greater value */
#define smaller(x,y)	((x)<=(y)? (x):(y))	/* return smaller value */
X
/* error.c */
extern void error(char *);		/* print error messages */
extern void warning(char *);		/* print warnings */
extern void fatal_error(char *);	/* print error messagea and exit */
X
/* stack.c */
extern void push(void *);
extern void *pop(void);
X
/* string.c */
extern char *joint(int,char *,...);	/* concatenate strings */
extern int is_euc(char);		/* Japanese character? */
extern int include_euc(char *);		/* include Japanese characters? */
X
#endif  /* ! _LIB_H */
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/lib/lib.h' &&
  chmod 0644 'pad2ps-3.1/src/lib/lib.h' ||
  $echo 'restore of' 'pad2ps-3.1/src/lib/lib.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/lib/lib.h:' 'MD5 check failed'
259647dfd335e357dee62f74443c2d67  pad2ps-3.1/src/lib/lib.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/lib/lib.h'`"
    test 1050 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/lib/lib.h:' 'original size' '1050,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/lib/error.c ==============
if test -f 'pad2ps-3.1/src/lib/error.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/lib/error.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/lib/error.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/lib/error.c' &&
/*                             */
/*  error.c -- handling errors */
/*                             */
/*  by S. Yoshida              */
/*                             */
X
#include "config.h"
X
#include <stdlib.h>
#include "lib.h"
X
int warning_count = 0;		/* warning count */
int error_count = 0;		/* error count */
X
void error(char *message)
{
X    error_count++;
X    fprintf(stderr,"\n%s ",message);
}
X
void warning(char *message)
{
X    warning_count++;
X    if(message != NULL)
X        fprintf(stderr,"\nwarning: %s ",message);
}
X
void fatal_error(char *message)
{
X    fprintf(stderr,"\n%s\n",message);
X    exit(1);
}
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/lib/error.c' &&
  chmod 0644 'pad2ps-3.1/src/lib/error.c' ||
  $echo 'restore of' 'pad2ps-3.1/src/lib/error.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/lib/error.c:' 'MD5 check failed'
84fb5e5bb2f10f2593c289ab43ecd5d4  pad2ps-3.1/src/lib/error.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/lib/error.c'`"
    test 617 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/lib/error.c:' 'original size' '617,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/lib/Makefile.in ==============
if test -f 'pad2ps-3.1/src/lib/Makefile.in' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/lib/Makefile.in' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/lib/Makefile.in' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/lib/Makefile.in' &&
### Makefile of lib  by S. Yoshida
X
### configuration by configure
X
CC = @CC@
X
RANLIB = @RANLIB@
X
### make commands
X
CFLAGS = -O2
LDFLAGS =
MFLAGS =
X
INCLUDES = -I..
X
HDRS = lib.h
SRCS = error.c stack.c string.c
OBJS = error.o stack.o string.o
X
TARGS = libpublic.a
X
all: ${TARGS}
X
libpublic.a: ${OBJS} ${HDRS}
X	ar cru $@ ${OBJS}
X	$(RANLIB) $@
X
%.o: %.c
X	$(CC) $(CFLAGS) $(INCLUDES) -c $<
X
install:
X
clean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X
distclean:
X	rm -f ${OBJS} ${TARGS} a.out core *~ *.bak
X	rm -f Makefile
SHAR_EOF
  $shar_touch -am 0820130496 'pad2ps-3.1/src/lib/Makefile.in' &&
  chmod 0644 'pad2ps-3.1/src/lib/Makefile.in' ||
  $echo 'restore of' 'pad2ps-3.1/src/lib/Makefile.in' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pad2ps-3.1/src/lib/Makefile.in:' 'MD5 check failed'
f20c235b2d4fbde47890f39073bc7d22  pad2ps-3.1/src/lib/Makefile.in
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pad2ps-3.1/src/lib/Makefile.in'`"
    test 522 -eq "$shar_count" ||
    $echo 'pad2ps-3.1/src/lib/Makefile.in:' 'original size' '522,' 'current size' "$shar_count!"
  fi
fi
# ============= pad2ps-3.1/src/main/main.c ==============
if test ! -d 'pad2ps-3.1/src/main'; then
  $echo 'x -' 'creating directory' 'pad2ps-3.1/src/main'
  mkdir 'pad2ps-3.1/src/main'
fi
if test -f 'pad2ps-3.1/src/main/main.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pad2ps-3.1/src/main/main.c' '(file already exists)'
  rm -f _sh23946/new
else
  > _sh23946/new
  $echo 'x -' extracting 'pad2ps-3.1/src/main/main.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pad2ps-3.1/src/main/main.c' &&
/*                                  */
/*  main.c -- overall main routine  */
/*                                  */
/*  pad2ps  by S. Yoshida           */
/*                                  */
X
#include "config.h"
X
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "main.h"
X
#ifdef DEBUG
static bool debug = Off;		/* -debug */
#endif
static bool ifdef = Off;		/* -ifdef */
#ifdef JAPANESE
static char kconv[BUFSIZ] = "nkf -e";	/* KANJI converter */
static bool noconv = Off;		/* -noconv */
#endif
static bool nohelp = Off;		/* -nohelp */
static bool quiet = Off;		/* -quiet */
static bool stdin_flag = Off;		/* -stdin */
X
static SRC source_type = Default;		/* type of source file */
X
static bool foo2pad_flag = Off;			/* whether foo2pad is executed */
X
static char thiscmd[BUFSIZ] = {'\0'};	/* executed command name */
static char filename[BUFSIZ] = {'\0'};	/* input file name */
static char outfile[BUFSIZ] = {'\0'};	/* output file name */
static char foo2padfile[BUFSIZ];	/* name of file to preserve output of foo2pad */
X
X
static void suffix(void);		/* select parser from suffix */
static void translator(int,char **);	/* execute foo2pad */
static void pad2ps(int,char **);	/* execute pad2p */
X
static void option(int,char **);		/* handle options */
static void mkargs(int,char **,char *,SRC);	/* create option strings */
static void print_help(void);			/* print help messages */
X
#if defined(HAVE_ATEXIT)
static void at_exit(void);		/* handle termination process */
#elif defined(HAVE_ON_EXIT)
static void at_exit(int,void *);	/* handle termination process */
#endif
X
int main(int argc,char **argv)
{
X    char *env;
X
X    /* handle exit() */
#if defined(HAVE_ATEXIT)
X    atexit(at_exit);
#elif defined(HAVE_ON_EXIT)
X    on_exit(at_exit,NULL);
#endif
X
X    /* name of file to preserve output of foo2pad */
#ifdef TMP
X    strcpy(foo2padfile,TMP);
X    strcat(foo2padfile,"/");
#else
X    strcpy(foo2padfile,"/tmp/");
#endif
X    if((env = getenv("TMP")) != NULL  &&  strlen(env) > 0){
X	/* get the environment variable TMP */
X	strcpy(foo2padfile,env);
X	strcat(foo2padfile,"/");
X    }
X    strcat(foo2padfile,"foo2pad-XXXXXX");
X
X    option(argc,argv);			/* handle options */
X
X    suffix();				/* select parser from suffix */
X    translator(argc,argv);		/* execute foo2pad */
X    pad2ps(argc,argv);			/* execute pad2ps */
X
X    return 0;
}
X
void suffix(void)
/* select parser from suffix */
{
X    int l;
X
X    if(stdin_flag == On){
X	if(filename[0] != '\0'){
X	    strcpy(outfile,filename);
X	    filename[0] = '\0';
X	}
X    }
X
X    if(filename[0] != '\0'  &&  source_type == Default){
X	l = strlen(filename);
X
X	if(l >= 4  &&  strcmp(&filename[l-4],".awk") == 0)
X	    source_type = Awk;
X	if((l >= 2  &&  strcmp(&filename[l-2],".c") == 0)  ||
X	   (l >= 2  &&  strcmp(&filename[l-2],".C") == 0)  ||
X	   (l >= 3  &&  strcmp(&filename[l-3],".cc") == 0)  ||
X	   (l >= 4  &&  strcmp(&filename[l-4],".cpp") == 0))
X	    source_type = C;
X	if(l >= 4  &&  strcmp(&filename[l-4],".csh") == 0)
X	    source_type = Csh;
X	if(l >= 5  &&  strcmp(&filename[l-5],".java") == 0)
X	    source_type = Java;
X	if(l >= 3  &&  strcmp(&filename[l-3],".sh") == 0)
X	    source_type = Sh;
X    }
}
X
void translator(int argc,char **argv)
/* execute foo2pad */
{
X    char tmp[BUFSIZ];
X    char lpath[BUFSIZ] = {'\0'};
X    char module[BUFSIZ];
X    char arguments[BUFSIZ] = {'\0'};
X    char *env;
X    int exit_code;
X    FILE *chk;
X
#ifdef LPATH
X    strcpy(lpath,LPATH);
X    strcat(lpath,"/");
#endif
X
X    if((env = getenv("PAD2PSLIB")) != NULL  &&  strlen(env) > 0){
X	/* get the environment variable PAD2PSLIB */
X	strcpy(lpath,env);
X	strcat(lpath,"/");
X    }
X
X    switch(source_type){
X	case Awk:
X	    strcpy(module,"awk2pad");
X	    break;
X	case C:
X	    strcpy(module,"c2pad");
X	    break;
X	case Csh:
X	    strcpy(module,"csh2pad");
X	    break;
X	case Java:
X	    strcpy(module,"java2pad");
X	    break;
X	case Sh:
X	    strcpy(module,"sh2pad");
X	    break;
X	case Pad:
X	case Default:
X	    return;
X    }
X
X    sprintf(tmp,"%s%s",lpath,module);
X    chk = fopen(tmp,"r");
X    if(chk == NULL)		/* modules not in lpath */
X	lpath[0] = '\0';
X    fclose(chk);
X
X    mkargs(argc,argv,arguments,source_type);
X
X    if(source_type == C  &&  ifdef == On){	/* -ifdef */
X	sprintf(tmp,"%sc2pad -nohelp %s",lpath,arguments);
X	exit_code = system(tmp);
X	exit(exit_code);
X    }
X
X    mktemp(foo2padfile);
X    sprintf(tmp,"%s%s -nohelp -quiet %s > %s",lpath,module,arguments,foo2padfile);
X    exit_code = system(tmp);
X 
X    foo2pad_flag = On;
X
X    if(exit_code != 0){
X	remove(foo2padfile);
X	exit(exit_code);
X    }
}
X
void pad2ps(int argc,char **argv)
/* execute pad2ps */
{
X    char tmp[BUFSIZ];
X    char lpath[BUFSIZ] = {'\0'};
X    char arguments[BUFSIZ] = {'\0'};
X    char dummy_inputfile[BUFSIZ] = {'\0'};
X    char *env;
X    int exit_code;
X    FILE *chk;
X
#ifdef LPATH
X    strcpy(lpath,LPATH);
X    strcat(lpath,"/");
#endif
X
X    if((env = getenv("PAD2PSLIB")) != NULL  &&  strlen(env) > 0){
X	/* get the environment variable PAD2PSLIB */
X	strcpy(lpath,env);
X	strcat(lpath,"/");
X    }
X
X    sprintf(tmp,"%s%s",lpath,thiscmd);
X    chk = fopen(tmp,"r");
X    if(chk == NULL){		/* modules not in lpath */
X	fclose(chk);
X	fprintf(stderr,"No %s module.\n",thiscmd);
X	exit(1);
X    }
X    fclose(chk);
X
X    if(stdin_flag == On  &&  outfile[0] != '\0')
X	strcpy(dummy_inputfile,outfile);
X
X    mkargs(argc,argv,arguments,Pad);
X    if(source_type != Pad  &&  source_type != Default)
X	sprintf(tmp,"cat %s | %s%s -nohelp -stdin %s %s",foo2padfile,lpath,thiscmd,dummy_inputfile,arguments);
X    else
X	sprintf(tmp,"%s%s -nohelp %s %s",lpath,thiscmd,dummy_inputfile,arguments);
X    exit_code = system(tmp);
X
X    if(source_type != Pad  &&  source_type != Default)
X	remove(foo2padfile);
X
X    if(exit_code != 0)
X	exit(exit_code);
}
X
void option(int argc,char **argv)
/* handle options */
{
X    int i,p = -1;
X
X    for(i = 0 ; argv[0][i] != '\0' ; i++){	/* get executed command name */
X	if(argv[0][i] == '/')
X	    p = i;
X    }
X    strcpy(thiscmd,&argv[0][p+1]);
X
X    for(i = 1 ; i < argc ; i++){
X	if(argv[i][0] != '-'){
X	    if(filename[0] == '\0'){		/* input file name */
X		strcpy(filename,argv[i]);
X	    }else if(outfile[0] == '\0')	/* output file name */
X		strcpy(outfile,argv[i]);
X	    else if(nohelp == Off){
X		print_help();
X		exit(1);
X	    }
X	}else{				/* options */
X	    switch(argv[i][1]){
X		case 'a':
X		    if(strcmp(argv[i],"-awk") == 0){
X			source_type = Awk;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'c':
X		    if(strcmp(argv[i],"-c") == 0){
X			source_type = C;
X		    }else if(strcmp(argv[i],"-c++") == 0){
X			source_type = C;
X		    }else if(strcmp(argv[i],"-csh") == 0){
X			source_type = Csh;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'D':
X		    if(strcmp(argv[i],"-D") == 0){
X			i++;
X			while(i < argc  &&  argv[i][0] != '-')
X			    i++;
X			i--;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'd':
X		    if(strcmp(argv[i],"-dir") == 0){
X			i++;
#ifdef DEBUG
X		    }else if(strcmp(argv[i],"-debug") == 0){
X			debug = On;
#endif
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'h':
X		    if(strcmp(argv[i],"-help") == 0){
X			print_help();
X			exit(0);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'i':
X		    if(strcmp(argv[i],"-ifdef") == 0){
X			ifdef = On;
X		    }else if(strcmp(argv[i],"-inline") == 0){
X			break;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'j':
X		    if(strcmp(argv[i],"-java") == 0){
X			source_type = Java;
X		    }
X		    break;
#ifdef JAPANESE
X		case 'k':
X		    if(strcmp(argv[i],"-kconv") == 0  &&  i + 1 < argc){
X			strcpy(kconv,argv[++i]);
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
#endif
X		case 'n':
X		    if(strcmp(argv[i],"-nohelp") == 0){
X			nohelp = On;
X		    }else if(strcmp(argv[i],"-noopt") == 0){
X			break;
#ifdef JAPANESE
X		    }else if(strcmp(argv[i],"-noconv") == 0){
X			noconv = On;
#endif
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'O':
X		    if(strcmp(argv[i],"-O") == 0){
X			break;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'P':
X		    if(strcmp(argv[i],"-P") == 0){
X			i++;
X			while(i < argc  &&  argv[i][0] != '-')
X			    i++;
X			i--;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'p':
X		    if(strcmp(argv[i],"-pad") == 0){
X			source_type = Pad;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'q':
X		    if(strcmp(argv[i],"-quiet") == 0){
X			quiet = On;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 's':
X		    if(strcmp(argv[i],"-semicolon") == 0){
X			break;
X		    }else if(strcmp(argv[i],"-stdin") == 0){
X			stdin_flag = On;
X		    }else if(strcmp(argv[i],"-sh") == 0){
X			source_type = Sh;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 't':
X		    if(strcmp(argv[i],"-tab") == 0){
X			i++;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		case 'w':
X		    if(strcmp(argv[i],"-warn") == 0){
X			break;
X		    }else if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X		default:
X		    if(nohelp == Off){
X			print_help();
X			exit(1);
X		    }
X		    break;
X	    }
X	}
X    }
}
X
void mkargs(int argc,char **argv,char *args,SRC src_type)
/* create option strings */
{
X    int i;
X
X    args[0] = '\0';
X
X    for(i = 1 ; i < argc ; i++){
X	if(argv[i][0] != '-'){		/* file name */
X	    strcat(args," ");
X	    strcat(args,argv[i]);
X	}else{				/* options */
X	    switch(argv[i][1]){
X		case 'D':
X		    if(strcmp(argv[i],"-D") == 0){
X			if(src_type == C)
X			    strcat(args," -D");
X			i++;
X			while(i < argc  &&  argv[i][0] != '-'){
X			    if(src_type == C){
X				strcat(args," ");
X				strcat(args,argv[i]);
X			    }
X			    i++;
X			}
X			if(src_type == C)
X			    strcat(args," -dummy");
X			i--;
X		    }
X		    break;
X		case 'd':
X		    if(strcmp(argv[i],"-dir") == 0){
X			i++;
X			if(src_type == Pad  ||  src_type == Default){
X			    strcat(args," -dir ");
X			    strcat(args,argv[i]);
X			}
#ifdef DEBUG
X		    }else if(strcmp(argv[i],"-debug") == 0){
X			strcat(args," -debug");
#endif
X		    }
X		    break;
X		case 'i':
X		    if(strcmp(argv[i],"-ifdef") == 0){
X			if(src_type == C)
X			    strcat(args," -ifdef");
X		    }else  if(strcmp(argv[i],"-inline") == 0){
X			if(src_type == C)
X			    strcat(args," -inline");
X		    }
X		    break;
#ifdef JAPANESE
X		case 'k':
X		    if(strcmp(argv[i],"-kconv") == 0  &&  i + 1 < argc){
X			strcat(args," -kconv ");
X			strcat(args,argv[++i]);
X		    }
X		    break;
#endif
SHAR_EOF
  : || $echo 'restore of' 'pad2ps-3.1/src/main/main.c' 'failed'
fi
$echo 'End of' 'archive' 'part' '8'
$echo 'File' 'pad2ps-3.1/src/main/main.c' 'is continued in part' '9'
echo 9 > _sh23946/seq
exit 0


