📄 word.c
字号:
#ifndef lintstatic CHTYPE *sccsid = "@(#)word.c 4.1 7/17/90";#endif lint/************************************************************************ * * * Copyright (c) 1986 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//* * * Modification History: * * 002 - Gary A. Gaudet, Wed Nov 9 10:24:49 EST 1988 * MIPS portability and bug fixes * * 001 - Gary Gaudet for Andy Gadsby 09-mar-88 * i18n version of csh * * * *//* * UNIX shell * * Bell Telephone Laboratories * */#include "defs.h"#include "sym.h"/* ======== character handling for command lines ========*/word(){ register CHTYPE c, d; struct argnod *arg = (struct argnod *)locstak(); register CHTYPE *argp = arg->argval; int alpha = 1; wdnum = 0; wdset = 0; while (1) { while (c = nextc(0), space(c)) /* skipc() */ ; if (c == COMCHAR) { while ((c = readc()) != NL && c != EOF); peekc = c; } else { break; /* out of comment - white space loop */ } } if (!eofmeta(c)) { do { if (c == LITERAL) { *argp++ = (DQUOTE); while ((c = readc()) && c != LITERAL) { *argp++ = (c | QUOTE); if (c == NL) chkpr(); } *argp++ = (DQUOTE); } else { *argp++ = (c); if (c == '=') wdset |= alpha; if (!alphanum(c)) alpha = 0; if (qotchar(c)) { d = c; while ((*argp++ = (c = nextc(d))) && c != d) { if (c == NL) chkpr(); } } } } while ((c = nextc(0), !eofmeta(c))); argp = endstak(argp); if (!letter(arg->argval[0])) wdset = 0; peekn = c | MARK; if (arg->argval[1] == 0 && (d = arg->argval[0], digit(d)) && (c == '>' || c == '<')) { word(); wdnum = d - '0'; } else /*check for reserved words*/ { if (reserv == FALSE || (wdval = syslook(arg->argval,reserved, no_reserved)) == 0) { wdarg = arg; wdval = 0; } } } else if (dipchar(c)) { if ((d = nextc(0)) == c) { wdval = c | SYMREP; if (c == '<') { if ((d = nextc(0)) == '-') wdnum |= IOSTRIP; else peekn = d | MARK; } } else { peekn = d | MARK; wdval = c; } } else { if ((wdval = c) == EOF) wdval = EOFSYM; if (iopend && eolchar(c)) { copy(iopend); iopend = 0; } } reserv = FALSE; return(wdval);}skipc(){ register CHTYPE c; while (c = nextc(0), space(c)) ; return(c);}nextc(quote)CHTYPE quote;{ register CHTYPE c, d;retry: if ((d = readc()) == ESCAPE) { if ((c = readc()) == NL) { chkpr(); goto retry; } else if (quote && c != quote && !escchar(c)) peekc = c | MARK; else d = c | QUOTE; } return((int)d);}readc(){ register CHTYPE c; register int len; register struct fileblk *f; if (peekn) { peekc = peekn; peekn = 0; } if (peekc) { c = peekc; peekc = 0; return(c); } f = standin;retry: if (f && f->fnxt != f->fend) /* GAG - MIPS port */ { if ((c = *f->fnxt++) == 0) { if (f->feval) { if (estabf(*f->feval++)) c = EOF; else c = SP; } else goto retry; /* = c = readc(); */ } if (flags & readpr && standin->fstak == 0) prc(c); if (c == NL) f->flin++; } else if (f->feof || f->fdes < 0) { c = EOF; f->feof++; } else if ((len = readb()) <= 0) { close(f->fdes); f->fdes = -1; c = EOF; f->feof++; } else { f->fend = (f->fnxt = f->fbuf) + len; goto retry; } return(c);}staticreadb(){ register struct fileblk *f = standin; register int len; do { if (trapnote & SIGSET) { newline(); sigchk(); } else if ((trapnote & TRAPSET) && (rwait > 0)) { newline(); chktrap(); clearup(); } } while ((len = readw(f->fdes, f->fbuf, f->fsiz)) < 0 && trapnote); return(len);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -