aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-01 21:13:32 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-03 21:23:16 +0300
commit24ec67c9f6375d34d88e79981ed8abbe15a78169 (patch)
tree6e68b1b409b10b48581422df05cfac9caedb0af2
parentda56e338d346e358de864d18ca42f574305d8dfc (diff)
downloadgrecs-24ec67c9f6375d34d88e79981ed8abbe15a78169.tar.gz
grecs-24ec67c9f6375d34d88e79981ed8abbe15a78169.tar.bz2
Reindent all, except wordsplit, which is shared with MU.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/format.c269
-rw-r--r--src/grecs-gram.y1086
-rw-r--r--src/grecs-lex.l579
-rw-r--r--src/grecs.h180
-rw-r--r--src/list.c177
-rw-r--r--src/preproc.c1050
-rw-r--r--src/text.c36
8 files changed, 1631 insertions, 1748 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f35f52..759716b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,3 +34,3 @@ INCLUDES = -I$(srcdir) @GRECS_INCLUDES@
34AM_YFLAGS = -dtv 34AM_YFLAGS = -dtv
35AM_LFLAGS = -dvp 35AM_LFLAGS = -d
36# Use a modified ylwrap implementation that understands the --prefix option. 36# Use a modified ylwrap implementation that understands the --prefix option.
diff --git a/src/format.c b/src/format.c
index a1aa67d..fc6c8d6 100644
--- a/src/format.c
+++ b/src/format.c
@@ -28,42 +28,41 @@ grecs_data_type_string (enum grecs_data_type type)
28{ 28{
29 switch (type) 29 switch (type) {
30 { 30 case grecs_type_void:
31 case grecs_type_void: 31 return "void";
32 return "void";
33 32
34 case grecs_type_string: 33 case grecs_type_string:
35 return "string"; 34 return "string";
36 35
37 case grecs_type_short: 36 case grecs_type_short:
38 case grecs_type_ushort: 37 case grecs_type_ushort:
39 case grecs_type_int: 38 case grecs_type_int:
40 case grecs_type_uint: 39 case grecs_type_uint:
41 case grecs_type_long: 40 case grecs_type_long:
42 case grecs_type_ulong: 41 case grecs_type_ulong:
43 case grecs_type_size: 42 case grecs_type_size:
44 /*FIXME case grecs_type_off:*/ 43 /*FIXME case grecs_type_off:*/
45 return "number"; 44 return "number";
46 45
47 case grecs_type_time: 46 case grecs_type_time:
48 return "time"; 47 return "time";
49 48
50 case grecs_type_bool: 49 case grecs_type_bool:
51 return "boolean"; 50 return "boolean";
52 51
53 case grecs_type_ipv4: 52 case grecs_type_ipv4:
54 return "IPv4"; 53 return "IPv4";
55 54
56 case grecs_type_cidr: 55 case grecs_type_cidr:
57 return "CIDR"; 56 return "CIDR";
58 57
59 case grecs_type_host: 58 case grecs_type_host:
60 return "hostname"; 59 return "hostname";
61 60
62 case grecs_type_sockaddr: 61 case grecs_type_sockaddr:
63 return "sock-addr"; 62 return "sock-addr";
64 63
65 case grecs_type_section: 64 case grecs_type_section:
66 return "section"; 65 return "section";
67 } 66 }
68 return "UNKNOWN?"; 67 return "UNKNOWN?";
69} 68}
@@ -71,6 +70,6 @@ grecs_data_type_string (enum grecs_data_type type)
71static void 70static void
72format_level (FILE *stream, unsigned level) 71format_level(FILE *stream, unsigned level)
73{ 72{
74 while (level--) 73 while (level--)
75 fprintf (stream, " "); 74 fprintf(stream, " ");
76} 75}
@@ -78,49 +77,43 @@ format_level (FILE *stream, unsigned level)
78void 77void
79grecs_format_docstring (FILE *stream, const char *docstring, unsigned level) 78grecs_format_docstring(FILE *stream, const char *docstring, unsigned level)
80{ 79{
81 size_t len = strlen (docstring); 80 size_t len = strlen(docstring);
82 int width = 78 - level * 2; 81 int width = 78 - level * 2;
83 82
84 if (width < 0) 83 if (width < 0) {
85 { 84 width = 78;
86 width = 78; 85 level = 0;
87 level = 0;
88 }
89
90 while (len)
91 {
92 size_t seglen;
93 const char *p;
94
95 for (seglen = 0, p = docstring; p < docstring + width && *p; p++)
96 {
97 if (*p == '\n')
98 {
99 seglen = p - docstring;
100 break;
101 }
102 if (isspace (*p))
103 seglen = p - docstring;
104 } 86 }
105 if (seglen == 0 || *p == 0) 87
106 seglen = p - docstring; 88 while (len) {
107 89 size_t seglen;
108 format_level (stream, level); 90 const char *p;
109 fprintf (stream, "# "); 91
110 fwrite (docstring, seglen, 1, stream); 92 for (seglen = 0, p = docstring; p < docstring + width && *p;
111 fputc ('\n', stream); 93 p++) {
112 len -= seglen; 94 if (*p == '\n') {
113 docstring += seglen; 95 seglen = p - docstring;
114 if (*docstring == '\n') 96 break;
115 { 97 }
116 docstring++; 98 if (isspace(*p))
117 len--; 99 seglen = p - docstring;
100 }
101 if (seglen == 0 || *p == 0)
102 seglen = p - docstring;
103
104 format_level(stream, level);
105 fprintf(stream, "# ");
106 fwrite(docstring, seglen, 1, stream);
107 fputc('\n', stream);
108 len -= seglen;
109 docstring += seglen;
110 if (*docstring == '\n') {
111 docstring++;
112 len--;
113 } else
114 while (*docstring && isspace(*docstring)) {
115 docstring++;
116 len--;
117 }
118 } 118 }
119 else
120 while (*docstring && isspace (*docstring))
121 {
122 docstring++;
123 len--;
124 }
125 }
126} 119}
@@ -128,30 +121,31 @@ grecs_format_docstring (FILE *stream, const char *docstring, unsigned level)
128void 121void
129grecs_format_simple_statement (FILE *stream, struct grecs_keyword *kwp, 122grecs_format_simple_statement(FILE *stream, struct grecs_keyword *kwp,
130 unsigned level) 123 unsigned level)
131{ 124{
132 const char *argstr; 125 const char *argstr;
133 126
134 if (kwp->docstring) 127 if (kwp->docstring)
135 grecs_format_docstring (stream, kwp->docstring, level); 128 grecs_format_docstring(stream, kwp->docstring, level);
136 format_level (stream, level); 129 format_level(stream, level);
137 130
138 if (kwp->argname) 131 if (kwp->argname)
139 argstr = kwp->argname; 132 argstr = kwp->argname;
140 else 133 else
141 argstr = N_("arg"); 134 argstr = N_("arg");
142 135
143 if (strchr ("<[", argstr[0])) 136 if (strchr("<[", argstr[0]))
144 fprintf (stream, "%s %s;\n", kwp->ident, gettext (argstr)); 137 fprintf(stream, "%s %s;\n", kwp->ident, gettext(argstr));
145 else if (strchr (argstr, ':')) 138 else if (strchr (argstr, ':'))
146 fprintf (stream, "%s <%s>;\n", kwp->ident, gettext (argstr)); 139 fprintf (stream, "%s <%s>;\n", kwp->ident, gettext(argstr));
147 else 140 else {
148 { 141 fprintf(stream, "%s <%s: ", kwp->ident, gettext(argstr));
149 fprintf (stream, "%s <%s: ", kwp->ident, gettext (argstr)); 142 if (GRECS_IS_LIST(kwp->type))
150 if (GRECS_IS_LIST (kwp->type)) 143 fprintf(stream, "list of %s",
151 fprintf (stream, "list of %s", 144 gettext(grecs_data_type_string(
152 gettext (grecs_data_type_string (GRECS_TYPE (kwp->type)))); 145 GRECS_TYPE (kwp->type))));
153 else 146 else
154 fprintf (stream, "%s", gettext (grecs_data_type_string (kwp->type))); 147 fprintf(stream, "%s",
155 fprintf (stream, ">;\n"); 148 gettext(grecs_data_type_string(kwp->type)));
156 } 149 fprintf(stream, ">;\n");
150 }
157} 151}
@@ -159,15 +153,15 @@ grecs_format_simple_statement (FILE *stream, struct grecs_keyword *kwp,
159void 153void
160grecs_format_block_statement (FILE *stream, struct grecs_keyword *kwp, 154grecs_format_block_statement(FILE *stream, struct grecs_keyword *kwp,
161 unsigned level) 155 unsigned level)
162{ 156{
163 if (kwp->docstring) 157 if (kwp->docstring)
164 grecs_format_docstring (stream, kwp->docstring, level); 158 grecs_format_docstring(stream, kwp->docstring, level);
165 format_level (stream, level); 159 format_level(stream, level);
166 fprintf (stream, "%s", kwp->ident); 160 fprintf(stream, "%s", kwp->ident);
167 if (kwp->argname) 161 if (kwp->argname)
168 fprintf (stream, " <%s>", gettext (kwp->argname)); 162 fprintf(stream, " <%s>", gettext(kwp->argname));
169 fprintf (stream, " {\n"); 163 fprintf(stream, " {\n");