File: count.c

package info (click to toggle)
scrollz 1.8m-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,616 kB
  • ctags: 4,000
  • sloc: ansic: 69,789; tcl: 2,866; sh: 503; makefile: 462
file content (25 lines) | stat: -rw-r--r-- 574 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Replacement for ircII's flex crap by Flier
 */

#include <stdio.h>
#include <string.h>

int main() {
    int  count=0;
    char buffer[128]; /* should be more than enough */
    char *tmpstr;
    FILE *fp;

    while ((fgets(buffer,128,stdin))) {
        /* valid lines start with #define */
        if (!strncmp(buffer,"#define",7) && (tmpstr=strstr(buffer,"$\n")) &&
            *(tmpstr+2)=='\0') {
            *tmpstr='\0';
            fprintf(stdout,"%s%d\n",buffer,count);
            count++;
        }
	else fprintf(stdout,"%s",buffer);
    }
    return(0);
}