Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.107
 
1.108
 
MAIN:ragge:20101125211249
 
cpp.c
_>7171 #ifdef HAVE_SYS_WAIT_H
 7272 #include <sys/wait.h>
 7373 #endif
<> 74+#include <sys/stat.h>
7475 
 7576 #include <fcntl.h>
 7677 #ifdef HAVE_UNISTD_H
     
 !
123124 struct incs {
 124125         struct incs *next;
 125126         usch *dir;
<> 127+        dev_t dev;
  128+        ino_t ino;
126129 } *incdir[2];
 127130 #define INCINC 0
 128131 #define SYSINC 1
     
 !
177180 void usage(void);
 178181 usch *xstrdup(const char *str);
 179182 const usch *prtprag(const usch *opb);
<> 183+static void addidir(char *idir, struct incs **ww);
180184 
<>181 -
182185 int
 183186 main(int argc, char **argv)
 184187 {
 185188         struct initar *it;
<>186 -        struct incs *w, *w2;
187189         struct symtab *nl;
 188190         register int ch;
 189191         const usch *fn1, *fn2;
     
 !
222224 
 223225                 case 'S':
 224226                 case 'I':
<>225 -                        if ((w = calloc(sizeof(struct incs), 1)) == NULL)
 226 -                                error("couldn't apply -%c %s", ch, optarg);
 227 -                        w->dir = (usch *)optarg;
 228 -                        w2 = incdir[ch == 'I' ? INCINC : SYSINC];
 229 -                        if (w2 != NULL) {
 230 -                                while (w2->next)
 231 -                                        w2 = w2->next;
 232 -                                w2->next = w;
 233 -                        } else
 234 -                                incdir[ch == 'I' ? INCINC : SYSINC] = w;
  227+                        addidir(optarg, &incdir[ch == 'I' ? INCINC : SYSINC]);
235228                         break;
 236229 
 237230 #ifdef CPP_DEBUG
     
 !
343336         return 0;
 344337 }
 345338 
<> 339+static void
  340+addidir(char *idir, struct incs **ww)
  341+{
  342+        struct incs *w;
  343+        struct stat st;
  344+
  345+        if (stat(idir, &st) == -1 || S_ISDIR(st.st_mode) == 0)
  346+                return; /* ignore */
  347+        if (*ww != NULL) {
  348+                for (w = *ww; w->next; w = w->next) {
  349+                        if (w->dev == st.st_dev && w->ino == st.st_ino)
  350+                                return;
  351+                }
  352+                if (w->dev == st.st_dev && w->ino == st.st_ino)
  353+                        return;
  354+                ww = &w->next;
  355+        }
  356+        if ((w = calloc(sizeof(struct incs), 1)) == NULL)
  357+                error("couldn't add path %s", idir);
  358+        w->dir = (usch *)idir;
  359+        w->dev = st.st_dev;
  360+        w->ino = st.st_ino;
  361+        *ww = w;
  362+}
  363+
<_346364 /*
 347365  * Expand the symbol nl read from input.
 348366  * Return a pointer to the fully expanded result.
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-22 23:06 +0100