Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Switch to Doxygen OO-in-C convention |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1620d60a3daf08652ccb9be5ebc5e578 |
User & Date: | darrenbane 2014-05-09 22:02:45.326 |
Context
2014-10-15
| ||
18:54 | Run through cppcheck check-in: af7f96faac user: darrenbane tags: trunk | |
2014-05-09
| ||
22:02 | Switch to Doxygen OO-in-C convention check-in: 1620d60a3d user: darrenbane tags: trunk | |
2014-02-23
| ||
17:49 | Makefile tweaks for FBSD again. There must be a better way to do this. check-in: 38b964f154 user: dbane tags: trunk | |
Changes
Changes to hdr/build.h.
︙ | ︙ | |||
15 16 17 18 19 20 21 | char *copy(char *str); /** * @brief Allocate a new type struct and add it to the global list of types. * @param name the type name * @return a pointer to the new struct */ | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | char *copy(char *str); /** * @brief Allocate a new type struct and add it to the global list of types. * @param name the type name * @return a pointer to the new struct */ Type *addtype(char *name); /** * @brief Define a new label. * @param lbltype type of label to define. Will be created if it doesn't already exist. * @param lbllevel nesting level of label. * @param lblname name by which label will be referred to in cross-references. */ |
︙ | ︙ |
Changes to hdr/find.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** @file * @brief Routines to find a type entry and a label entry. */ #ifndef _FIND_H_ #define _FIND_H_ /** * Find a label by name. * @param tp the type of label to find * @param name the label name * @return a pointer to the label struct; or NULL if it can't be found */ | > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /** @file * @brief Routines to find a type entry and a label entry. */ #ifndef _FIND_H_ #define _FIND_H_ /** * Find a label by name. * @public @memberof Type * @param tp the type of label to find * @param name the label name * @return a pointer to the label struct; or NULL if it can't be found */ Label *typeFindlabel(Type *tp, char *name); /** * Find a label type, optionally creating it if it doesn't exist. * @param name the type name * @param create whether or not to create the type if it doesn't exist * @return a pointer to the type struct */ Type *findtype(char *name, int create); #endif |
Changes to hdr/printl.h.
1 2 3 4 5 6 7 8 9 10 11 12 | /** @file * @brief Routines to print a label according to a format. */ #ifndef _PRINTL_H_ #define _PRINTL_H_ /** * @brief Print a label. * @param lab label to print. * @param out file handle to output on. */ | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** @file * @brief Routines to print a label according to a format. */ #ifndef _PRINTL_H_ #define _PRINTL_H_ /** * @brief Print a label. * @public @memberof Label * @param lab label to print. * @param out file handle to output on. */ void labelPrint(Label *lab, FILE *out); #endif |
Changes to hdr/types.h.
︙ | ︙ | |||
31 32 33 34 35 36 37 38 | /** Type for header levels member of label struct */ typedef us int levels[NLEVELS]; /** Header format */ typedef char *format; /** Label type */ | > > > > | | | | | | | | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /** Type for header levels member of label struct */ typedef us int levels[NLEVELS]; /** Header format */ typedef char *format; typedef struct Type Type; /**< Type type */ typedef struct Label Label; /**< Label type */ typedef struct Keyword Keyword; /**< Keyword type */ /** Label type */ struct Type { char *t_name; /**< name */ levels t_levels; /**< current header levels */ format t_format; /**< format */ LIST_HEAD(, Label) labelhead; /**< list of labels of this type */ LIST_ENTRY(Type) link; /**< next type in list of types */ }; /** Label definition */ struct Label { char *l_name; /**< Name */ Type *l_type; /**< Back-reference to label type */ levels l_levels; /**< Counter for label no. at different levels */ us int l_bottom; /**< Last significant level */ char *l_file; /**< File where defined */ long l_line; /**< line where defined */ LIST_ENTRY(Label) link; /**< Next label in list of labels */ }; /** Action routine for keyword processing */ typedef int (*func) (); /** Command keyword, to come after ".L=" at the start of an input line */ struct Keyword { char *k_name; /**< How is the keyword spelt */ func k_action; /**< Function pointer for action to take */ us int k_minargs; /**< Min no. of args for k_action */ us int k_maxargs; /**< Max no. of args for k_action */ }; #endif |
Added mk/check.mk.
> > | 1 2 | .PHONY: clangcheck |
Changes to src/Makefile.
1 2 | .POSIX: | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | .POSIX: BINOWN= darrenbane BINGRP= darrenbane SHAREOWN= darrenbane SHAREGRP= darrenbane .include <bsd.own.mk> PREFIX?= /home/dbane BINDIR= $(PREFIX)/bin MANDIR= $(PREFIX)/man/man PROG= lbl # Need _DARWIN_C_SOURCE for strlcpy/strlcat #CFLAGS+= -I../hdr -Wall -std=c11 -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE CFLAGS+= -I../hdr -Wall -std=c11 MAN= ../doc/lbl.1 SRCS= lbl.c actions.c build.c externs.c find.c keyword.c list.c \ printl.c rescan.c scan.c signals.c LIBC= /usr/lib/libSystem.dylib .include <bsd.prog.mk> #.include "check.mk" |
Changes to src/actions.c.
︙ | ︙ | |||
49 50 51 52 53 54 55 | /*ARGSUSED*/ void a_format(nargs, argvec) int nargs; char *argvec[]; { | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /*ARGSUSED*/ void a_format(nargs, argvec) int nargs; char *argvec[]; { Type *tp = findtype(argvec[1], 1); if (tp->t_format != def_format) warnx("%s[warning] format for %s redefined", maybe_loc(), tp->t_name); tp->t_format = copy(argvec[2]); } /*ARGSUSED*/ void a_last(nargs, argvec) int nargs; char *argvec[]; { Type *tp = findtype(argvec[1], 1); int indx; nargs -= 2; argvec += 2; for (indx = 0; indx < nargs; indx++) { if (!isdigit(argvec[indx][0])) { warnx("%snon-numeric label index", maybe_loc()); |
︙ | ︙ |
Changes to src/build.c.
︙ | ︙ | |||
15 16 17 18 19 20 21 | #include <sysexits.h> #include "build.h" #include "find.h" extern char *def_format; extern char *filename; extern long fileline; | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <sysexits.h> #include "build.h" #include "find.h" extern char *def_format; extern char *filename; extern long fileline; extern LIST_HEAD(, Type) typehead; char * alloc(nbytes) us int nbytes; { char *ptr = malloc(nbytes); |
︙ | ︙ | |||
44 45 46 47 48 49 50 | void addlbl(lbltype, lbllevel, lblname) char *lbltype; char *lbllevel; char *lblname; { | | | | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | void addlbl(lbltype, lbllevel, lblname) char *lbltype; char *lbllevel; char *lblname; { Type *tp = findtype(lbltype, 1); Label *lp; Label *last, *last_next; us int bottom; us int indx; if (!isdigit(lbllevel[0])) { warnx("%snon-numeric index level", maybe_loc()); return; } if ((bottom = atoi(lbllevel)) == 0 || bottom > NLEVELS) { warnx("%sindex level must be in range 1-%u", maybe_loc(), NLEVELS); return; } bottom--; ++(tp->t_levels[bottom]); for (indx = bottom + 1; indx < NLEVELS; indx++) tp->t_levels[indx] = 0; if (strcmp(lblname, "*") != 0) { lp = typeFindlabel(tp, lblname); if (lp != NULL) { warnx("%sredefinition of %s ignored", maybe_loc(), lblname); return; } lp = (Label *) alloc(sizeof(Label)); lp->l_name = copy(lblname); lp->l_type = tp; for (indx = 0; indx < bottom; indx++) lp->l_levels[indx] = tp->t_levels[indx]; lp->l_levels[bottom] = tp->t_levels[bottom]; lp->l_bottom = bottom; |
︙ | ︙ | |||
99 100 101 102 103 104 105 | last_next = LIST_NEXT(last, link); } LIST_INSERT_AFTER(last, lp, link); } } } | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | last_next = LIST_NEXT(last, link); } LIST_INSERT_AFTER(last, lp, link); } } } Type * addtype(name) char *name; { Type *tp = (Type *) alloc(sizeof(Type)); us int indx; tp->t_name = copy(name); for (indx = 0; indx < NLEVELS; indx++) tp->t_levels[indx] = 0; tp->t_format = def_format; LIST_INIT(&(tp->labelhead)); LIST_INSERT_HEAD(&typehead, tp, link); return tp; } |
Changes to src/externs.c.
︙ | ︙ | |||
15 16 17 18 19 20 21 | char *def_format = STDFORM; char *progname = "lbl"; char *filename = NULL; int lflag = 0; int sflag = 0; FILE *tempfile = NULL; long fileline; | | | 15 16 17 18 19 20 21 22 | char *def_format = STDFORM; char *progname = "lbl"; char *filename = NULL; int lflag = 0; int sflag = 0; FILE *tempfile = NULL; long fileline; LIST_HEAD(, Type) typehead = LIST_HEAD_INITIALIZER(typehead); |
Changes to src/find.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | */ #include <string.h> #include <lbl.h> #include "build.h" #include "find.h" | | | | | | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | */ #include <string.h> #include <lbl.h> #include "build.h" #include "find.h" extern LIST_HEAD(, Type) typehead; Type * findtype(name, create) rg char *name; rg int create; { rg Type *tp; LIST_FOREACH(tp, &typehead, link) if (strcmp(name, tp->t_name) == 0) return tp; if (create) return addtype(name); return NULL; } Label * typeFindlabel(tp, name) rg Type *tp; rg char *name; { rg Label *lp; if (tp == NULL) return NULL; LIST_FOREACH(lp, &(tp->labelhead), link) if (strcmp(name, lp->l_name) == 0) return lp; return NULL; |
︙ | ︙ |
Changes to src/keyword.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | #include <string.h> #include <lbl.h> extern int a_delimiter(); extern int a_format(); extern int a_last(); | | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <string.h> #include <lbl.h> extern int a_delimiter(); extern int a_format(); extern int a_last(); Keyword keytable[] = { {"delimiter", a_delimiter, 2, 2}, {"format", a_format, 3, 3}, {"last", a_last, 3, 22} }; #define NKEYS (sizeof(keytable) / sizeof(Keyword)) Keyword * findkeyword(word) char *word; { int indx; for (indx = 0; indx < NKEYS; indx++) if (strcmp(word, keytable[indx].k_name) == 0) |
︙ | ︙ |
Changes to src/list.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* (C) C.D.F. Miller, Heriot-Watt University, March 1984 * * Permission is hereby given to reproduce or modify this * software freely, provided that this notice be retained, * and that no use be made of the software for commercial * purposes without the express written permission of the * author. */ #include <lbl.h> #include "list.h" #include "printl.h" | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* (C) C.D.F. Miller, Heriot-Watt University, March 1984 * * Permission is hereby given to reproduce or modify this * software freely, provided that this notice be retained, * and that no use be made of the software for commercial * purposes without the express written permission of the * author. */ #include <lbl.h> #include "list.h" #include "printl.h" void listtype(Type *); extern char *def_format; extern LIST_HEAD(, Type) typehead; void listdefs() { Type *tp; if (LIST_EMPTY(&typehead)) { fprintf(stderr, "No labels defined\n"); return; } LIST_FOREACH(tp, &typehead, link) listtype(tp); } void listtype(tp) Type *tp; { Label *lp; fprintf(stderr, "*** Type %s: format %s\n", tp->t_name, tp->t_format == def_format ? "default" : tp->t_format); if (LIST_EMPTY(&(tp->labelhead))) { fprintf(stderr, "(No labels defined\n)"); return; } LIST_FOREACH(lp, &(tp->labelhead), link) { fprintf(stderr, "%-16.16s %-14.14s %-6ld ", lp->l_name, lp->l_file, lp->l_line); labelPrint(lp, stderr); putc('\n', stderr); } putc('\n', stderr); } |
Changes to src/printl.c.
︙ | ︙ | |||
13 14 15 16 17 18 19 | void printr(char, us int, FILE *); static void printd(us int, FILE *); static void printa(char, us int, FILE *); static void auxprinta(char, us int, FILE *); void | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | void printr(char, us int, FILE *); static void printd(us int, FILE *); static void printa(char, us int, FILE *); static void auxprinta(char, us int, FILE *); void labelPrint(lab, out) rg Label *lab; rg FILE *out; { rg format f = lab->l_type->t_format; rg us int i; for (i = 0; i <= lab->l_bottom; i++) { while (*f) { |
︙ | ︙ |
Changes to src/rescan.c.
︙ | ︙ | |||
88 89 90 91 92 93 94 | void doreplace() { rg int c; char typename[BUFSIZ]; char labelname[BUFSIZ]; | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | void doreplace() { rg int c; char typename[BUFSIZ]; char labelname[BUFSIZ]; rg Type *tp; rg Label *lp; /* <delimiter><delimiter> gives <delimiter> as output */ if ((c = getc(tempfile)) == delimiter) { putchar(delimiter); return; } ungetc(c, tempfile); |
︙ | ︙ | |||
113 114 115 116 117 118 119 | return; } if ((tp = findtype(typename, 0)) == NULL) { warnx("%sundefined type '%s'", maybe_loc(), typename); printf("<<%s %s>>", typename, labelname); return; } | | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | return; } if ((tp = findtype(typename, 0)) == NULL) { warnx("%sundefined type '%s'", maybe_loc(), typename); printf("<<%s %s>>", typename, labelname); return; } if ((lp = typeFindlabel(tp, labelname)) == NULL) { warnx("%sundefined label '%s'", maybe_loc(), labelname); printf("<<%s %s>>", typename, labelname); return; } labelPrint(lp, stdout); } void getword(buffer) rg char *buffer; { rg int c; |
︙ | ︙ |
Changes to src/scan.c.
︙ | ︙ | |||
55 56 57 58 59 60 61 | } void process(line) char *line; { us int split(); | | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } void process(line) char *line; { us int split(); Keyword *findkeyword(); us int nargs; char *argvec[NLEVELS + 2]; Keyword *key; if ((nargs = split(line, argvec)) == 0) { warnx("%sempty .%s line", maybe_loc(), macroname); return; } /* Check for and act upon reserved words */ if ((key = findkeyword(argvec[0])) != NULL) { |
︙ | ︙ |