17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate
237c478bd9Sstevel@tonic-gate /*
247c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
257c478bd9Sstevel@tonic-gate * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
28*dc5a8425Srobbin /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29*dc5a8425Srobbin /* All Rights Reserved */
30*dc5a8425Srobbin
31*dc5a8425Srobbin #pragma ident "%Z%%M% %I% %E% SMI"
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include "stdio.h"
347c478bd9Sstevel@tonic-gate #include "awk.def"
357c478bd9Sstevel@tonic-gate #include "awk.h"
36*dc5a8425Srobbin #include <stdlib.h>
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate CELL *symtab[MAXSYM]; /* symbol table pointers */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gate wchar_t **FS; /* initial field sep */
427c478bd9Sstevel@tonic-gate wchar_t **RS; /* initial record sep */
437c478bd9Sstevel@tonic-gate wchar_t **OFS; /* output field sep */
447c478bd9Sstevel@tonic-gate wchar_t **ORS; /* output record sep */
457c478bd9Sstevel@tonic-gate wchar_t **OFMT; /* output format for numbers */
467c478bd9Sstevel@tonic-gate awkfloat *NF; /* number of fields in current record */
477c478bd9Sstevel@tonic-gate awkfloat *NR; /* number of current record */
487c478bd9Sstevel@tonic-gate wchar_t **FILENAME; /* current filename argument */
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate CELL *recloc; /* location of record */
527c478bd9Sstevel@tonic-gate CELL *nrloc; /* NR */
537c478bd9Sstevel@tonic-gate CELL *nfloc; /* NF */
547c478bd9Sstevel@tonic-gate
55*dc5a8425Srobbin void recbld(void);
567c478bd9Sstevel@tonic-gate
57*dc5a8425Srobbin void
syminit(void)58*dc5a8425Srobbin syminit(void)
597c478bd9Sstevel@tonic-gate {
607c478bd9Sstevel@tonic-gate static wchar_t L_0[] = L"0";
617c478bd9Sstevel@tonic-gate static wchar_t L_zeronull[] = L"$zero&null";
627c478bd9Sstevel@tonic-gate static wchar_t L_record[] = L"$record";
637c478bd9Sstevel@tonic-gate static wchar_t L_FS[] = L"FS";
647c478bd9Sstevel@tonic-gate static wchar_t L_OFS[] = L"OFS";
657c478bd9Sstevel@tonic-gate static wchar_t L_ORS[] = L"ORS";
667c478bd9Sstevel@tonic-gate static wchar_t L_RS[] = L"RS";
677c478bd9Sstevel@tonic-gate static wchar_t L_OFMT[] = L"OFMT";
687c478bd9Sstevel@tonic-gate static wchar_t L_space[] = L" ";
697c478bd9Sstevel@tonic-gate static wchar_t L_newline[] = L"\n";
707c478bd9Sstevel@tonic-gate static wchar_t L_dot6g[] = L"%.6g";
717c478bd9Sstevel@tonic-gate static wchar_t L_FILENAME[] = L"FILENAME";
727c478bd9Sstevel@tonic-gate static wchar_t L_NF[] = L"NF";
737c478bd9Sstevel@tonic-gate static wchar_t L_NR[] = L"NR";
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate setsymtab(L_0, tostring(L_0), 0.0, NUM|STR|CON|FLD, symtab);
777c478bd9Sstevel@tonic-gate /* this one is used for if (x)... tests: */
787c478bd9Sstevel@tonic-gate setsymtab(L_zeronull, tostring(L_NULL), 0.0, NUM|STR|CON|FLD, symtab);
797c478bd9Sstevel@tonic-gate recloc = setsymtab(L_record, record, 0.0, STR|FLD, symtab);
807c478bd9Sstevel@tonic-gate dprintf("recloc %o lookup %o\n",
817c478bd9Sstevel@tonic-gate recloc, lookup(L_record, symtab, 0), NULL);
827c478bd9Sstevel@tonic-gate FS = &setsymtab(L_FS, tostring(L_space), 0.0, STR|FLD, symtab)->sval;
837c478bd9Sstevel@tonic-gate RS = &setsymtab(L_RS, tostring(L_newline), 0.0, STR|FLD, symtab)->sval;
847c478bd9Sstevel@tonic-gate OFS = &setsymtab(L_OFS, tostring(L_space), 0.0, STR|FLD, symtab)->sval;
857c478bd9Sstevel@tonic-gate ORS = &setsymtab(L_ORS, tostring(L_newline), 0.0, STR|FLD,
867c478bd9Sstevel@tonic-gate symtab)->sval;
877c478bd9Sstevel@tonic-gate OFMT = &setsymtab(L_OFMT, tostring(L_dot6g), 0.0, STR|FLD,
887c478bd9Sstevel@tonic-gate symtab)->sval;
897c478bd9Sstevel@tonic-gate FILENAME = &setsymtab(L_FILENAME, NULL, 0.0, STR|FLD, symtab)->sval;
907c478bd9Sstevel@tonic-gate nfloc = setsymtab(L_NF, NULL, 0.0, NUM, symtab);
917c478bd9Sstevel@tonic-gate NF = &nfloc->fval;
927c478bd9Sstevel@tonic-gate nrloc = setsymtab(L_NR, NULL, 0.0, NUM, symtab);
937c478bd9Sstevel@tonic-gate NR = &nrloc->fval;
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate
97*dc5a8425Srobbin CELL **
makesymtab(void)98*dc5a8425Srobbin makesymtab(void)
997c478bd9Sstevel@tonic-gate {
1007c478bd9Sstevel@tonic-gate int i;
1017c478bd9Sstevel@tonic-gate CELL **cp;
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate cp = (CELL **) malloc(MAXSYM * sizeof (CELL *));
1057c478bd9Sstevel@tonic-gate if (cp == NULL)
1067c478bd9Sstevel@tonic-gate error(FATAL, "out of space in makesymtab");
1077c478bd9Sstevel@tonic-gate for (i = 0; i < MAXSYM; i++)
1087c478bd9Sstevel@tonic-gate cp[i] = 0;
1097c478bd9Sstevel@tonic-gate return (cp);
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate
1127c478bd9Sstevel@tonic-gate
113*dc5a8425Srobbin void
freesymtab(CELL * ap)114*dc5a8425Srobbin freesymtab(CELL *ap) /* free symbol table */
1157c478bd9Sstevel@tonic-gate {
1167c478bd9Sstevel@tonic-gate CELL *cp, **tp, *next;
1177c478bd9Sstevel@tonic-gate int i;
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate if (!(ap->tval & ARR))
1217c478bd9Sstevel@tonic-gate return;
1227c478bd9Sstevel@tonic-gate tp = (CELL **) ap->sval;
1237c478bd9Sstevel@tonic-gate for (i = 0; i < MAXSYM; i++) {
1247c478bd9Sstevel@tonic-gate for (cp = tp[i]; cp != NULL; cp = next) {
1257c478bd9Sstevel@tonic-gate next = cp->nextval;
1267c478bd9Sstevel@tonic-gate xfree(cp->nval);
1277c478bd9Sstevel@tonic-gate xfree(cp->sval);
1287c478bd9Sstevel@tonic-gate free(cp);
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate xfree(tp);
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gate
135*dc5a8425Srobbin CELL *
setsymtab(wchar_t * n,wchar_t * s,awkfloat f,unsigned t,CELL ** tab)136*dc5a8425Srobbin setsymtab(wchar_t *n, wchar_t *s, awkfloat f, unsigned t, CELL **tab)
1377c478bd9Sstevel@tonic-gate {
138*dc5a8425Srobbin int h;
139*dc5a8425Srobbin CELL *p;
1407c478bd9Sstevel@tonic-gate CELL *lookup();
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate if (n != NULL && (p = lookup(n, tab, 0)) != NULL) {
1447c478bd9Sstevel@tonic-gate xfree(s);
1457c478bd9Sstevel@tonic-gate dprintf("setsymtab found %o: %ws\n", p, p->nval, NULL);
1467c478bd9Sstevel@tonic-gate dprintf(" %ws %g %o\n", p->sval, p->fval, p->tval);
1477c478bd9Sstevel@tonic-gate return (p);
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate p = (CELL *) malloc(sizeof (CELL));
1507c478bd9Sstevel@tonic-gate if (p == NULL)
1517c478bd9Sstevel@tonic-gate error(FATAL, "symbol table overflow at %ws", n);
1527c478bd9Sstevel@tonic-gate p->nval = tostring(n);
1537c478bd9Sstevel@tonic-gate p->sval = s;
1547c478bd9Sstevel@tonic-gate p->fval = f;
1557c478bd9Sstevel@tonic-gate p->tval = t;
1567c478bd9Sstevel@tonic-gate h = hash(n);
1577c478bd9Sstevel@tonic-gate p->nextval = tab[h];
1587c478bd9Sstevel@tonic-gate tab[h] = p;
1597c478bd9Sstevel@tonic-gate dprintf("setsymtab set %o: %ws\n", p, p->nval, NULL);
1607c478bd9Sstevel@tonic-gate dprintf(" %ws %g %o\n", p->sval, p->fval, p->tval);
1617c478bd9Sstevel@tonic-gate return (p);
1627c478bd9Sstevel@tonic-gate }
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate
165*dc5a8425Srobbin int
hash(wchar_t * s)166*dc5a8425Srobbin hash(wchar_t *s) /* form hash value for string s */
1677c478bd9Sstevel@tonic-gate {
168*dc5a8425Srobbin unsigned hashval;
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gate for (hashval = 0; *s != '\0'; /* dummy */)
1727c478bd9Sstevel@tonic-gate hashval += *s++;
1737c478bd9Sstevel@tonic-gate return (hashval % MAXSYM);
1747c478bd9Sstevel@tonic-gate }
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate
177*dc5a8425Srobbin CELL *
lookup(wchar_t * s,CELL ** tab,int flag)178*dc5a8425Srobbin lookup(wchar_t *s, CELL **tab, int flag)
179*dc5a8425Srobbin /* look for s in tab, flag must match */
1807c478bd9Sstevel@tonic-gate {
181*dc5a8425Srobbin CELL *p;
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gate for (p = tab[hash(s)]; p != NULL; p = p->nextval)
1857c478bd9Sstevel@tonic-gate if (wscmp(s, p->nval) == 0 &&
1867c478bd9Sstevel@tonic-gate (flag == 0 || flag == p->tval))
1877c478bd9Sstevel@tonic-gate return (p); /* found it */
1887c478bd9Sstevel@tonic-gate return (NULL); /* not found */
1897c478bd9Sstevel@tonic-gate }
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate
192*dc5a8425Srobbin awkfloat
setfval(CELL * vp,awkfloat f)193*dc5a8425Srobbin setfval(CELL *vp, awkfloat f)
1947c478bd9Sstevel@tonic-gate {
1957c478bd9Sstevel@tonic-gate dprintf("setfval: %o %g\n", vp, f, NULL);
1967c478bd9Sstevel@tonic-gate /* imb */
1977c478bd9Sstevel@tonic-gate if (vp->tval & ARR)
1987c478bd9Sstevel@tonic-gate error(FATAL, "illegal reference to array %s", vp->nval);
1997c478bd9Sstevel@tonic-gate if ((vp->tval & (NUM | STR)) == 0)
2007c478bd9Sstevel@tonic-gate error(FATAL, "funny variable %o: %ws %ws %g %o", vp, vp->nval,
2017c478bd9Sstevel@tonic-gate vp->sval, vp->fval, vp->tval);
2027c478bd9Sstevel@tonic-gate /* imb */
2037c478bd9Sstevel@tonic-gate if (vp == recloc)
2047c478bd9Sstevel@tonic-gate error(FATAL, "can't set $0");
2057c478bd9Sstevel@tonic-gate vp->tval &= ~STR; /* mark string invalid */
2067c478bd9Sstevel@tonic-gate vp->tval |= NUM; /* mark number ok */
2077c478bd9Sstevel@tonic-gate if ((vp->tval & FLD) && vp->nval == 0) {
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate * FLD really means that the string value was not
2107c478bd9Sstevel@tonic-gate * "malloc"ed and should not be freed. All fields
2117c478bd9Sstevel@tonic-gate * have this property, but not all cells with this
2127c478bd9Sstevel@tonic-gate * property are fields. However, all cells with
2137c478bd9Sstevel@tonic-gate * this property and with a NULL "nval" are fields.
2147c478bd9Sstevel@tonic-gate * If we are setting the value of a field, indicate
2157c478bd9Sstevel@tonic-gate * that the value of the record has to be recomputed,
2167c478bd9Sstevel@tonic-gate * and if it's a higher field than the last one we
2177c478bd9Sstevel@tonic-gate * assigned to, remember it for when we clear the
2187c478bd9Sstevel@tonic-gate * fields out for the next record.
2197c478bd9Sstevel@tonic-gate */
2207c478bd9Sstevel@tonic-gate donerec = 0;
2217c478bd9Sstevel@tonic-gate if (vp > maxmfld)
2227c478bd9Sstevel@tonic-gate maxmfld = vp;
2237c478bd9Sstevel@tonic-gate }
2247c478bd9Sstevel@tonic-gate return (vp->fval = f);
2257c478bd9Sstevel@tonic-gate }
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate
228*dc5a8425Srobbin wchar_t *
setsval(CELL * vp,wchar_t * s)229*dc5a8425Srobbin setsval(CELL *vp, wchar_t *s)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate dprintf("setsval: %o %ws\n", vp, s, NULL);
2327c478bd9Sstevel@tonic-gate if (vp->tval & ARR)
2337c478bd9Sstevel@tonic-gate error(FATAL, "illegal reference to array %ws", vp->nval);
2347c478bd9Sstevel@tonic-gate if ((vp->tval & (NUM | STR)) == 0)
2357c478bd9Sstevel@tonic-gate error(FATAL, "funny variable %o: %ws %ws %g %o", vp, vp->nval,
2367c478bd9Sstevel@tonic-gate vp->sval, vp->fval, vp->tval);
2377c478bd9Sstevel@tonic-gate if (vp == recloc)
2387c478bd9Sstevel@tonic-gate error(FATAL, "can't set $0");
2397c478bd9Sstevel@tonic-gate vp->tval &= ~NUM;
2407c478bd9Sstevel@tonic-gate vp->tval |= STR;
2417c478bd9Sstevel@tonic-gate if ((vp->tval & FLD) && vp->nval == 0) {
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate * See comment in "setfval".
2447c478bd9Sstevel@tonic-gate */
2457c478bd9Sstevel@tonic-gate donerec = 0;
2467c478bd9Sstevel@tonic-gate if (vp > maxmfld)
2477c478bd9Sstevel@tonic-gate maxmfld = vp;
2487c478bd9Sstevel@tonic-gate }
2497c478bd9Sstevel@tonic-gate if (!(vp->tval&FLD))
2507c478bd9Sstevel@tonic-gate xfree(vp->sval);
2517c478bd9Sstevel@tonic-gate vp->tval &= ~FLD;
2527c478bd9Sstevel@tonic-gate return (vp->sval = tostring(s));
2537c478bd9Sstevel@tonic-gate }
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate
256*dc5a8425Srobbin awkfloat
getfval(CELL * vp)257*dc5a8425Srobbin getfval(CELL *vp)
2587c478bd9Sstevel@tonic-gate {
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gate if (vp->sval == record && donerec == 0)
2627c478bd9Sstevel@tonic-gate recbld();
2637c478bd9Sstevel@tonic-gate dprintf("getfval: %o", vp, NULL, NULL);
2647c478bd9Sstevel@tonic-gate if (vp->tval & ARR)
2657c478bd9Sstevel@tonic-gate error(FATAL, "illegal reference to array %ws", vp->nval);
2667c478bd9Sstevel@tonic-gate if ((vp->tval & (NUM | STR)) == 0)
2677c478bd9Sstevel@tonic-gate error(FATAL, "funny variable %o: %ws %ws %g %o", vp, vp->nval,
2687c478bd9Sstevel@tonic-gate vp->sval, vp->fval, vp->tval);
2697c478bd9Sstevel@tonic-gate if ((vp->tval & NUM) == 0) {
2707c478bd9Sstevel@tonic-gate /* the problem is to make non-numeric things */
2717c478bd9Sstevel@tonic-gate /* have unlikely numeric variables, so that */
2727c478bd9Sstevel@tonic-gate /* $1 == $2 comparisons sort of make sense when */
2737c478bd9Sstevel@tonic-gate /* one or the other is numeric */
2747c478bd9Sstevel@tonic-gate if (isanumber(vp->sval)) {
2757c478bd9Sstevel@tonic-gate vp->fval = watof(vp->sval);
2767c478bd9Sstevel@tonic-gate if (!(vp->tval & CON))
2777c478bd9Sstevel@tonic-gate /* don't change type of a constant */
2787c478bd9Sstevel@tonic-gate vp->tval |= NUM;
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate else
2817c478bd9Sstevel@tonic-gate vp->fval = 0.0; /* not a very good idea */
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate dprintf(" %g\n", vp->fval, NULL, NULL);
2847c478bd9Sstevel@tonic-gate return (vp->fval);
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate
288*dc5a8425Srobbin wchar_t *
getsval(CELL * vp)289*dc5a8425Srobbin getsval(CELL *vp)
2907c478bd9Sstevel@tonic-gate {
2917c478bd9Sstevel@tonic-gate char s[100];
2927c478bd9Sstevel@tonic-gate wchar_t ws[100];
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate if (vp->sval == record && donerec == 0)
2967c478bd9Sstevel@tonic-gate recbld();
2977c478bd9Sstevel@tonic-gate dprintf("getsval: %o", vp, NULL, NULL);
2987c478bd9Sstevel@tonic-gate if (vp->tval & ARR)
2997c478bd9Sstevel@tonic-gate error(FATAL, "illegal reference to array %ws", vp->nval);
3007c478bd9Sstevel@tonic-gate if ((vp->tval & (NUM | STR)) == 0)
3017c478bd9Sstevel@tonic-gate error(FATAL, "funny variable %o: %ws %ws %g %o", vp, vp->nval,
3027c478bd9Sstevel@tonic-gate vp->sval, vp->fval, vp->tval);
3037c478bd9Sstevel@tonic-gate if ((vp->tval & STR) == 0) {
3047c478bd9Sstevel@tonic-gate if (!(vp->tval&FLD))
3057c478bd9Sstevel@tonic-gate xfree(vp->sval);
3067c478bd9Sstevel@tonic-gate if ((long long)vp->fval == vp->fval)
3077c478bd9Sstevel@tonic-gate sprintf(s, "%.20g", vp->fval);
3087c478bd9Sstevel@tonic-gate else
3097c478bd9Sstevel@tonic-gate sprintf(s, toeuccode(*OFMT), vp->fval);
3107c478bd9Sstevel@tonic-gate mbstowcs(ws, s, sizeof (ws) / sizeof (wchar_t));
3117c478bd9Sstevel@tonic-gate vp->sval = tostring(ws);
3127c478bd9Sstevel@tonic-gate vp->tval &= ~FLD;
3137c478bd9Sstevel@tonic-gate vp->tval |= STR;
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate dprintf(" %ws\n", vp->sval, NULL, NULL);
3167c478bd9Sstevel@tonic-gate return (vp->sval);
3177c478bd9Sstevel@tonic-gate }
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gate
320*dc5a8425Srobbin wchar_t *
tostring(wchar_t * s)321*dc5a8425Srobbin tostring(wchar_t *s)
3227c478bd9Sstevel@tonic-gate {
323*dc5a8425Srobbin wchar_t *p;
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate
3267c478bd9Sstevel@tonic-gate p = (wchar_t *) malloc((wslen(s)+1)*sizeof (wchar_t));
3277c478bd9Sstevel@tonic-gate if (p == NULL)
3287c478bd9Sstevel@tonic-gate error(FATAL, "out of space in tostring on %ws", s);
3297c478bd9Sstevel@tonic-gate wscpy(p, s);
3307c478bd9Sstevel@tonic-gate return (p);
3317c478bd9Sstevel@tonic-gate }
3327c478bd9Sstevel@tonic-gate
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate #ifndef yfree
yfree(char * a)335*dc5a8425Srobbin yfree(char *a)
3367c478bd9Sstevel@tonic-gate {
3377c478bd9Sstevel@tonic-gate printf("%o\n", a);
3387c478bd9Sstevel@tonic-gate free(a);
3397c478bd9Sstevel@tonic-gate }
3407c478bd9Sstevel@tonic-gate #endif
341