Annotation of 41BSD/cmd/cifplot/readpat.c, revision 1.1.1.1

1.1       root        1: /*******************************************************************
                      2: *                                                                  *
                      3: *    File: CIFPLOT/readpat.c                                       *
                      4: *    Written by Dan Fitzpatrick                                    *
                      5: *    copyright 1980 -- Regents of the University of California     *
                      6: *                                                                  *
                      7: ********************************************************************/
                      8: 
                      9: #include <stdio.h>
                     10: #include "defs.h"
                     11: 
                     12: #define STRING 2
                     13: #define INTEGER 1
                     14: 
                     15: extern int lncnt;
                     16: 
                     17: FILE *patfile;
                     18: int patval;
                     19: char *patstr;
                     20: 
                     21: readpat(s)
                     22: char *s;
                     23: {
                     24:     int *pat;
                     25:     int i,j;
                     26: 
                     27:     if((patfile = fopen(s,"r")) == NULL) {
                     28:        perror(s);
                     29:        Error("Can't open pattern file",RUNTIME);
                     30:        }
                     31:     /* Read name followed by NO_PAT_LINE (8) integers */
                     32:     i = yylex();
                     33:     while(i == STRING) {
                     34:        /* Allocate space for NO_PAT_LINE (8) integers */
                     35:        pat = (int *) alloc(NO_PAT_LINE * sizeof(int));
                     36:        for(j=0; j<NO_PAT_LINE; j++) {
                     37:            if(yylex() != INTEGER) {
                     38:                sprintf(s,"Expected integer in pattern file. (line %d)",lncnt);
                     39:                Error(s,RUNTIME);
                     40:                }
                     41:            pat[j] = patval;
                     42:            }
                     43:        /* Enter the names and integers into layer table */
                     44:        CreatLayer(patstr,pat);
                     45:        i = yylex();
                     46:        }
                     47:     if(i != 0) {
                     48:        sprintf(s,"Expected name in pattern file. (line %d)",lncnt);
                     49:        Error(s,RUNTIME);
                     50:        }
                     51:     fclose(patfile);
                     52:     }
                     53: 
                     54: unquote(s)
                     55: char *s;
                     56: /* remove quotes from around the string s */
                     57: {
                     58:     char *p;
                     59: 
                     60:     if(*s == '\"') s++;
                     61:     for(p=s;*p && *p != '\"';p++);
                     62:     *p = '\0';
                     63:     return(Concat(s,0));
                     64:     }

unix.superglobalmegacorp.com

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