Annotation of pgp/contrib/langtool/pickpstr.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *   pickpstr.c
                      3:  *     Read a set of files.
                      4:  *     Find all strings of the form PSTR("...").
                      5:  *     Output them, minus the enclosing PSTR( and ) to stdout.
                      6:  */
                      7: 
                      8: #include <stdio.h>
                      9: #define        STR     "LANG(\""
                     10: 
                     11: main (ac, av)
                     12: char   **av;
                     13: {
                     14:        int     copying, match, bslash;
                     15:        FILE    *f;
                     16:        int     c;
                     17: 
                     18:        if (ac < 2) {
                     19:                fprintf (stderr, "Usage: %s file [...]\n", av[0]);
                     20:                exit (1);
                     21:        }
                     22: 
                     23:        while (*++av) {
                     24:                if ((f = fopen (*av, "r")) == NULL) {
                     25:                        fprintf (stderr, "Unable to open file %s, skipping\n");
                     26:                        continue;
                     27:                }
                     28:                match = 0;
                     29:                copying = 0;
                     30:                while ((c = getc(f)) != EOF) {
                     31:                        if (!copying) {
                     32:                                if (c == STR[match]) {
                     33:                                        if (++match == strlen(STR)) {
                     34:                                                copying = 1;
                     35:                                                match = 0;
                     36:                                                bslash = 0;
                     37:                                                putchar (c);
                     38:                                        }
                     39:                                } else
                     40:                                        match = 0;
                     41:                        } else {
                     42:                                if (!bslash) {
                     43:                                        if (c == '"') {
                     44:                                                putchar (c);
                     45:                                                putchar ('\n');
                     46:                                                putchar ('\n');
                     47:                                                copying = 0;
                     48:                                        } else if (c == '\\') {
                     49:                                                bslash = 1;
                     50:                                                putchar (c);
                     51:                                        } else
                     52:                                                putchar (c);
                     53:                                } else {
                     54:                                        putchar (c);
                     55:                                        bslash = 0;
                     56:                                }
                     57:                        }
                     58:                }
                     59:                fclose (f);
                     60:        }
                     61:        exit (0);
                     62: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.