📄 washprog.c
字号:
/* washprog.c Copyright (C) 2002 Georg Post * * This file is part of Numparam, see: readme.txt * Free software under the terms of the GNU Lesser General Public License *//**** washprog: trivial text substitution utility. ****//* history: this was an exercise to make an 'intersection' language of C and Java, that would look like Basic. A complete failure, of course. Now only used to clean my Basic/Pascal-contaminated C code. With the rules file below, it destroys all those macros of mine for quiche eaters, which seem offensive to C aficionados. Standard rules file needed : downgrad.txt Typical command line: ./washprog -r downgrad washprog.c There is no printf. Console Output/Input primitives are as follows: wc ws wr wn wi wln rln The bare-bones string(=Pchar) manipulation library is this: pscopy streq str length upcase scopy sadd saddn cadd posFormat of substitution rules: s <string> <string> substitute. use "" around string if spaces inside. w <string> <string> first string must be a whole word only m <macro1> <macro2> macro substitution with args 1 2 3 ... u <macro1> <macro2> macro with atomic args, no punctuation "(;,:)" inside. x <strng1> <strng2> exclude text section from strng1 to strng2. a <mac1> <mac2> dynamically add a new macro rule, if table space left. string: may contain special chars: ^A ... ^Z \n \" macro1: string with "placeholders" 1 2 ... 9, in this order macro2: may contain the "arguments" anywhere non-arg digits in macro2 are prefixed 0 Heavy use of 3 string operations: - pscopy() substring extraction. - comparison: match(). - spos() substring search added : special postprocessing for C to place the ; and } :1. any ';' following a ';' or '}' is wiped out.2. any ';' preceding a '}' is wiped out.3. any remaining ';' on start of line is shifted to end of preceding one.*/#include <stdio.h> /* NULL FILE fopen feof fgets fclose fputs fputc gets */#include "general.h"Cconst(nsub, 100+1) /*max nbr of substitution rules */Cconst(nargs, 11) /*max number of macro args + 1*/Cconst(wild,'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -