Bug Summary

File:libexec/got-read-gotconfig/obj/parse.c
Warning:line 945, column 18
Use of zero-allocated memory

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd6.9 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name parse.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/local/lib/clang/11.1.0 -I /home/ben/Projects/got/libexec/got-read-gotconfig/../../include -I /home/ben/Projects/got/libexec/got-read-gotconfig/../../lib -I /home/ben/Projects/got/libexec/got-read-gotconfig -D GOT_LIBEXECDIR=/home/ben/bin -D GOT_VERSION=0.53-current -internal-isystem /usr/local/lib/clang/11.1.0/include -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir /home/ben/Projects/got/libexec/got-read-gotconfig/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /home/ben/Projects/got/scan/2021-05-28-230913-68537-1 -x c parse.c
1#include <stdlib.h>
2#include <string.h>
3#define YYBYACC1 1
4#define YYMAJOR1 1
5#define YYMINOR9 9
6#define YYLEXyylex() yylex()
7#define YYEMPTY-1 -1
8#define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1))
9#define yyerrok(yyerrflag=0) (yyerrflag=0)
10#define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0)
11#define YYPREFIX"yy" "yy"
12#line 25 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
13#include <sys/types.h>
14#include <sys/queue.h>
15
16#include <netdb.h>
17
18#include <ctype.h>
19#include <err.h>
20#include <errno(*__errno()).h>
21#include <limits.h>
22#include <stdarg.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26
27#include "got_error.h"
28#include "gotconfig.h"
29
30static struct file {
31 FILE *stream;
32 const char *name;
33 size_t ungetpos;
34 size_t ungetsize;
35 u_char *ungetbuf;
36 int eof_reached;
37 int lineno;
38} *file;
39static const struct got_error* newfile(struct file**, const char *, int *);
40static void closefile(struct file *);
41int yyparse(void);
42int yylex(void);
43int yyerror(const char *, ...)
44 __attribute__((__format__ (printf, 1, 2)))
45 __attribute__((__nonnull__ (1)));
46int kw_cmp(const void *, const void *);
47int lookup(char *);
48int igetc(void);
49int lgetc(int);
50void lungetc(int);
51int findeol(void);
52static int parseport(char *, long long *);
53
54TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last
; }
symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void *)0), &(symhead).tqh_first };
55struct sym {
56 TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry;
57 int used;
58 int persist;
59 char *nam;
60 char *val;
61};
62
63int symset(const char *, const char *, int);
64char *symget(const char *);
65
66static int atoul(char *, u_long *);
67
68static const struct got_error* gerror;
69static struct gotconfig_remote_repo *remote;
70static struct gotconfig gotconfig;
71static const struct got_error* new_remote(struct gotconfig_remote_repo **);
72
73typedef struct {
74 union {
75 long long number;
76 char *string;
77 struct node_branch *branch;
78 struct node_ref *ref;
79 } v;
80 int lineno;
81} YYSTYPE;
82
83#line 84 "parse.c"
84#define ERROR257 257
85#define REMOTE258 258
86#define REPOSITORY259 259
87#define SERVER260 260
88#define PORT261 261
89#define PROTOCOL262 262
90#define MIRROR_REFERENCES263 263
91#define BRANCH264 264
92#define AUTHOR265 265
93#define FETCH_ALL_BRANCHES266 266
94#define REFERENCE267 267
95#define STRING268 268
96#define NUMBER269 269
97#define YYERRCODE256 256
98const short yylhs[] =
99 { -1,
100 0, 0, 0, 0, 1, 3, 3, 2, 4, 4,
101 4, 5, 6, 6, 7, 7, 7, 8, 9, 9,
102 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
103 17, 11, 10, 12, 12, 16, 13, 13,
104};
105const short yylen[] =
106 { 2,
107 0, 2, 3, 3, 1, 1, 1, 1, 0, 1,
108 4, 1, 2, 4, 0, 1, 4, 1, 2, 4,
109 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
110 0, 7, 2, 2, 0, 2, 1, 0,
111};
112const short yydefred[] =
113 { 1,
114 0, 0, 0, 2, 0, 0, 31, 33, 3, 4,
115 0, 0, 0, 0, 34, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 23, 24, 7, 6, 28,
117 8, 25, 5, 26, 12, 0, 29, 10, 27, 18,
118 0, 30, 16, 32, 0, 22, 0, 0, 0, 21,
119 0, 0, 0, 0, 36, 13, 11, 37, 0, 19,
120 17, 0, 0, 0, 14, 20,
121};
122const short yydgoto[] =
123 { 1,
124 34, 30, 31, 37, 38, 52, 42, 43, 54, 5,
125 6, 14, 59, 24, 25, 50, 11,
126};
127const short yysindex[] =
128 { 0,
129 6, -258, -254, 0, 5, 8, 0, 0, 0, 0,
130 -103, 11, 11, -211, 0, -244, -243, -256, -241, -240,
131 -120, -240, -119, -108, 11, 0, 0, 0, 0, 0,
132 0, 0, 0, 0, 0, 11, 0, 0, 0, 0,
133 11, 0, 0, 0, 19, 0, -237, -236, 11, 0,
134 11, -39, 11, -38, 0, 0, 0, 0, -237, 0,
135 0, -236, 11, 11, 0, 0,};
136const short yyrindex[] =
137 { 0,
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
139 0, -200, -43, 0, 0, 0, 0, 0, 0, 0,
140 -10, 0, -1, 0, -99, 0, 0, 0, 0, 0,
141 0, 0, 0, 0, 0, -237, 0, 0, 0, 0,
142 -237, 0, 0, 0, 0, 0, 0, 0, -99, 0,
143 -42, -235, -42, -235, 0, 0, 0, 0, 0, 0,
144 0, 0, -42, -42, 0, 0,};
145const short yygindex[] =
146 { 0,
147 12, 0, 0, 0, -36, 0, 0, -40, 0, 0,
148 0, -6, -18, 0, 13, 0, 0,
149};
150#define YYTABLESIZE271 271
151const short yytable[] =
152 { 9,
153 35, 35, 36, 41, 58, 58, 15, 53, 15, 7,
154 51, 28, 29, 8, 9, 4, 44, 10, 46, 12,
155 13, 64, 63, 26, 27, 35, 32, 33, 49, 47,
156 35, 40, 38, 39, 48, 62, 45, 0, 0, 0,
157 0, 0, 55, 0, 56, 0, 60, 16, 17, 18,
158 19, 20, 21, 0, 22, 23, 65, 66, 35, 35,
159 35, 35, 35, 35, 0, 35, 35, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 0, 35, 35, 0, 0, 57, 61, 0, 0, 0,
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 9, 0, 0, 0, 0, 0,
165 0, 0, 0, 15, 0, 0, 0, 0, 0, 0,
166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167 0, 0, 0, 0, 0, 0, 0, 35, 40, 0,
168 16, 17, 18, 19, 20, 21, 0, 22, 23, 35,
169 35, 35, 35, 35, 35, 0, 35, 35, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 0, 0, 0, 0, 35, 35, 35, 35, 35,
175 35, 0, 35, 35, 35, 35, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 9, 9,
178 9, 9, 9, 9, 0, 9, 9, 15, 15, 15,
179 15, 15, 15, 2, 15, 15, 0, 0, 0, 0,
180 3,
181};
182const short yycheck[] =
183 { 10,
184 44, 44, 123, 123, 44, 44, 13, 48, 10, 268,
185 47, 268, 269, 268, 10, 10, 125, 10, 25, 123,
186 10, 62, 59, 268, 268, 125, 268, 268, 10, 36,
187 268, 268, 268, 22, 41, 54, 24, -1, -1, -1,
188 -1, -1, 49, -1, 51, -1, 53, 259, 260, 261,
189 262, 263, 264, -1, 266, 267, 63, 64, 259, 260,
190 261, 262, 263, 264, -1, 266, 267, -1, -1, -1,
191 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
192 -1, 125, 125, -1, -1, 125, 125, -1, -1, -1,
193 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
194 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
195 -1, -1, -1, -1, 125, -1, -1, -1, -1, -1,
196 -1, -1, -1, 125, -1, -1, -1, -1, -1, -1,
197 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
198 -1, -1, -1, -1, -1, -1, -1, 268, 268, -1,
199 259, 260, 261, 262, 263, 264, -1, 266, 267, 259,
200 260, 261, 262, 263, 264, -1, 266, 267, -1, -1,
201 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
202 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
203 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
204 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
205 -1, -1, -1, -1, -1, 259, 260, 261, 262, 263,
206 264, -1, 266, 267, 268, 268, -1, -1, -1, -1,
207 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
208 -1, -1, -1, -1, -1, -1, -1, -1, 259, 260,
209 261, 262, 263, 264, -1, 266, 267, 259, 260, 261,
210 262, 263, 264, 258, 266, 267, -1, -1, -1, -1,
211 265,
212};
213#define YYFINAL1 1
214#ifndef YYDEBUG0
215#define YYDEBUG0 0
216#endif
217#define YYMAXTOKEN269 269
218#if YYDEBUG0
219const char * const yyname[] =
220 {
221"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2220,0,0,0,0,0,0,0,0,0,0,0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2240,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2260,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2270,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ERROR",
228"REMOTE","REPOSITORY","SERVER","PORT","PROTOCOL","MIRROR_REFERENCES","BRANCH",
229"AUTHOR","FETCH_ALL_BRANCHES","REFERENCE","STRING","NUMBER",
230};
231const char * const yyrule[] =
232 {"$accept : grammar",
233"grammar :",
234"grammar : grammar '\\n'",
235"grammar : grammar author '\\n'",
236"grammar : grammar remote '\\n'",
237"boolean : STRING",
238"numberstring : NUMBER",
239"numberstring : STRING",
240"portplain : numberstring",
241"branch :",
242"branch : xbranch",
243"branch : '{' optnl branch_list '}'",
244"xbranch : STRING",
245"branch_list : xbranch optnl",
246"branch_list : branch_list comma xbranch optnl",
247"ref :",
248"ref : xref",
249"ref : '{' optnl ref_list '}'",
250"xref : STRING",
251"ref_list : xref optnl",
252"ref_list : ref_list comma xref optnl",
253"remoteopts2 : remoteopts2 remoteopts1 nl",
254"remoteopts2 : remoteopts1 optnl",
255"remoteopts1 : REPOSITORY STRING",
256"remoteopts1 : SERVER STRING",
257"remoteopts1 : PROTOCOL STRING",
258"remoteopts1 : MIRROR_REFERENCES boolean",
259"remoteopts1 : FETCH_ALL_BRANCHES boolean",
260"remoteopts1 : PORT portplain",
261"remoteopts1 : BRANCH branch",
262"remoteopts1 : REFERENCE ref",
263"$$1 :",
264"remote : REMOTE STRING $$1 '{' optnl remoteopts2 '}'",
265"author : AUTHOR STRING",
266"optnl : '\\n' optnl",
267"optnl :",
268"nl : '\\n' optnl",
269"comma : ','",
270"comma :",
271};
272#endif
273#ifdef YYSTACKSIZE10000
274#undef YYMAXDEPTH10000
275#define YYMAXDEPTH10000 YYSTACKSIZE10000
276#else
277#ifdef YYMAXDEPTH10000
278#define YYSTACKSIZE10000 YYMAXDEPTH10000
279#else
280#define YYSTACKSIZE10000 10000
281#define YYMAXDEPTH10000 10000
282#endif
283#endif
284#define YYINITSTACKSIZE200 200
285/* LINTUSED */
286int yydebug;
287int yynerrs;
288int yyerrflag;
289int yychar;
290short *yyssp;
291YYSTYPE *yyvsp;
292YYSTYPE yyval;
293YYSTYPE yylval;
294short *yyss;
295short *yysslim;
296YYSTYPE *yyvs;
297unsigned int yystacksize;
298int yyparse(void);
299#line 275 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
300
301struct keywords {
302 const char *k_name;
303 int k_val;
304};
305
306int
307yyerror(const char *fmt, ...)
308{
309 va_list ap;
310 char *msg;
311 char *err = NULL((void *)0);
312
313 va_start(ap, fmt)__builtin_va_start(ap, fmt);
314 if (vasprintf(&msg, fmt, ap) == -1) {
315 gerror = got_error_from_errno("vasprintf");
316 return 0;
317 }
318 va_end(ap)__builtin_va_end(ap);
319 if (asprintf(&err, "%s: line %d: %s", file->name, yylval.lineno,
320 msg) == -1) {
321 gerror = got_error_from_errno("asprintf");
322 return(0);
323 }
324 gerror = got_error_msg(GOT_ERR_PARSE_CONFIG127, strdup(err));
325 free(msg);
326 free(err);
327 return(0);
328}
329int
330kw_cmp(const void *k, const void *e)
331{
332 return (strcmp(k, ((const struct keywords *)e)->k_name));
333}
334
335int
336lookup(char *s)
337{
338 /* This has to be sorted always. */
339 static const struct keywords keywords[] = {
340 {"author", AUTHOR265},
341 {"branch", BRANCH264},
342 {"fetch-all-branches", FETCH_ALL_BRANCHES266},
343 {"mirror-references", MIRROR_REFERENCES263},
344 {"port", PORT261},
345 {"protocol", PROTOCOL262},
346 {"reference", REFERENCE267},
347 {"remote", REMOTE258},
348 {"repository", REPOSITORY259},
349 {"server", SERVER260},
350 };
351 const struct keywords *p;
352
353 p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
354 sizeof(keywords[0]), kw_cmp);
355
356 if (p)
357 return (p->k_val);
358 else
359 return (STRING268);
360}
361
362#define START_EXPAND1 1
363#define DONE_EXPAND2 2
364
365static int expanding;
366
367int
368igetc(void)
369{
370 int c;
371
372 while (1) {
373 if (file->ungetpos > 0)
374 c = file->ungetbuf[--file->ungetpos];
375 else
376 c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
;
377
378 if (c == START_EXPAND1)
379 expanding = 1;
380 else if (c == DONE_EXPAND2)
381 expanding = 0;
382 else
383 break;
384 }
385 return (c);
386}
387
388int
389lgetc(int quotec)
390{
391 int c, next;
392
393 if (quotec) {
394 c = igetc();
395 if (c == EOF(-1)) {
396 yyerror("reached end of file while parsing "
397 "quoted string");
398 }
399 return (c);
400 }
401
402 c = igetc();
403 while (c == '\\') {
404 next = igetc();
405 if (next != '\n') {
406 c = next;
407 break;
408 }
409 yylval.lineno = file->lineno;
410 file->lineno++;
411 }
412
413 return (c);
414}
415
416void
417lungetc(int c)
418{
419 if (c == EOF(-1))
420 return;
421
422 if (file->ungetpos >= file->ungetsize) {
423 void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
424 if (p == NULL((void *)0))
425 err(1, "%s", __func__);
426 file->ungetbuf = p;
427 file->ungetsize *= 2;
428 }
429 file->ungetbuf[file->ungetpos++] = c;
430}
431
432int
433findeol(void)
434{
435 int c;
436
437 /* Skip to either EOF or the first real EOL. */
438 while (1) {
439 c = lgetc(0);
440 if (c == '\n') {
441 file->lineno++;
442 break;
443 }
444 if (c == EOF(-1))
445 break;
446 }
447 return (ERROR257);
448}
449
450static long long
451getservice(char *n)
452{
453 struct servent *s;
454 u_long ulval;
455
456 if (atoul(n, &ulval) == 0) {
457 if (ulval > 65535) {
458 yyerror("illegal port value %lu", ulval);
459 return (-1);
460 }
461 return ulval;
462 } else {
463 s = getservbyname(n, "tcp");
464 if (s == NULL((void *)0))
465 s = getservbyname(n, "udp");
466 if (s == NULL((void *)0)) {
467 yyerror("unknown port %s", n);
468 return (-1);
469 }
470 return (s->s_port);
471 }
472}
473
474static int
475parseport(char *port, long long *pn)
476{
477 if ((*pn = getservice(port)) == -1) {
478 *pn = 0LL;
479 return (-1);
480 }
481 return (0);
482}
483
484
485int
486yylex(void)
487{
488 unsigned char buf[8096];
489 unsigned char *p, *val;
490 int quotec, next, c;
491 int token;
492
493top:
494 p = buf;
495 c = lgetc(0);
496 while (c == ' ' || c == '\t')
497 c = lgetc(0); /* nothing */
498
499 yylval.lineno = file->lineno;
500 if (c == '#') {
501 c = lgetc(0);
502 while (c != '\n' && c != EOF(-1))
503 c = lgetc(0); /* nothing */
504 }
505 if (c == '$' && !expanding) {
506 while (1) {
507 c = lgetc(0);
508 if (c == EOF(-1))
509 return (0);
510
511 if (p + 1 >= buf + sizeof(buf) - 1) {
512 yyerror("string too long");
513 return (findeol());
514 }
515 if (isalnum(c) || c == '_') {
516 *p++ = c;
517 continue;
518 }
519 *p = '\0';
520 lungetc(c);
521 break;
522 }
523 val = symget(buf);
524 if (val == NULL((void *)0)) {
525 yyerror("macro '%s' not defined", buf);
526 return (findeol());
527 }
528 p = val + strlen(val) - 1;
529 lungetc(DONE_EXPAND2);
530 while (p >= val) {
531 lungetc(*p);
532 p--;
533 }
534 lungetc(START_EXPAND1);
535 goto top;
536 }
537
538 switch (c) {
539 case '\'':
540 case '"':
541 quotec = c;
542 while (1) {
543 c = lgetc(quotec);
544 if (c == EOF(-1))
545 return (0);
546 if (c == '\n') {
547 file->lineno++;
548 continue;
549 } else if (c == '\\') {
550 next = lgetc(quotec);
551 if (next == EOF(-1))
552 return (0);
553 if (next == quotec || c == ' ' || c == '\t')
554 c = next;
555 else if (next == '\n') {
556 file->lineno++;
557 continue;
558 } else
559 lungetc(next);
560 } else if (c == quotec) {
561 *p = '\0';
562 break;
563 } else if (c == '\0') {
564 yyerror("syntax error");
565 return (findeol());
566 }
567 if (p + 1 >= buf + sizeof(buf) - 1) {
568 yyerror("string too long");
569 return (findeol());
570 }
571 *p++ = c;
572 }
573 yylval.v.string = strdup(buf);
574 if (yylval.v.string == NULL((void *)0))
575 err(1, "%s", __func__);
576 return (STRING268);
577 }
578
579#define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' ||
x == '=')
\
580 (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
581
582 if (c == '-' || isdigit(c)) {
583 do {
584 *p++ = c;
585 if ((unsigned)(p-buf) >= sizeof(buf)) {
586 yyerror("string too long");
587 return (findeol());
588 }
589 c = lgetc(0);
590 } while (c != EOF(-1) && isdigit(c));
591 lungetc(c);
592 if (p == buf + 1 && buf[0] == '-')
593 goto nodigits;
594 if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' ||
c == '=')
) {
595 const char *errstr = NULL((void *)0);
596
597 *p = '\0';
598 yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL),
599 LLONG_MAX9223372036854775807LL, &errstr);
600 if (errstr) {
601 yyerror("\"%s\" invalid number: %s",
602 buf, errstr);
603 return (findeol());
604 }
605 return (NUMBER269);
606 } else {
607nodigits:
608 while (p > buf + 1)
609 lungetc(*--p);
610 c = *--p;
611 if (c == '-')
612 return (c);
613 }
614 }
615
616#define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x !=
')' && x != '{' && x != '}' && x != '!'
&& x != '=' && x != '#' && x != ',')
)
\
617 (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
618 x != '{' && x != '}' && \
619 x != '!' && x != '=' && x != '#' && \
620 x != ','))
621
622 if (isalnum(c) || c == ':' || c == '_') {
623 do {
624 *p++ = c;
625 if ((unsigned)(p-buf) >= sizeof(buf)) {
626 yyerror("string too long");
627 return (findeol());
628 }
629 c = lgetc(0);
630 } while (c != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c !=
')' && c != '{' && c != '}' && c != '!'
&& c != '=' && c != '#' && c != ',')
)
));
631 lungetc(c);
632 *p = '\0';
633 token = lookup(buf);
634 if (token == STRING268) {
635 yylval.v.string = strdup(buf);
636 if (yylval.v.string == NULL((void *)0))
637 err(1, "%s", __func__);
638 }
639 return (token);
640 }
641 if (c == '\n') {
642 yylval.lineno = file->lineno;
643 file->lineno++;
644 }
645 if (c == EOF(-1))
646 return (0);
647 return (c);
648}
649
650static const struct got_error*
651newfile(struct file **nfile, const char *filename, int *fd)
652{
653 const struct got_error* error = NULL((void *)0);
654
655 (*nfile) = calloc(1, sizeof(struct file));
656 if ((*nfile) == NULL((void *)0))
657 return got_error_from_errno("calloc");
658 (*nfile)->stream = fdopen(*fd, "r");
659 if ((*nfile)->stream == NULL((void *)0)) {
660 error = got_error_from_errno("fdopen");
661 free((*nfile));
662 return error;
663 }
664 *fd = -1; /* Stream owns the file descriptor now. */
665 (*nfile)->name = filename;
666 (*nfile)->lineno = 1;
667 (*nfile)->ungetsize = 16;
668 (*nfile)->ungetbuf = malloc((*nfile)->ungetsize);
669 if ((*nfile)->ungetbuf == NULL((void *)0)) {
670 error = got_error_from_errno("malloc");
671 fclose((*nfile)->stream);
672 free((*nfile));
673 return error;
674 }
675 return NULL((void *)0);
676}
677
678static const struct got_error*
679new_remote(struct gotconfig_remote_repo **remote)
680{
681 const struct got_error *error = NULL((void *)0);
682
683 *remote = calloc(1, sizeof(**remote));
684 if (*remote == NULL((void *)0))
685 error = got_error_from_errno("calloc");
686 return error;
687}
688
689static void
690closefile(struct file *file)
691{
692 fclose(file->stream);
693 free(file->ungetbuf);
694 free(file);
695}
696
697const struct got_error *
698gotconfig_parse(struct gotconfig **conf, const char *filename, int *fd)
699{
700 const struct got_error *err = NULL((void *)0);
701 struct sym *sym, *next;
702
703 *conf = NULL((void *)0);
704
705 err = newfile(&file, filename, fd);
706 if (err)
707 return err;
708
709 TAILQ_INIT(&gotconfig.remotes)do { (&gotconfig.remotes)->tqh_first = ((void *)0); (&
gotconfig.remotes)->tqh_last = &(&gotconfig.remotes
)->tqh_first; } while (0)
;
710
711 yyparse();
712 closefile(file);
713
714 /* Free macros and check which have not been used. */
715 TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0) && ((next) = ((sym)->entry.tqe_next), 1); (sym
) = (next))
{
716 if (!sym->persist) {
717 free(sym->nam);
718 free(sym->val);
719 TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)->
entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev;
else (&symhead)->tqh_last = (sym)->entry.tqe_prev;
*(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while
(0)
;
720 free(sym);
721 }
722 }
723
724 if (gerror == NULL((void *)0))
725 *conf = &gotconfig;
726 return gerror;
727}
728
729void
730gotconfig_free(struct gotconfig *conf)
731{
732 struct gotconfig_remote_repo *remote;
733
734 free(conf->author);
735 while (!TAILQ_EMPTY(&conf->remotes)(((&conf->remotes)->tqh_first) == ((void *)0))) {
736 remote = TAILQ_FIRST(&conf->remotes)((&conf->remotes)->tqh_first);
737 TAILQ_REMOVE(&conf->remotes, remote, entry)do { if (((remote)->entry.tqe_next) != ((void *)0)) (remote
)->entry.tqe_next->entry.tqe_prev = (remote)->entry.
tqe_prev; else (&conf->remotes)->tqh_last = (remote
)->entry.tqe_prev; *(remote)->entry.tqe_prev = (remote)
->entry.tqe_next; ; ; } while (0)
;
738 free(remote->name);
739 free(remote->repository);
740 free(remote->server);
741 free(remote->protocol);
742 free(remote);
743 }
744}
745
746int
747symset(const char *nam, const char *val, int persist)
748{
749 struct sym *sym;
750
751 TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0); (sym) = ((sym)->entry.tqe_next))
{
752 if (strcmp(nam, sym->nam) == 0)
753 break;
754 }
755
756 if (sym != NULL((void *)0)) {
757 if (sym->persist == 1)
758 return (0);
759 else {
760 free(sym->nam);
761 free(sym->val);
762 TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)->
entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev;
else (&symhead)->tqh_last = (sym)->entry.tqe_prev;
*(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while
(0)
;
763 free(sym);
764 }
765 }
766 sym = calloc(1, sizeof(*sym));
767 if (sym == NULL((void *)0))
768 return (-1);
769
770 sym->nam = strdup(nam);
771 if (sym->nam == NULL((void *)0)) {
772 free(sym);
773 return (-1);
774 }
775 sym->val = strdup(val);
776 if (sym->val == NULL((void *)0)) {
777 free(sym->nam);
778 free(sym);
779 return (-1);
780 }
781 sym->used = 0;
782 sym->persist = persist;
783 TAILQ_INSERT_TAIL(&symhead, sym, entry)do { (sym)->entry.tqe_next = ((void *)0); (sym)->entry.
tqe_prev = (&symhead)->tqh_last; *(&symhead)->tqh_last
= (sym); (&symhead)->tqh_last = &(sym)->entry.
tqe_next; } while (0)
;
784 return (0);
785}
786
787int
788cmdline_symset(char *s)
789{
790 char *sym, *val;
791 int ret;
792 size_t len;
793
794 val = strrchr(s, '=');
795 if (val == NULL((void *)0))
796 return (-1);
797
798 len = strlen(s) - strlen(val) + 1;
799 sym = malloc(len);
800 if (sym == NULL((void *)0))
801 errx(1, "cmdline_symset: malloc");
802
803 strlcpy(sym, s, len);
804
805 ret = symset(sym, val + 1, 1);
806 free(sym);
807
808 return (ret);
809}
810
811char *
812symget(const char *nam)
813{
814 struct sym *sym;
815
816 TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void *
)0); (sym) = ((sym)->entry.tqe_next))
{
817 if (strcmp(nam, sym->nam) == 0) {
818 sym->used = 1;
819 return (sym->val);
820 }
821 }
822 return (NULL((void *)0));
823}
824
825static int
826atoul(char *s, u_long *ulvalp)
827{
828 u_long ulval;
829 char *ep;
830
831 errno(*__errno()) = 0;
832 ulval = strtoul(s, &ep, 0);
833 if (s[0] == '\0' || *ep != '\0')
834 return (-1);
835 if (errno(*__errno()) == ERANGE34 && ulval == ULONG_MAX(9223372036854775807L *2UL+1UL))
836 return (-1);
837 *ulvalp = ulval;
838 return (0);
839}
840#line 833 "parse.c"
841/* allocate initial stack or double stack size, up to YYMAXDEPTH */
842static int yygrowstack(void)
843{
844 unsigned int newsize;
845 long sslen;
846 short *newss;
847 YYSTYPE *newvs;
848
849 if ((newsize = yystacksize) == 0)
22
Assuming the condition is false
23
Taking false branch
850 newsize = YYINITSTACKSIZE200;
851 else if (newsize >= YYMAXDEPTH10000)
24
Assuming 'newsize' is < YYMAXDEPTH
25
Taking false branch
852 return -1;
853 else if ((newsize *= 2) > YYMAXDEPTH10000)
26
Assuming the condition is false
27
Taking false branch
854 newsize = YYMAXDEPTH10000;
855 sslen = yyssp - yyss;
856#ifdef SIZE_MAX
857#define YY_SIZE_MAX0xffffffffU SIZE_MAX
858#else
859#define YY_SIZE_MAX0xffffffffU 0xffffffffU
860#endif
861 if (newsize && YY_SIZE_MAX0xffffffffU / newsize < sizeof *newss)
28
Assuming 'newsize' is 0
862 goto bail;
863 newss = (short *)realloc(yyss, newsize * sizeof *newss);
864 if (newss == NULL((void *)0))
29
Assuming 'newss' is not equal to NULL
30
Taking false branch
865 goto bail;
866 yyss = newss;
867 yyssp = newss + sslen;
868 if (newsize
30.1
'newsize' is 0
&& YY_SIZE_MAX0xffffffffU / newsize < sizeof *newvs)
869 goto bail;
870 newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs);
871 if (newvs == NULL((void *)0))
31
Assuming 'newvs' is not equal to NULL
32
Taking false branch
872 goto bail;
873 yyvs = newvs;
874 yyvsp = newvs + sslen;
875 yystacksize = newsize;
876 yysslim = yyss + newsize - 1;
877 return 0;
878bail:
879 if (yyss)
880 free(yyss);
881 if (yyvs)
882 free(yyvs);
883 yyss = yyssp = NULL((void *)0);
884 yyvs = yyvsp = NULL((void *)0);
885 yystacksize = 0;
886 return -1;
887}
888
889#define YYABORTgoto yyabort goto yyabort
890#define YYREJECTgoto yyabort goto yyabort
891#define YYACCEPTgoto yyaccept goto yyaccept
892#define YYERRORgoto yyerrlab goto yyerrlab
893int
894yyparse(void)
895{
896 int yym, yyn, yystate;
897#if YYDEBUG0
898 const char *yys;
899
900 if ((yys = getenv("YYDEBUG")))
901 {
902 yyn = *yys;
903 if (yyn >= '0' && yyn <= '9')
904 yydebug = yyn - '0';
905 }
906#endif /* YYDEBUG */
907
908 yynerrs = 0;
909 yyerrflag = 0;
910 yychar = (-1);
911
912 if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow;
1
Assuming 'yyss' is not equal to NULL
913 yyssp = yyss;
914 yyvsp = yyvs;
915 *yyssp = yystate = 0;
916
917yyloop:
918 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
2
Taking true branch
3
Control jumps to line 1025
13
Taking false branch
919 if (yychar
13.1
'yychar' is >= 0
< 0)
14
Taking false branch
920 {
921 if ((yychar = yylex()) < 0) yychar = 0;
922#if YYDEBUG0
923 if (yydebug)
924 {
925 yys = 0;
926 if (yychar <= YYMAXTOKEN269) yys = yyname[yychar];
927 if (!yys) yys = "illegal-symbol";
928 printf("%sdebug: state %d, reading %d (%s)\n",
929 YYPREFIX"yy", yystate, yychar, yys);
930 }
931#endif
932 }
933 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
15
Assuming 'yyn' is not equal to 0
16
Assuming the condition is true
19
Taking true branch
934 yyn <= YYTABLESIZE271 && yycheck[yyn] == yychar)
17
Assuming 'yyn' is <= YYTABLESIZE
18
Assuming the condition is true
935 {
936#if YYDEBUG0
937 if (yydebug)
938 printf("%sdebug: state %d, shifting to state %d\n",
939 YYPREFIX"yy", yystate, yytable[yyn]);
940#endif
941 if (yyssp >= yysslim && yygrowstack())
20
Assuming 'yyssp' is >= 'yysslim'
21
Calling 'yygrowstack'
33
Returning from 'yygrowstack'
34
Taking false branch
942 {
943 goto yyoverflow;
944 }
945 *++yyssp = yystate = yytable[yyn];
35
Use of zero-allocated memory
946 *++yyvsp = yylval;
947 yychar = (-1);
948 if (yyerrflag > 0) --yyerrflag;
949 goto yyloop;
950 }
951 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
952 yyn <= YYTABLESIZE271 && yycheck[yyn] == yychar)
953 {
954 yyn = yytable[yyn];
955 goto yyreduce;
956 }
957 if (yyerrflag) goto yyinrecovery;
958#if defined(__GNUC__4)
959 goto yynewerror;
960#endif
961yynewerror:
962 yyerror("syntax error");
963#if defined(__GNUC__4)
964 goto yyerrlab;
965#endif
966yyerrlab:
967 ++yynerrs;
968yyinrecovery:
969 if (yyerrflag < 3)
970 {
971 yyerrflag = 3;
972 for (;;)
973 {
974 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 &&
975 yyn <= YYTABLESIZE271 && yycheck[yyn] == YYERRCODE256)
976 {
977#if YYDEBUG0
978 if (yydebug)
979 printf("%sdebug: state %d, error recovery shifting\
980 to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]);
981#endif
982 if (yyssp >= yysslim && yygrowstack())
983 {
984 goto yyoverflow;
985 }
986 *++yyssp = yystate = yytable[yyn];
987 *++yyvsp = yylval;
988 goto yyloop;
989 }
990 else
991 {
992#if YYDEBUG0
993 if (yydebug)
994 printf("%sdebug: error recovery discarding state %d\n",
995 YYPREFIX"yy", *yyssp);
996#endif
997 if (yyssp <= yyss) goto yyabort;
998 --yyssp;
999 --yyvsp;
1000 }
1001 }
1002 }
1003 else
1004 {
1005 if (yychar == 0) goto yyabort;
1006#if YYDEBUG0
1007 if (yydebug)
1008 {
1009 yys = 0;
1010 if (yychar <= YYMAXTOKEN269) yys = yyname[yychar];
1011 if (!yys) yys = "illegal-symbol";
1012 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1013 YYPREFIX"yy", yystate, yychar, yys);
1014 }
1015#endif
1016 yychar = (-1);
1017 goto yyloop;
1018 }
1019yyreduce:
1020#if YYDEBUG0
1021 if (yydebug)
1022 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1023 YYPREFIX"yy", yystate, yyn, yyrule[yyn]);
1024#endif
1025 yym = yylen[yyn];
1026 if (yym
3.1
'yym' is 0
)
4
Taking false branch
1027 yyval = yyvsp[1-yym];
1028 else
1029 memset(&yyval, 0, sizeof yyval);
1030 switch (yyn)
5
'Default' branch taken. Execution continues on line 1249
1031 {
1032case 5:
1033#line 114 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1034{
1035 if (strcasecmp(yyvsp[0].v.string, "true") == 0 ||
1036 strcasecmp(yyvsp[0].v.string, "yes") == 0)
1037 yyval.v.number = 1;
1038 else if (strcasecmp(yyvsp[0].v.string, "false") == 0 ||
1039 strcasecmp(yyvsp[0].v.string, "no") == 0)
1040 yyval.v.number = 0;
1041 else {
1042 yyerror("invalid boolean value '%s'", yyvsp[0].v.string);
1043 free(yyvsp[0].v.string);
1044 YYERRORgoto yyerrlab;
1045 }
1046 free(yyvsp[0].v.string);
1047 }
1048break;
1049case 6:
1050#line 129 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1051{
1052 char *s;
1053 if (asprintf(&s, "%lld", yyvsp[0].v.number) == -1) {
1054 yyerror("string: asprintf");
1055 YYERRORgoto yyerrlab;
1056 }
1057 yyval.v.string = s;
1058 }
1059break;
1060case 8:
1061#line 139 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1062{
1063 if (parseport(yyvsp[0].v.string, &yyval.v.number) == -1) {
1064 free(yyvsp[0].v.string);
1065 YYERRORgoto yyerrlab;
1066 }
1067 free(yyvsp[0].v.string);
1068 }
1069break;
1070case 9:
1071#line 147 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1072{ yyval.v.branch = NULL((void *)0); }
1073break;
1074case 10:
1075#line 148 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1076{ yyval.v.branch = yyvsp[0].v.branch; }
1077break;
1078case 11:
1079#line 149 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1080{ yyval.v.branch = yyvsp[-1].v.branch; }
1081break;
1082case 12:
1083#line 151 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1084{
1085 yyval.v.branch = calloc(1, sizeof(struct node_branch));
1086 if (yyval.v.branch == NULL((void *)0)) {
1087 yyerror("calloc");
1088 YYERRORgoto yyerrlab;
1089 }
1090 yyval.v.branch->branch_name = yyvsp[0].v.string;
1091 yyval.v.branch->tail = yyval.v.branch;
1092 }
1093break;
1094case 13:
1095#line 161 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1096{ yyval.v.branch = yyvsp[-1].v.branch; }
1097break;
1098case 14:
1099#line 162 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1100{
1101 yyvsp[-3].v.branch->tail->next = yyvsp[-1].v.branch;
1102 yyvsp[-3].v.branch->tail = yyvsp[-1].v.branch;
1103 yyval.v.branch = yyvsp[-3].v.branch;
1104 }
1105break;
1106case 15:
1107#line 168 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1108{ yyval.v.ref = NULL((void *)0); }
1109break;
1110case 16:
1111#line 169 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1112{ yyval.v.ref = yyvsp[0].v.ref; }
1113break;
1114case 17:
1115#line 170 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1116{ yyval.v.ref = yyvsp[-1].v.ref; }
1117break;
1118case 18:
1119#line 172 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1120{
1121 yyval.v.ref = calloc(1, sizeof(struct node_ref));
1122 if (yyval.v.ref == NULL((void *)0)) {
1123 yyerror("calloc");
1124 YYERRORgoto yyerrlab;
1125 }
1126 yyval.v.ref->ref_name = yyvsp[0].v.string;
1127 yyval.v.ref->tail = yyval.v.ref;
1128 }
1129break;
1130case 19:
1131#line 182 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1132{ yyval.v.ref = yyvsp[-1].v.ref; }
1133break;
1134case 20:
1135#line 183 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1136{
1137 yyvsp[-3].v.ref->tail->next = yyvsp[-1].v.ref;
1138 yyvsp[-3].v.ref->tail = yyvsp[-1].v.ref;
1139 yyval.v.ref = yyvsp[-3].v.ref;
1140 }
1141break;
1142case 23:
1143#line 192 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1144{
1145 remote->repository = strdup(yyvsp[0].v.string);
1146 if (remote->repository == NULL((void *)0)) {
1147 free(yyvsp[0].v.string);
1148 yyerror("strdup");
1149 YYERRORgoto yyerrlab;
1150 }
1151 free(yyvsp[0].v.string);
1152 }
1153break;
1154case 24:
1155#line 201 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1156{
1157 remote->server = strdup(yyvsp[0].v.string);
1158 if (remote->server == NULL((void *)0)) {
1159 free(yyvsp[0].v.string);
1160 yyerror("strdup");
1161 YYERRORgoto yyerrlab;
1162 }
1163 free(yyvsp[0].v.string);
1164 }
1165break;
1166case 25:
1167#line 210 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1168{
1169 remote->protocol = strdup(yyvsp[0].v.string);
1170 if (remote->protocol == NULL((void *)0)) {
1171 free(yyvsp[0].v.string);
1172 yyerror("strdup");
1173 YYERRORgoto yyerrlab;
1174 }
1175 free(yyvsp[0].v.string);
1176 }
1177break;
1178case 26:
1179#line 219 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1180{
1181 remote->mirror_references = yyvsp[0].v.number;
1182 }
1183break;
1184case 27:
1185#line 222 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1186{
1187 remote->fetch_all_branches = yyvsp[0].v.number;
1188 }
1189break;
1190case 28:
1191#line 225 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1192{
1193 remote->port = yyvsp[0].v.number;
1194 }
1195break;
1196case 29:
1197#line 228 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1198{
1199 remote->branch = yyvsp[0].v.branch;
1200 }
1201break;
1202case 30:
1203#line 231 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1204{
1205 remote->ref = yyvsp[0].v.ref;
1206 }
1207break;
1208case 31:
1209#line 235 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1210{
1211 static const struct got_error* error;
1212
1213 error = new_remote(&remote);
1214 if (error) {
1215 free(yyvsp[0].v.string);
1216 yyerror("%s", error->msg);
1217 YYERRORgoto yyerrlab;
1218 }
1219 remote->name = strdup(yyvsp[0].v.string);
1220 if (remote->name == NULL((void *)0)) {
1221 free(yyvsp[0].v.string);
1222 yyerror("strdup");
1223 YYERRORgoto yyerrlab;
1224 }
1225 free(yyvsp[0].v.string);
1226 }
1227break;
1228case 32:
1229#line 251 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1230{
1231 TAILQ_INSERT_TAIL(&gotconfig.remotes, remote, entry)do { (remote)->entry.tqe_next = ((void *)0); (remote)->
entry.tqe_prev = (&gotconfig.remotes)->tqh_last; *(&
gotconfig.remotes)->tqh_last = (remote); (&gotconfig.remotes
)->tqh_last = &(remote)->entry.tqe_next; } while (0
)
;
1232 gotconfig.nremotes++;
1233 }
1234break;
1235case 33:
1236#line 256 "/home/ben/Projects/got/libexec/got-read-gotconfig/parse.y"
1237{
1238 gotconfig.author = strdup(yyvsp[0].v.string);
1239 if (gotconfig.author == NULL((void *)0)) {
1240 free(yyvsp[0].v.string);
1241 yyerror("strdup");
1242 YYERRORgoto yyerrlab;
1243 }
1244 free(yyvsp[0].v.string);
1245 }
1246break;
1247#line 1240 "parse.c"
1248 }
1249 yyssp -= yym;
1250 yystate = *yyssp;
1251 yyvsp -= yym;
1252 yym = yylhs[yyn];
1253 if (yystate
5.1
'yystate' is equal to 0
== 0 && yym
5.2
'yym' is equal to 0
== 0)
6
Taking true branch
1254 {
1255#if YYDEBUG0
1256 if (yydebug)
1257 printf("%sdebug: after reduction, shifting from state 0 to\
1258 state %d\n", YYPREFIX"yy", YYFINAL1);
1259#endif
1260 yystate = YYFINAL1;
1261 *++yyssp = YYFINAL1;
1262 *++yyvsp = yyval;
1263 if (yychar
6.1
'yychar' is < 0
< 0)
7
Taking true branch
1264 {
1265 if ((yychar = yylex()) < 0) yychar = 0;
8
Assuming the condition is false
9
Taking false branch
1266#if YYDEBUG0
1267 if (yydebug)
1268 {
1269 yys = 0;
1270 if (yychar <= YYMAXTOKEN269) yys = yyname[yychar];
1271 if (!yys) yys = "illegal-symbol";
1272 printf("%sdebug: state %d, reading %d (%s)\n",
1273 YYPREFIX"yy", YYFINAL1, yychar, yys);
1274 }
1275#endif
1276 }
1277 if (yychar == 0) goto yyaccept;
10
Assuming 'yychar' is not equal to 0
11
Taking false branch
1278 goto yyloop;
12
Control jumps to line 918
1279 }
1280 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1281 yyn <= YYTABLESIZE271 && yycheck[yyn] == yystate)
1282 yystate = yytable[yyn];
1283 else
1284 yystate = yydgoto[yym];
1285#if YYDEBUG0
1286 if (yydebug)
1287 printf("%sdebug: after reduction, shifting from state %d \
1288to state %d\n", YYPREFIX"yy", *yyssp, yystate);
1289#endif
1290 if (yyssp >= yysslim && yygrowstack())
1291 {
1292 goto yyoverflow;
1293 }
1294 *++yyssp = yystate;
1295 *++yyvsp = yyval;
1296 goto yyloop;
1297yyoverflow:
1298 yyerror("yacc stack overflow");
1299yyabort:
1300 if (yyss)
1301 free(yyss);
1302 if (yyvs)
1303 free(yyvs);
1304 yyss = yyssp = NULL((void *)0);
1305 yyvs = yyvsp = NULL((void *)0);
1306 yystacksize = 0;
1307 return (1);
1308yyaccept:
1309 if (yyss)
1310 free(yyss);
1311 if (yyvs)
1312 free(yyvs);
1313 yyss = yyssp = NULL((void *)0);
1314 yyvs = yyvsp = NULL((void *)0);
1315 yystacksize = 0;
1316 return (0);
1317}