Lines Matching +full:tf +full:- +full:a
1 /*-
2 * Copyright (c) 2012-2017 Dag-Erling Smørgrav
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * Read a word from the temp file and verify that the result matches our
56 * expectations: whether a word was read at all, how many lines were read
61 orw_expect(struct t_file *tf, const char *expected, int lines, int eof, int eol) in orw_expect() argument
68 got = openpam_readword(tf->file, &lineno, &len); in orw_expect()
70 if (t_ferror(tf)) in orw_expect()
71 err(1, "%s(): %s", __func__, tf->name); in orw_expect()
88 if (eof && !t_feof(tf)) { in orw_expect()
92 if (!eof && t_feof(tf)) { in orw_expect()
96 ch = fgetc(tf->file); in orw_expect()
97 if (t_ferror(tf)) in orw_expect()
98 err(1, "%s(): %s", __func__, tf->name); in orw_expect()
107 ungetc(ch, tf->file); in orw_expect()
118 struct t_file *tf; variable
121 tf = t_fopen(NULL);
122 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
123 t_fclose(tf);
129 struct t_file *tf; variable
132 tf = t_fopen(NULL);
133 t_fprintf(tf, "\n");
134 t_frewind(tf);
135 ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
136 t_fclose(tf);
142 struct t_file *tf; variable
145 tf = t_fopen(NULL);
146 t_fprintf(tf, " ");
147 t_frewind(tf);
148 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
149 t_fclose(tf);
155 struct t_file *tf; variable
158 tf = t_fopen(NULL);
159 t_fprintf(tf, " \n");
160 t_frewind(tf);
161 ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
162 t_fclose(tf);
168 struct t_file *tf; variable
171 tf = t_fopen(NULL);
172 t_fprintf(tf, " \t\r\n");
173 t_frewind(tf);
174 ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
175 t_fclose(tf);
181 struct t_file *tf; variable
184 tf = t_fopen(NULL);
185 t_fprintf(tf, "# comment\n");
186 t_frewind(tf);
187 ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
188 t_fclose(tf);
194 struct t_file *tf; variable
197 tf = t_fopen(NULL);
198 t_fprintf(tf, " # comment\n");
199 t_frewind(tf);
200 ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
201 t_fclose(tf);
205 T_FUNC(single_quoted_comment, "single-quoted comment")
207 struct t_file *tf; variable
210 tf = t_fopen(NULL);
211 t_fprintf(tf, " '# comment'\n");
212 t_frewind(tf);
213 ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
214 t_fclose(tf);
218 T_FUNC(double_quoted_comment, "double-quoted comment")
220 struct t_file *tf; variable
223 tf = t_fopen(NULL);
224 t_fprintf(tf, " \"# comment\"\n");
225 t_frewind(tf);
226 ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
227 t_fclose(tf);
233 struct t_file *tf; variable
236 tf = t_fopen(NULL);
237 t_fprintf(tf, "# comment");
238 t_frewind(tf);
239 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
240 t_fclose(tf);
246 * Simple cases - no quotes or escapes
252 struct t_file *tf; variable
255 tf = t_fopen(NULL);
256 t_fprintf(tf, "%s\n", word);
257 t_frewind(tf);
258 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
259 t_fclose(tf);
266 struct t_file *tf; variable
269 tf = t_fopen(NULL);
270 t_fprintf(tf, " %s\n", word);
271 t_frewind(tf);
272 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
273 t_fclose(tf);
280 struct t_file *tf; variable
283 tf = t_fopen(NULL);
284 t_fprintf(tf, " %s\n", word);
285 t_frewind(tf);
286 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
287 t_fclose(tf);
294 struct t_file *tf; variable
297 tf = t_fopen(NULL);
298 t_fprintf(tf, "%s \n", word);
299 t_frewind(tf);
300 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 0 /*eol*/);
301 t_fclose(tf);
308 struct t_file *tf; variable
311 tf = t_fopen(NULL);
312 t_fprintf(tf, "%s \n", word);
313 t_frewind(tf);
314 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 0 /*eol*/);
315 t_fclose(tf);
322 struct t_file *tf; variable
325 tf = t_fopen(NULL);
326 t_fprintf(tf, "%s # comment\n", word);
327 t_frewind(tf);
328 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
329 orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
330 t_fclose(tf);
337 struct t_file *tf; variable
340 tf = t_fopen(NULL);
341 t_fprintf(tf, "%s\n", word);
342 t_frewind(tf);
343 ret = orw_expect(tf, word, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
344 t_fclose(tf);
351 struct t_file *tf; variable
354 tf = t_fopen(NULL);
355 t_fprintf(tf, "%s %s\n", word[0], word[1]);
356 t_frewind(tf);
357 ret = orw_expect(tf, word[0], 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
358 orw_expect(tf, word[1], 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
359 t_fclose(tf);
370 struct t_file *tf; variable
373 tf = t_fopen(NULL);
374 t_fprintf(tf, "\\");
375 t_frewind(tf);
376 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
377 t_fclose(tf);
383 struct t_file *tf; variable
386 tf = t_fopen(NULL);
387 t_fprintf(tf, "\\\\\n");
388 t_frewind(tf);
389 ret = orw_expect(tf, "\\", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
390 t_fclose(tf);
396 struct t_file *tf; variable
399 tf = t_fopen(NULL);
400 t_fprintf(tf, "\\ \\\t \\\r \\\n\n");
401 t_frewind(tf);
402 ret = orw_expect(tf, " ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
403 orw_expect(tf, "\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
404 orw_expect(tf, "\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
405 /* this last one is a line continuation */
406 orw_expect(tf, NULL, 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
407 t_fclose(tf);
413 struct t_file *tf; variable
416 tf = t_fopen(NULL);
417 t_fprintf(tf, "\\\nhello world\n");
418 t_frewind(tf);
419 ret = orw_expect(tf, "hello", 1 /*lines*/, 0 /*eof*/, 0 /*eol*/);
420 t_fclose(tf);
426 struct t_file *tf; variable
429 tf = t_fopen(NULL);
430 t_fprintf(tf, "hello\\\nworld\n");
431 t_frewind(tf);
432 ret = orw_expect(tf, "helloworld", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
433 t_fclose(tf);
439 struct t_file *tf; variable
442 tf = t_fopen(NULL);
443 t_fprintf(tf, "hello\\\n world\n");
444 t_frewind(tf);
445 ret = orw_expect(tf, "hello", 1 /*lines*/, 0 /*eof*/, 0 /*eol*/);
446 t_fclose(tf);
452 struct t_file *tf; variable
455 tf = t_fopen(NULL);
456 t_fprintf(tf, "\\z\n");
457 t_frewind(tf);
458 ret = orw_expect(tf, "z", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
459 t_fclose(tf);
465 struct t_file *tf; variable
468 tf = t_fopen(NULL);
469 t_fprintf(tf, " \\# comment\n");
470 t_frewind(tf);
471 ret = orw_expect(tf, "#", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
472 orw_expect(tf, "comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
473 t_fclose(tf);
479 struct t_file *tf; variable
482 tf = t_fopen(NULL);
483 t_fprintf(tf, "z\\");
484 t_frewind(tf);
485 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
486 t_fclose(tf);
497 struct t_file *tf; variable
500 tf = t_fopen(NULL);
501 t_fprintf(tf, "'");
502 t_frewind(tf);
503 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
504 t_fclose(tf);
510 struct t_file *tf; variable
513 tf = t_fopen(NULL);
514 t_fprintf(tf, "\"");
515 t_frewind(tf);
516 ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
517 t_fclose(tf);
523 struct t_file *tf; variable
526 tf = t_fopen(NULL);
527 t_fprintf(tf, "''\n");
528 t_frewind(tf);
529 ret = orw_expect(tf, "", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
530 t_fclose(tf);
536 struct t_file *tf; variable
539 tf = t_fopen(NULL);
540 t_fprintf(tf, "\"\"\n");
541 t_frewind(tf);
542 ret = orw_expect(tf, "", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
543 t_fclose(tf);
549 struct t_file *tf; variable
552 tf = t_fopen(NULL);
553 t_fprintf(tf, "\"' '\"\n");
554 t_frewind(tf);
555 ret = orw_expect(tf, "' '", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
556 t_fclose(tf);
562 struct t_file *tf; variable
565 tf = t_fopen(NULL);
566 t_fprintf(tf, "'\" \"'\n");
567 t_frewind(tf);
568 ret = orw_expect(tf, "\" \"", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
569 t_fclose(tf);
573 T_FUNC(single_quoted_whitespace, "single-quoted whitespace")
575 struct t_file *tf; variable
578 tf = t_fopen(NULL);
579 t_fprintf(tf, "' ' '\t' '\r' '\n'\n");
580 t_frewind(tf);
581 ret = orw_expect(tf, " ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
582 orw_expect(tf, "\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
583 orw_expect(tf, "\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
584 orw_expect(tf, "\n", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
585 t_fclose(tf);
589 T_FUNC(double_quoted_whitespace, "double-quoted whitespace")
591 struct t_file *tf; variable
594 tf = t_fopen(NULL);
595 t_fprintf(tf, "\" \" \"\t\" \"\r\" \"\n\"\n");
596 t_frewind(tf);
597 ret = orw_expect(tf, " ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
598 orw_expect(tf, "\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
599 orw_expect(tf, "\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
600 orw_expect(tf, "\n", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
601 t_fclose(tf);
605 T_FUNC(single_quoted_words, "single-quoted words")
607 struct t_file *tf; variable
610 tf = t_fopen(NULL);
611 t_fprintf(tf, "'hello world'\n");
612 t_frewind(tf);
613 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
614 t_fclose(tf);
618 T_FUNC(double_quoted_words, "double-quoted words")
620 struct t_file *tf; variable
623 tf = t_fopen(NULL);
624 t_fprintf(tf, "\"hello world\"\n");
625 t_frewind(tf);
626 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
627 t_fclose(tf);
638 struct t_file *tf; variable
641 tf = t_fopen(NULL);
642 t_fprintf(tf, "'hello 'world\n");
643 t_frewind(tf);
644 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
645 t_fclose(tf);
651 struct t_file *tf; variable
654 tf = t_fopen(NULL);
655 t_fprintf(tf, "\"hello \"world\n");
656 t_frewind(tf);
657 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
658 t_fclose(tf);
664 struct t_file *tf; variable
667 tf = t_fopen(NULL);
668 t_fprintf(tf, "hello' 'world\n");
669 t_frewind(tf);
670 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
671 t_fclose(tf);
677 struct t_file *tf; variable
680 tf = t_fopen(NULL);
681 t_fprintf(tf, "hello\" \"world\n");
682 t_frewind(tf);
683 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
684 t_fclose(tf);
690 struct t_file *tf; variable
693 tf = t_fopen(NULL);
694 t_fprintf(tf, "hello' world'\n");
695 t_frewind(tf);
696 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
697 t_fclose(tf);
703 struct t_file *tf; variable
706 tf = t_fopen(NULL);
707 t_fprintf(tf, "hello\" world\"\n");
708 t_frewind(tf);
709 ret = orw_expect(tf, "hello world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
710 t_fclose(tf);
722 struct t_file *tf; variable
725 tf = t_fopen(NULL);
726 t_fprintf(tf, "\\'\n");
727 t_frewind(tf);
728 ret = orw_expect(tf, "'", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
729 t_fclose(tf);
736 struct t_file *tf; variable
739 tf = t_fopen(NULL);
740 t_fprintf(tf, "\\\"\n");
741 t_frewind(tf);
742 ret = orw_expect(tf, "\"", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
743 t_fclose(tf);
750 struct t_file *tf; variable
753 tf = t_fopen(NULL);
754 t_fprintf(tf, "'\\ ' '\\\t' '\\\r' '\\\n'\n");
755 t_frewind(tf);
756 ret = orw_expect(tf, "\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
757 orw_expect(tf, "\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
758 orw_expect(tf, "\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
759 orw_expect(tf, "\\\n", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
760 t_fclose(tf);
767 struct t_file *tf; variable
770 tf = t_fopen(NULL);
771 t_fprintf(tf, "\"\\ \" \"\\\t\" \"\\\r\" \"\\\n\"\n");
772 t_frewind(tf);
773 ret = orw_expect(tf, "\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
774 orw_expect(tf, "\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
775 orw_expect(tf, "\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
776 /* this last one is a line continuation */
777 orw_expect(tf, "", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
778 t_fclose(tf);
785 struct t_file *tf; variable
788 tf = t_fopen(NULL);
789 t_fprintf(tf, "'\\z'\n");
790 t_frewind(tf);
791 ret = orw_expect(tf, "\\z", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
792 t_fclose(tf);
799 struct t_file *tf; variable
802 tf = t_fopen(NULL);
803 t_fprintf(tf, "\"\\z\"\n");
804 t_frewind(tf);
805 ret = orw_expect(tf, "\\z", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
806 t_fclose(tf);
813 struct t_file *tf; variable
816 tf = t_fopen(NULL);
817 t_fprintf(tf, "'\\\\'\n");
818 t_frewind(tf);
819 ret = orw_expect(tf, "\\\\", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
820 t_fclose(tf);
827 struct t_file *tf; variable
830 tf = t_fopen(NULL);
831 t_fprintf(tf, "\"\\\\\"\n");
832 t_frewind(tf);
833 ret = orw_expect(tf, "\\", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
834 t_fclose(tf);
841 struct t_file *tf; variable
844 tf = t_fopen(NULL);
845 t_fprintf(tf, "'\\''\n");
846 t_frewind(tf);
847 ret = orw_expect(tf, NULL, 1 /*lines*/, 1 /*eof*/, 0 /*eol*/);
848 t_fclose(tf);
855 struct t_file *tf; variable
858 tf = t_fopen(NULL);
859 t_fprintf(tf, "'\\\"'\n");
860 t_frewind(tf);
861 ret = orw_expect(tf, "\\\"", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
862 t_fclose(tf);
869 struct t_file *tf; variable
872 tf = t_fopen(NULL);
873 t_fprintf(tf, "\"\\'\"\n");
874 t_frewind(tf);
875 ret = orw_expect(tf, "\\'", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
876 t_fclose(tf);
883 struct t_file *tf; variable
886 tf = t_fopen(NULL);
887 t_fprintf(tf, "\"\\\"\"\n");
888 t_frewind(tf);
889 ret = orw_expect(tf, "\"", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
890 t_fclose(tf);
901 struct t_file *tf; variable
904 tf = t_fopen(NULL);
905 t_fprintf(tf, "hello \\\n world\n");
906 t_frewind(tf);
907 ret = orw_expect(tf, "hello", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
908 orw_expect(tf, "world", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
909 t_fclose(tf);
915 struct t_file *tf; variable
918 tf = t_fopen(NULL);
919 t_fprintf(tf, "hello\\\n world\n");
920 t_frewind(tf);
921 ret = orw_expect(tf, "hello", 1 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
922 orw_expect(tf, "world", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
923 t_fclose(tf);
929 struct t_file *tf; variable
932 tf = t_fopen(NULL);
933 t_fprintf(tf, "hello \\\nworld\n");
934 t_frewind(tf);
935 ret = orw_expect(tf, "hello", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
936 orw_expect(tf, "world", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
937 t_fclose(tf);
943 struct t_file *tf; variable
946 tf = t_fopen(NULL);
947 t_fprintf(tf, "hello\\\nworld\n");
948 t_frewind(tf);
949 ret = orw_expect(tf, "helloworld", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
950 t_fclose(tf);