• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

oga's tools


Commit MetaInfo

修訂1a9aa91c35b8f69631392402d6cc73efc1c75f5e (tree)
時間2013-12-29 22:00:39
作者oga <oga@mxg....>
Commiteroga

Log Message

add comdel.c

Change Summary

差異

--- a/Makefile.linux
+++ b/Makefile.linux
@@ -19,7 +19,7 @@ TARGETS=$(VP)/age $(VP)/cal2 $(VP)/cgrep $(VP)/cmem $(VP)/cpkt $(VP)/cpuid \
1919 $(VP)/sosu $(VP)/sosum $(VP)/stat $(VP)/stereo3d $(VP)/strftime \
2020 $(VP)/subdecode $(VP)/sysinfd $(VP)/tbl2csv $(VP)/tcpan $(VP)/tcpdmpan \
2121 $(VP)/test64 $(VP)/train $(VP)/u2dos $(VP)/ifchk $(VP)/ifchk2 $(VP)/rand \
22- $(VP)/base64 $(VP)/ht $(VP)/filer
22+ $(VP)/base64 $(VP)/ht $(VP)/filer $(VP)/comdel
2323
2424 all: $(TARGETS)
2525
@@ -44,6 +44,9 @@ $(VP)/cgrep : $(TOOL)/cgrep.c
4444 $(VP)/cmem : $(TOOL)/cmem.c
4545 ${CC} $? -o $@ -O
4646
47+$(VP)/comdel : $(TOOL)/comdel.c
48+ ${CC} $? -o $@ -O
49+
4750 $(VP)/cpkt : $(TOOL)/cpkt.c
4851 ${CC} $? -o $@ -O
4952
--- /dev/null
+++ b/comdel.c
@@ -0,0 +1,65 @@
1+/********************************************************************
2+ * comment delete filter by Hyper halx.oga *
3+ * 199X.XX.XX first version *
4+ * 1994.09.20 add stdin/filename *
5+ * 1995.05.11 add error line *
6+ * *
7+ * usage : cat filename | comdel *
8+ * comdel [filename] *
9+ ********************************************************************/
10+#include <stdio.h>
11+#include <stdlib.h>
12+#include <string.h>
13+
14+#define LINEUP(z) if (z == '\n') ++line
15+
16+main(a,b)
17+int a;
18+char *b[];
19+{
20+ FILE *fpin;
21+
22+ char xx[3]; /* char xx[2]; */
23+ int c;
24+ int i, j, line=1, saveline;
25+
26+ if (a == 1)
27+ fpin = stdin;
28+ else {
29+ if ((fpin = fopen(b[1],"r")) == NULL) {
30+ perror("comdel");
31+ exit(1);
32+ }
33+
34+ }
35+ xx[2] = '\0'; /**/
36+ xx[0] = getc(fpin);
37+ LINEUP(xx[0]);
38+ xx[1] = getc(fpin);
39+ LINEUP(xx[1]);
40+ while (xx[1] != EOF) {
41+ if (strcmp(xx,"/*") == 0 ) {
42+ saveline = line;
43+ putchar(xx[0]);
44+ putchar(xx[1]);
45+ while(strcmp(xx,"*/") != 0) {
46+ xx[0] = xx[1];
47+ if ((xx[1] = getc(fpin)) == EOF ) {
48+ putchar('\n');
49+ if (a == 1)
50+ fprintf(stderr, "*** Error : comment not closed. (line=%d) *** \n",saveline);
51+ else
52+ fprintf(stderr, "*** Error : comment not closed. (line=%d) *** (%s)\n",saveline,b[1]);
53+ exit(1);
54+ }
55+ LINEUP(xx[1]);
56+ }
57+ }
58+ putchar(xx[0]);
59+ xx[0] = xx[1];
60+ xx[1] = getc(fpin);
61+ LINEUP(xx[1]);
62+ }
63+ putchar(xx[0]);
64+ exit(0);
65+}