From 96eb2dc401f785e2b35a2089dda24416ff9bb305 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Mon, 26 Sep 2005 12:49:52 +0000 Subject: Relevant BUGIDs: none Purpose of commit: bugfix Commit summary: --------------- Fix spec generation and creating tar archive with automake: * configure.in: Add doc/specs/Makefile. * Makefile.am: Add releasedocs rule. * doc/Makefile.am: Add specs subdir, remove files from specs directory, add rfc86.0.txt to releasedocs. * doc/specs/Makefile.am: New file. * doc/specs/formatter/parse.y: move from here ... * doc/specs/parse.y: ... here. * doc/specs/formatter/parse.lex: move from here ... * doc/specs/parse.lex: ... here. --- ChangeLog | 12 ++ Makefile.am | 3 + configure.in | 3 +- doc/Makefile.am | 21 ++- doc/specs/.cvsignore | 2 + doc/specs/Makefile.am | 23 ++++ doc/specs/formatter/Makefile | 16 --- doc/specs/formatter/parse.lex | 11 -- doc/specs/formatter/parse.y | 293 ----------------------------------------- doc/specs/parse.lex | 11 ++ doc/specs/parse.y | 294 ++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 357 insertions(+), 332 deletions(-) create mode 100644 doc/specs/Makefile.am delete mode 100644 doc/specs/formatter/Makefile delete mode 100644 doc/specs/formatter/parse.lex delete mode 100644 doc/specs/formatter/parse.y create mode 100644 doc/specs/parse.lex create mode 100644 doc/specs/parse.y diff --git a/ChangeLog b/ChangeLog index 2e74e940..f73fc84f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-09-26 Thorsten Kukuk + + * configure.in: Add doc/specs/Makefile. + * Makefile.am: Add releasedocs rule. + * doc/Makefile.am: Add specs subdir, remove files from specs + directory, add rfc86.0.txt to releasedocs. + * doc/specs/Makefile.am: New file. + * doc/specs/formatter/parse.y: move from here ... + * doc/specs/parse.y: ... here. + * doc/specs/formatter/parse.lex: move from here ... + * doc/specs/parse.lex: ... here. + 2005-09-23 Tomas Mraz * modules/pam_access/pam_access.c (from_match): Support NULL from. diff --git a/Makefile.am b/Makefile.am index 361ca041..b62e26a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,3 +14,6 @@ EXTRA_DIST = config.rpath mkinstalldirs pgp.keys.asc CHANGELOG \ Copyright $(M4_FILES) ACLOCAL_AMFLAGS = -I m4 + +releasedocs: + make -C doc releasedocs diff --git a/configure.in b/configure.in index 1c8d7dd0..2a13a83b 100644 --- a/configure.in +++ b/configure.in @@ -396,4 +396,5 @@ AC_OUTPUT(Makefile libpam/Makefile libpamc/Makefile libpamc/test/Makefile \ modules/pam_time/Makefile modules/pam_umask/Makefile \ modules/pam_unix/Makefile modules/pam_userdb/Makefile \ modules/pam_warn/Makefile modules/pam_wheel/Makefile \ - modules/pam_xauth/Makefile doc/Makefile examples/Makefile) + modules/pam_xauth/Makefile doc/Makefile doc/specs/Makefile \ + examples/Makefile) diff --git a/doc/Makefile.am b/doc/Makefile.am index 81b24b4c..a2967461 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,6 +2,8 @@ # Copyright (c) 2005 Thorsten Kukuk # +SUBDIRS = specs + FILES=pam pam_appl pam_modules FSRCS=$(srcdir)/pam_appl.sgml $(srcdir)/pam_modules.sgml @@ -13,8 +15,7 @@ PDFFILES=pdf/pam.pdf pdf/pam_appl.pdf pdf/pam_modules.pdf MODULES=$(shell ls $(srcdir)/modules/*.sgml) CLEANFILES = *~ */*~ $(TEXTS) $(PSFILES) $(PDFFILES) html/pam*.html \ - ps/missfont.log MODULES-SGML pam.sgml \ - specs/draft-morgan-pam-current.txt + ps/missfont.log MODULES-SGML pam.sgml EXTRA_DIST = $(FSRCS) CREDITS NOTES figs/pam_orient.txt pdf/README \ ps/README html/index.html txts/README man/template-man $(MANS) \ @@ -139,14 +140,12 @@ if HAVE_SGML2HTML done endif -spec: specs/draft-morgan-pam.raw - cd specs/formatter && $(MAKE) - specs/formatter/padout < specs/draft-morgan-pam.raw > specs/draft-morgan-pam-current.txt - -releasedocs: all spec - tar zvfc Linux-PAM-$(VERSION)-docs.tar.gz \ +releasedocs: all + tar zvfc ../Linux-PAM-$(VERSION)-docs.tar.gz \ --exclude CVS --exclude .cvsignore --exclude '.#*' \ - html ps txts pdf specs/draft-morgan-pam-current.txt - tar jvfc Linux-PAM-$(VERSION)-docs.tar.bz2 \ + --exclude README html ps txts pdf \ + specs/draft-morgan-pam-current.txt specs/rfc86.0.txt + tar jvfc ../Linux-PAM-$(VERSION)-docs.tar.bz2 \ --exclude CVS --exclude .cvsignore --exclude '.#*' \ - html ps txts pdf specs/draft-morgan-pam-current.txt + --exclude README html ps txts pdf \ + specs/draft-morgan-pam-current.txt specs/rfc86.0.txt diff --git a/doc/specs/.cvsignore b/doc/specs/.cvsignore index bac7934f..33cd58dc 100644 --- a/doc/specs/.cvsignore +++ b/doc/specs/.cvsignore @@ -1,3 +1,5 @@ draft-morgan-pam-*.txt Makefile Makefile.in +parse.c +lex.yy.c diff --git a/doc/specs/Makefile.am b/doc/specs/Makefile.am new file mode 100644 index 00000000..749f0ba7 --- /dev/null +++ b/doc/specs/Makefile.am @@ -0,0 +1,23 @@ +# +# Copyright (c) 2005 Thorsten Kukuk +# + +CLEANFILES = draft-morgan-pam-current.txt *~ + +EXTRA_DIST = draft-morgan-pam.raw std-agent-id.raw rfc86.0.txt lex.yy.c + +all: padout spec + +spec: draft-morgan-pam.raw + ./padout < draft-morgan-pam.raw > draft-morgan-pam-current.txt + +noinst_PROGRAMS = padout + +padout_SOURCES = parse.y parse.lex + +padout_LDADD = @LEXLIB@ + +parse.c: lex.yy.c + +lex.yy.c: parse.lex + $(LEX) parse.lex diff --git a/doc/specs/formatter/Makefile b/doc/specs/formatter/Makefile deleted file mode 100644 index d73258d7..00000000 --- a/doc/specs/formatter/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -LIBS=-lfl - -padout: parse.tab.o - $(CC) -o padout parse.tab.o $(LIBS) - -parse.tab.o: parse.tab.c lex.yy.c - $(CC) -c parse.tab.c - -parse.tab.c: parse.y - bison parse.y - -lex.yy.c: parse.lex - flex parse.lex - -clean: - rm -f parse.tab.o parse.tab.c lex.yy.c padout *~ core diff --git a/doc/specs/formatter/parse.lex b/doc/specs/formatter/parse.lex deleted file mode 100644 index 1d5c898e..00000000 --- a/doc/specs/formatter/parse.lex +++ /dev/null @@ -1,11 +0,0 @@ -%% - -\#[\$]+[a-zA-Z]*(\=[0-9]+)? return NEW_COUNTER; -\#\{[a-zA-Z][a-zA-Z0-9\_]*\} return LABEL; -\# return NO_INDENT; -\#\# return RIGHT; -\\\# return HASH; -[^\n] return CHAR; -[\n] return NEWLINE; - -%% diff --git a/doc/specs/formatter/parse.y b/doc/specs/formatter/parse.y deleted file mode 100644 index 6da47d17..00000000 --- a/doc/specs/formatter/parse.y +++ /dev/null @@ -1,293 +0,0 @@ - -%{ -#include -#include -#include - -#define MAXLINE 1000 -#define INDENT_STRING " " -#define PAPER_WIDTH 74 - - int indent=0; - int line=1; - char *last_label=NULL; - - extern void yyerror(const char *x); - extern char *get_label(const char *label); - extern void set_label(const char *label, const char *target); - char *new_counter(const char *key); - -#include "lex.yy.c" - -%} - -%union { - int def; - char *string; -} - -%token NEW_COUNTER LABEL HASH CHAR NEWLINE NO_INDENT RIGHT -%type stuff text - -%start doc - -%% - -doc: -| doc NEWLINE { - printf("\n"); - ++line; -} -| doc stuff NEWLINE { - if (strlen($2) > (PAPER_WIDTH-(indent ? strlen(INDENT_STRING):0))) { - yyerror("line too long"); - } - printf("%s%s\n", indent ? INDENT_STRING:"", $2); - free($2); - indent = 1; - ++line; -} -| doc stuff RIGHT stuff NEWLINE { - char fixed[PAPER_WIDTH+1]; - int len; - - len = PAPER_WIDTH-(strlen($2)+strlen($4)); - - if (len >= 0) { - memset(fixed, ' ', len); - fixed[len] = '\0'; - } else { - yyerror("line too wide"); - fixed[0] = '\0'; - } - printf("%s%s%s\n", $2, fixed, $4); - free($2); - free($4); - indent = 1; - ++line; -} -| doc stuff RIGHT stuff RIGHT stuff NEWLINE { - char fixed[PAPER_WIDTH+1]; - int len, l; - - len = PAPER_WIDTH-(strlen($2)+strlen($4)); - - if (len < 0) { - len = 0; - yyerror("line too wide"); - } - - l = len/2; - memset(fixed, ' ', l); - fixed[l] = '\0'; - printf("%s%s%s", $2, fixed, $4); - free($2); - free($4); - - l = (len+1)/2; - memset(fixed, ' ', l); - fixed[l] = '\0'; - printf("%s%s\n", fixed, $6); - free($6); - - indent = 1; - ++line; -} -| doc stuff RIGHT stuff RIGHT stuff NEWLINE { - char fixed[PAPER_WIDTH+1]; - int len, l; - - len = PAPER_WIDTH-(strlen($2)+strlen($4)); - - if (len < 0) { - len = 0; - yyerror("line too wide"); - } - - l = len/2; - memset(fixed, ' ', l); - fixed[l] = '\0'; - printf("%s%s%s", $2, fixed, $4); - free($2); - free($4); - - l = (len+1)/2; - memset(fixed, ' ', l); - fixed[l] = '\0'; - printf("%s%s\n", fixed, $6); - free($6); - - indent = 1; - ++line; -} -; - -stuff: { - $$ = strdup(""); -} -| stuff text { - $$ = malloc(strlen($1)+strlen($2)+1); - sprintf($$,"%s%s", $1, $2); - free($1); - free($2); -} -; - -text: CHAR { - $$ = strdup(yytext); -} -| text CHAR { - $$ = malloc(strlen($1)+2); - sprintf($$,"%s%s", $1, yytext); - free($1); -} -| NO_INDENT { - $$ = strdup(""); - indent = 0; -} -| HASH { - $$ = strdup("#"); -} -| LABEL { - if (($$ = get_label(yytext)) == NULL) { - set_label(yytext, last_label); - $$ = strdup(""); - } -} -| NEW_COUNTER { - $$ = new_counter(yytext); -} -; - -%% - -typedef struct node_s { - struct node_s *left, *right; - const char *key; - char *value; -} *node_t; - -node_t label_root = NULL; -node_t counter_root = NULL; - -const char *find_key(node_t root, const char *key) -{ - while (root) { - int cmp = strcmp(key, root->key); - - if (cmp > 0) { - root = root->right; - } else if (cmp) { - root = root->left; - } else { - return root->value; - } - } - return NULL; -} - -node_t set_key(node_t root, const char *key, const char *value) -{ - if (root) { - int cmp = strcmp(key, root->key); - if (cmp > 0) { - root->right = set_key(root->right, key, value); - } else if (cmp) { - root->left = set_key(root->left, key, value); - } else { - free(root->value); - root->value = strdup(value); - } - } else { - root = malloc(sizeof(struct node_s)); - root->right = root->left = NULL; - root->key = strdup(key); - root->value = strdup(value); - } - return root; -} - -void yyerror(const char *x) -{ - fprintf(stderr, "line %d: %s\n", line, x); -} - -char *get_label(const char *label) -{ - const char *found = find_key(label_root, label); - - if (found) { - return strdup(found); - } - return NULL; -} - -void set_label(const char *label, const char *target) -{ - if (target == NULL) { - yyerror("no hanging value for label"); - target = ""; - } - label_root = set_key(label_root, label, target); -} - -char *new_counter(const char *key) -{ - int i=0, j, ndollars = 0; - const char *old; - char *new; - - if (key[i++] != '#') { - yyerror("bad index"); - return strdup(""); - } - - while (key[i] == '$') { - ++ndollars; - ++i; - } - - key += i; - old = find_key(counter_root, key); - new = malloc(20*ndollars); - - if (old) { - for (j=0; ndollars > 1 && old[j]; ) { - if (old[j++] == '.' && --ndollars <= 0) { - break; - } - } - if (j) { - strncpy(new, old, j); - } - if (old[j]) { - i = atoi(old+j); - } else { - new[j++] = '.'; - i = 0; - } - } else { - j=0; - while (--ndollars > 0) { - new[j++] = '0'; - new[j++] = '.'; - } - i = 0; - } - new[j] = '\0'; - sprintf(new+j, "%d", ++i); - - counter_root = set_key(counter_root, key, new); - - if (last_label) { - free(last_label); - } - last_label = strdup(new); - - return new; -} - -main() -{ - yyparse(); -} diff --git a/doc/specs/parse.lex b/doc/specs/parse.lex new file mode 100644 index 00000000..1d5c898e --- /dev/null +++ b/doc/specs/parse.lex @@ -0,0 +1,11 @@ +%% + +\#[\$]+[a-zA-Z]*(\=[0-9]+)? return NEW_COUNTER; +\#\{[a-zA-Z][a-zA-Z0-9\_]*\} return LABEL; +\# return NO_INDENT; +\#\# return RIGHT; +\\\# return HASH; +[^\n] return CHAR; +[\n] return NEWLINE; + +%% diff --git a/doc/specs/parse.y b/doc/specs/parse.y new file mode 100644 index 00000000..9d0e2534 --- /dev/null +++ b/doc/specs/parse.y @@ -0,0 +1,294 @@ + +%{ +#include +#include +#include + +#define MAXLINE 1000 +#define INDENT_STRING " " +#define PAPER_WIDTH 74 + + int indent=0; + int line=1; + char *last_label=NULL; + + extern void yyerror(const char *x); + extern char *get_label(const char *label); + extern void set_label(const char *label, const char *target); + char *new_counter(const char *key); + +#include "lex.yy.c" + +%} + +%union { + int def; + char *string; +} + +%token NEW_COUNTER LABEL HASH CHAR NEWLINE NO_INDENT RIGHT +%type stuff text + +%start doc + +%% + +doc: +| doc NEWLINE { + printf("\n"); + ++line; +} +| doc stuff NEWLINE { + if (strlen($2) > (PAPER_WIDTH-(indent ? strlen(INDENT_STRING):0))) { + yyerror("line too long"); + } + printf("%s%s\n", indent ? INDENT_STRING:"", $2); + free($2); + indent = 1; + ++line; +} +| doc stuff RIGHT stuff NEWLINE { + char fixed[PAPER_WIDTH+1]; + int len; + + len = PAPER_WIDTH-(strlen($2)+strlen($4)); + + if (len >= 0) { + memset(fixed, ' ', len); + fixed[len] = '\0'; + } else { + yyerror("line too wide"); + fixed[0] = '\0'; + } + printf("%s%s%s\n", $2, fixed, $4); + free($2); + free($4); + indent = 1; + ++line; +} +| doc stuff RIGHT stuff RIGHT stuff NEWLINE { + char fixed[PAPER_WIDTH+1]; + int len, l; + + len = PAPER_WIDTH-(strlen($2)+strlen($4)); + + if (len < 0) { + len = 0; + yyerror("line too wide"); + } + + l = len/2; + memset(fixed, ' ', l); + fixed[l] = '\0'; + printf("%s%s%s", $2, fixed, $4); + free($2); + free($4); + + l = (len+1)/2; + memset(fixed, ' ', l); + fixed[l] = '\0'; + printf("%s%s\n", fixed, $6); + free($6); + + indent = 1; + ++line; +} +| doc stuff RIGHT stuff RIGHT stuff NEWLINE { + char fixed[PAPER_WIDTH+1]; + int len, l; + + len = PAPER_WIDTH-(strlen($2)+strlen($4)); + + if (len < 0) { + len = 0; + yyerror("line too wide"); + } + + l = len/2; + memset(fixed, ' ', l); + fixed[l] = '\0'; + printf("%s%s%s", $2, fixed, $4); + free($2); + free($4); + + l = (len+1)/2; + memset(fixed, ' ', l); + fixed[l] = '\0'; + printf("%s%s\n", fixed, $6); + free($6); + + indent = 1; + ++line; +} +; + +stuff: { + $$ = strdup(""); +} +| stuff text { + $$ = malloc(strlen($1)+strlen($2)+1); + sprintf($$,"%s%s", $1, $2); + free($1); + free($2); +} +; + +text: CHAR { + $$ = strdup(yytext); +} +| text CHAR { + $$ = malloc(strlen($1)+2); + sprintf($$,"%s%s", $1, yytext); + free($1); +} +| NO_INDENT { + $$ = strdup(""); + indent = 0; +} +| HASH { + $$ = strdup("#"); +} +| LABEL { + if (($$ = get_label(yytext)) == NULL) { + set_label(yytext, last_label); + $$ = strdup(""); + } +} +| NEW_COUNTER { + $$ = new_counter(yytext); +} +; + +%% + +typedef struct node_s { + struct node_s *left, *right; + const char *key; + char *value; +} *node_t; + +node_t label_root = NULL; +node_t counter_root = NULL; + +static const char *find_key(node_t root, const char *key) +{ + while (root) { + int cmp = strcmp(key, root->key); + + if (cmp > 0) { + root = root->right; + } else if (cmp) { + root = root->left; + } else { + return root->value; + } + } + return NULL; +} + +static node_t set_key(node_t root, const char *key, const char *value) +{ + if (root) { + int cmp = strcmp(key, root->key); + if (cmp > 0) { + root->right = set_key(root->right, key, value); + } else if (cmp) { + root->left = set_key(root->left, key, value); + } else { + free(root->value); + root->value = strdup(value); + } + } else { + root = malloc(sizeof(struct node_s)); + root->right = root->left = NULL; + root->key = strdup(key); + root->value = strdup(value); + } + return root; +} + +void yyerror(const char *x) +{ + fprintf(stderr, "line %d: %s\n", line, x); +} + +char *get_label(const char *label) +{ + const char *found = find_key(label_root, label); + + if (found) { + return strdup(found); + } + return NULL; +} + +void set_label(const char *label, const char *target) +{ + if (target == NULL) { + yyerror("no hanging value for label"); + target = ""; + } + label_root = set_key(label_root, label, target); +} + +char *new_counter(const char *key) +{ + int i=0, j, ndollars = 0; + const char *old; + char *new; + + if (key[i++] != '#') { + yyerror("bad index"); + return strdup(""); + } + + while (key[i] == '$') { + ++ndollars; + ++i; + } + + key += i; + old = find_key(counter_root, key); + new = malloc(20*ndollars); + + if (old) { + for (j=0; ndollars > 1 && old[j]; ) { + if (old[j++] == '.' && --ndollars <= 0) { + break; + } + } + if (j) { + strncpy(new, old, j); + } + if (old[j]) { + i = atoi(old+j); + } else { + new[j++] = '.'; + i = 0; + } + } else { + j=0; + while (--ndollars > 0) { + new[j++] = '0'; + new[j++] = '.'; + } + i = 0; + } + new[j] = '\0'; + sprintf(new+j, "%d", ++i); + + counter_root = set_key(counter_root, key, new); + + if (last_label) { + free(last_label); + } + last_label = strdup(new); + + return new; +} + +int +main(void) +{ + return yyparse(); +} -- cgit v1.2.3