Bugzilla – Attachment 213165 Details for
Bug 387148
Can't refresh the factory repo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
pattern lint tool.
pattern_lint.c (text/plain), 2.01 KB, created by
Michael Meeks
on 2008-05-07 13:41:56 UTC
(
hide
)
Description:
pattern lint tool.
Filename:
MIME Type:
Creator:
Michael Meeks
Created:
2008-05-07 13:41:56 UTC
Size:
2.01 KB
patch
obsolete
>/* > * Simple tool to find silly errors in pattern files. > */ > >#include <stdio.h> >#include <string.h> >#include <stdlib.h> > >static int >do_lint (const char *pat_fname) >{ > FILE *f; > char blb[4096]; > int counts[256] = {0, }; > int line_no = 0; > char *tags[256]; > int tag_num = 0; > > f = fopen (pat_fname, "r"); > if (!f) { > fprintf (stderr, "error opening %s\n", pat_fname); > return 1; > } > > while (fgets (blb, sizeof (blb), f) != NULL) { > unsigned char key; > int i; > > line_no++; > if (blb[0] != '+' && blb[0] != '-') > continue; > > for (i = 1; (blb[i] != '\0' && blb[i] != '\n' && > blb[i] != '\r' && blb[i] != ':'); i++) > ; > blb[i] = '\0'; > > if (tag_num >= ((sizeof (tags)/sizeof(char *)) - 2)) { > fprintf (stderr, "Too many nested tags at %s:%d\n", pat_fname, line_no); > return 1; > } > if (blb[0] == '+') /* push */ > tags[tag_num++] = strdup (blb + 1); > > else { /* pop */ > tag_num--; > if (tag_num < 0) { > fprintf (stderr, "more tags popped than pushed at %s:%d\n", pat_fname, line_no); > return 1; > } > if (strcmp (blb + 1, tags[tag_num])) { > fprintf (stderr, "mis-matched tags at %s:%d - '%s' expecting '%s'\n", > pat_fname, line_no, blb + 1, tags[tag_num]); > return 1; > } > free (tags[tag_num]); > } > } > if (tag_num > 0) { > fprintf (stderr, "un-closed tags left at end of '%s' - at least %s\n", > pat_fname, tags[0]); > return 1; > } > > fprintf (stderr, "file %s clean\n", pat_fname); > fclose (f); > return 0; >} > >int main (int argc, char **argv) >{ > int i; > if (argc < 1) { > fprintf (stderr, "pattern_lint: <pattern file>...\n"); > return 1; > } > for (i = 1 ; i < argc; i++) { > if (do_lint (argv[i])) > return 1; > } > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 387148
: 213165