PostgreSQL Source Code: src/tools/pg_bsd_indent/indent.h File Reference (original) (raw)
Go to the source code of this file.
Macros | |
---|---|
#define | nitems(x) (sizeof((x)) / sizeof((x)[0])) |
Functions | |
---|---|
void | add_typename (const char *) |
void | alloc_typenames (void) |
int | compute_code_target (void) |
int | compute_label_target (void) |
int | count_spaces (int, char *) |
int | count_spaces_until (int, char *, char *) |
int | lexi (struct parser_state *) |
void | diag2 (int, const char *) |
void | diag3 (int, const char *, int) |
void | diag4 (int, const char *, int, int) |
void | dump_line (void) |
int | lookahead (void) |
void | lookahead_reset (void) |
void | fill_buffer (void) |
void | parse (int) |
void | pr_comment (void) |
void | set_defaults (void) |
void | set_option (char *) |
void | set_profile (const char *) |
◆ nitems
| #define nitems | ( | | x | ) | (sizeof((x)) / sizeof((x)[0])) | | -------------- | - | | ---------------------------------------------------- | - | -------------------------------------------------------------------------------------------------------------------------------------- |
◆ add_typename()
void add_typename | ( | const char * | key | ) |
---|
Definition at line 687 of file lexi.c.
688{
689 int comparison;
690 const char *copy;
691
696 err(1, NULL);
697 }
701
702 if (comparison == 0)
703 return;
705 }
706 else {
707 int p;
708
709 for (p = 0; (comparison = strcmp(key, typenames[p])) > 0; p++)
710 ;
711 if (comparison == 0)
712 return;
716 }
717
718 if (copy == NULL)
719 err(1, NULL);
720}
void err(int eval, const char *fmt,...)
References err(), sort-test::key, realloc, typename_count, typename_top, and typenames.
Referenced by add_typedefs_from_file(), and set_option().
◆ alloc_typenames()
void alloc_typenames | ( | void | ) |
---|
◆ compute_code_target()
int compute_code_target | ( | void | ) |
---|
Definition at line 223 of file io.c.
224{
226
233 else {
234 int w;
236
239 t -= w + 1;
240 if (t > target_col)
241 target_col = t;
242 }
243 else
244 target_col = t;
245 }
248 return target_col;
249}
int lineup_to_parens_always
int count_spaces(int cur, char *buffer)
References continuation_indent, count_spaces(), parser_state::ind_level, parser_state::ind_size, parser_state::ind_stmt, lineup_to_parens, lineup_to_parens_always, max_col, parser_state::paren_level, paren_target, ps, and s_code.
Referenced by dump_line(), main(), and pr_comment().
◆ compute_label_target()
int compute_label_target | ( | void | ) |
---|
◆ count_spaces()
int count_spaces | ( | int | cur, |
---|---|---|---|
char * | buffer | ||
) |
◆ count_spaces_until()
int count_spaces_until | ( | int | cur, |
---|---|---|---|
char * | buffer, | ||
char * | end | ||
) |
Definition at line 517 of file io.c.
522{
523 char *buf;
524
525 for (buf = buffer; *buf != '\0' && buf != end; ++buf) {
526 switch (*buf) {
527
528 case '\n':
529 case 014:
531 break;
532
533 case '\t':
535 break;
536
537 case 010:
539 break;
540
541 default:
543 break;
544 }
545 }
546 return (cur);
547}
References buf, cur, and tabsize.
Referenced by count_spaces(), main(), and pr_comment().
◆ diag2()
void diag2 | ( | int | level, |
---|---|---|---|
const char * | msg | ||
) |
Definition at line 590 of file io.c.
591{
592 if (level)
595 fprintf(stdout, "/**INDENT** %s@%d: ", level == 0 ? "Warning" : "Error", line_no);
598 }
599 else {
600 fprintf(stderr, "%s@%d: ", level == 0 ? "Warning" : "Error", line_no);
601 fprintf(stderr, "%s", msg);
603 }
604}
#define fprintf(file, fmt, msg)
References found_err, fprintf, line_no, output, and generate_unaccent_rules::stdout.
Referenced by lexi(), main(), and parse().
◆ diag3()
void diag3 | ( | int | level, |
---|---|---|---|
const char * | msg, | ||
int | a | ||
) |
Definition at line 573 of file io.c.
574{
575 if (level)
578 fprintf(stdout, "/**INDENT** %s@%d: ", level == 0 ? "Warning" : "Error", line_no);
581 }
582 else {
583 fprintf(stderr, "%s@%d: ", level == 0 ? "Warning" : "Error", line_no);
586 }
587}
References a, found_err, fprintf, line_no, output, and generate_unaccent_rules::stdout.
Referenced by main().
◆ diag4()
void diag4 | ( | int | level, |
---|---|---|---|
const char * | msg, | ||
int | a, | ||
int | b | ||
) |
Definition at line 556 of file io.c.
557{
558 if (level)
561 fprintf(stdout, "/**INDENT** %s@%d: ", level == 0 ? "Warning" : "Error", line_no);
564 }
565 else {
566 fprintf(stderr, "%s@%d: ", level == 0 ? "Warning" : "Error", line_no);
569 }
570}
References a, b, found_err, fprintf, line_no, output, and generate_unaccent_rules::stdout.
◆ dump_line()
Definition at line 61 of file io.c.
62{
63
64
65
66
67 int cur_col,
68 target_col = 1;
69 static int not_first_line;
70
74 }
78 else {
81 }
82 }
90 }
91 else {
94 }
95 }
101
102
103
105 ++code_lines;
106
107
112 }
117 if (s_lab[0] == '#' && (strncmp(s_lab, "#else", 5) == 0
118 || strncmp(s_lab, "#endif", 6) == 0)) {
121 do putc(*s++, output);
122 while (s < e_lab && 'a' <= *s && *s<='z');
123 while ((*s == ' ' || *s == '\t') && s < e_lab)
124 s++;
126 fprintf(output, s[0]=='/' && s[1]=='*' ? "\t%.*s" : "\t/* %.*s */",
127 (int)(e_lab - s), s);
128 }
131 }
132 else
133 cur_col = 1;
134
136
138 char *p;
139
143 }
145 {
146 int i;
147
151 }
152 cur_col = pad_output(cur_col, target_col);
154 if (*p == (char) 0200)
156 else
159 }
162 char *com_st = s_com;
163
165 while (*com_st == '\t')
166
167 com_st++, target += tabsize;
168 while (target <= 0)
169 if (*com_st == ' ')
170 target++, com_st++;
171 else if (*com_st == '\t')
172 target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++;
173 else
174 target = 1;
175 if (cur_col > target) {
176
178 cur_col = 1;
180 }
181 while (e_com > com_st && isspace((unsigned char)e_com[-1]))
184 fwrite(com_st, e_com - com_st, 1, output);
187 }
189 putc('\014', output);
190 else
196 }
197 else
200 }
202
203
204
205
206
207
219 not_first_line = 1;
220}
int blanklines_after_declarations
int postfix_blankline_requested
int prefix_blankline_requested
int swallow_optional_blanklines
int compute_code_target(void)
int compute_label_target(void)
static int pad_output(int current, int target)
References parser_state::bl_line, blanklines_after_declarations, parser_state::block_init, parser_state::block_init_level, code_lines, parser_state::com_col, parser_state::com_lines, combuf, parser_state::comment_delta, comment_open, compute_code_target(), compute_label_target(), count_spaces(), parser_state::decl_on_line, parser_state::dumped_decl_indent, e_code, e_com, e_lab, fprintf, i, parser_state::i_l_follow, parser_state::in_decl, parser_state::in_stmt, parser_state::ind_level, parser_state::ind_stmt, inhibit_formatting, parser_state::just_saw_decl, parser_state::n_comment_delta, n_real_blanklines, parser_state::out_lines, output, parser_state::p_l_follow, pad_output(), parser_state::paren_indents, parser_state::paren_level, paren_target, parser_state::pcase, postfix_blankline_requested, prefix_blankline_requested, parser_state::procname, ps, s_code, s_com, s_lab, suppress_blanklines, swallow_optional_blanklines, tabsize, and parser_state::use_ff.
Referenced by fill_buffer(), main(), and pr_comment().
◆ fill_buffer()
void fill_buffer | ( | void | ) |
---|
Definition at line 346 of file io.c.
347{
348 char *p;
349 int i;
351
352 if (bp_save != NULL) {
358 return;
359
360 }
367 errx(1, "input line too long");
370 }
373 } else {
375 if ((i = getc(f)) == EOF) {
376 *p++ = ' ';
377 *p++ = '\n';
379 break;
380 }
381 }
382 if (i != '\0')
383 *p++ = i;
384 if (i == '\n')
385 break;
386 }
389 if (p - in_buffer > 2 && p[-2] == '/' && p[-3] == '*') {
390 if (in_buffer[3] == 'I' && strncmp(in_buffer, "/**INDENT**", 11) == 0)
391 fill_buffer();
392 else {
393 int com = 0;
394
396 while (*p == ' ' || *p == '\t')
397 p++;
398 if (*p == '/' && p[1] == '*') {
399 p += 2;
400 while (*p == ' ' || *p == '\t')
401 p++;
402 if (p[0] == 'I' && p[1] == 'N' && p[2] == 'D' && p[3] == 'E'
403 && p[4] == 'N' && p[5] == 'T') {
404 p += 6;
405 while (*p == ' ' || *p == '\t')
406 p++;
407 if (*p == '*')
408 com = 1;
409 else if (*p == 'O') {
410 if (*++p == 'N')
411 p++, com = 1;
412 else if (*p == 'F' && *++p == 'F')
413 p++, com = 2;
414 }
415 while (*p == ' ' || *p == '\t')
416 p++;
417 if (p[0] == '*' && p[1] == '/' && p[2] == '\n' && com) {
425 }
426 }
427 }
428 }
429 }
430 }
433 do
435 while (*p++ != '\n');
436 }
437}
void errx(int eval, const char *fmt,...)
static char * lookahead_bp_save
static char * lookahead_start
static char * lookahead_buf
static char * lookahead_ptr
static char * lookahead_end
References be_save, bp_save, buf_end, buf_ptr, dump_line(), e_code, e_com, e_lab, errx(), fill_buffer(), had_eof, i, in_buffer, in_buffer_limit, inhibit_formatting, input, lookahead_bp_save, lookahead_buf, lookahead_end, lookahead_ptr, lookahead_start, n_real_blanklines, output, postfix_blankline_requested, prefix_blankline_requested, realloc, s_code, s_com, s_lab, and suppress_blanklines.
Referenced by fill_buffer(), lexi(), main(), and pr_comment().
◆ lexi()
Definition at line 216 of file lexi.c.
217{
218 int unary_delim;
219
220 int code;
221 char qchar;
222
224 unary_delim = false;
225 state->col_1 = state->last_nl;
226
227
228 state->last_nl = false;
229
230 while (*buf_ptr == ' ' || *buf_ptr == '\t') {
231 state->col_1 = false;
232
235 }
236
237
239 (buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
240
241
242
244
245 if (isdigit((unsigned char)*buf_ptr) ||
246 (buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
247 int seendot = 0,
248 seenexp = 0,
249 seensfx = 0;
250
251
252
253
256
260 len = strspn(buf_ptr + 2, "0123456789ABCDEFabcdef") + 2;
261 else
262 len = strspn(buf_ptr + 1, "012345678") + 1;
263 if (len > 0) {
268 }
269 else
270 diag2(1, "Unterminated literal");
271 }
272 else
273 while (1) {
275 if (seendot)
276 break;
277 else
278 seendot++;
279 }
282 if (!isdigit((unsigned char)*buf_ptr) && *buf_ptr != '.') {
284 break;
285 else {
286 seenexp++;
287 seendot++;
291 }
292 }
293 }
294
295 while (1) {
297 if (!(seensfx & 1) && (*buf_ptr == 'U' || *buf_ptr == 'u')) {
299 seensfx |= 1;
300 continue;
301 }
302 if (!(seensfx & 2) && (strchr("fFlL", *buf_ptr) != NULL)) {
306 seensfx |= 2;
307 continue;
308 }
309 break;
310 }
311 }
312 else
314
316 if (*(buf_ptr + 1) == '\n') {
320 } else
321 break;
322 }
324
328 }
330
334
335 while (*buf_ptr == ' ' || *buf_ptr == '\t') {
338 }
339 state->keyword = 0;
341
342
343
344 state->last_u_d = true;
345 return (decl);
346 }
347
348
349
351
357 if (p == NULL) {
358 char *u;
359
360
362 strcmp(u, "_t") == 0) || (typename_top >= 0 &&
365 state->keyword = 4;
366 state->last_u_d = true;
367 goto found_typename;
368 }
369 } else {
371 state->last_u_d = true;
373 case 7:
375 case 8:
377
378 case 3:
379
380 case 4:
381 found_typename:
382 if (state->p_l_follow) {
383
384 state->cast_mask |= (1 << state->p_l_follow) & ~state->not_cast_mask;
385 }
387 state->keyword = 0;
388 break;
389 }
390 if (p != NULL && p->rwcode == 3)
392 if (state->p_l_follow)
393 break;
394 return (decl);
395
396 case 5:
398
399 case 6:
401
402 case 10:
404
405 case 11:
407
408 default:
409
411 }
412 }
413 if (*buf_ptr == '(' && state->tos <= 1 && state->ind_level == 0 &&
414 state->in_parameter_declaration == 0 && state->block_init == 0) {
416 strncpy(state->procname, token, sizeof state->procname - 1);
417 if (state->in_decl)
418 state->in_parameter_declaration = 1;
420 }
421 }
422
423
424
425
426
427 else if (->p_l_follow &&
->block_init &&
428 ->in_stmt &&
430 isalpha((unsigned char)*buf_ptr)) &&
433 state->keyword = 4;
434 state->last_u_d = true;
436 }
437 if (state->last_token == decl)
438
439 state->last_u_d = true;
440 return (ident);
441 }
442
443
444
447
451
452 switch (*token) {
453 case '\n':
454 unary_delim = state->last_u_d;
455 state->last_nl = true;
457
458
459
460
461
462 break;
463
464 case '\'':
465 case '"':
467 do {
468 while (1) {
470 diag2(1, "Unterminated literal");
471 goto stop_lit;
472 }
477 if (*e_token == BACKSLASH) {
478 if (*buf_ptr == '\n')
481 ++e_token;
482
485 }
486 else
487 break;
488 }
489 } while (*e_token++ != qchar);
490stop_lit:
492 break;
493
494 case ('('):
495 case ('['):
496 unary_delim = true;
498 break;
499
500 case (')'):
501 case (']'):
503 break;
504
505 case '#':
506 unary_delim = state->last_u_d;
508 break;
509
510 case '?':
511 unary_delim = true;
513 break;
514
515 case (':'):
517 unary_delim = true;
518 break;
519
520 case (';'):
521 unary_delim = true;
523 break;
524
525 case ('{'):
526 unary_delim = true;
527
528
529
530
531
533 break;
534
535 case ('}'):
536 unary_delim = true;
537
539 break;
540
541 case 014:
542 unary_delim = state->last_u_d;
543 state->last_nl = true;
544
546 break;
547
548 case (','):
549 unary_delim = true;
551 break;
552
553 case '.':
554 unary_delim = false;
556 break;
557
558 case '-':
559 case '+':
561 unary_delim = true;
562
564
566
569
570 unary_delim = false;
571 }
572 }
573 else if (*buf_ptr == '=')
574
576 else if (*buf_ptr == '>') {
577
579 unary_delim = false;
581 state->want_blank = false;
582 }
583 break;
584
585
586 case '=':
587 if (state->in_or_st)
588 state->block_init = 1;
589#ifdef undef
590 if (chartype[*buf_ptr & 127] == opchar) {
594 *e_token++ = '=';
596 }
597#else
598 if (*buf_ptr == '=') {
599 *e_token++ = '=';
602 }
603#endif
605 unary_delim = true;
606 break;
607
608
609 case '>':
610 case '<':
611 case '!':
616 }
620 unary_delim = true;
621 break;
622
623 case '*':
624 unary_delim = true;
625 if (->last_u_d) {
629 break;
630 }
631 while (*buf_ptr == '*' || isspace((unsigned char)*buf_ptr)) {
635 }
638 }
640 break;
641
642 default:
644
646
649
651 unary_delim = state->last_u_d;
652 break;
653 }
655
656
657
662 }
664 unary_delim = true;
665
666
667 }
670 state->last_u_d = unary_delim;
672 *e_token = '\0';
673 return (code);
674}
void diag2(int, const char *)
#define CHECK_SIZE_TOKEN(desired_size)
static int strcmp_type(const void *e1, const void *e2)
static int is_func_definition(char *tp)
References alphanum, auto_typedefs, BACKSLASH, binary_op, buf_end, buf_ptr, casestmt, chartype, CHECK_SIZE_TOKEN, colon, comma, comment, decl, diag2(), e_token, fill_buffer(), form_feed, funcname, had_eof, ident, is_func_definition(), lbrace, len, line_no, lparen, newline, period, postop, preesc, question, rbrace, rparen, templ::rwcode, s_token, semicolon, sp_nparen, sp_paren, specials, storage, strcmp_type(), strpfx, structure, swstmt, token, type_def, typename_top, typenames, and unary_op.
Referenced by main().
◆ lookahead()
Definition at line 275 of file io.c.
276{
277
280
283
284 if (i == EOF)
285 return i;
286 if (i == '\0')
287 continue;
288
290
291 char *new_buf;
292 size_t req;
293
295 req = 64;
296 new_buf = malloc(req);
297 } else {
300 }
301 if (new_buf == NULL)
302 errx(1, "too much lookahead required");
308 }
309
311 }
313}
static char * lookahead_buf_end
References be_save, errx(), i, input, lookahead_bp_save, lookahead_buf, lookahead_buf_end, lookahead_end, lookahead_ptr, lookahead_start, malloc, and realloc.
Referenced by is_func_definition().
◆ lookahead_reset()
void lookahead_reset | ( | void | ) |
---|
◆ parse()
Definition at line 49 of file parse.c.
50{
51 int i;
52
53#ifdef debug
55#endif
56
58
60
61 reduce();
62 }
63
64
65 switch (tk) {
66
67
68 case decl:
70
72
73 break_comma = true;
74
77
78 if (ps.ljust_decl) {
79
81 for (i = ps.tos - 1; i > 0; --i)
84
86 }
87 }
88 break;
89
90 case ifstmt:
92
93
94
95
96
98
99
100 case dolit:
101 case forstmt:
104 ++ps.i_l_follow;
106 break;
107
108 case lbrace:
109 break_comma = false;
112 ++ps.i_l_follow;
113
114 else {
116
117
118
120
121
122
125
126
127
128 }
129 }
130
134
136 break;
137
138 case whilestmt:
140
144 }
145 else {
150 }
151
152 break;
153
154 case elselit:
155
157 diag2(1, "Unmatched 'else'");
158 else {
160
162
164
166 }
167 break;
168
169 case rbrace:
170
174 }
175 else
176 diag2(1, "Statement nesting error");
177 break;
178
179 case swstmt:
182
185
186
188
190 break;
191
192 case semicolon:
193 break_comma = false;
194
197 break;
198
199 default:
200 diag2(1, "Unknown code to parser");
201 return;
202
203
204 }
205
207 errx(1, "Parser stack overflow");
208
209 reduce();
210
211#ifdef debug
212 for (i = 1; i <= ps.tos; ++i)
215#endif
216
217 return;
218}
References break_comma, btype_2, case_ind, parser_state::case_indent, parser_state::cstk, decl, diag2(), dohead, dolit, e_code, parser_state::else_if, elsehead, elselit, errx(), forstmt, i, parser_state::i_l_follow, ifhead, ifstmt, parser_state::il, parser_state::ind_level, lbrace, parser_state::ljust_decl, nitems, parser_state::p_stack, printf, ps, rbrace, reduce(), s_code, parser_state::search_brace, semicolon, stmt, stmtl, swstmt, parser_state::tos, and whilestmt.
◆ pr_comment()
Definition at line 79 of file pr_comment.c.
80{
81 int now_col;
82 int adj_max_col;
83
84 char *last_bl;
85
86 char *t_ptr;
91 last_bl = NULL;
93
94
96
97
98
100
102 break_delim = false;
104 }
105 else {
109
110
111
112
113
114
115 break_delim = false;
116 }
118
119
120
121
122
127 }
128 else {
129 int target_col;
130 break_delim = false;
133 else {
134 target_col = 1;
137 }
139 (strncmp(s_lab, "#endif", 6) == 0 ||
140 strncmp(s_lab, "#else", 5) == 0))
143 else
148 if (ps.com_col + 24 > adj_max_col)
150 }
151 }
153
154
155
156
157
158
159
160
162
166 }
167 else {
171 }
173 *e_com++ = '/';
177
178
179
180
181 if (break_delim)
182 for (t_ptr = buf_ptr; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) {
185 if (t_ptr[0] == '*' && t_ptr[1] == '/') {
187 break_delim = false;
188 break;
189 }
190 }
191
192 if (break_delim) {
202 }
203
204
205
206 while (1) {
207
208 switch (*buf_ptr) {
209 case 014:
211 if (.box_com) {
213
215 last_bl = NULL;
219 ;
220 }
221 else {
225 }
226 break;
227
228 case '\n':
229 if (had_eof) {
230 printf("Unterminated comment\n");
232 return;
233 }
234 last_bl = NULL;
237
244 }
248 }
249 else {
251 if (*(e_com - 1) == ' ' || *(e_com - 1) == '\t')
252 last_bl = e_com - 1;
253
254
255
256
257 else {
260 }
261 }
262 ++line_no;
264 int nstar = 1;
265 do {
266
269 if (*buf_ptr == '*' && --nstar >= 0) {
273 goto end_of_comment;
274 }
276 }
279 break;
280
281 case '*':
282
286 if (*buf_ptr == '/') {
287 end_of_comment:
290 if (break_delim) {
293 }
294 else
297 }
299 *e_com++ = ' ';
302 return;
303 }
304 else
306 break;
307 default:
309 do {
315 last_bl = e_com;
317 now_col++;
318 } while (!memchr("*\n\r\b\t", *buf_ptr, 6) &&
319 (now_col <= adj_max_col || !last_bl));
321 if (now_col > adj_max_col && .box_com && e_com[-1] > ' ') {
322
323
324
325 if (last_bl == NULL) {
329 break;
330 }
336 for (t_ptr = last_bl + 1; *t_ptr == ' ' || *t_ptr == '\t';
337 t_ptr++)
338 ;
339 last_bl = NULL;
340
341
342
343
344
345 while (*t_ptr != '\0') {
346 if (*t_ptr == ' ' || *t_ptr == '\t')
348 *e_com++ = *t_ptr++;
349 }
350 }
351 break;
352 }
353 }
354}
int compute_code_target(void)
int compute_label_target(void)
int count_spaces_until(int, char *, char *)
int count_spaces(int, char *)
int block_comment_max_col
#define CHECK_SIZE_COM(desired_size)
int blanklines_before_blockcomments
int format_block_comments
int comment_delimiter_on_blankline
if(TABLE==NULL||TABLE_index==NULL)
References blanklines_before_blockcomments, block_comment_max_col, parser_state::box_com, buf_end, buf_ptr, CHECK_SIZE_COM, parser_state::col_1, parser_state::com_col, parser_state::com_ind, comment_delimiter_on_blankline, parser_state::comment_delta, compute_code_target(), compute_label_target(), count_spaces(), count_spaces_until(), parser_state::decl_com_ind, parser_state::decl_on_line, dump_line(), e_code, e_com, e_lab, else_endif_com_ind, fill_buffer(), format_block_comments, format_col1_comments, had_eof, if(), in_buffer, parser_state::ind_level, parser_state::ind_size, parser_state::just_saw_decl, parser_state::last_nl, parser_state::last_token, lbrace, line_no, max_col, parser_state::n_comment_delta, parser_state::out_coms, prefix_blankline_requested, printf, ps, s_code, s_com, s_lab, save_com, sc_buf, sc_size, star_comment_cont, start, tabsize, parser_state::unindent_displace, and parser_state::use_ff.
Referenced by main().
◆ set_defaults()
void set_defaults | ( | void | ) |
---|
◆ set_option()
void set_option | ( | char * | arg | ) |
---|
Definition at line 261 of file args.c.
262{
263 struct pro *p;
264 const char *param_start;
265
266 arg++;
269 goto found;
271found:
273
276
277 case IGN:
278 break;
279
280 case CLI:
281 if (*param_start == 0)
282 goto need_param;
284 break;
285
287 if (input == NULL)
291 break;
292
293 case KEY:
294 if (*param_start == 0)
295 goto need_param;
297 break;
298
300 if (*param_start == 0)
301 goto need_param;
303 break;
304
307 exit(0);
308
309 default:
310 errx(1, "set_option: internal error: p_special %d", p->p_special);
311 }
312 break;
313
316 *p->p_obj = false;
317 else
318 *p->p_obj = true;
319 break;
320
322 if (!isdigit((unsigned char)*param_start)) {
323 need_param:
325 }
326 *p->p_obj = atoi(param_start);
327 break;
328
329 default:
330 errx(1, "set_option: internal error: p_type %d", p->p_type);
331 }
332}
static const char * eqin(const char *s1, const char *s2)
void add_typedefs_from_file(const char *str)
const char * option_source
void add_typename(const char *)
References add_typedefs_from_file(), add_typename(), arg, parser_state::case_indent, CLI, eqin(), errx(), IGN, INDENT_VERSION, input, KEY, KEY_FILE, OFF, option_source, output, pro::p_name, pro::p_obj, pro::p_special, pro::p_type, printf, PRO_BOOL, PRO_INT, PRO_SPECIAL, ps, STDIN, generate_unaccent_rules::stdout, and VERSION.
Referenced by scan_profile().
◆ set_profile()
void set_profile | ( | const char * | profile_name | ) |
---|
Definition at line 176 of file args.c.
177{
178 FILE *f;
180 static char prof[] = ".indent.pro";
181
182 if (profile_name == NULL)
183 snprintf(fname, sizeof(fname), "%s/%s", getenv("HOME"), prof);
184 else
185 snprintf(fname, sizeof(fname), "%s", profile_name + 2);
186 if ((f = fopen(option_source = fname, "r")) != NULL) {
188 (void) fclose(f);
189 }
190 if ((f = fopen(option_source = prof, "r")) != NULL) {
192 (void) fclose(f);
193 }
195}
static void scan_profile(FILE *f)
References MAXPGPATH, option_source, scan_profile(), and snprintf.
Referenced by main().