Lines Matching refs:fp

74 #define isoption(fp,c)	((fp)->flags&(1L<<((c)-'a')))  argument
75 #define setoption(fp,c) ((fp)->flags|=(1L<<((c)-'a'))) argument
76 #define clroption(fp,c) ((fp)->flags&=~(1L<<((c)-'a'))) argument
79 outline(Fmt_t* fp) in outline() argument
81 register char* cp = fp->outbuf; in outline()
86 if (!fp->outp) in outline()
88 while (fp->outp[-1] == ' ') in outline()
89 fp->outp--; in outline()
90 *fp->outp = 0; in outline()
96 cp = &fp->outbuf[TABSZ*n]; in outline()
101 cp = fp->outbuf; in outline()
102 fp->nwords = 0; in outline()
103 if (!isoption(fp, 'o')) in outline()
104 sfputr(fp->out, cp, '\n'); in outline()
107 n = fp->indent; in outline()
115 sfputc(fp->out, ' '); in outline()
116 if (fp->quote) in outline()
118 if ((d = (fp->outp - cp)) <= 0) in outline()
120 else if ((c = fp->outp[-1]) == 'n' && d > 1 && fp->outp[-2] == '\\') in outline()
122 sfprintf(fp->out, "\"%s%s\"\n", cp, c == ']' || c == '{' || c == '}' ? "" : " "); in outline()
125 sfputr(fp->out, cp, '\n'); in outline()
126 if (fp->nextdent) in outline()
128 fp->indent += fp->nextdent; in outline()
129 fp->endbuf -= fp->nextdent; in outline()
130 fp->nextdent = 0; in outline()
133 fp->outp = 0; in outline()
137 split(Fmt_t* fp, char* buf, int splice) in split() argument
154 if ((*ep == 0 || *buf == '.') && !isoption(fp, 'o')) in split()
158 outline(fp); in split()
159 strcpy(fp->outbuf, buf); in split()
160 fp->outp = fp->outbuf+prefix; in split()
161 outline(fp); in split()
164 if (fp->prefix < prefix && !isoption(fp, 'c')) in split()
165 outline(fp); in split()
166 if (!fp->outp || prefix < fp->prefix) in split()
167 fp->prefix = prefix; in split()
173 if (cp != ep && isoption(fp, 'u')) in split()
189 if (n && isoption(fp, 'o')) in split()
199 if (fp->nwords > 0 && &fp->outp[n] >= fp->endbuf && !fp->retain && !q) in split()
200 outline(fp); in split()
202 if (fp->nwords == 0) in split()
204 if (fp->prefix) in split()
205 memset(fp->outbuf, ' ', fp->prefix); in split()
206 fp->outp = &fp->outbuf[fp->prefix]; in split()
211 memcpy(fp->outp, cp, n); in split()
212 fp->outp += n; in split()
213 fp->nwords++; in split()
215 if (isoption(fp, 's') || *buf == 0) in split()
216 outline(fp); in split()
217 else if (fp->outp) in split()
223 if (!isoption(fp, 'o') && strchr(".:!?", fp->outp[-1])) in split()
224 *fp->outp++ = ' '; in split()
225 …plice && !fp->retain && (!fp->quote || (fp->outp - fp->outbuf) < 2 || fp->outp[-2] != '\\' || fp->… in split()
226 *fp->outp++ = ' '; in split()
231 dofmt(Fmt_t* fp) in dofmt() argument
245 …(fp->in, '\n', 0)) && !(splice = 0) && (lp = cp + sfvalue(fp->in) - 1) || (cp = sfgetr(fp->in, '\n… in dofmt()
247 if (isoption(fp, 'o')) in dofmt()
249 if (!isoption(fp, 'i')) in dofmt()
251 setoption(fp, 'i'); in dofmt()
263 fp->indent = roundof(b, INDENT); in dofmt()
268 if (!isoption(fp, 'q') && cp < lp) in dofmt()
270 setoption(fp, 'q'); in dofmt()
277 fp->quote = 1; in dofmt()
296 if (isoption(fp, 'o')) in dofmt()
374 if (fp->quote) in dofmt()
376 fp->section = 0; in dofmt()
408 fp->section = 1; in dofmt()
409 fp->retain = 0; in dofmt()
413 split(fp, buf, 0); in dofmt()
414 outline(fp); in dofmt()
418 else if (fp->section) in dofmt()
423 fp->retain = 1; in dofmt()
430 fp->section = 0; in dofmt()
453 if (fp->endbuf > (fp->outbuf + fp->indent + 2*INDENT)) in dofmt()
454 fp->nextdent = 2*INDENT; in dofmt()
458 fp->section = 0; in dofmt()
462 if (fp->indent && (b || *(cp - 2) != 'f')) in dofmt()
466 fp->indent -= 2*INDENT; in dofmt()
467 fp->endbuf += 2*INDENT; in dofmt()
477 fp->section = 0; in dofmt()
482 fp->section = 0; in dofmt()
486 if (fp->retain) in dofmt()
494 split(fp, buf, 0); in dofmt()
497 fp->retain = 0; in dofmt()
498 if (fp->outp >= fp->endbuf) in dofmt()
499 outline(fp); in dofmt()
524 c = isoption(fp, 'o') ? 1 : TABSZ - (dp - buf) % TABSZ; in dofmt()
559 split(fp, buf, splice); in dofmt()